babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/webRequest" {
  410. /**
  411. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  412. */
  413. export class WebRequest {
  414. private _xhr;
  415. /**
  416. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  417. * i.e. when loading files, where the server/service expects an Authorization header
  418. */
  419. static CustomRequestHeaders: {
  420. [key: string]: string;
  421. };
  422. /**
  423. * Add callback functions in this array to update all the requests before they get sent to the network
  424. */
  425. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  426. private _injectCustomRequestHeaders;
  427. /**
  428. * Gets or sets a function to be called when loading progress changes
  429. */
  430. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  431. /**
  432. * Returns client's state
  433. */
  434. readonly readyState: number;
  435. /**
  436. * Returns client's status
  437. */
  438. readonly status: number;
  439. /**
  440. * Returns client's status as a text
  441. */
  442. readonly statusText: string;
  443. /**
  444. * Returns client's response
  445. */
  446. readonly response: any;
  447. /**
  448. * Returns client's response url
  449. */
  450. readonly responseURL: string;
  451. /**
  452. * Returns client's response as text
  453. */
  454. readonly responseText: string;
  455. /**
  456. * Gets or sets the expected response type
  457. */
  458. responseType: XMLHttpRequestResponseType;
  459. /** @hidden */
  460. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  461. /** @hidden */
  462. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  463. /**
  464. * Cancels any network activity
  465. */
  466. abort(): void;
  467. /**
  468. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  469. * @param body defines an optional request body
  470. */
  471. send(body?: Document | BodyInit | null): void;
  472. /**
  473. * Sets the request method, request URL
  474. * @param method defines the method to use (GET, POST, etc..)
  475. * @param url defines the url to connect with
  476. */
  477. open(method: string, url: string): void;
  478. }
  479. }
  480. declare module "babylonjs/Misc/fileRequest" {
  481. import { Observable } from "babylonjs/Misc/observable";
  482. /**
  483. * File request interface
  484. */
  485. export interface IFileRequest {
  486. /**
  487. * Raised when the request is complete (success or error).
  488. */
  489. onCompleteObservable: Observable<IFileRequest>;
  490. /**
  491. * Aborts the request for a file.
  492. */
  493. abort: () => void;
  494. }
  495. }
  496. declare module "babylonjs/Maths/math.scalar" {
  497. /**
  498. * Scalar computation library
  499. */
  500. export class Scalar {
  501. /**
  502. * Two pi constants convenient for computation.
  503. */
  504. static TwoPi: number;
  505. /**
  506. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  507. * @param a number
  508. * @param b number
  509. * @param epsilon (default = 1.401298E-45)
  510. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  511. */
  512. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  513. /**
  514. * Returns a string : the upper case translation of the number i to hexadecimal.
  515. * @param i number
  516. * @returns the upper case translation of the number i to hexadecimal.
  517. */
  518. static ToHex(i: number): string;
  519. /**
  520. * Returns -1 if value is negative and +1 is value is positive.
  521. * @param value the value
  522. * @returns the value itself if it's equal to zero.
  523. */
  524. static Sign(value: number): number;
  525. /**
  526. * Returns the value itself if it's between min and max.
  527. * Returns min if the value is lower than min.
  528. * Returns max if the value is greater than max.
  529. * @param value the value to clmap
  530. * @param min the min value to clamp to (default: 0)
  531. * @param max the max value to clamp to (default: 1)
  532. * @returns the clamped value
  533. */
  534. static Clamp(value: number, min?: number, max?: number): number;
  535. /**
  536. * the log2 of value.
  537. * @param value the value to compute log2 of
  538. * @returns the log2 of value.
  539. */
  540. static Log2(value: number): number;
  541. /**
  542. * Loops the value, so that it is never larger than length and never smaller than 0.
  543. *
  544. * This is similar to the modulo operator but it works with floating point numbers.
  545. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  546. * With t = 5 and length = 2.5, the result would be 0.0.
  547. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  548. * @param value the value
  549. * @param length the length
  550. * @returns the looped value
  551. */
  552. static Repeat(value: number, length: number): number;
  553. /**
  554. * Normalize the value between 0.0 and 1.0 using min and max values
  555. * @param value value to normalize
  556. * @param min max to normalize between
  557. * @param max min to normalize between
  558. * @returns the normalized value
  559. */
  560. static Normalize(value: number, min: number, max: number): number;
  561. /**
  562. * Denormalize the value from 0.0 and 1.0 using min and max values
  563. * @param normalized value to denormalize
  564. * @param min max to denormalize between
  565. * @param max min to denormalize between
  566. * @returns the denormalized value
  567. */
  568. static Denormalize(normalized: number, min: number, max: number): number;
  569. /**
  570. * Calculates the shortest difference between two given angles given in degrees.
  571. * @param current current angle in degrees
  572. * @param target target angle in degrees
  573. * @returns the delta
  574. */
  575. static DeltaAngle(current: number, target: number): number;
  576. /**
  577. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  578. * @param tx value
  579. * @param length length
  580. * @returns The returned value will move back and forth between 0 and length
  581. */
  582. static PingPong(tx: number, length: number): number;
  583. /**
  584. * Interpolates between min and max with smoothing at the limits.
  585. *
  586. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  587. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  588. * @param from from
  589. * @param to to
  590. * @param tx value
  591. * @returns the smooth stepped value
  592. */
  593. static SmoothStep(from: number, to: number, tx: number): number;
  594. /**
  595. * Moves a value current towards target.
  596. *
  597. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  598. * Negative values of maxDelta pushes the value away from target.
  599. * @param current current value
  600. * @param target target value
  601. * @param maxDelta max distance to move
  602. * @returns resulting value
  603. */
  604. static MoveTowards(current: number, target: number, maxDelta: number): number;
  605. /**
  606. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  607. *
  608. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  609. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  610. * @param current current value
  611. * @param target target value
  612. * @param maxDelta max distance to move
  613. * @returns resulting angle
  614. */
  615. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  616. /**
  617. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  618. * @param start start value
  619. * @param end target value
  620. * @param amount amount to lerp between
  621. * @returns the lerped value
  622. */
  623. static Lerp(start: number, end: number, amount: number): number;
  624. /**
  625. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  626. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  627. * @param start start value
  628. * @param end target value
  629. * @param amount amount to lerp between
  630. * @returns the lerped value
  631. */
  632. static LerpAngle(start: number, end: number, amount: number): number;
  633. /**
  634. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  635. * @param a start value
  636. * @param b target value
  637. * @param value value between a and b
  638. * @returns the inverseLerp value
  639. */
  640. static InverseLerp(a: number, b: number, value: number): number;
  641. /**
  642. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  643. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  644. * @param value1 spline value
  645. * @param tangent1 spline value
  646. * @param value2 spline value
  647. * @param tangent2 spline value
  648. * @param amount input value
  649. * @returns hermite result
  650. */
  651. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  652. /**
  653. * Returns a random float number between and min and max values
  654. * @param min min value of random
  655. * @param max max value of random
  656. * @returns random value
  657. */
  658. static RandomRange(min: number, max: number): number;
  659. /**
  660. * This function returns percentage of a number in a given range.
  661. *
  662. * RangeToPercent(40,20,60) will return 0.5 (50%)
  663. * RangeToPercent(34,0,100) will return 0.34 (34%)
  664. * @param number to convert to percentage
  665. * @param min min range
  666. * @param max max range
  667. * @returns the percentage
  668. */
  669. static RangeToPercent(number: number, min: number, max: number): number;
  670. /**
  671. * This function returns number that corresponds to the percentage in a given range.
  672. *
  673. * PercentToRange(0.34,0,100) will return 34.
  674. * @param percent to convert to number
  675. * @param min min range
  676. * @param max max range
  677. * @returns the number
  678. */
  679. static PercentToRange(percent: number, min: number, max: number): number;
  680. /**
  681. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  682. * @param angle The angle to normalize in radian.
  683. * @return The converted angle.
  684. */
  685. static NormalizeRadians(angle: number): number;
  686. }
  687. }
  688. declare module "babylonjs/Maths/math.constants" {
  689. /**
  690. * Constant used to convert a value to gamma space
  691. * @ignorenaming
  692. */
  693. export const ToGammaSpace: number;
  694. /**
  695. * Constant used to convert a value to linear space
  696. * @ignorenaming
  697. */
  698. export const ToLinearSpace = 2.2;
  699. /**
  700. * Constant used to define the minimal number value in Babylon.js
  701. * @ignorenaming
  702. */
  703. let Epsilon: number;
  704. export { Epsilon };
  705. }
  706. declare module "babylonjs/Maths/math.viewport" {
  707. /**
  708. * Class used to represent a viewport on screen
  709. */
  710. export class Viewport {
  711. /** viewport left coordinate */
  712. x: number;
  713. /** viewport top coordinate */
  714. y: number;
  715. /**viewport width */
  716. width: number;
  717. /** viewport height */
  718. height: number;
  719. /**
  720. * Creates a Viewport object located at (x, y) and sized (width, height)
  721. * @param x defines viewport left coordinate
  722. * @param y defines viewport top coordinate
  723. * @param width defines the viewport width
  724. * @param height defines the viewport height
  725. */
  726. constructor(
  727. /** viewport left coordinate */
  728. x: number,
  729. /** viewport top coordinate */
  730. y: number,
  731. /**viewport width */
  732. width: number,
  733. /** viewport height */
  734. height: number);
  735. /**
  736. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  737. * @param renderWidth defines the rendering width
  738. * @param renderHeight defines the rendering height
  739. * @returns a new Viewport
  740. */
  741. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  742. /**
  743. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  744. * @param renderWidth defines the rendering width
  745. * @param renderHeight defines the rendering height
  746. * @param ref defines the target viewport
  747. * @returns the current viewport
  748. */
  749. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  750. /**
  751. * Returns a new Viewport copied from the current one
  752. * @returns a new Viewport
  753. */
  754. clone(): Viewport;
  755. }
  756. }
  757. declare module "babylonjs/Misc/arrayTools" {
  758. /**
  759. * Class containing a set of static utilities functions for arrays.
  760. */
  761. export class ArrayTools {
  762. /**
  763. * Returns an array of the given size filled with element built from the given constructor and the paramters
  764. * @param size the number of element to construct and put in the array
  765. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  766. * @returns a new array filled with new objects
  767. */
  768. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  769. }
  770. }
  771. declare module "babylonjs/Maths/math.like" {
  772. import { float, int, DeepImmutable } from "babylonjs/types";
  773. /**
  774. * @hidden
  775. */
  776. export interface IColor4Like {
  777. r: float;
  778. g: float;
  779. b: float;
  780. a: float;
  781. }
  782. /**
  783. * @hidden
  784. */
  785. export interface IColor3Like {
  786. r: float;
  787. g: float;
  788. b: float;
  789. }
  790. /**
  791. * @hidden
  792. */
  793. export interface IVector4Like {
  794. x: float;
  795. y: float;
  796. z: float;
  797. w: float;
  798. }
  799. /**
  800. * @hidden
  801. */
  802. export interface IVector3Like {
  803. x: float;
  804. y: float;
  805. z: float;
  806. }
  807. /**
  808. * @hidden
  809. */
  810. export interface IVector2Like {
  811. x: float;
  812. y: float;
  813. }
  814. /**
  815. * @hidden
  816. */
  817. export interface IMatrixLike {
  818. toArray(): DeepImmutable<Float32Array>;
  819. updateFlag: int;
  820. }
  821. /**
  822. * @hidden
  823. */
  824. export interface IViewportLike {
  825. x: float;
  826. y: float;
  827. width: float;
  828. height: float;
  829. }
  830. /**
  831. * @hidden
  832. */
  833. export interface IPlaneLike {
  834. normal: IVector3Like;
  835. d: float;
  836. normalize(): void;
  837. }
  838. }
  839. declare module "babylonjs/Maths/math.vector" {
  840. import { Viewport } from "babylonjs/Maths/math.viewport";
  841. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  842. import { IPlaneLike } from "babylonjs/Maths/math.like";
  843. /**
  844. * Class representing a vector containing 2 coordinates
  845. */
  846. export class Vector2 {
  847. /** defines the first coordinate */
  848. x: number;
  849. /** defines the second coordinate */
  850. y: number;
  851. /**
  852. * Creates a new Vector2 from the given x and y coordinates
  853. * @param x defines the first coordinate
  854. * @param y defines the second coordinate
  855. */
  856. constructor(
  857. /** defines the first coordinate */
  858. x?: number,
  859. /** defines the second coordinate */
  860. y?: number);
  861. /**
  862. * Gets a string with the Vector2 coordinates
  863. * @returns a string with the Vector2 coordinates
  864. */
  865. toString(): string;
  866. /**
  867. * Gets class name
  868. * @returns the string "Vector2"
  869. */
  870. getClassName(): string;
  871. /**
  872. * Gets current vector hash code
  873. * @returns the Vector2 hash code as a number
  874. */
  875. getHashCode(): number;
  876. /**
  877. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  878. * @param array defines the source array
  879. * @param index defines the offset in source array
  880. * @returns the current Vector2
  881. */
  882. toArray(array: FloatArray, index?: number): Vector2;
  883. /**
  884. * Copy the current vector to an array
  885. * @returns a new array with 2 elements: the Vector2 coordinates.
  886. */
  887. asArray(): number[];
  888. /**
  889. * Sets the Vector2 coordinates with the given Vector2 coordinates
  890. * @param source defines the source Vector2
  891. * @returns the current updated Vector2
  892. */
  893. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  894. /**
  895. * Sets the Vector2 coordinates with the given floats
  896. * @param x defines the first coordinate
  897. * @param y defines the second coordinate
  898. * @returns the current updated Vector2
  899. */
  900. copyFromFloats(x: number, y: number): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. set(x: number, y: number): Vector2;
  908. /**
  909. * Add another vector with the current one
  910. * @param otherVector defines the other vector
  911. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  912. */
  913. add(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  916. * @param otherVector defines the other vector
  917. * @param result defines the target vector
  918. * @returns the unmodified current Vector2
  919. */
  920. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  921. /**
  922. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  923. * @param otherVector defines the other vector
  924. * @returns the current updated Vector2
  925. */
  926. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  927. /**
  928. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  929. * @param otherVector defines the other vector
  930. * @returns a new Vector2
  931. */
  932. addVector3(otherVector: Vector3): Vector2;
  933. /**
  934. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  935. * @param otherVector defines the other vector
  936. * @returns a new Vector2
  937. */
  938. subtract(otherVector: Vector2): Vector2;
  939. /**
  940. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  941. * @param otherVector defines the other vector
  942. * @param result defines the target vector
  943. * @returns the unmodified current Vector2
  944. */
  945. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  946. /**
  947. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns the current updated Vector2
  950. */
  951. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Multiplies in place the current Vector2 coordinates by the given ones
  954. * @param otherVector defines the other vector
  955. * @returns the current updated Vector2
  956. */
  957. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  958. /**
  959. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  960. * @param otherVector defines the other vector
  961. * @returns a new Vector2
  962. */
  963. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  964. /**
  965. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  966. * @param otherVector defines the other vector
  967. * @param result defines the target vector
  968. * @returns the unmodified current Vector2
  969. */
  970. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  971. /**
  972. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  973. * @param x defines the first coordinate
  974. * @param y defines the second coordinate
  975. * @returns a new Vector2
  976. */
  977. multiplyByFloats(x: number, y: number): Vector2;
  978. /**
  979. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  980. * @param otherVector defines the other vector
  981. * @returns a new Vector2
  982. */
  983. divide(otherVector: Vector2): Vector2;
  984. /**
  985. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  986. * @param otherVector defines the other vector
  987. * @param result defines the target vector
  988. * @returns the unmodified current Vector2
  989. */
  990. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  991. /**
  992. * Divides the current Vector2 coordinates by the given ones
  993. * @param otherVector defines the other vector
  994. * @returns the current updated Vector2
  995. */
  996. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  997. /**
  998. * Gets a new Vector2 with current Vector2 negated coordinates
  999. * @returns a new Vector2
  1000. */
  1001. negate(): Vector2;
  1002. /**
  1003. * Multiply the Vector2 coordinates by scale
  1004. * @param scale defines the scaling factor
  1005. * @returns the current updated Vector2
  1006. */
  1007. scaleInPlace(scale: number): Vector2;
  1008. /**
  1009. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1010. * @param scale defines the scaling factor
  1011. * @returns a new Vector2
  1012. */
  1013. scale(scale: number): Vector2;
  1014. /**
  1015. * Scale the current Vector2 values by a factor to a given Vector2
  1016. * @param scale defines the scale factor
  1017. * @param result defines the Vector2 object where to store the result
  1018. * @returns the unmodified current Vector2
  1019. */
  1020. scaleToRef(scale: number, result: Vector2): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Gets a boolean if two vectors are equals
  1030. * @param otherVector defines the other vector
  1031. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1032. */
  1033. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1034. /**
  1035. * Gets a boolean if two vectors are equals (using an epsilon value)
  1036. * @param otherVector defines the other vector
  1037. * @param epsilon defines the minimal distance to consider equality
  1038. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1039. */
  1040. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1041. /**
  1042. * Gets a new Vector2 from current Vector2 floored values
  1043. * @returns a new Vector2
  1044. */
  1045. floor(): Vector2;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. fract(): Vector2;
  1051. /**
  1052. * Gets the length of the vector
  1053. * @returns the vector length (float)
  1054. */
  1055. length(): number;
  1056. /**
  1057. * Gets the vector squared length
  1058. * @returns the vector squared length (float)
  1059. */
  1060. lengthSquared(): number;
  1061. /**
  1062. * Normalize the vector
  1063. * @returns the current updated Vector2
  1064. */
  1065. normalize(): Vector2;
  1066. /**
  1067. * Gets a new Vector2 copied from the Vector2
  1068. * @returns a new Vector2
  1069. */
  1070. clone(): Vector2;
  1071. /**
  1072. * Gets a new Vector2(0, 0)
  1073. * @returns a new Vector2
  1074. */
  1075. static Zero(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(1, 1)
  1078. * @returns a new Vector2
  1079. */
  1080. static One(): Vector2;
  1081. /**
  1082. * Gets a new Vector2 set from the given index element of the given array
  1083. * @param array defines the data source
  1084. * @param offset defines the offset in the data source
  1085. * @returns a new Vector2
  1086. */
  1087. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1088. /**
  1089. * Sets "result" from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @param result defines the target vector
  1093. */
  1094. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1095. /**
  1096. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1097. * @param value1 defines 1st point of control
  1098. * @param value2 defines 2nd point of control
  1099. * @param value3 defines 3rd point of control
  1100. * @param value4 defines 4th point of control
  1101. * @param amount defines the interpolation factor
  1102. * @returns a new Vector2
  1103. */
  1104. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1105. /**
  1106. * 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".
  1107. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1108. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1109. * @param value defines the value to clamp
  1110. * @param min defines the lower limit
  1111. * @param max defines the upper limit
  1112. * @returns a new Vector2
  1113. */
  1114. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1115. /**
  1116. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1117. * @param value1 defines the 1st control point
  1118. * @param tangent1 defines the outgoing tangent
  1119. * @param value2 defines the 2nd control point
  1120. * @param tangent2 defines the incoming tangent
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1127. * @param start defines the start vector
  1128. * @param end defines the end vector
  1129. * @param amount defines the interpolation factor
  1130. * @returns a new Vector2
  1131. */
  1132. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1133. /**
  1134. * Gets the dot product of the vector "left" and the vector "right"
  1135. * @param left defines first vector
  1136. * @param right defines second vector
  1137. * @returns the dot product (float)
  1138. */
  1139. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1140. /**
  1141. * Returns a new Vector2 equal to the normalized given vector
  1142. * @param vector defines the vector to normalize
  1143. * @returns a new Vector2
  1144. */
  1145. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1146. /**
  1147. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1148. * @param left defines 1st vector
  1149. * @param right defines 2nd vector
  1150. * @returns a new Vector2
  1151. */
  1152. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1162. * @param vector defines the vector to transform
  1163. * @param transformation defines the matrix to apply
  1164. * @returns a new Vector2
  1165. */
  1166. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1167. /**
  1168. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @param result defines the target vector
  1172. */
  1173. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1174. /**
  1175. * Determines if a given vector is included in a triangle
  1176. * @param p defines the vector to test
  1177. * @param p0 defines 1st triangle point
  1178. * @param p1 defines 2nd triangle point
  1179. * @param p2 defines 3rd triangle point
  1180. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1181. */
  1182. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1183. /**
  1184. * Gets the distance between the vectors "value1" and "value2"
  1185. * @param value1 defines first vector
  1186. * @param value2 defines second vector
  1187. * @returns the distance between vectors
  1188. */
  1189. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1190. /**
  1191. * Returns the squared distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the squared distance between vectors
  1195. */
  1196. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns a new Vector2
  1202. */
  1203. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1204. /**
  1205. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1206. * @param p defines the middle point
  1207. * @param segA defines one point of the segment
  1208. * @param segB defines the other point of the segment
  1209. * @returns the shortest distance
  1210. */
  1211. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1212. }
  1213. /**
  1214. * Classed used to store (x,y,z) vector representation
  1215. * A Vector3 is the main object used in 3D geometry
  1216. * It can represent etiher the coordinates of a point the space, either a direction
  1217. * Reminder: js uses a left handed forward facing system
  1218. */
  1219. export class Vector3 {
  1220. /**
  1221. * Defines the first coordinates (on X axis)
  1222. */
  1223. x: number;
  1224. /**
  1225. * Defines the second coordinates (on Y axis)
  1226. */
  1227. y: number;
  1228. /**
  1229. * Defines the third coordinates (on Z axis)
  1230. */
  1231. z: number;
  1232. private static _UpReadOnly;
  1233. private static _ZeroReadOnly;
  1234. /**
  1235. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1236. * @param x defines the first coordinates (on X axis)
  1237. * @param y defines the second coordinates (on Y axis)
  1238. * @param z defines the third coordinates (on Z axis)
  1239. */
  1240. constructor(
  1241. /**
  1242. * Defines the first coordinates (on X axis)
  1243. */
  1244. x?: number,
  1245. /**
  1246. * Defines the second coordinates (on Y axis)
  1247. */
  1248. y?: number,
  1249. /**
  1250. * Defines the third coordinates (on Z axis)
  1251. */
  1252. z?: number);
  1253. /**
  1254. * Creates a string representation of the Vector3
  1255. * @returns a string with the Vector3 coordinates.
  1256. */
  1257. toString(): string;
  1258. /**
  1259. * Gets the class name
  1260. * @returns the string "Vector3"
  1261. */
  1262. getClassName(): string;
  1263. /**
  1264. * Creates the Vector3 hash code
  1265. * @returns a number which tends to be unique between Vector3 instances
  1266. */
  1267. getHashCode(): number;
  1268. /**
  1269. * Creates an array containing three elements : the coordinates of the Vector3
  1270. * @returns a new array of numbers
  1271. */
  1272. asArray(): number[];
  1273. /**
  1274. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1275. * @param array defines the destination array
  1276. * @param index defines the offset in the destination array
  1277. * @returns the current Vector3
  1278. */
  1279. toArray(array: FloatArray, index?: number): Vector3;
  1280. /**
  1281. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1282. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1283. */
  1284. toQuaternion(): Quaternion;
  1285. /**
  1286. * Adds the given vector to the current Vector3
  1287. * @param otherVector defines the second operand
  1288. * @returns the current updated Vector3
  1289. */
  1290. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the given coordinates to the current Vector3
  1293. * @param x defines the x coordinate of the operand
  1294. * @param y defines the y coordinate of the operand
  1295. * @param z defines the z coordinate of the operand
  1296. * @returns the current updated Vector3
  1297. */
  1298. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1299. /**
  1300. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1301. * @param otherVector defines the second operand
  1302. * @returns the resulting Vector3
  1303. */
  1304. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1307. * @param otherVector defines the second operand
  1308. * @param result defines the Vector3 object where to store the result
  1309. * @returns the current Vector3
  1310. */
  1311. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1312. /**
  1313. * Subtract the given vector from the current Vector3
  1314. * @param otherVector defines the second operand
  1315. * @returns the current updated Vector3
  1316. */
  1317. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1318. /**
  1319. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1320. * @param otherVector defines the second operand
  1321. * @returns the resulting Vector3
  1322. */
  1323. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1324. /**
  1325. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1326. * @param otherVector defines the second operand
  1327. * @param result defines the Vector3 object where to store the result
  1328. * @returns the current Vector3
  1329. */
  1330. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1331. /**
  1332. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1333. * @param x defines the x coordinate of the operand
  1334. * @param y defines the y coordinate of the operand
  1335. * @param z defines the z coordinate of the operand
  1336. * @returns the resulting Vector3
  1337. */
  1338. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1339. /**
  1340. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1341. * @param x defines the x coordinate of the operand
  1342. * @param y defines the y coordinate of the operand
  1343. * @param z defines the z coordinate of the operand
  1344. * @param result defines the Vector3 object where to store the result
  1345. * @returns the current Vector3
  1346. */
  1347. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1348. /**
  1349. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1350. * @returns a new Vector3
  1351. */
  1352. negate(): Vector3;
  1353. /**
  1354. * Multiplies the Vector3 coordinates by the float "scale"
  1355. * @param scale defines the multiplier factor
  1356. * @returns the current updated Vector3
  1357. */
  1358. scaleInPlace(scale: number): Vector3;
  1359. /**
  1360. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1361. * @param scale defines the multiplier factor
  1362. * @returns a new Vector3
  1363. */
  1364. scale(scale: number): Vector3;
  1365. /**
  1366. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1367. * @param scale defines the multiplier factor
  1368. * @param result defines the Vector3 object where to store the result
  1369. * @returns the current Vector3
  1370. */
  1371. scaleToRef(scale: number, result: Vector3): Vector3;
  1372. /**
  1373. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1374. * @param scale defines the scale factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the unmodified current Vector3
  1377. */
  1378. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1381. * @param otherVector defines the second operand
  1382. * @returns true if both vectors are equals
  1383. */
  1384. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1385. /**
  1386. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1387. * @param otherVector defines the second operand
  1388. * @param epsilon defines the minimal distance to define values as equals
  1389. * @returns true if both vectors are distant less than epsilon
  1390. */
  1391. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 coordinates equals the given floats
  1394. * @param x defines the x coordinate of the operand
  1395. * @param y defines the y coordinate of the operand
  1396. * @param z defines the z coordinate of the operand
  1397. * @returns true if both vectors are equals
  1398. */
  1399. equalsToFloats(x: number, y: number, z: number): boolean;
  1400. /**
  1401. * Multiplies the current Vector3 coordinates by the given ones
  1402. * @param otherVector defines the second operand
  1403. * @returns the current updated Vector3
  1404. */
  1405. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1406. /**
  1407. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1408. * @param otherVector defines the second operand
  1409. * @returns the new Vector3
  1410. */
  1411. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1412. /**
  1413. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1414. * @param otherVector defines the second operand
  1415. * @param result defines the Vector3 object where to store the result
  1416. * @returns the current Vector3
  1417. */
  1418. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1419. /**
  1420. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1421. * @param x defines the x coordinate of the operand
  1422. * @param y defines the y coordinate of the operand
  1423. * @param z defines the z coordinate of the operand
  1424. * @returns the new Vector3
  1425. */
  1426. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1427. /**
  1428. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1429. * @param otherVector defines the second operand
  1430. * @returns the new Vector3
  1431. */
  1432. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1433. /**
  1434. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1435. * @param otherVector defines the second operand
  1436. * @param result defines the Vector3 object where to store the result
  1437. * @returns the current Vector3
  1438. */
  1439. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones.
  1442. * @param otherVector defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. divideInPlace(otherVector: Vector3): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1448. * @param other defines the second operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1454. * @param other defines the second operand
  1455. * @returns the current updated Vector3
  1456. */
  1457. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1458. /**
  1459. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1460. * @param x defines the x coordinate of the operand
  1461. * @param y defines the y coordinate of the operand
  1462. * @param z defines the z coordinate of the operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1466. /**
  1467. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1468. * @param x defines the x coordinate of the operand
  1469. * @param y defines the y coordinate of the operand
  1470. * @param z defines the z coordinate of the operand
  1471. * @returns the current updated Vector3
  1472. */
  1473. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1474. /**
  1475. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1476. * Check if is non uniform within a certain amount of decimal places to account for this
  1477. * @param epsilon the amount the values can differ
  1478. * @returns if the the vector is non uniform to a certain number of decimal places
  1479. */
  1480. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1481. /**
  1482. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1483. */
  1484. readonly isNonUniform: boolean;
  1485. /**
  1486. * Gets a new Vector3 from current Vector3 floored values
  1487. * @returns a new Vector3
  1488. */
  1489. floor(): Vector3;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. fract(): Vector3;
  1495. /**
  1496. * Gets the length of the Vector3
  1497. * @returns the length of the Vector3
  1498. */
  1499. length(): number;
  1500. /**
  1501. * Gets the squared length of the Vector3
  1502. * @returns squared length of the Vector3
  1503. */
  1504. lengthSquared(): number;
  1505. /**
  1506. * Normalize the current Vector3.
  1507. * Please note that this is an in place operation.
  1508. * @returns the current updated Vector3
  1509. */
  1510. normalize(): Vector3;
  1511. /**
  1512. * Reorders the x y z properties of the vector in place
  1513. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1514. * @returns the current updated vector
  1515. */
  1516. reorderInPlace(order: string): this;
  1517. /**
  1518. * Rotates the vector around 0,0,0 by a quaternion
  1519. * @param quaternion the rotation quaternion
  1520. * @param result vector to store the result
  1521. * @returns the resulting vector
  1522. */
  1523. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1524. /**
  1525. * Rotates a vector around a given point
  1526. * @param quaternion the rotation quaternion
  1527. * @param point the point to rotate around
  1528. * @param result vector to store the result
  1529. * @returns the resulting vector
  1530. */
  1531. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1532. /**
  1533. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1534. * The cross product is then orthogonal to both current and "other"
  1535. * @param other defines the right operand
  1536. * @returns the cross product
  1537. */
  1538. cross(other: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * 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"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * 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"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Checks if a given vector is inside a specific range
  1777. * @param v defines the vector to test
  1778. * @param min defines the minimum range
  1779. * @param max defines the maximum range
  1780. */
  1781. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1782. /**
  1783. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1784. * @param value1 defines the first control point
  1785. * @param tangent1 defines the first tangent vector
  1786. * @param value2 defines the second control point
  1787. * @param tangent2 defines the second tangent vector
  1788. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1789. * @returns the new Vector3
  1790. */
  1791. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1792. /**
  1793. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1794. * @param start defines the start value
  1795. * @param end defines the end value
  1796. * @param amount max defines amount between both (between 0 and 1)
  1797. * @returns the new Vector3
  1798. */
  1799. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1800. /**
  1801. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1802. * @param start defines the start value
  1803. * @param end defines the end value
  1804. * @param amount max defines amount between both (between 0 and 1)
  1805. * @param result defines the Vector3 where to store the result
  1806. */
  1807. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1808. /**
  1809. * Returns the dot product (float) between the vectors "left" and "right"
  1810. * @param left defines the left operand
  1811. * @param right defines the right operand
  1812. * @returns the dot product
  1813. */
  1814. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1815. /**
  1816. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1817. * The cross product is then orthogonal to both "left" and "right"
  1818. * @param left defines the left operand
  1819. * @param right defines the right operand
  1820. * @returns the cross product
  1821. */
  1822. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1823. /**
  1824. * Sets the given vector "result" with the cross product of "left" and "right"
  1825. * The cross product is then orthogonal to both "left" and "right"
  1826. * @param left defines the left operand
  1827. * @param right defines the right operand
  1828. * @param result defines the Vector3 where to store the result
  1829. */
  1830. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1831. /**
  1832. * Returns a new Vector3 as the normalization of the given vector
  1833. * @param vector defines the Vector3 to normalize
  1834. * @returns the new Vector3
  1835. */
  1836. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1837. /**
  1838. * Sets the given vector "result" with the normalization of the given first vector
  1839. * @param vector defines the Vector3 to normalize
  1840. * @param result defines the Vector3 where to store the result
  1841. */
  1842. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1843. /**
  1844. * Project a Vector3 onto screen space
  1845. * @param vector defines the Vector3 to project
  1846. * @param world defines the world matrix to use
  1847. * @param transform defines the transform (view x projection) matrix to use
  1848. * @param viewport defines the screen viewport to use
  1849. * @returns the new Vector3
  1850. */
  1851. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1852. /** @hidden */
  1853. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param transform defines the transform (view x projection) matrix to use
  1861. * @returns the new Vector3
  1862. */
  1863. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1864. /**
  1865. * Unproject from screen space to object space
  1866. * @param source defines the screen space Vector3 to use
  1867. * @param viewportWidth defines the current width of the viewport
  1868. * @param viewportHeight defines the current height of the viewport
  1869. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1870. * @param view defines the view matrix to use
  1871. * @param projection defines the projection matrix to use
  1872. * @returns the new Vector3
  1873. */
  1874. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1875. /**
  1876. * Unproject from screen space to object space
  1877. * @param source defines the screen space Vector3 to use
  1878. * @param viewportWidth defines the current width of the viewport
  1879. * @param viewportHeight defines the current height of the viewport
  1880. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1881. * @param view defines the view matrix to use
  1882. * @param projection defines the projection matrix to use
  1883. * @param result defines the Vector3 where to store the result
  1884. */
  1885. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1886. /**
  1887. * Unproject from screen space to object space
  1888. * @param sourceX defines the screen space x coordinate to use
  1889. * @param sourceY defines the screen space y coordinate to use
  1890. * @param sourceZ defines the screen space z coordinate to use
  1891. * @param viewportWidth defines the current width of the viewport
  1892. * @param viewportHeight defines the current height of the viewport
  1893. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1894. * @param view defines the view matrix to use
  1895. * @param projection defines the projection matrix to use
  1896. * @param result defines the Vector3 where to store the result
  1897. */
  1898. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1899. /**
  1900. * Gets the minimal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Gets the maximal coordinate values between two Vector3
  1908. * @param left defines the first operand
  1909. * @param right defines the second operand
  1910. * @returns the new Vector3
  1911. */
  1912. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * Returns the distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the distance
  1918. */
  1919. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns the squared distance between the vectors "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the squared distance
  1925. */
  1926. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1927. /**
  1928. * Returns a new Vector3 located at the center between "value1" and "value2"
  1929. * @param value1 defines the first operand
  1930. * @param value2 defines the second operand
  1931. * @returns the new Vector3
  1932. */
  1933. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1934. /**
  1935. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1936. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1937. * to something in order to rotate it from its local system to the given target system
  1938. * Note: axis1, axis2 and axis3 are normalized during this operation
  1939. * @param axis1 defines the first axis
  1940. * @param axis2 defines the second axis
  1941. * @param axis3 defines the third axis
  1942. * @returns a new Vector3
  1943. */
  1944. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1947. * @param axis1 defines the first axis
  1948. * @param axis2 defines the second axis
  1949. * @param axis3 defines the third axis
  1950. * @param ref defines the Vector3 where to store the result
  1951. */
  1952. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1953. }
  1954. /**
  1955. * Vector4 class created for EulerAngle class conversion to Quaternion
  1956. */
  1957. export class Vector4 {
  1958. /** x value of the vector */
  1959. x: number;
  1960. /** y value of the vector */
  1961. y: number;
  1962. /** z value of the vector */
  1963. z: number;
  1964. /** w value of the vector */
  1965. w: number;
  1966. /**
  1967. * Creates a Vector4 object from the given floats.
  1968. * @param x x value of the vector
  1969. * @param y y value of the vector
  1970. * @param z z value of the vector
  1971. * @param w w value of the vector
  1972. */
  1973. constructor(
  1974. /** x value of the vector */
  1975. x: number,
  1976. /** y value of the vector */
  1977. y: number,
  1978. /** z value of the vector */
  1979. z: number,
  1980. /** w value of the vector */
  1981. w: number);
  1982. /**
  1983. * Returns the string with the Vector4 coordinates.
  1984. * @returns a string containing all the vector values
  1985. */
  1986. toString(): string;
  1987. /**
  1988. * Returns the string "Vector4".
  1989. * @returns "Vector4"
  1990. */
  1991. getClassName(): string;
  1992. /**
  1993. * Returns the Vector4 hash code.
  1994. * @returns a unique hash code
  1995. */
  1996. getHashCode(): number;
  1997. /**
  1998. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1999. * @returns the resulting array
  2000. */
  2001. asArray(): number[];
  2002. /**
  2003. * Populates the given array from the given index with the Vector4 coordinates.
  2004. * @param array array to populate
  2005. * @param index index of the array to start at (default: 0)
  2006. * @returns the Vector4.
  2007. */
  2008. toArray(array: FloatArray, index?: number): Vector4;
  2009. /**
  2010. * Adds the given vector to the current Vector4.
  2011. * @param otherVector the vector to add
  2012. * @returns the updated Vector4.
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2015. /**
  2016. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2017. * @param otherVector the vector to add
  2018. * @returns the resulting vector
  2019. */
  2020. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2021. /**
  2022. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2023. * @param otherVector the vector to add
  2024. * @param result the vector to store the result
  2025. * @returns the current Vector4.
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2028. /**
  2029. * Subtract in place the given vector from the current Vector4.
  2030. * @param otherVector the vector to subtract
  2031. * @returns the updated Vector4.
  2032. */
  2033. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2034. /**
  2035. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2036. * @param otherVector the vector to add
  2037. * @returns the new vector with the result
  2038. */
  2039. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2040. /**
  2041. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2042. * @param otherVector the vector to subtract
  2043. * @param result the vector to store the result
  2044. * @returns the current Vector4.
  2045. */
  2046. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2049. */
  2050. /**
  2051. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @returns new vector containing the result
  2057. */
  2058. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2059. /**
  2060. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2061. * @param x value to subtract
  2062. * @param y value to subtract
  2063. * @param z value to subtract
  2064. * @param w value to subtract
  2065. * @param result the vector to store the result in
  2066. * @returns the current Vector4.
  2067. */
  2068. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2069. /**
  2070. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2071. * @returns a new vector with the negated values
  2072. */
  2073. negate(): Vector4;
  2074. /**
  2075. * Multiplies the current Vector4 coordinates by scale (float).
  2076. * @param scale the number to scale with
  2077. * @returns the updated Vector4.
  2078. */
  2079. scaleInPlace(scale: number): Vector4;
  2080. /**
  2081. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2082. * @param scale the number to scale with
  2083. * @returns a new vector with the result
  2084. */
  2085. scale(scale: number): Vector4;
  2086. /**
  2087. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2088. * @param scale the number to scale with
  2089. * @param result a vector to store the result in
  2090. * @returns the current Vector4.
  2091. */
  2092. scaleToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2095. * @param scale defines the scale factor
  2096. * @param result defines the Vector4 object where to store the result
  2097. * @returns the unmodified current Vector4
  2098. */
  2099. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2100. /**
  2101. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2102. * @param otherVector the vector to compare against
  2103. * @returns true if they are equal
  2104. */
  2105. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2106. /**
  2107. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2108. * @param otherVector vector to compare against
  2109. * @param epsilon (Default: very small number)
  2110. * @returns true if they are equal
  2111. */
  2112. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2113. /**
  2114. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2115. * @param x x value to compare against
  2116. * @param y y value to compare against
  2117. * @param z z value to compare against
  2118. * @param w w value to compare against
  2119. * @returns true if equal
  2120. */
  2121. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2122. /**
  2123. * Multiplies in place the current Vector4 by the given one.
  2124. * @param otherVector vector to multiple with
  2125. * @returns the updated Vector4.
  2126. */
  2127. multiplyInPlace(otherVector: Vector4): Vector4;
  2128. /**
  2129. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2130. * @param otherVector vector to multiple with
  2131. * @returns resulting new vector
  2132. */
  2133. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2134. /**
  2135. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2136. * @param otherVector vector to multiple with
  2137. * @param result vector to store the result
  2138. * @returns the current Vector4.
  2139. */
  2140. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2143. * @param x x value multiply with
  2144. * @param y y value multiply with
  2145. * @param z z value multiply with
  2146. * @param w w value multiply with
  2147. * @returns resulting new vector
  2148. */
  2149. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2150. /**
  2151. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2152. * @param otherVector vector to devide with
  2153. * @returns resulting new vector
  2154. */
  2155. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2156. /**
  2157. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2158. * @param otherVector vector to devide with
  2159. * @param result vector to store the result
  2160. * @returns the current Vector4.
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2163. /**
  2164. * Divides the current Vector3 coordinates by the given ones.
  2165. * @param otherVector vector to devide with
  2166. * @returns the updated Vector3.
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2169. /**
  2170. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2171. * @param other defines the second operand
  2172. * @returns the current updated Vector4
  2173. */
  2174. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2175. /**
  2176. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2177. * @param other defines the second operand
  2178. * @returns the current updated Vector4
  2179. */
  2180. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2181. /**
  2182. * Gets a new Vector4 from current Vector4 floored values
  2183. * @returns a new Vector4
  2184. */
  2185. floor(): Vector4;
  2186. /**
  2187. * Gets a new Vector4 from current Vector3 floored values
  2188. * @returns a new Vector4
  2189. */
  2190. fract(): Vector4;
  2191. /**
  2192. * Returns the Vector4 length (float).
  2193. * @returns the length
  2194. */
  2195. length(): number;
  2196. /**
  2197. * Returns the Vector4 squared length (float).
  2198. * @returns the length squared
  2199. */
  2200. lengthSquared(): number;
  2201. /**
  2202. * Normalizes in place the Vector4.
  2203. * @returns the updated Vector4.
  2204. */
  2205. normalize(): Vector4;
  2206. /**
  2207. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2208. * @returns this converted to a new vector3
  2209. */
  2210. toVector3(): Vector3;
  2211. /**
  2212. * Returns a new Vector4 copied from the current one.
  2213. * @returns the new cloned vector
  2214. */
  2215. clone(): Vector4;
  2216. /**
  2217. * Updates the current Vector4 with the given one coordinates.
  2218. * @param source the source vector to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to copy from
  2225. * @param y float to copy from
  2226. * @param z float to copy from
  2227. * @param w float to copy from
  2228. * @returns the updated Vector4.
  2229. */
  2230. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Updates the current Vector4 coordinates with the given floats.
  2233. * @param x float to set from
  2234. * @param y float to set from
  2235. * @param z float to set from
  2236. * @param w float to set from
  2237. * @returns the updated Vector4.
  2238. */
  2239. set(x: number, y: number, z: number, w: number): Vector4;
  2240. /**
  2241. * Copies the given float to the current Vector3 coordinates
  2242. * @param v defines the x, y, z and w coordinates of the operand
  2243. * @returns the current updated Vector3
  2244. */
  2245. setAll(v: number): Vector4;
  2246. /**
  2247. * Returns a new Vector4 set from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @returns the new vector
  2251. */
  2252. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" from the starting index of the given Float32Array.
  2262. * @param array the array to pull values from
  2263. * @param offset the offset into the array to start at
  2264. * @param result the vector to store the result in
  2265. */
  2266. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2267. /**
  2268. * Updates the given vector "result" coordinates from the given floats.
  2269. * @param x float to set from
  2270. * @param y float to set from
  2271. * @param z float to set from
  2272. * @param w float to set from
  2273. * @param result the vector to the floats in
  2274. */
  2275. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2276. /**
  2277. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2278. * @returns the new vector
  2279. */
  2280. static Zero(): Vector4;
  2281. /**
  2282. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2283. * @returns the new vector
  2284. */
  2285. static One(): Vector4;
  2286. /**
  2287. * Returns a new normalized Vector4 from the given one.
  2288. * @param vector the vector to normalize
  2289. * @returns the vector
  2290. */
  2291. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2292. /**
  2293. * Updates the given vector "result" from the normalization of the given one.
  2294. * @param vector the vector to normalize
  2295. * @param result the vector to store the result in
  2296. */
  2297. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2298. /**
  2299. * Returns a vector with the minimum values from the left and right vectors
  2300. * @param left left vector to minimize
  2301. * @param right right vector to minimize
  2302. * @returns a new vector with the minimum of the left and right vector values
  2303. */
  2304. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns a vector with the maximum values from the left and right vectors
  2307. * @param left left vector to maximize
  2308. * @param right right vector to maximize
  2309. * @returns a new vector with the maximum of the left and right vector values
  2310. */
  2311. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2312. /**
  2313. * Returns the distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors
  2317. */
  2318. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the distance between
  2322. * @param value2 value to calulate the distance between
  2323. * @return the distance between the two vectors squared
  2324. */
  2325. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2326. /**
  2327. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2328. * @param value1 value to calulate the center between
  2329. * @param value2 value to calulate the center between
  2330. * @return the center between the two vectors
  2331. */
  2332. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2333. /**
  2334. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2335. * This methods computes transformed normalized direction vectors only.
  2336. * @param vector the vector to transform
  2337. * @param transformation the transformation matrix to apply
  2338. * @returns the new vector
  2339. */
  2340. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2341. /**
  2342. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2343. * This methods computes transformed normalized direction vectors only.
  2344. * @param vector the vector to transform
  2345. * @param transformation the transformation matrix to apply
  2346. * @param result the vector to store the result in
  2347. */
  2348. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2349. /**
  2350. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2351. * This methods computes transformed normalized direction vectors only.
  2352. * @param x value to transform
  2353. * @param y value to transform
  2354. * @param z value to transform
  2355. * @param w value to transform
  2356. * @param transformation the transformation matrix to apply
  2357. * @param result the vector to store the results in
  2358. */
  2359. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2360. /**
  2361. * Creates a new Vector4 from a Vector3
  2362. * @param source defines the source data
  2363. * @param w defines the 4th component (default is 0)
  2364. * @returns a new Vector4
  2365. */
  2366. static FromVector3(source: Vector3, w?: number): Vector4;
  2367. }
  2368. /**
  2369. * Class used to store quaternion data
  2370. * @see https://en.wikipedia.org/wiki/Quaternion
  2371. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2372. */
  2373. export class Quaternion {
  2374. /** defines the first component (0 by default) */
  2375. x: number;
  2376. /** defines the second component (0 by default) */
  2377. y: number;
  2378. /** defines the third component (0 by default) */
  2379. z: number;
  2380. /** defines the fourth component (1.0 by default) */
  2381. w: number;
  2382. /**
  2383. * Creates a new Quaternion from the given floats
  2384. * @param x defines the first component (0 by default)
  2385. * @param y defines the second component (0 by default)
  2386. * @param z defines the third component (0 by default)
  2387. * @param w defines the fourth component (1.0 by default)
  2388. */
  2389. constructor(
  2390. /** defines the first component (0 by default) */
  2391. x?: number,
  2392. /** defines the second component (0 by default) */
  2393. y?: number,
  2394. /** defines the third component (0 by default) */
  2395. z?: number,
  2396. /** defines the fourth component (1.0 by default) */
  2397. w?: number);
  2398. /**
  2399. * Gets a string representation for the current quaternion
  2400. * @returns a string with the Quaternion coordinates
  2401. */
  2402. toString(): string;
  2403. /**
  2404. * Gets the class name of the quaternion
  2405. * @returns the string "Quaternion"
  2406. */
  2407. getClassName(): string;
  2408. /**
  2409. * Gets a hash code for this quaternion
  2410. * @returns the quaternion hash code
  2411. */
  2412. getHashCode(): number;
  2413. /**
  2414. * Copy the quaternion to an array
  2415. * @returns a new array populated with 4 elements from the quaternion coordinates
  2416. */
  2417. asArray(): number[];
  2418. /**
  2419. * Check if two quaternions are equals
  2420. * @param otherQuaternion defines the second operand
  2421. * @return true if the current quaternion and the given one coordinates are strictly equals
  2422. */
  2423. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2424. /**
  2425. * Clone the current quaternion
  2426. * @returns a new quaternion copied from the current one
  2427. */
  2428. clone(): Quaternion;
  2429. /**
  2430. * Copy a quaternion to the current one
  2431. * @param other defines the other quaternion
  2432. * @returns the updated current quaternion
  2433. */
  2434. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2435. /**
  2436. * Updates the current quaternion with the given float coordinates
  2437. * @param x defines the x coordinate
  2438. * @param y defines the y coordinate
  2439. * @param z defines the z coordinate
  2440. * @param w defines the w coordinate
  2441. * @returns the updated current quaternion
  2442. */
  2443. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2444. /**
  2445. * Updates the current quaternion from the given float coordinates
  2446. * @param x defines the x coordinate
  2447. * @param y defines the y coordinate
  2448. * @param z defines the z coordinate
  2449. * @param w defines the w coordinate
  2450. * @returns the updated current quaternion
  2451. */
  2452. set(x: number, y: number, z: number, w: number): Quaternion;
  2453. /**
  2454. * Adds two quaternions
  2455. * @param other defines the second operand
  2456. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2457. */
  2458. add(other: DeepImmutable<Quaternion>): Quaternion;
  2459. /**
  2460. * Add a quaternion to the current one
  2461. * @param other defines the quaternion to add
  2462. * @returns the current quaternion
  2463. */
  2464. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2465. /**
  2466. * Subtract two quaternions
  2467. * @param other defines the second operand
  2468. * @returns a new quaternion as the subtraction result of the given one from the current one
  2469. */
  2470. subtract(other: Quaternion): Quaternion;
  2471. /**
  2472. * Multiplies the current quaternion by a scale factor
  2473. * @param value defines the scale factor
  2474. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2475. */
  2476. scale(value: number): Quaternion;
  2477. /**
  2478. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2479. * @param scale defines the scale factor
  2480. * @param result defines the Quaternion object where to store the result
  2481. * @returns the unmodified current quaternion
  2482. */
  2483. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2484. /**
  2485. * Multiplies in place the current quaternion by a scale factor
  2486. * @param value defines the scale factor
  2487. * @returns the current modified quaternion
  2488. */
  2489. scaleInPlace(value: number): Quaternion;
  2490. /**
  2491. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2492. * @param scale defines the scale factor
  2493. * @param result defines the Quaternion object where to store the result
  2494. * @returns the unmodified current quaternion
  2495. */
  2496. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2497. /**
  2498. * Multiplies two quaternions
  2499. * @param q1 defines the second operand
  2500. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2501. */
  2502. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2503. /**
  2504. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2505. * @param q1 defines the second operand
  2506. * @param result defines the target quaternion
  2507. * @returns the current quaternion
  2508. */
  2509. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2510. /**
  2511. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2512. * @param q1 defines the second operand
  2513. * @returns the currentupdated quaternion
  2514. */
  2515. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2518. * @param ref defines the target quaternion
  2519. * @returns the current quaternion
  2520. */
  2521. conjugateToRef(ref: Quaternion): Quaternion;
  2522. /**
  2523. * Conjugates in place (1-q) the current quaternion
  2524. * @returns the current updated quaternion
  2525. */
  2526. conjugateInPlace(): Quaternion;
  2527. /**
  2528. * Conjugates in place (1-q) the current quaternion
  2529. * @returns a new quaternion
  2530. */
  2531. conjugate(): Quaternion;
  2532. /**
  2533. * Gets length of current quaternion
  2534. * @returns the quaternion length (float)
  2535. */
  2536. length(): number;
  2537. /**
  2538. * Normalize in place the current quaternion
  2539. * @returns the current updated quaternion
  2540. */
  2541. normalize(): Quaternion;
  2542. /**
  2543. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2544. * @param order is a reserved parameter and is ignore for now
  2545. * @returns a new Vector3 containing the Euler angles
  2546. */
  2547. toEulerAngles(order?: string): Vector3;
  2548. /**
  2549. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2550. * @param result defines the vector which will be filled with the Euler angles
  2551. * @param order is a reserved parameter and is ignore for now
  2552. * @returns the current unchanged quaternion
  2553. */
  2554. toEulerAnglesToRef(result: Vector3): Quaternion;
  2555. /**
  2556. * Updates the given rotation matrix with the current quaternion values
  2557. * @param result defines the target matrix
  2558. * @returns the current unchanged quaternion
  2559. */
  2560. toRotationMatrix(result: Matrix): Quaternion;
  2561. /**
  2562. * Updates the current quaternion from the given rotation matrix values
  2563. * @param matrix defines the source matrix
  2564. * @returns the current updated quaternion
  2565. */
  2566. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2567. /**
  2568. * Creates a new quaternion from a rotation matrix
  2569. * @param matrix defines the source matrix
  2570. * @returns a new quaternion created from the given rotation matrix values
  2571. */
  2572. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2573. /**
  2574. * Updates the given quaternion with the given rotation matrix values
  2575. * @param matrix defines the source matrix
  2576. * @param result defines the target quaternion
  2577. */
  2578. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2579. /**
  2580. * Returns the dot product (float) between the quaternions "left" and "right"
  2581. * @param left defines the left operand
  2582. * @param right defines the right operand
  2583. * @returns the dot product
  2584. */
  2585. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2586. /**
  2587. * Checks if the two quaternions are close to each other
  2588. * @param quat0 defines the first quaternion to check
  2589. * @param quat1 defines the second quaternion to check
  2590. * @returns true if the two quaternions are close to each other
  2591. */
  2592. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2593. /**
  2594. * Creates an empty quaternion
  2595. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2596. */
  2597. static Zero(): Quaternion;
  2598. /**
  2599. * Inverse a given quaternion
  2600. * @param q defines the source quaternion
  2601. * @returns a new quaternion as the inverted current quaternion
  2602. */
  2603. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2604. /**
  2605. * Inverse a given quaternion
  2606. * @param q defines the source quaternion
  2607. * @param result the quaternion the result will be stored in
  2608. * @returns the result quaternion
  2609. */
  2610. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2611. /**
  2612. * Creates an identity quaternion
  2613. * @returns the identity quaternion
  2614. */
  2615. static Identity(): Quaternion;
  2616. /**
  2617. * Gets a boolean indicating if the given quaternion is identity
  2618. * @param quaternion defines the quaternion to check
  2619. * @returns true if the quaternion is identity
  2620. */
  2621. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2622. /**
  2623. * Creates a quaternion from a rotation around an axis
  2624. * @param axis defines the axis to use
  2625. * @param angle defines the angle to use
  2626. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2627. */
  2628. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2629. /**
  2630. * Creates a rotation around an axis and stores it into the given quaternion
  2631. * @param axis defines the axis to use
  2632. * @param angle defines the angle to use
  2633. * @param result defines the target quaternion
  2634. * @returns the target quaternion
  2635. */
  2636. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2637. /**
  2638. * Creates a new quaternion from data stored into an array
  2639. * @param array defines the data source
  2640. * @param offset defines the offset in the source array where the data starts
  2641. * @returns a new quaternion
  2642. */
  2643. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2644. /**
  2645. * Create a quaternion from Euler rotation angles
  2646. * @param x Pitch
  2647. * @param y Yaw
  2648. * @param z Roll
  2649. * @returns the new Quaternion
  2650. */
  2651. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2652. /**
  2653. * Updates a quaternion from Euler rotation angles
  2654. * @param x Pitch
  2655. * @param y Yaw
  2656. * @param z Roll
  2657. * @param result the quaternion to store the result
  2658. * @returns the updated quaternion
  2659. */
  2660. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2661. /**
  2662. * Create a quaternion from Euler rotation vector
  2663. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2664. * @returns the new Quaternion
  2665. */
  2666. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2667. /**
  2668. * Updates a quaternion from Euler rotation vector
  2669. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2670. * @param result the quaternion to store the result
  2671. * @returns the updated quaternion
  2672. */
  2673. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2674. /**
  2675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2676. * @param yaw defines the rotation around Y axis
  2677. * @param pitch defines the rotation around X axis
  2678. * @param roll defines the rotation around Z axis
  2679. * @returns the new quaternion
  2680. */
  2681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2682. /**
  2683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2684. * @param yaw defines the rotation around Y axis
  2685. * @param pitch defines the rotation around X axis
  2686. * @param roll defines the rotation around Z axis
  2687. * @param result defines the target quaternion
  2688. */
  2689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2690. /**
  2691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2692. * @param alpha defines the rotation around first axis
  2693. * @param beta defines the rotation around second axis
  2694. * @param gamma defines the rotation around third axis
  2695. * @returns the new quaternion
  2696. */
  2697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2698. /**
  2699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2700. * @param alpha defines the rotation around first axis
  2701. * @param beta defines the rotation around second axis
  2702. * @param gamma defines the rotation around third axis
  2703. * @param result defines the target quaternion
  2704. */
  2705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2706. /**
  2707. * 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)
  2708. * @param axis1 defines the first axis
  2709. * @param axis2 defines the second axis
  2710. * @param axis3 defines the third axis
  2711. * @returns the new quaternion
  2712. */
  2713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2714. /**
  2715. * 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
  2716. * @param axis1 defines the first axis
  2717. * @param axis2 defines the second axis
  2718. * @param axis3 defines the third axis
  2719. * @param ref defines the target quaternion
  2720. */
  2721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2722. /**
  2723. * Interpolates between two quaternions
  2724. * @param left defines first quaternion
  2725. * @param right defines second quaternion
  2726. * @param amount defines the gradient to use
  2727. * @returns the new interpolated quaternion
  2728. */
  2729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2730. /**
  2731. * Interpolates between two quaternions and stores it into a target quaternion
  2732. * @param left defines first quaternion
  2733. * @param right defines second quaternion
  2734. * @param amount defines the gradient to use
  2735. * @param result defines the target quaternion
  2736. */
  2737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2738. /**
  2739. * Interpolate between two quaternions using Hermite interpolation
  2740. * @param value1 defines first quaternion
  2741. * @param tangent1 defines the incoming tangent
  2742. * @param value2 defines second quaternion
  2743. * @param tangent2 defines the outgoing tangent
  2744. * @param amount defines the target quaternion
  2745. * @returns the new interpolated quaternion
  2746. */
  2747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2748. }
  2749. /**
  2750. * Class used to store matrix data (4x4)
  2751. */
  2752. export class Matrix {
  2753. private static _updateFlagSeed;
  2754. private static _identityReadOnly;
  2755. private _isIdentity;
  2756. private _isIdentityDirty;
  2757. private _isIdentity3x2;
  2758. private _isIdentity3x2Dirty;
  2759. /**
  2760. * Gets the update flag of the matrix which is an unique number for the matrix.
  2761. * It will be incremented every time the matrix data change.
  2762. * You can use it to speed the comparison between two versions of the same matrix.
  2763. */
  2764. updateFlag: number;
  2765. private readonly _m;
  2766. /**
  2767. * Gets the internal data of the matrix
  2768. */
  2769. readonly m: DeepImmutable<Float32Array>;
  2770. /** @hidden */
  2771. _markAsUpdated(): void;
  2772. /** @hidden */
  2773. private _updateIdentityStatus;
  2774. /**
  2775. * Creates an empty matrix (filled with zeros)
  2776. */
  2777. constructor();
  2778. /**
  2779. * Check if the current matrix is identity
  2780. * @returns true is the matrix is the identity matrix
  2781. */
  2782. isIdentity(): boolean;
  2783. /**
  2784. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2785. * @returns true is the matrix is the identity matrix
  2786. */
  2787. isIdentityAs3x2(): boolean;
  2788. /**
  2789. * Gets the determinant of the matrix
  2790. * @returns the matrix determinant
  2791. */
  2792. determinant(): number;
  2793. /**
  2794. * Returns the matrix as a Float32Array
  2795. * @returns the matrix underlying array
  2796. */
  2797. toArray(): DeepImmutable<Float32Array>;
  2798. /**
  2799. * Returns the matrix as a Float32Array
  2800. * @returns the matrix underlying array.
  2801. */
  2802. asArray(): DeepImmutable<Float32Array>;
  2803. /**
  2804. * Inverts the current matrix in place
  2805. * @returns the current inverted matrix
  2806. */
  2807. invert(): Matrix;
  2808. /**
  2809. * Sets all the matrix elements to zero
  2810. * @returns the current matrix
  2811. */
  2812. reset(): Matrix;
  2813. /**
  2814. * Adds the current matrix with a second one
  2815. * @param other defines the matrix to add
  2816. * @returns a new matrix as the addition of the current matrix and the given one
  2817. */
  2818. add(other: DeepImmutable<Matrix>): Matrix;
  2819. /**
  2820. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2821. * @param other defines the matrix to add
  2822. * @param result defines the target matrix
  2823. * @returns the current matrix
  2824. */
  2825. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2826. /**
  2827. * Adds in place the given matrix to the current matrix
  2828. * @param other defines the second operand
  2829. * @returns the current updated matrix
  2830. */
  2831. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2832. /**
  2833. * Sets the given matrix to the current inverted Matrix
  2834. * @param other defines the target matrix
  2835. * @returns the unmodified current matrix
  2836. */
  2837. invertToRef(other: Matrix): Matrix;
  2838. /**
  2839. * add a value at the specified position in the current Matrix
  2840. * @param index the index of the value within the matrix. between 0 and 15.
  2841. * @param value the value to be added
  2842. * @returns the current updated matrix
  2843. */
  2844. addAtIndex(index: number, value: number): Matrix;
  2845. /**
  2846. * mutiply the specified position in the current Matrix by a value
  2847. * @param index the index of the value within the matrix. between 0 and 15.
  2848. * @param value the value to be added
  2849. * @returns the current updated matrix
  2850. */
  2851. multiplyAtIndex(index: number, value: number): Matrix;
  2852. /**
  2853. * Inserts the translation vector (using 3 floats) in the current matrix
  2854. * @param x defines the 1st component of the translation
  2855. * @param y defines the 2nd component of the translation
  2856. * @param z defines the 3rd component of the translation
  2857. * @returns the current updated matrix
  2858. */
  2859. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2860. /**
  2861. * Adds the translation vector (using 3 floats) in the current matrix
  2862. * @param x defines the 1st component of the translation
  2863. * @param y defines the 2nd component of the translation
  2864. * @param z defines the 3rd component of the translation
  2865. * @returns the current updated matrix
  2866. */
  2867. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2868. /**
  2869. * Inserts the translation vector in the current matrix
  2870. * @param vector3 defines the translation to insert
  2871. * @returns the current updated matrix
  2872. */
  2873. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2874. /**
  2875. * Gets the translation value of the current matrix
  2876. * @returns a new Vector3 as the extracted translation from the matrix
  2877. */
  2878. getTranslation(): Vector3;
  2879. /**
  2880. * Fill a Vector3 with the extracted translation from the matrix
  2881. * @param result defines the Vector3 where to store the translation
  2882. * @returns the current matrix
  2883. */
  2884. getTranslationToRef(result: Vector3): Matrix;
  2885. /**
  2886. * Remove rotation and scaling part from the matrix
  2887. * @returns the updated matrix
  2888. */
  2889. removeRotationAndScaling(): Matrix;
  2890. /**
  2891. * Multiply two matrices
  2892. * @param other defines the second operand
  2893. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2894. */
  2895. multiply(other: DeepImmutable<Matrix>): Matrix;
  2896. /**
  2897. * Copy the current matrix from the given one
  2898. * @param other defines the source matrix
  2899. * @returns the current updated matrix
  2900. */
  2901. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Populates the given array from the starting index with the current matrix values
  2904. * @param array defines the target array
  2905. * @param offset defines the offset in the target array where to start storing values
  2906. * @returns the current matrix
  2907. */
  2908. copyToArray(array: Float32Array, offset?: number): Matrix;
  2909. /**
  2910. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2911. * @param other defines the second operand
  2912. * @param result defines the matrix where to store the multiplication
  2913. * @returns the current matrix
  2914. */
  2915. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2916. /**
  2917. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2918. * @param other defines the second operand
  2919. * @param result defines the array where to store the multiplication
  2920. * @param offset defines the offset in the target array where to start storing values
  2921. * @returns the current matrix
  2922. */
  2923. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2924. /**
  2925. * Check equality between this matrix and a second one
  2926. * @param value defines the second matrix to compare
  2927. * @returns true is the current matrix and the given one values are strictly equal
  2928. */
  2929. equals(value: DeepImmutable<Matrix>): boolean;
  2930. /**
  2931. * Clone the current matrix
  2932. * @returns a new matrix from the current matrix
  2933. */
  2934. clone(): Matrix;
  2935. /**
  2936. * Returns the name of the current matrix class
  2937. * @returns the string "Matrix"
  2938. */
  2939. getClassName(): string;
  2940. /**
  2941. * Gets the hash code of the current matrix
  2942. * @returns the hash code
  2943. */
  2944. getHashCode(): number;
  2945. /**
  2946. * Decomposes the current Matrix into a translation, rotation and scaling components
  2947. * @param scale defines the scale vector3 given as a reference to update
  2948. * @param rotation defines the rotation quaternion given as a reference to update
  2949. * @param translation defines the translation vector3 given as a reference to update
  2950. * @returns true if operation was successful
  2951. */
  2952. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2953. /**
  2954. * Gets specific row of the matrix
  2955. * @param index defines the number of the row to get
  2956. * @returns the index-th row of the current matrix as a new Vector4
  2957. */
  2958. getRow(index: number): Nullable<Vector4>;
  2959. /**
  2960. * Sets the index-th row of the current matrix to the vector4 values
  2961. * @param index defines the number of the row to set
  2962. * @param row defines the target vector4
  2963. * @returns the updated current matrix
  2964. */
  2965. setRow(index: number, row: Vector4): Matrix;
  2966. /**
  2967. * Compute the transpose of the matrix
  2968. * @returns the new transposed matrix
  2969. */
  2970. transpose(): Matrix;
  2971. /**
  2972. * Compute the transpose of the matrix and store it in a given matrix
  2973. * @param result defines the target matrix
  2974. * @returns the current matrix
  2975. */
  2976. transposeToRef(result: Matrix): Matrix;
  2977. /**
  2978. * Sets the index-th row of the current matrix with the given 4 x float values
  2979. * @param index defines the row index
  2980. * @param x defines the x component to set
  2981. * @param y defines the y component to set
  2982. * @param z defines the z component to set
  2983. * @param w defines the w component to set
  2984. * @returns the updated current matrix
  2985. */
  2986. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2987. /**
  2988. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2989. * @param scale defines the scale factor
  2990. * @returns a new matrix
  2991. */
  2992. scale(scale: number): Matrix;
  2993. /**
  2994. * Scale the current matrix values by a factor to a given result matrix
  2995. * @param scale defines the scale factor
  2996. * @param result defines the matrix to store the result
  2997. * @returns the current matrix
  2998. */
  2999. scaleToRef(scale: number, result: Matrix): Matrix;
  3000. /**
  3001. * Scale the current matrix values by a factor and add the result to a given matrix
  3002. * @param scale defines the scale factor
  3003. * @param result defines the Matrix to store the result
  3004. * @returns the current matrix
  3005. */
  3006. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3007. /**
  3008. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3009. * @param ref matrix to store the result
  3010. */
  3011. toNormalMatrix(ref: Matrix): void;
  3012. /**
  3013. * Gets only rotation part of the current matrix
  3014. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3015. */
  3016. getRotationMatrix(): Matrix;
  3017. /**
  3018. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3019. * @param result defines the target matrix to store data to
  3020. * @returns the current matrix
  3021. */
  3022. getRotationMatrixToRef(result: Matrix): Matrix;
  3023. /**
  3024. * Toggles model matrix from being right handed to left handed in place and vice versa
  3025. */
  3026. toggleModelMatrixHandInPlace(): void;
  3027. /**
  3028. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3029. */
  3030. toggleProjectionMatrixHandInPlace(): void;
  3031. /**
  3032. * Creates a matrix from an array
  3033. * @param array defines the source array
  3034. * @param offset defines an offset in the source array
  3035. * @returns a new Matrix set from the starting index of the given array
  3036. */
  3037. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3038. /**
  3039. * Copy the content of an array into a given matrix
  3040. * @param array defines the source array
  3041. * @param offset defines an offset in the source array
  3042. * @param result defines the target matrix
  3043. */
  3044. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3045. /**
  3046. * Stores an array into a matrix after having multiplied each component by a given factor
  3047. * @param array defines the source array
  3048. * @param offset defines the offset in the source array
  3049. * @param scale defines the scaling factor
  3050. * @param result defines the target matrix
  3051. */
  3052. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3053. /**
  3054. * Gets an identity matrix that must not be updated
  3055. */
  3056. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3057. /**
  3058. * Stores a list of values (16) inside a given matrix
  3059. * @param initialM11 defines 1st value of 1st row
  3060. * @param initialM12 defines 2nd value of 1st row
  3061. * @param initialM13 defines 3rd value of 1st row
  3062. * @param initialM14 defines 4th value of 1st row
  3063. * @param initialM21 defines 1st value of 2nd row
  3064. * @param initialM22 defines 2nd value of 2nd row
  3065. * @param initialM23 defines 3rd value of 2nd row
  3066. * @param initialM24 defines 4th value of 2nd row
  3067. * @param initialM31 defines 1st value of 3rd row
  3068. * @param initialM32 defines 2nd value of 3rd row
  3069. * @param initialM33 defines 3rd value of 3rd row
  3070. * @param initialM34 defines 4th value of 3rd row
  3071. * @param initialM41 defines 1st value of 4th row
  3072. * @param initialM42 defines 2nd value of 4th row
  3073. * @param initialM43 defines 3rd value of 4th row
  3074. * @param initialM44 defines 4th value of 4th row
  3075. * @param result defines the target matrix
  3076. */
  3077. 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;
  3078. /**
  3079. * Creates new matrix from a list of values (16)
  3080. * @param initialM11 defines 1st value of 1st row
  3081. * @param initialM12 defines 2nd value of 1st row
  3082. * @param initialM13 defines 3rd value of 1st row
  3083. * @param initialM14 defines 4th value of 1st row
  3084. * @param initialM21 defines 1st value of 2nd row
  3085. * @param initialM22 defines 2nd value of 2nd row
  3086. * @param initialM23 defines 3rd value of 2nd row
  3087. * @param initialM24 defines 4th value of 2nd row
  3088. * @param initialM31 defines 1st value of 3rd row
  3089. * @param initialM32 defines 2nd value of 3rd row
  3090. * @param initialM33 defines 3rd value of 3rd row
  3091. * @param initialM34 defines 4th value of 3rd row
  3092. * @param initialM41 defines 1st value of 4th row
  3093. * @param initialM42 defines 2nd value of 4th row
  3094. * @param initialM43 defines 3rd value of 4th row
  3095. * @param initialM44 defines 4th value of 4th row
  3096. * @returns the new matrix
  3097. */
  3098. 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;
  3099. /**
  3100. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3101. * @param scale defines the scale vector3
  3102. * @param rotation defines the rotation quaternion
  3103. * @param translation defines the translation vector3
  3104. * @returns a new matrix
  3105. */
  3106. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3107. /**
  3108. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3109. * @param scale defines the scale vector3
  3110. * @param rotation defines the rotation quaternion
  3111. * @param translation defines the translation vector3
  3112. * @param result defines the target matrix
  3113. */
  3114. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3115. /**
  3116. * Creates a new identity matrix
  3117. * @returns a new identity matrix
  3118. */
  3119. static Identity(): Matrix;
  3120. /**
  3121. * Creates a new identity matrix and stores the result in a given matrix
  3122. * @param result defines the target matrix
  3123. */
  3124. static IdentityToRef(result: Matrix): void;
  3125. /**
  3126. * Creates a new zero matrix
  3127. * @returns a new zero matrix
  3128. */
  3129. static Zero(): Matrix;
  3130. /**
  3131. * Creates a new rotation matrix for "angle" radians around the X axis
  3132. * @param angle defines the angle (in radians) to use
  3133. * @return the new matrix
  3134. */
  3135. static RotationX(angle: number): Matrix;
  3136. /**
  3137. * Creates a new matrix as the invert of a given matrix
  3138. * @param source defines the source matrix
  3139. * @returns the new matrix
  3140. */
  3141. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3142. /**
  3143. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3144. * @param angle defines the angle (in radians) to use
  3145. * @param result defines the target matrix
  3146. */
  3147. static RotationXToRef(angle: number, result: Matrix): void;
  3148. /**
  3149. * Creates a new rotation matrix for "angle" radians around the Y axis
  3150. * @param angle defines the angle (in radians) to use
  3151. * @return the new matrix
  3152. */
  3153. static RotationY(angle: number): Matrix;
  3154. /**
  3155. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3156. * @param angle defines the angle (in radians) to use
  3157. * @param result defines the target matrix
  3158. */
  3159. static RotationYToRef(angle: number, result: Matrix): void;
  3160. /**
  3161. * Creates a new rotation matrix for "angle" radians around the Z axis
  3162. * @param angle defines the angle (in radians) to use
  3163. * @return the new matrix
  3164. */
  3165. static RotationZ(angle: number): Matrix;
  3166. /**
  3167. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3168. * @param angle defines the angle (in radians) to use
  3169. * @param result defines the target matrix
  3170. */
  3171. static RotationZToRef(angle: number, result: Matrix): void;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the given axis
  3174. * @param axis defines the axis to use
  3175. * @param angle defines the angle (in radians) to use
  3176. * @return the new matrix
  3177. */
  3178. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3179. /**
  3180. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3181. * @param axis defines the axis to use
  3182. * @param angle defines the angle (in radians) to use
  3183. * @param result defines the target matrix
  3184. */
  3185. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3186. /**
  3187. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3188. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3189. * @param from defines the vector to align
  3190. * @param to defines the vector to align to
  3191. * @param result defines the target matrix
  3192. */
  3193. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a rotation matrix
  3196. * @param yaw defines the yaw angle in radians (Y axis)
  3197. * @param pitch defines the pitch angle in radians (X axis)
  3198. * @param roll defines the roll angle in radians (X axis)
  3199. * @returns the new rotation matrix
  3200. */
  3201. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3202. /**
  3203. * Creates a rotation matrix and stores it in a given matrix
  3204. * @param yaw defines the yaw angle in radians (Y axis)
  3205. * @param pitch defines the pitch angle in radians (X axis)
  3206. * @param roll defines the roll angle in radians (X axis)
  3207. * @param result defines the target matrix
  3208. */
  3209. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3210. /**
  3211. * Creates a scaling matrix
  3212. * @param x defines the scale factor on X axis
  3213. * @param y defines the scale factor on Y axis
  3214. * @param z defines the scale factor on Z axis
  3215. * @returns the new matrix
  3216. */
  3217. static Scaling(x: number, y: number, z: number): Matrix;
  3218. /**
  3219. * Creates a scaling matrix and stores it in a given matrix
  3220. * @param x defines the scale factor on X axis
  3221. * @param y defines the scale factor on Y axis
  3222. * @param z defines the scale factor on Z axis
  3223. * @param result defines the target matrix
  3224. */
  3225. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3226. /**
  3227. * Creates a translation matrix
  3228. * @param x defines the translation on X axis
  3229. * @param y defines the translation on Y axis
  3230. * @param z defines the translationon Z axis
  3231. * @returns the new matrix
  3232. */
  3233. static Translation(x: number, y: number, z: number): Matrix;
  3234. /**
  3235. * Creates a translation matrix and stores it in a given matrix
  3236. * @param x defines the translation on X axis
  3237. * @param y defines the translation on Y axis
  3238. * @param z defines the translationon Z axis
  3239. * @param result defines the target matrix
  3240. */
  3241. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3242. /**
  3243. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3244. * @param startValue defines the start value
  3245. * @param endValue defines the end value
  3246. * @param gradient defines the gradient factor
  3247. * @returns the new matrix
  3248. */
  3249. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3250. /**
  3251. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3252. * @param startValue defines the start value
  3253. * @param endValue defines the end value
  3254. * @param gradient defines the gradient factor
  3255. * @param result defines the Matrix object where to store data
  3256. */
  3257. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3258. /**
  3259. * Builds a new matrix whose values are computed by:
  3260. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3261. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3262. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3263. * @param startValue defines the first matrix
  3264. * @param endValue defines the second matrix
  3265. * @param gradient defines the gradient between the two matrices
  3266. * @returns the new matrix
  3267. */
  3268. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3269. /**
  3270. * Update a matrix to values which are computed by:
  3271. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3272. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3273. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3274. * @param startValue defines the first matrix
  3275. * @param endValue defines the second matrix
  3276. * @param gradient defines the gradient between the two matrices
  3277. * @param result defines the target matrix
  3278. */
  3279. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3280. /**
  3281. * 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"
  3282. * This function works in left handed mode
  3283. * @param eye defines the final position of the entity
  3284. * @param target defines where the entity should look at
  3285. * @param up defines the up vector for the entity
  3286. * @returns the new matrix
  3287. */
  3288. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3289. /**
  3290. * 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".
  3291. * This function works in left handed mode
  3292. * @param eye defines the final position of the entity
  3293. * @param target defines where the entity should look at
  3294. * @param up defines the up vector for the entity
  3295. * @param result defines the target matrix
  3296. */
  3297. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * 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"
  3300. * This function works in right handed mode
  3301. * @param eye defines the final position of the entity
  3302. * @param target defines where the entity should look at
  3303. * @param up defines the up vector for the entity
  3304. * @returns the new matrix
  3305. */
  3306. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3307. /**
  3308. * 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".
  3309. * This function works in right handed mode
  3310. * @param eye defines the final position of the entity
  3311. * @param target defines where the entity should look at
  3312. * @param up defines the up vector for the entity
  3313. * @param result defines the target matrix
  3314. */
  3315. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3316. /**
  3317. * Create a left-handed orthographic projection matrix
  3318. * @param width defines the viewport width
  3319. * @param height defines the viewport height
  3320. * @param znear defines the near clip plane
  3321. * @param zfar defines the far clip plane
  3322. * @returns a new matrix as a left-handed orthographic projection matrix
  3323. */
  3324. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3325. /**
  3326. * Store a left-handed orthographic projection to a given matrix
  3327. * @param width defines the viewport width
  3328. * @param height defines the viewport height
  3329. * @param znear defines the near clip plane
  3330. * @param zfar defines the far clip plane
  3331. * @param result defines the target matrix
  3332. */
  3333. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3334. /**
  3335. * Create a left-handed orthographic projection matrix
  3336. * @param left defines the viewport left coordinate
  3337. * @param right defines the viewport right coordinate
  3338. * @param bottom defines the viewport bottom coordinate
  3339. * @param top defines the viewport top coordinate
  3340. * @param znear defines the near clip plane
  3341. * @param zfar defines the far clip plane
  3342. * @returns a new matrix as a left-handed orthographic projection matrix
  3343. */
  3344. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3345. /**
  3346. * Stores a left-handed orthographic projection into a given matrix
  3347. * @param left defines the viewport left coordinate
  3348. * @param right defines the viewport right coordinate
  3349. * @param bottom defines the viewport bottom coordinate
  3350. * @param top defines the viewport top coordinate
  3351. * @param znear defines the near clip plane
  3352. * @param zfar defines the far clip plane
  3353. * @param result defines the target matrix
  3354. */
  3355. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3356. /**
  3357. * Creates a right-handed orthographic projection matrix
  3358. * @param left defines the viewport left coordinate
  3359. * @param right defines the viewport right coordinate
  3360. * @param bottom defines the viewport bottom coordinate
  3361. * @param top defines the viewport top coordinate
  3362. * @param znear defines the near clip plane
  3363. * @param zfar defines the far clip plane
  3364. * @returns a new matrix as a right-handed orthographic projection matrix
  3365. */
  3366. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3367. /**
  3368. * Stores a right-handed orthographic projection into a given matrix
  3369. * @param left defines the viewport left coordinate
  3370. * @param right defines the viewport right coordinate
  3371. * @param bottom defines the viewport bottom coordinate
  3372. * @param top defines the viewport top coordinate
  3373. * @param znear defines the near clip plane
  3374. * @param zfar defines the far clip plane
  3375. * @param result defines the target matrix
  3376. */
  3377. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3378. /**
  3379. * Creates a left-handed perspective projection matrix
  3380. * @param width defines the viewport width
  3381. * @param height defines the viewport height
  3382. * @param znear defines the near clip plane
  3383. * @param zfar defines the far clip plane
  3384. * @returns a new matrix as a left-handed perspective projection matrix
  3385. */
  3386. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3387. /**
  3388. * Creates a left-handed perspective projection matrix
  3389. * @param fov defines the horizontal field of view
  3390. * @param aspect defines the aspect ratio
  3391. * @param znear defines the near clip plane
  3392. * @param zfar defines the far clip plane
  3393. * @returns a new matrix as a left-handed perspective projection matrix
  3394. */
  3395. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3396. /**
  3397. * Stores a left-handed perspective projection into a given matrix
  3398. * @param fov defines the horizontal field of view
  3399. * @param aspect defines the aspect ratio
  3400. * @param znear defines the near clip plane
  3401. * @param zfar defines the far clip plane
  3402. * @param result defines the target matrix
  3403. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3404. */
  3405. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3406. /**
  3407. * Creates a right-handed perspective projection matrix
  3408. * @param fov defines the horizontal field of view
  3409. * @param aspect defines the aspect ratio
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @returns a new matrix as a right-handed perspective projection matrix
  3413. */
  3414. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3415. /**
  3416. * Stores a right-handed perspective projection into a given matrix
  3417. * @param fov defines the horizontal field of view
  3418. * @param aspect defines the aspect ratio
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @param result defines the target matrix
  3422. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3423. */
  3424. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3425. /**
  3426. * Stores a perspective projection for WebVR info a given matrix
  3427. * @param fov defines the field of view
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @param result defines the target matrix
  3431. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3432. */
  3433. static PerspectiveFovWebVRToRef(fov: {
  3434. upDegrees: number;
  3435. downDegrees: number;
  3436. leftDegrees: number;
  3437. rightDegrees: number;
  3438. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3439. /**
  3440. * Computes a complete transformation matrix
  3441. * @param viewport defines the viewport to use
  3442. * @param world defines the world matrix
  3443. * @param view defines the view matrix
  3444. * @param projection defines the projection matrix
  3445. * @param zmin defines the near clip plane
  3446. * @param zmax defines the far clip plane
  3447. * @returns the transformation matrix
  3448. */
  3449. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3450. /**
  3451. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3452. * @param matrix defines the matrix to use
  3453. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3454. */
  3455. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3456. /**
  3457. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3458. * @param matrix defines the matrix to use
  3459. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3460. */
  3461. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3462. /**
  3463. * Compute the transpose of a given matrix
  3464. * @param matrix defines the matrix to transpose
  3465. * @returns the new matrix
  3466. */
  3467. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3468. /**
  3469. * Compute the transpose of a matrix and store it in a target matrix
  3470. * @param matrix defines the matrix to transpose
  3471. * @param result defines the target matrix
  3472. */
  3473. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3474. /**
  3475. * Computes a reflection matrix from a plane
  3476. * @param plane defines the reflection plane
  3477. * @returns a new matrix
  3478. */
  3479. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3480. /**
  3481. * Computes a reflection matrix from a plane
  3482. * @param plane defines the reflection plane
  3483. * @param result defines the target matrix
  3484. */
  3485. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3486. /**
  3487. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3488. * @param xaxis defines the value of the 1st axis
  3489. * @param yaxis defines the value of the 2nd axis
  3490. * @param zaxis defines the value of the 3rd axis
  3491. * @param result defines the target matrix
  3492. */
  3493. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3494. /**
  3495. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3496. * @param quat defines the quaternion to use
  3497. * @param result defines the target matrix
  3498. */
  3499. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3500. }
  3501. /**
  3502. * @hidden
  3503. */
  3504. export class TmpVectors {
  3505. static Vector2: Vector2[];
  3506. static Vector3: Vector3[];
  3507. static Vector4: Vector4[];
  3508. static Quaternion: Quaternion[];
  3509. static Matrix: Matrix[];
  3510. }
  3511. }
  3512. declare module "babylonjs/Maths/math.color" {
  3513. import { DeepImmutable, FloatArray } from "babylonjs/types";
  3514. /**
  3515. * Class used to hold a RBG color
  3516. */
  3517. export class Color3 {
  3518. /**
  3519. * Defines the red component (between 0 and 1, default is 0)
  3520. */
  3521. r: number;
  3522. /**
  3523. * Defines the green component (between 0 and 1, default is 0)
  3524. */
  3525. g: number;
  3526. /**
  3527. * Defines the blue component (between 0 and 1, default is 0)
  3528. */
  3529. b: number;
  3530. /**
  3531. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3532. * @param r defines the red component (between 0 and 1, default is 0)
  3533. * @param g defines the green component (between 0 and 1, default is 0)
  3534. * @param b defines the blue component (between 0 and 1, default is 0)
  3535. */
  3536. constructor(
  3537. /**
  3538. * Defines the red component (between 0 and 1, default is 0)
  3539. */
  3540. r?: number,
  3541. /**
  3542. * Defines the green component (between 0 and 1, default is 0)
  3543. */
  3544. g?: number,
  3545. /**
  3546. * Defines the blue component (between 0 and 1, default is 0)
  3547. */
  3548. b?: number);
  3549. /**
  3550. * Creates a string with the Color3 current values
  3551. * @returns the string representation of the Color3 object
  3552. */
  3553. toString(): string;
  3554. /**
  3555. * Returns the string "Color3"
  3556. * @returns "Color3"
  3557. */
  3558. getClassName(): string;
  3559. /**
  3560. * Compute the Color3 hash code
  3561. * @returns an unique number that can be used to hash Color3 objects
  3562. */
  3563. getHashCode(): number;
  3564. /**
  3565. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3566. * @param array defines the array where to store the r,g,b components
  3567. * @param index defines an optional index in the target array to define where to start storing values
  3568. * @returns the current Color3 object
  3569. */
  3570. toArray(array: FloatArray, index?: number): Color3;
  3571. /**
  3572. * Returns a new Color4 object from the current Color3 and the given alpha
  3573. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3574. * @returns a new Color4 object
  3575. */
  3576. toColor4(alpha?: number): Color4;
  3577. /**
  3578. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3579. * @returns the new array
  3580. */
  3581. asArray(): number[];
  3582. /**
  3583. * Returns the luminance value
  3584. * @returns a float value
  3585. */
  3586. toLuminance(): number;
  3587. /**
  3588. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3589. * @param otherColor defines the second operand
  3590. * @returns the new Color3 object
  3591. */
  3592. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3593. /**
  3594. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3595. * @param otherColor defines the second operand
  3596. * @param result defines the Color3 object where to store the result
  3597. * @returns the current Color3
  3598. */
  3599. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3600. /**
  3601. * Determines equality between Color3 objects
  3602. * @param otherColor defines the second operand
  3603. * @returns true if the rgb values are equal to the given ones
  3604. */
  3605. equals(otherColor: DeepImmutable<Color3>): boolean;
  3606. /**
  3607. * Determines equality between the current Color3 object and a set of r,b,g values
  3608. * @param r defines the red component to check
  3609. * @param g defines the green component to check
  3610. * @param b defines the blue component to check
  3611. * @returns true if the rgb values are equal to the given ones
  3612. */
  3613. equalsFloats(r: number, g: number, b: number): boolean;
  3614. /**
  3615. * Multiplies in place each rgb value by scale
  3616. * @param scale defines the scaling factor
  3617. * @returns the updated Color3
  3618. */
  3619. scale(scale: number): Color3;
  3620. /**
  3621. * Multiplies the rgb values by scale and stores the result into "result"
  3622. * @param scale defines the scaling factor
  3623. * @param result defines the Color3 object where to store the result
  3624. * @returns the unmodified current Color3
  3625. */
  3626. scaleToRef(scale: number, result: Color3): Color3;
  3627. /**
  3628. * Scale the current Color3 values by a factor and add the result to a given Color3
  3629. * @param scale defines the scale factor
  3630. * @param result defines color to store the result into
  3631. * @returns the unmodified current Color3
  3632. */
  3633. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3634. /**
  3635. * Clamps the rgb values by the min and max values and stores the result into "result"
  3636. * @param min defines minimum clamping value (default is 0)
  3637. * @param max defines maximum clamping value (default is 1)
  3638. * @param result defines color to store the result into
  3639. * @returns the original Color3
  3640. */
  3641. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3642. /**
  3643. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3644. * @param otherColor defines the second operand
  3645. * @returns the new Color3
  3646. */
  3647. add(otherColor: DeepImmutable<Color3>): Color3;
  3648. /**
  3649. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3650. * @param otherColor defines the second operand
  3651. * @param result defines Color3 object to store the result into
  3652. * @returns the unmodified current Color3
  3653. */
  3654. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3655. /**
  3656. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3657. * @param otherColor defines the second operand
  3658. * @returns the new Color3
  3659. */
  3660. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3661. /**
  3662. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3663. * @param otherColor defines the second operand
  3664. * @param result defines Color3 object to store the result into
  3665. * @returns the unmodified current Color3
  3666. */
  3667. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3668. /**
  3669. * Copy the current object
  3670. * @returns a new Color3 copied the current one
  3671. */
  3672. clone(): Color3;
  3673. /**
  3674. * Copies the rgb values from the source in the current Color3
  3675. * @param source defines the source Color3 object
  3676. * @returns the updated Color3 object
  3677. */
  3678. copyFrom(source: DeepImmutable<Color3>): Color3;
  3679. /**
  3680. * Updates the Color3 rgb values from the given floats
  3681. * @param r defines the red component to read from
  3682. * @param g defines the green component to read from
  3683. * @param b defines the blue component to read from
  3684. * @returns the current Color3 object
  3685. */
  3686. copyFromFloats(r: number, g: number, b: number): Color3;
  3687. /**
  3688. * Updates the Color3 rgb values from the given floats
  3689. * @param r defines the red component to read from
  3690. * @param g defines the green component to read from
  3691. * @param b defines the blue component to read from
  3692. * @returns the current Color3 object
  3693. */
  3694. set(r: number, g: number, b: number): Color3;
  3695. /**
  3696. * Compute the Color3 hexadecimal code as a string
  3697. * @returns a string containing the hexadecimal representation of the Color3 object
  3698. */
  3699. toHexString(): string;
  3700. /**
  3701. * Computes a new Color3 converted from the current one to linear space
  3702. * @returns a new Color3 object
  3703. */
  3704. toLinearSpace(): Color3;
  3705. /**
  3706. * Converts current color in rgb space to HSV values
  3707. * @returns a new color3 representing the HSV values
  3708. */
  3709. toHSV(): Color3;
  3710. /**
  3711. * Converts current color in rgb space to HSV values
  3712. * @param result defines the Color3 where to store the HSV values
  3713. */
  3714. toHSVToRef(result: Color3): void;
  3715. /**
  3716. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3717. * @param convertedColor defines the Color3 object where to store the linear space version
  3718. * @returns the unmodified Color3
  3719. */
  3720. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3721. /**
  3722. * Computes a new Color3 converted from the current one to gamma space
  3723. * @returns a new Color3 object
  3724. */
  3725. toGammaSpace(): Color3;
  3726. /**
  3727. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3728. * @param convertedColor defines the Color3 object where to store the gamma space version
  3729. * @returns the unmodified Color3
  3730. */
  3731. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3732. private static _BlackReadOnly;
  3733. /**
  3734. * Convert Hue, saturation and value to a Color3 (RGB)
  3735. * @param hue defines the hue
  3736. * @param saturation defines the saturation
  3737. * @param value defines the value
  3738. * @param result defines the Color3 where to store the RGB values
  3739. */
  3740. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3741. /**
  3742. * Creates a new Color3 from the string containing valid hexadecimal values
  3743. * @param hex defines a string containing valid hexadecimal values
  3744. * @returns a new Color3 object
  3745. */
  3746. static FromHexString(hex: string): Color3;
  3747. /**
  3748. * Creates a new Color3 from the starting index of the given array
  3749. * @param array defines the source array
  3750. * @param offset defines an offset in the source array
  3751. * @returns a new Color3 object
  3752. */
  3753. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3754. /**
  3755. * Creates a new Color3 from integer values (< 256)
  3756. * @param r defines the red component to read from (value between 0 and 255)
  3757. * @param g defines the green component to read from (value between 0 and 255)
  3758. * @param b defines the blue component to read from (value between 0 and 255)
  3759. * @returns a new Color3 object
  3760. */
  3761. static FromInts(r: number, g: number, b: number): Color3;
  3762. /**
  3763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3764. * @param start defines the start Color3 value
  3765. * @param end defines the end Color3 value
  3766. * @param amount defines the gradient value between start and end
  3767. * @returns a new Color3 object
  3768. */
  3769. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3770. /**
  3771. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3772. * @param left defines the start value
  3773. * @param right defines the end value
  3774. * @param amount defines the gradient factor
  3775. * @param result defines the Color3 object where to store the result
  3776. */
  3777. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3778. /**
  3779. * Returns a Color3 value containing a red color
  3780. * @returns a new Color3 object
  3781. */
  3782. static Red(): Color3;
  3783. /**
  3784. * Returns a Color3 value containing a green color
  3785. * @returns a new Color3 object
  3786. */
  3787. static Green(): Color3;
  3788. /**
  3789. * Returns a Color3 value containing a blue color
  3790. * @returns a new Color3 object
  3791. */
  3792. static Blue(): Color3;
  3793. /**
  3794. * Returns a Color3 value containing a black color
  3795. * @returns a new Color3 object
  3796. */
  3797. static Black(): Color3;
  3798. /**
  3799. * Gets a Color3 value containing a black color that must not be updated
  3800. */
  3801. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3802. /**
  3803. * Returns a Color3 value containing a white color
  3804. * @returns a new Color3 object
  3805. */
  3806. static White(): Color3;
  3807. /**
  3808. * Returns a Color3 value containing a purple color
  3809. * @returns a new Color3 object
  3810. */
  3811. static Purple(): Color3;
  3812. /**
  3813. * Returns a Color3 value containing a magenta color
  3814. * @returns a new Color3 object
  3815. */
  3816. static Magenta(): Color3;
  3817. /**
  3818. * Returns a Color3 value containing a yellow color
  3819. * @returns a new Color3 object
  3820. */
  3821. static Yellow(): Color3;
  3822. /**
  3823. * Returns a Color3 value containing a gray color
  3824. * @returns a new Color3 object
  3825. */
  3826. static Gray(): Color3;
  3827. /**
  3828. * Returns a Color3 value containing a teal color
  3829. * @returns a new Color3 object
  3830. */
  3831. static Teal(): Color3;
  3832. /**
  3833. * Returns a Color3 value containing a random color
  3834. * @returns a new Color3 object
  3835. */
  3836. static Random(): Color3;
  3837. }
  3838. /**
  3839. * Class used to hold a RBGA color
  3840. */
  3841. export class Color4 {
  3842. /**
  3843. * Defines the red component (between 0 and 1, default is 0)
  3844. */
  3845. r: number;
  3846. /**
  3847. * Defines the green component (between 0 and 1, default is 0)
  3848. */
  3849. g: number;
  3850. /**
  3851. * Defines the blue component (between 0 and 1, default is 0)
  3852. */
  3853. b: number;
  3854. /**
  3855. * Defines the alpha component (between 0 and 1, default is 1)
  3856. */
  3857. a: number;
  3858. /**
  3859. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3860. * @param r defines the red component (between 0 and 1, default is 0)
  3861. * @param g defines the green component (between 0 and 1, default is 0)
  3862. * @param b defines the blue component (between 0 and 1, default is 0)
  3863. * @param a defines the alpha component (between 0 and 1, default is 1)
  3864. */
  3865. constructor(
  3866. /**
  3867. * Defines the red component (between 0 and 1, default is 0)
  3868. */
  3869. r?: number,
  3870. /**
  3871. * Defines the green component (between 0 and 1, default is 0)
  3872. */
  3873. g?: number,
  3874. /**
  3875. * Defines the blue component (between 0 and 1, default is 0)
  3876. */
  3877. b?: number,
  3878. /**
  3879. * Defines the alpha component (between 0 and 1, default is 1)
  3880. */
  3881. a?: number);
  3882. /**
  3883. * Adds in place the given Color4 values to the current Color4 object
  3884. * @param right defines the second operand
  3885. * @returns the current updated Color4 object
  3886. */
  3887. addInPlace(right: DeepImmutable<Color4>): Color4;
  3888. /**
  3889. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3890. * @returns the new array
  3891. */
  3892. asArray(): number[];
  3893. /**
  3894. * Stores from the starting index in the given array the Color4 successive values
  3895. * @param array defines the array where to store the r,g,b components
  3896. * @param index defines an optional index in the target array to define where to start storing values
  3897. * @returns the current Color4 object
  3898. */
  3899. toArray(array: number[], index?: number): Color4;
  3900. /**
  3901. * Determines equality between Color4 objects
  3902. * @param otherColor defines the second operand
  3903. * @returns true if the rgba values are equal to the given ones
  3904. */
  3905. equals(otherColor: DeepImmutable<Color4>): boolean;
  3906. /**
  3907. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3908. * @param right defines the second operand
  3909. * @returns a new Color4 object
  3910. */
  3911. add(right: DeepImmutable<Color4>): Color4;
  3912. /**
  3913. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3914. * @param right defines the second operand
  3915. * @returns a new Color4 object
  3916. */
  3917. subtract(right: DeepImmutable<Color4>): Color4;
  3918. /**
  3919. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3920. * @param right defines the second operand
  3921. * @param result defines the Color4 object where to store the result
  3922. * @returns the current Color4 object
  3923. */
  3924. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3925. /**
  3926. * Creates a new Color4 with the current Color4 values multiplied by scale
  3927. * @param scale defines the scaling factor to apply
  3928. * @returns a new Color4 object
  3929. */
  3930. scale(scale: number): Color4;
  3931. /**
  3932. * Multiplies the current Color4 values by scale and stores the result in "result"
  3933. * @param scale defines the scaling factor to apply
  3934. * @param result defines the Color4 object where to store the result
  3935. * @returns the current unmodified Color4
  3936. */
  3937. scaleToRef(scale: number, result: Color4): Color4;
  3938. /**
  3939. * Scale the current Color4 values by a factor and add the result to a given Color4
  3940. * @param scale defines the scale factor
  3941. * @param result defines the Color4 object where to store the result
  3942. * @returns the unmodified current Color4
  3943. */
  3944. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3945. /**
  3946. * Clamps the rgb values by the min and max values and stores the result into "result"
  3947. * @param min defines minimum clamping value (default is 0)
  3948. * @param max defines maximum clamping value (default is 1)
  3949. * @param result defines color to store the result into.
  3950. * @returns the cuurent Color4
  3951. */
  3952. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3953. /**
  3954. * Multipy an Color4 value by another and return a new Color4 object
  3955. * @param color defines the Color4 value to multiply by
  3956. * @returns a new Color4 object
  3957. */
  3958. multiply(color: Color4): Color4;
  3959. /**
  3960. * Multipy a Color4 value by another and push the result in a reference value
  3961. * @param color defines the Color4 value to multiply by
  3962. * @param result defines the Color4 to fill the result in
  3963. * @returns the result Color4
  3964. */
  3965. multiplyToRef(color: Color4, result: Color4): Color4;
  3966. /**
  3967. * Creates a string with the Color4 current values
  3968. * @returns the string representation of the Color4 object
  3969. */
  3970. toString(): string;
  3971. /**
  3972. * Returns the string "Color4"
  3973. * @returns "Color4"
  3974. */
  3975. getClassName(): string;
  3976. /**
  3977. * Compute the Color4 hash code
  3978. * @returns an unique number that can be used to hash Color4 objects
  3979. */
  3980. getHashCode(): number;
  3981. /**
  3982. * Creates a new Color4 copied from the current one
  3983. * @returns a new Color4 object
  3984. */
  3985. clone(): Color4;
  3986. /**
  3987. * Copies the given Color4 values into the current one
  3988. * @param source defines the source Color4 object
  3989. * @returns the current updated Color4 object
  3990. */
  3991. copyFrom(source: Color4): Color4;
  3992. /**
  3993. * Copies the given float values into the current one
  3994. * @param r defines the red component to read from
  3995. * @param g defines the green component to read from
  3996. * @param b defines the blue component to read from
  3997. * @param a defines the alpha component to read from
  3998. * @returns the current updated Color4 object
  3999. */
  4000. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4001. /**
  4002. * Copies the given float values into the current one
  4003. * @param r defines the red component to read from
  4004. * @param g defines the green component to read from
  4005. * @param b defines the blue component to read from
  4006. * @param a defines the alpha component to read from
  4007. * @returns the current updated Color4 object
  4008. */
  4009. set(r: number, g: number, b: number, a: number): Color4;
  4010. /**
  4011. * Compute the Color4 hexadecimal code as a string
  4012. * @returns a string containing the hexadecimal representation of the Color4 object
  4013. */
  4014. toHexString(): string;
  4015. /**
  4016. * Computes a new Color4 converted from the current one to linear space
  4017. * @returns a new Color4 object
  4018. */
  4019. toLinearSpace(): Color4;
  4020. /**
  4021. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4022. * @param convertedColor defines the Color4 object where to store the linear space version
  4023. * @returns the unmodified Color4
  4024. */
  4025. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4026. /**
  4027. * Computes a new Color4 converted from the current one to gamma space
  4028. * @returns a new Color4 object
  4029. */
  4030. toGammaSpace(): Color4;
  4031. /**
  4032. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4033. * @param convertedColor defines the Color4 object where to store the gamma space version
  4034. * @returns the unmodified Color4
  4035. */
  4036. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4037. /**
  4038. * Creates a new Color4 from the string containing valid hexadecimal values
  4039. * @param hex defines a string containing valid hexadecimal values
  4040. * @returns a new Color4 object
  4041. */
  4042. static FromHexString(hex: string): Color4;
  4043. /**
  4044. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4045. * @param left defines the start value
  4046. * @param right defines the end value
  4047. * @param amount defines the gradient factor
  4048. * @returns a new Color4 object
  4049. */
  4050. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4051. /**
  4052. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4053. * @param left defines the start value
  4054. * @param right defines the end value
  4055. * @param amount defines the gradient factor
  4056. * @param result defines the Color4 object where to store data
  4057. */
  4058. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4059. /**
  4060. * Creates a new Color4 from a Color3 and an alpha value
  4061. * @param color3 defines the source Color3 to read from
  4062. * @param alpha defines the alpha component (1.0 by default)
  4063. * @returns a new Color4 object
  4064. */
  4065. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4066. /**
  4067. * Creates a new Color4 from the starting index element of the given array
  4068. * @param array defines the source array to read from
  4069. * @param offset defines the offset in the source array
  4070. * @returns a new Color4 object
  4071. */
  4072. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4073. /**
  4074. * Creates a new Color3 from integer values (< 256)
  4075. * @param r defines the red component to read from (value between 0 and 255)
  4076. * @param g defines the green component to read from (value between 0 and 255)
  4077. * @param b defines the blue component to read from (value between 0 and 255)
  4078. * @param a defines the alpha component to read from (value between 0 and 255)
  4079. * @returns a new Color3 object
  4080. */
  4081. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4082. /**
  4083. * Check the content of a given array and convert it to an array containing RGBA data
  4084. * If the original array was already containing count * 4 values then it is returned directly
  4085. * @param colors defines the array to check
  4086. * @param count defines the number of RGBA data to expect
  4087. * @returns an array containing count * 4 values (RGBA)
  4088. */
  4089. static CheckColors4(colors: number[], count: number): number[];
  4090. }
  4091. /**
  4092. * @hidden
  4093. */
  4094. export class TmpColors {
  4095. static Color3: Color3[];
  4096. static Color4: Color4[];
  4097. }
  4098. }
  4099. declare module "babylonjs/Maths/sphericalPolynomial" {
  4100. import { Vector3 } from "babylonjs/Maths/math.vector";
  4101. import { Color3 } from "babylonjs/Maths/math.color";
  4102. /**
  4103. * Class representing spherical harmonics coefficients to the 3rd degree
  4104. */
  4105. export class SphericalHarmonics {
  4106. /**
  4107. * Defines whether or not the harmonics have been prescaled for rendering.
  4108. */
  4109. preScaled: boolean;
  4110. /**
  4111. * The l0,0 coefficients of the spherical harmonics
  4112. */
  4113. l00: Vector3;
  4114. /**
  4115. * The l1,-1 coefficients of the spherical harmonics
  4116. */
  4117. l1_1: Vector3;
  4118. /**
  4119. * The l1,0 coefficients of the spherical harmonics
  4120. */
  4121. l10: Vector3;
  4122. /**
  4123. * The l1,1 coefficients of the spherical harmonics
  4124. */
  4125. l11: Vector3;
  4126. /**
  4127. * The l2,-2 coefficients of the spherical harmonics
  4128. */
  4129. l2_2: Vector3;
  4130. /**
  4131. * The l2,-1 coefficients of the spherical harmonics
  4132. */
  4133. l2_1: Vector3;
  4134. /**
  4135. * The l2,0 coefficients of the spherical harmonics
  4136. */
  4137. l20: Vector3;
  4138. /**
  4139. * The l2,1 coefficients of the spherical harmonics
  4140. */
  4141. l21: Vector3;
  4142. /**
  4143. * The l2,2 coefficients of the spherical harmonics
  4144. */
  4145. l22: Vector3;
  4146. /**
  4147. * Adds a light to the spherical harmonics
  4148. * @param direction the direction of the light
  4149. * @param color the color of the light
  4150. * @param deltaSolidAngle the delta solid angle of the light
  4151. */
  4152. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4153. /**
  4154. * Scales the spherical harmonics by the given amount
  4155. * @param scale the amount to scale
  4156. */
  4157. scaleInPlace(scale: number): void;
  4158. /**
  4159. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4160. *
  4161. * ```
  4162. * E_lm = A_l * L_lm
  4163. * ```
  4164. *
  4165. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4166. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4167. * the scaling factors are given in equation 9.
  4168. */
  4169. convertIncidentRadianceToIrradiance(): void;
  4170. /**
  4171. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4172. *
  4173. * ```
  4174. * L = (1/pi) * E * rho
  4175. * ```
  4176. *
  4177. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4178. */
  4179. convertIrradianceToLambertianRadiance(): void;
  4180. /**
  4181. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4182. * required operations at run time.
  4183. *
  4184. * This is simply done by scaling back the SH with Ylm constants parameter.
  4185. * The trigonometric part being applied by the shader at run time.
  4186. */
  4187. preScaleForRendering(): void;
  4188. /**
  4189. * Constructs a spherical harmonics from an array.
  4190. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4191. * @returns the spherical harmonics
  4192. */
  4193. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4194. /**
  4195. * Gets the spherical harmonics from polynomial
  4196. * @param polynomial the spherical polynomial
  4197. * @returns the spherical harmonics
  4198. */
  4199. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4200. }
  4201. /**
  4202. * Class representing spherical polynomial coefficients to the 3rd degree
  4203. */
  4204. export class SphericalPolynomial {
  4205. private _harmonics;
  4206. /**
  4207. * The spherical harmonics used to create the polynomials.
  4208. */
  4209. readonly preScaledHarmonics: SphericalHarmonics;
  4210. /**
  4211. * The x coefficients of the spherical polynomial
  4212. */
  4213. x: Vector3;
  4214. /**
  4215. * The y coefficients of the spherical polynomial
  4216. */
  4217. y: Vector3;
  4218. /**
  4219. * The z coefficients of the spherical polynomial
  4220. */
  4221. z: Vector3;
  4222. /**
  4223. * The xx coefficients of the spherical polynomial
  4224. */
  4225. xx: Vector3;
  4226. /**
  4227. * The yy coefficients of the spherical polynomial
  4228. */
  4229. yy: Vector3;
  4230. /**
  4231. * The zz coefficients of the spherical polynomial
  4232. */
  4233. zz: Vector3;
  4234. /**
  4235. * The xy coefficients of the spherical polynomial
  4236. */
  4237. xy: Vector3;
  4238. /**
  4239. * The yz coefficients of the spherical polynomial
  4240. */
  4241. yz: Vector3;
  4242. /**
  4243. * The zx coefficients of the spherical polynomial
  4244. */
  4245. zx: Vector3;
  4246. /**
  4247. * Adds an ambient color to the spherical polynomial
  4248. * @param color the color to add
  4249. */
  4250. addAmbient(color: Color3): void;
  4251. /**
  4252. * Scales the spherical polynomial by the given amount
  4253. * @param scale the amount to scale
  4254. */
  4255. scaleInPlace(scale: number): void;
  4256. /**
  4257. * Gets the spherical polynomial from harmonics
  4258. * @param harmonics the spherical harmonics
  4259. * @returns the spherical polynomial
  4260. */
  4261. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4262. /**
  4263. * Constructs a spherical polynomial from an array.
  4264. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4265. * @returns the spherical polynomial
  4266. */
  4267. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4268. }
  4269. }
  4270. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  4271. /**
  4272. * Define options used to create a render target texture
  4273. */
  4274. export class RenderTargetCreationOptions {
  4275. /**
  4276. * Specifies is mipmaps must be generated
  4277. */
  4278. generateMipMaps?: boolean;
  4279. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4280. generateDepthBuffer?: boolean;
  4281. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4282. generateStencilBuffer?: boolean;
  4283. /** Defines texture type (int by default) */
  4284. type?: number;
  4285. /** Defines sampling mode (trilinear by default) */
  4286. samplingMode?: number;
  4287. /** Defines format (RGBA by default) */
  4288. format?: number;
  4289. }
  4290. }
  4291. declare module "babylonjs/Instrumentation/timeToken" {
  4292. import { Nullable } from "babylonjs/types";
  4293. /**
  4294. * @hidden
  4295. **/
  4296. export class _TimeToken {
  4297. _startTimeQuery: Nullable<WebGLQuery>;
  4298. _endTimeQuery: Nullable<WebGLQuery>;
  4299. _timeElapsedQuery: Nullable<WebGLQuery>;
  4300. _timeElapsedQueryEnded: boolean;
  4301. }
  4302. }
  4303. declare module "babylonjs/Engines/constants" {
  4304. /** Defines the cross module used constants to avoid circular dependncies */
  4305. export class Constants {
  4306. /** Defines that alpha blending is disabled */
  4307. static readonly ALPHA_DISABLE: number;
  4308. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4309. static readonly ALPHA_ADD: number;
  4310. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4311. static readonly ALPHA_COMBINE: number;
  4312. /** Defines that alpha blending to DEST - SRC * DEST */
  4313. static readonly ALPHA_SUBTRACT: number;
  4314. /** Defines that alpha blending to SRC * DEST */
  4315. static readonly ALPHA_MULTIPLY: number;
  4316. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4317. static readonly ALPHA_MAXIMIZED: number;
  4318. /** Defines that alpha blending to SRC + DEST */
  4319. static readonly ALPHA_ONEONE: number;
  4320. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4321. static readonly ALPHA_PREMULTIPLIED: number;
  4322. /**
  4323. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4324. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4325. */
  4326. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4327. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4328. static readonly ALPHA_INTERPOLATE: number;
  4329. /**
  4330. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4331. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4332. */
  4333. static readonly ALPHA_SCREENMODE: number;
  4334. /**
  4335. * Defines that alpha blending to SRC + DST
  4336. * Alpha will be set to SRC ALPHA + DST ALPHA
  4337. */
  4338. static readonly ALPHA_ONEONE_ONEONE: number;
  4339. /**
  4340. * Defines that alpha blending to SRC * DST ALPHA + DST
  4341. * Alpha will be set to 0
  4342. */
  4343. static readonly ALPHA_ALPHATOCOLOR: number;
  4344. /**
  4345. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4346. */
  4347. static readonly ALPHA_REVERSEONEMINUS: number;
  4348. /**
  4349. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4350. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4351. */
  4352. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4353. /**
  4354. * Defines that alpha blending to SRC + DST
  4355. * Alpha will be set to SRC ALPHA
  4356. */
  4357. static readonly ALPHA_ONEONE_ONEZERO: number;
  4358. /** Defines that alpha blending equation a SUM */
  4359. static readonly ALPHA_EQUATION_ADD: number;
  4360. /** Defines that alpha blending equation a SUBSTRACTION */
  4361. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4362. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4363. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4364. /** Defines that alpha blending equation a MAX operation */
  4365. static readonly ALPHA_EQUATION_MAX: number;
  4366. /** Defines that alpha blending equation a MIN operation */
  4367. static readonly ALPHA_EQUATION_MIN: number;
  4368. /**
  4369. * Defines that alpha blending equation a DARKEN operation:
  4370. * It takes the min of the src and sums the alpha channels.
  4371. */
  4372. static readonly ALPHA_EQUATION_DARKEN: number;
  4373. /** Defines that the ressource is not delayed*/
  4374. static readonly DELAYLOADSTATE_NONE: number;
  4375. /** Defines that the ressource was successfully delay loaded */
  4376. static readonly DELAYLOADSTATE_LOADED: number;
  4377. /** Defines that the ressource is currently delay loading */
  4378. static readonly DELAYLOADSTATE_LOADING: number;
  4379. /** Defines that the ressource is delayed and has not started loading */
  4380. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4381. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4382. static readonly NEVER: number;
  4383. /** 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 */
  4384. static readonly ALWAYS: number;
  4385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4386. static readonly LESS: number;
  4387. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4388. static readonly EQUAL: number;
  4389. /** 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 */
  4390. static readonly LEQUAL: number;
  4391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4392. static readonly GREATER: number;
  4393. /** 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 */
  4394. static readonly GEQUAL: number;
  4395. /** 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 */
  4396. static readonly NOTEQUAL: number;
  4397. /** Passed to stencilOperation to specify that stencil value must be kept */
  4398. static readonly KEEP: number;
  4399. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4400. static readonly REPLACE: number;
  4401. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4402. static readonly INCR: number;
  4403. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4404. static readonly DECR: number;
  4405. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4406. static readonly INVERT: number;
  4407. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4408. static readonly INCR_WRAP: number;
  4409. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4410. static readonly DECR_WRAP: number;
  4411. /** Texture is not repeating outside of 0..1 UVs */
  4412. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4413. /** Texture is repeating outside of 0..1 UVs */
  4414. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4415. /** Texture is repeating and mirrored */
  4416. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4417. /** ALPHA */
  4418. static readonly TEXTUREFORMAT_ALPHA: number;
  4419. /** LUMINANCE */
  4420. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4421. /** LUMINANCE_ALPHA */
  4422. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4423. /** RGB */
  4424. static readonly TEXTUREFORMAT_RGB: number;
  4425. /** RGBA */
  4426. static readonly TEXTUREFORMAT_RGBA: number;
  4427. /** RED */
  4428. static readonly TEXTUREFORMAT_RED: number;
  4429. /** RED (2nd reference) */
  4430. static readonly TEXTUREFORMAT_R: number;
  4431. /** RG */
  4432. static readonly TEXTUREFORMAT_RG: number;
  4433. /** RED_INTEGER */
  4434. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4435. /** RED_INTEGER (2nd reference) */
  4436. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4437. /** RG_INTEGER */
  4438. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4439. /** RGB_INTEGER */
  4440. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4441. /** RGBA_INTEGER */
  4442. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4443. /** UNSIGNED_BYTE */
  4444. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4445. /** UNSIGNED_BYTE (2nd reference) */
  4446. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4447. /** FLOAT */
  4448. static readonly TEXTURETYPE_FLOAT: number;
  4449. /** HALF_FLOAT */
  4450. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4451. /** BYTE */
  4452. static readonly TEXTURETYPE_BYTE: number;
  4453. /** SHORT */
  4454. static readonly TEXTURETYPE_SHORT: number;
  4455. /** UNSIGNED_SHORT */
  4456. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4457. /** INT */
  4458. static readonly TEXTURETYPE_INT: number;
  4459. /** UNSIGNED_INT */
  4460. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4461. /** UNSIGNED_SHORT_4_4_4_4 */
  4462. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4463. /** UNSIGNED_SHORT_5_5_5_1 */
  4464. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4465. /** UNSIGNED_SHORT_5_6_5 */
  4466. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4467. /** UNSIGNED_INT_2_10_10_10_REV */
  4468. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4469. /** UNSIGNED_INT_24_8 */
  4470. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4471. /** UNSIGNED_INT_10F_11F_11F_REV */
  4472. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4473. /** UNSIGNED_INT_5_9_9_9_REV */
  4474. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4475. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4476. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4477. /** nearest is mag = nearest and min = nearest and mip = linear */
  4478. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4479. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4480. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4481. /** Trilinear is mag = linear and min = linear and mip = linear */
  4482. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4483. /** nearest is mag = nearest and min = nearest and mip = linear */
  4484. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4485. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4486. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4487. /** Trilinear is mag = linear and min = linear and mip = linear */
  4488. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4489. /** mag = nearest and min = nearest and mip = nearest */
  4490. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4491. /** mag = nearest and min = linear and mip = nearest */
  4492. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4493. /** mag = nearest and min = linear and mip = linear */
  4494. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4495. /** mag = nearest and min = linear and mip = none */
  4496. static readonly TEXTURE_NEAREST_LINEAR: number;
  4497. /** mag = nearest and min = nearest and mip = none */
  4498. static readonly TEXTURE_NEAREST_NEAREST: number;
  4499. /** mag = linear and min = nearest and mip = nearest */
  4500. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4501. /** mag = linear and min = nearest and mip = linear */
  4502. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4503. /** mag = linear and min = linear and mip = none */
  4504. static readonly TEXTURE_LINEAR_LINEAR: number;
  4505. /** mag = linear and min = nearest and mip = none */
  4506. static readonly TEXTURE_LINEAR_NEAREST: number;
  4507. /** Explicit coordinates mode */
  4508. static readonly TEXTURE_EXPLICIT_MODE: number;
  4509. /** Spherical coordinates mode */
  4510. static readonly TEXTURE_SPHERICAL_MODE: number;
  4511. /** Planar coordinates mode */
  4512. static readonly TEXTURE_PLANAR_MODE: number;
  4513. /** Cubic coordinates mode */
  4514. static readonly TEXTURE_CUBIC_MODE: number;
  4515. /** Projection coordinates mode */
  4516. static readonly TEXTURE_PROJECTION_MODE: number;
  4517. /** Skybox coordinates mode */
  4518. static readonly TEXTURE_SKYBOX_MODE: number;
  4519. /** Inverse Cubic coordinates mode */
  4520. static readonly TEXTURE_INVCUBIC_MODE: number;
  4521. /** Equirectangular coordinates mode */
  4522. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4523. /** Equirectangular Fixed coordinates mode */
  4524. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4525. /** Equirectangular Fixed Mirrored coordinates mode */
  4526. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4527. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4528. static readonly SCALEMODE_FLOOR: number;
  4529. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4530. static readonly SCALEMODE_NEAREST: number;
  4531. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4532. static readonly SCALEMODE_CEILING: number;
  4533. /**
  4534. * The dirty texture flag value
  4535. */
  4536. static readonly MATERIAL_TextureDirtyFlag: number;
  4537. /**
  4538. * The dirty light flag value
  4539. */
  4540. static readonly MATERIAL_LightDirtyFlag: number;
  4541. /**
  4542. * The dirty fresnel flag value
  4543. */
  4544. static readonly MATERIAL_FresnelDirtyFlag: number;
  4545. /**
  4546. * The dirty attribute flag value
  4547. */
  4548. static readonly MATERIAL_AttributesDirtyFlag: number;
  4549. /**
  4550. * The dirty misc flag value
  4551. */
  4552. static readonly MATERIAL_MiscDirtyFlag: number;
  4553. /**
  4554. * The all dirty flag value
  4555. */
  4556. static readonly MATERIAL_AllDirtyFlag: number;
  4557. /**
  4558. * Returns the triangle fill mode
  4559. */
  4560. static readonly MATERIAL_TriangleFillMode: number;
  4561. /**
  4562. * Returns the wireframe mode
  4563. */
  4564. static readonly MATERIAL_WireFrameFillMode: number;
  4565. /**
  4566. * Returns the point fill mode
  4567. */
  4568. static readonly MATERIAL_PointFillMode: number;
  4569. /**
  4570. * Returns the point list draw mode
  4571. */
  4572. static readonly MATERIAL_PointListDrawMode: number;
  4573. /**
  4574. * Returns the line list draw mode
  4575. */
  4576. static readonly MATERIAL_LineListDrawMode: number;
  4577. /**
  4578. * Returns the line loop draw mode
  4579. */
  4580. static readonly MATERIAL_LineLoopDrawMode: number;
  4581. /**
  4582. * Returns the line strip draw mode
  4583. */
  4584. static readonly MATERIAL_LineStripDrawMode: number;
  4585. /**
  4586. * Returns the triangle strip draw mode
  4587. */
  4588. static readonly MATERIAL_TriangleStripDrawMode: number;
  4589. /**
  4590. * Returns the triangle fan draw mode
  4591. */
  4592. static readonly MATERIAL_TriangleFanDrawMode: number;
  4593. /**
  4594. * Stores the clock-wise side orientation
  4595. */
  4596. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4597. /**
  4598. * Stores the counter clock-wise side orientation
  4599. */
  4600. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4601. /**
  4602. * Nothing
  4603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4604. */
  4605. static readonly ACTION_NothingTrigger: number;
  4606. /**
  4607. * On pick
  4608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4609. */
  4610. static readonly ACTION_OnPickTrigger: number;
  4611. /**
  4612. * On left pick
  4613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4614. */
  4615. static readonly ACTION_OnLeftPickTrigger: number;
  4616. /**
  4617. * On right pick
  4618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4619. */
  4620. static readonly ACTION_OnRightPickTrigger: number;
  4621. /**
  4622. * On center pick
  4623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4624. */
  4625. static readonly ACTION_OnCenterPickTrigger: number;
  4626. /**
  4627. * On pick down
  4628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4629. */
  4630. static readonly ACTION_OnPickDownTrigger: number;
  4631. /**
  4632. * On double pick
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnDoublePickTrigger: number;
  4636. /**
  4637. * On pick up
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnPickUpTrigger: number;
  4641. /**
  4642. * On pick out.
  4643. * This trigger will only be raised if you also declared a OnPickDown
  4644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4645. */
  4646. static readonly ACTION_OnPickOutTrigger: number;
  4647. /**
  4648. * On long press
  4649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4650. */
  4651. static readonly ACTION_OnLongPressTrigger: number;
  4652. /**
  4653. * On pointer over
  4654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4655. */
  4656. static readonly ACTION_OnPointerOverTrigger: number;
  4657. /**
  4658. * On pointer out
  4659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4660. */
  4661. static readonly ACTION_OnPointerOutTrigger: number;
  4662. /**
  4663. * On every frame
  4664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4665. */
  4666. static readonly ACTION_OnEveryFrameTrigger: number;
  4667. /**
  4668. * On intersection enter
  4669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4670. */
  4671. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4672. /**
  4673. * On intersection exit
  4674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4675. */
  4676. static readonly ACTION_OnIntersectionExitTrigger: number;
  4677. /**
  4678. * On key down
  4679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4680. */
  4681. static readonly ACTION_OnKeyDownTrigger: number;
  4682. /**
  4683. * On key up
  4684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4685. */
  4686. static readonly ACTION_OnKeyUpTrigger: number;
  4687. /**
  4688. * Billboard mode will only apply to Y axis
  4689. */
  4690. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4691. /**
  4692. * Billboard mode will apply to all axes
  4693. */
  4694. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4695. /**
  4696. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4697. */
  4698. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4699. /**
  4700. * Gets or sets base Assets URL
  4701. */
  4702. static PARTICLES_BaseAssetsUrl: string;
  4703. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4704. * Test order :
  4705. * Is the bounding sphere outside the frustum ?
  4706. * If not, are the bounding box vertices outside the frustum ?
  4707. * It not, then the cullable object is in the frustum.
  4708. */
  4709. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4710. /** Culling strategy : Bounding Sphere Only.
  4711. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4712. * It's also less accurate than the standard because some not visible objects can still be selected.
  4713. * Test : is the bounding sphere outside the frustum ?
  4714. * If not, then the cullable object is in the frustum.
  4715. */
  4716. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4717. /** Culling strategy : Optimistic Inclusion.
  4718. * This in an inclusion test first, then the standard exclusion test.
  4719. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4720. * 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.
  4721. * Anyway, it's as accurate as the standard strategy.
  4722. * Test :
  4723. * Is the cullable object bounding sphere center in the frustum ?
  4724. * If not, apply the default culling strategy.
  4725. */
  4726. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4727. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4728. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4729. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4730. * 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.
  4731. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4732. * Test :
  4733. * Is the cullable object bounding sphere center in the frustum ?
  4734. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4735. */
  4736. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4737. /**
  4738. * No logging while loading
  4739. */
  4740. static readonly SCENELOADER_NO_LOGGING: number;
  4741. /**
  4742. * Minimal logging while loading
  4743. */
  4744. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4745. /**
  4746. * Summary logging while loading
  4747. */
  4748. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4749. /**
  4750. * Detailled logging while loading
  4751. */
  4752. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4753. }
  4754. }
  4755. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  4756. import { Nullable } from "babylonjs/types";
  4757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  4758. /**
  4759. * This represents the required contract to create a new type of texture loader.
  4760. */
  4761. export interface IInternalTextureLoader {
  4762. /**
  4763. * Defines wether the loader supports cascade loading the different faces.
  4764. */
  4765. supportCascades: boolean;
  4766. /**
  4767. * This returns if the loader support the current file information.
  4768. * @param extension defines the file extension of the file being loaded
  4769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4770. * @param fallback defines the fallback internal texture if any
  4771. * @param isBase64 defines whether the texture is encoded as a base64
  4772. * @param isBuffer defines whether the texture data are stored as a buffer
  4773. * @returns true if the loader can load the specified file
  4774. */
  4775. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4776. /**
  4777. * Transform the url before loading if required.
  4778. * @param rootUrl the url of the texture
  4779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4780. * @returns the transformed texture
  4781. */
  4782. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4783. /**
  4784. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4785. * @param rootUrl the url of the texture
  4786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4787. * @returns the fallback texture
  4788. */
  4789. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4790. /**
  4791. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4792. * @param data contains the texture data
  4793. * @param texture defines the BabylonJS internal texture
  4794. * @param createPolynomials will be true if polynomials have been requested
  4795. * @param onLoad defines the callback to trigger once the texture is ready
  4796. * @param onError defines the callback to trigger in case of error
  4797. */
  4798. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4799. /**
  4800. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4801. * @param data contains the texture data
  4802. * @param texture defines the BabylonJS internal texture
  4803. * @param callback defines the method to call once ready to upload
  4804. */
  4805. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/IPipelineContext" {
  4809. /**
  4810. * Class used to store and describe the pipeline context associated with an effect
  4811. */
  4812. export interface IPipelineContext {
  4813. /**
  4814. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4815. */
  4816. isAsync: boolean;
  4817. /**
  4818. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4819. */
  4820. isReady: boolean;
  4821. /** @hidden */
  4822. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4823. }
  4824. }
  4825. declare module "babylonjs/Meshes/dataBuffer" {
  4826. /**
  4827. * Class used to store gfx data (like WebGLBuffer)
  4828. */
  4829. export class DataBuffer {
  4830. /**
  4831. * Gets or sets the number of objects referencing this buffer
  4832. */
  4833. references: number;
  4834. /** Gets or sets the size of the underlying buffer */
  4835. capacity: number;
  4836. /**
  4837. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4838. */
  4839. is32Bits: boolean;
  4840. /**
  4841. * Gets the underlying buffer
  4842. */
  4843. readonly underlyingResource: any;
  4844. }
  4845. }
  4846. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4847. /** @hidden */
  4848. export interface IShaderProcessor {
  4849. attributeProcessor?: (attribute: string) => string;
  4850. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4851. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4852. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4853. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4854. lineProcessor?: (line: string, isFragment: boolean) => string;
  4855. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4856. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4857. }
  4858. }
  4859. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4860. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4861. /** @hidden */
  4862. export interface ProcessingOptions {
  4863. defines: string[];
  4864. indexParameters: any;
  4865. isFragment: boolean;
  4866. shouldUseHighPrecisionShader: boolean;
  4867. supportsUniformBuffers: boolean;
  4868. shadersRepository: string;
  4869. includesShadersStore: {
  4870. [key: string]: string;
  4871. };
  4872. processor?: IShaderProcessor;
  4873. version: string;
  4874. platformName: string;
  4875. lookForClosingBracketForUniformBuffer?: boolean;
  4876. }
  4877. }
  4878. declare module "babylonjs/Misc/stringTools" {
  4879. /**
  4880. * Helper to manipulate strings
  4881. */
  4882. export class StringTools {
  4883. /**
  4884. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4885. * @param str Source string
  4886. * @param suffix Suffix to search for in the source string
  4887. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4888. */
  4889. static EndsWith(str: string, suffix: string): boolean;
  4890. /**
  4891. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4892. * @param str Source string
  4893. * @param suffix Suffix to search for in the source string
  4894. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4895. */
  4896. static StartsWith(str: string, suffix: string): boolean;
  4897. }
  4898. }
  4899. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4900. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4901. /** @hidden */
  4902. export class ShaderCodeNode {
  4903. line: string;
  4904. children: ShaderCodeNode[];
  4905. additionalDefineKey?: string;
  4906. additionalDefineValue?: string;
  4907. isValid(preprocessors: {
  4908. [key: string]: string;
  4909. }): boolean;
  4910. process(preprocessors: {
  4911. [key: string]: string;
  4912. }, options: ProcessingOptions): string;
  4913. }
  4914. }
  4915. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4916. /** @hidden */
  4917. export class ShaderCodeCursor {
  4918. private _lines;
  4919. lineIndex: number;
  4920. readonly currentLine: string;
  4921. readonly canRead: boolean;
  4922. lines: string[];
  4923. }
  4924. }
  4925. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4926. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4927. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4928. /** @hidden */
  4929. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4930. process(preprocessors: {
  4931. [key: string]: string;
  4932. }, options: ProcessingOptions): string;
  4933. }
  4934. }
  4935. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4936. /** @hidden */
  4937. export class ShaderDefineExpression {
  4938. isTrue(preprocessors: {
  4939. [key: string]: string;
  4940. }): boolean;
  4941. }
  4942. }
  4943. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4944. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4945. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4946. /** @hidden */
  4947. export class ShaderCodeTestNode extends ShaderCodeNode {
  4948. testExpression: ShaderDefineExpression;
  4949. isValid(preprocessors: {
  4950. [key: string]: string;
  4951. }): boolean;
  4952. }
  4953. }
  4954. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4955. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4956. /** @hidden */
  4957. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4958. define: string;
  4959. not: boolean;
  4960. constructor(define: string, not?: boolean);
  4961. isTrue(preprocessors: {
  4962. [key: string]: string;
  4963. }): boolean;
  4964. }
  4965. }
  4966. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4967. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4968. /** @hidden */
  4969. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4970. leftOperand: ShaderDefineExpression;
  4971. rightOperand: ShaderDefineExpression;
  4972. isTrue(preprocessors: {
  4973. [key: string]: string;
  4974. }): boolean;
  4975. }
  4976. }
  4977. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4978. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4979. /** @hidden */
  4980. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4981. leftOperand: ShaderDefineExpression;
  4982. rightOperand: ShaderDefineExpression;
  4983. isTrue(preprocessors: {
  4984. [key: string]: string;
  4985. }): boolean;
  4986. }
  4987. }
  4988. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4989. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4990. /** @hidden */
  4991. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4992. define: string;
  4993. operand: string;
  4994. testValue: string;
  4995. constructor(define: string, operand: string, testValue: string);
  4996. isTrue(preprocessors: {
  4997. [key: string]: string;
  4998. }): boolean;
  4999. }
  5000. }
  5001. declare module "babylonjs/Misc/loadFileError" {
  5002. import { WebRequest } from "babylonjs/Misc/webRequest";
  5003. /**
  5004. * @ignore
  5005. * Application error to support additional information when loading a file
  5006. */
  5007. export class LoadFileError extends Error {
  5008. /** defines the optional web request */
  5009. request?: WebRequest | undefined;
  5010. private static _setPrototypeOf;
  5011. /**
  5012. * Creates a new LoadFileError
  5013. * @param message defines the message of the error
  5014. * @param request defines the optional web request
  5015. */
  5016. constructor(message: string,
  5017. /** defines the optional web request */
  5018. request?: WebRequest | undefined);
  5019. }
  5020. }
  5021. declare module "babylonjs/Offline/IOfflineProvider" {
  5022. /**
  5023. * Class used to enable access to offline support
  5024. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5025. */
  5026. export interface IOfflineProvider {
  5027. /**
  5028. * Gets a boolean indicating if scene must be saved in the database
  5029. */
  5030. enableSceneOffline: boolean;
  5031. /**
  5032. * Gets a boolean indicating if textures must be saved in the database
  5033. */
  5034. enableTexturesOffline: boolean;
  5035. /**
  5036. * Open the offline support and make it available
  5037. * @param successCallback defines the callback to call on success
  5038. * @param errorCallback defines the callback to call on error
  5039. */
  5040. open(successCallback: () => void, errorCallback: () => void): void;
  5041. /**
  5042. * Loads an image from the offline support
  5043. * @param url defines the url to load from
  5044. * @param image defines the target DOM image
  5045. */
  5046. loadImage(url: string, image: HTMLImageElement): void;
  5047. /**
  5048. * Loads a file from offline support
  5049. * @param url defines the URL to load from
  5050. * @param sceneLoaded defines a callback to call on success
  5051. * @param progressCallBack defines a callback to call when progress changed
  5052. * @param errorCallback defines a callback to call on error
  5053. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5054. */
  5055. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5056. }
  5057. }
  5058. declare module "babylonjs/Misc/filesInputStore" {
  5059. /**
  5060. * Class used to help managing file picking and drag'n'drop
  5061. * File Storage
  5062. */
  5063. export class FilesInputStore {
  5064. /**
  5065. * List of files ready to be loaded
  5066. */
  5067. static FilesToLoad: {
  5068. [key: string]: File;
  5069. };
  5070. }
  5071. }
  5072. declare module "babylonjs/Misc/retryStrategy" {
  5073. import { WebRequest } from "babylonjs/Misc/webRequest";
  5074. /**
  5075. * Class used to define a retry strategy when error happens while loading assets
  5076. */
  5077. export class RetryStrategy {
  5078. /**
  5079. * Function used to defines an exponential back off strategy
  5080. * @param maxRetries defines the maximum number of retries (3 by default)
  5081. * @param baseInterval defines the interval between retries
  5082. * @returns the strategy function to use
  5083. */
  5084. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/fileTools" {
  5088. import { WebRequest } from "babylonjs/Misc/webRequest";
  5089. import { Nullable } from "babylonjs/types";
  5090. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  5091. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  5092. /**
  5093. * @hidden
  5094. */
  5095. export class FileTools {
  5096. /**
  5097. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5098. */
  5099. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5100. /**
  5101. * Gets or sets the base URL to use to load assets
  5102. */
  5103. static BaseUrl: string;
  5104. /**
  5105. * Default behaviour for cors in the application.
  5106. * It can be a string if the expected behavior is identical in the entire app.
  5107. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5108. */
  5109. static CorsBehavior: string | ((url: string | string[]) => string);
  5110. /**
  5111. * Gets or sets a function used to pre-process url before using them to load assets
  5112. */
  5113. static PreprocessUrl: (url: string) => string;
  5114. /**
  5115. * Removes unwanted characters from an url
  5116. * @param url defines the url to clean
  5117. * @returns the cleaned url
  5118. */
  5119. private static _CleanUrl;
  5120. /**
  5121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5122. * @param url define the url we are trying
  5123. * @param element define the dom element where to configure the cors policy
  5124. */
  5125. static SetCorsBehavior(url: string | string[], element: {
  5126. crossOrigin: string | null;
  5127. }): void;
  5128. /**
  5129. * Loads an image as an HTMLImageElement.
  5130. * @param input url string, ArrayBuffer, or Blob to load
  5131. * @param onLoad callback called when the image successfully loads
  5132. * @param onError callback called when the image fails to load
  5133. * @param offlineProvider offline provider for caching
  5134. * @returns the HTMLImageElement of the loaded image
  5135. */
  5136. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5137. /**
  5138. * Loads a file
  5139. * @param fileToLoad defines the file to load
  5140. * @param callback defines the callback to call when data is loaded
  5141. * @param progressCallBack defines the callback to call during loading process
  5142. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5143. * @returns a file request object
  5144. */
  5145. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5146. /**
  5147. * Loads a file
  5148. * @param url url string, ArrayBuffer, or Blob to load
  5149. * @param onSuccess callback called when the file successfully loads
  5150. * @param onProgress callback called while file is loading (if the server supports this mode)
  5151. * @param offlineProvider defines the offline provider for caching
  5152. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5153. * @param onError callback called when the file fails to load
  5154. * @returns a file request object
  5155. */
  5156. 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;
  5157. /**
  5158. * Checks if the loaded document was accessed via `file:`-Protocol.
  5159. * @returns boolean
  5160. */
  5161. static IsFileURL(): boolean;
  5162. }
  5163. }
  5164. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5165. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5166. /** @hidden */
  5167. export class ShaderProcessor {
  5168. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5169. private static _ProcessPrecision;
  5170. private static _ExtractOperation;
  5171. private static _BuildSubExpression;
  5172. private static _BuildExpression;
  5173. private static _MoveCursorWithinIf;
  5174. private static _MoveCursor;
  5175. private static _EvaluatePreProcessors;
  5176. private static _PreparePreProcessors;
  5177. private static _ProcessShaderConversion;
  5178. private static _ProcessIncludes;
  5179. }
  5180. }
  5181. declare module "babylonjs/Materials/iEffectFallbacks" {
  5182. import { Effect } from "babylonjs/Materials/effect";
  5183. /**
  5184. * Interface used to define common properties for effect fallbacks
  5185. */
  5186. export interface IEffectFallbacks {
  5187. /**
  5188. * Removes the defines that should be removed when falling back.
  5189. * @param currentDefines defines the current define statements for the shader.
  5190. * @param effect defines the current effect we try to compile
  5191. * @returns The resulting defines with defines of the current rank removed.
  5192. */
  5193. reduce(currentDefines: string, effect: Effect): string;
  5194. /**
  5195. * Removes the fallback from the bound mesh.
  5196. */
  5197. unBindMesh(): void;
  5198. /**
  5199. * Checks to see if more fallbacks are still availible.
  5200. */
  5201. hasMoreFallbacks: boolean;
  5202. }
  5203. }
  5204. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5205. /**
  5206. * Class used to evalaute queries containing `and` and `or` operators
  5207. */
  5208. export class AndOrNotEvaluator {
  5209. /**
  5210. * Evaluate a query
  5211. * @param query defines the query to evaluate
  5212. * @param evaluateCallback defines the callback used to filter result
  5213. * @returns true if the query matches
  5214. */
  5215. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5216. private static _HandleParenthesisContent;
  5217. private static _SimplifyNegation;
  5218. }
  5219. }
  5220. declare module "babylonjs/Misc/tags" {
  5221. /**
  5222. * Class used to store custom tags
  5223. */
  5224. export class Tags {
  5225. /**
  5226. * Adds support for tags on the given object
  5227. * @param obj defines the object to use
  5228. */
  5229. static EnableFor(obj: any): void;
  5230. /**
  5231. * Removes tags support
  5232. * @param obj defines the object to use
  5233. */
  5234. static DisableFor(obj: any): void;
  5235. /**
  5236. * Gets a boolean indicating if the given object has tags
  5237. * @param obj defines the object to use
  5238. * @returns a boolean
  5239. */
  5240. static HasTags(obj: any): boolean;
  5241. /**
  5242. * Gets the tags available on a given object
  5243. * @param obj defines the object to use
  5244. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5245. * @returns the tags
  5246. */
  5247. static GetTags(obj: any, asString?: boolean): any;
  5248. /**
  5249. * Adds tags to an object
  5250. * @param obj defines the object to use
  5251. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5252. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5253. */
  5254. static AddTagsTo(obj: any, tagsString: string): void;
  5255. /**
  5256. * @hidden
  5257. */
  5258. static _AddTagTo(obj: any, tag: string): void;
  5259. /**
  5260. * Removes specific tags from a specific object
  5261. * @param obj defines the object to use
  5262. * @param tagsString defines the tags to remove
  5263. */
  5264. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5265. /**
  5266. * @hidden
  5267. */
  5268. static _RemoveTagFrom(obj: any, tag: string): void;
  5269. /**
  5270. * Defines if tags hosted on an object match a given query
  5271. * @param obj defines the object to use
  5272. * @param tagsQuery defines the tag query
  5273. * @returns a boolean
  5274. */
  5275. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5276. }
  5277. }
  5278. declare module "babylonjs/Maths/math.path" {
  5279. import { DeepImmutable, Nullable } from "babylonjs/types";
  5280. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5281. /**
  5282. * Defines potential orientation for back face culling
  5283. */
  5284. export enum Orientation {
  5285. /**
  5286. * Clockwise
  5287. */
  5288. CW = 0,
  5289. /** Counter clockwise */
  5290. CCW = 1
  5291. }
  5292. /** Class used to represent a Bezier curve */
  5293. export class BezierCurve {
  5294. /**
  5295. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5296. * @param t defines the time
  5297. * @param x1 defines the left coordinate on X axis
  5298. * @param y1 defines the left coordinate on Y axis
  5299. * @param x2 defines the right coordinate on X axis
  5300. * @param y2 defines the right coordinate on Y axis
  5301. * @returns the interpolated value
  5302. */
  5303. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5304. }
  5305. /**
  5306. * Defines angle representation
  5307. */
  5308. export class Angle {
  5309. private _radians;
  5310. /**
  5311. * Creates an Angle object of "radians" radians (float).
  5312. * @param radians the angle in radians
  5313. */
  5314. constructor(radians: number);
  5315. /**
  5316. * Get value in degrees
  5317. * @returns the Angle value in degrees (float)
  5318. */
  5319. degrees(): number;
  5320. /**
  5321. * Get value in radians
  5322. * @returns the Angle value in radians (float)
  5323. */
  5324. radians(): number;
  5325. /**
  5326. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5327. * @param a defines first vector
  5328. * @param b defines second vector
  5329. * @returns a new Angle
  5330. */
  5331. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5332. /**
  5333. * Gets a new Angle object from the given float in radians
  5334. * @param radians defines the angle value in radians
  5335. * @returns a new Angle
  5336. */
  5337. static FromRadians(radians: number): Angle;
  5338. /**
  5339. * Gets a new Angle object from the given float in degrees
  5340. * @param degrees defines the angle value in degrees
  5341. * @returns a new Angle
  5342. */
  5343. static FromDegrees(degrees: number): Angle;
  5344. }
  5345. /**
  5346. * This represents an arc in a 2d space.
  5347. */
  5348. export class Arc2 {
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2;
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2;
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2;
  5355. /**
  5356. * Defines the center point of the arc.
  5357. */
  5358. centerPoint: Vector2;
  5359. /**
  5360. * Defines the radius of the arc.
  5361. */
  5362. radius: number;
  5363. /**
  5364. * Defines the angle of the arc (from mid point to end point).
  5365. */
  5366. angle: Angle;
  5367. /**
  5368. * Defines the start angle of the arc (from start point to middle point).
  5369. */
  5370. startAngle: Angle;
  5371. /**
  5372. * Defines the orientation of the arc (clock wise/counter clock wise).
  5373. */
  5374. orientation: Orientation;
  5375. /**
  5376. * Creates an Arc object from the three given points : start, middle and end.
  5377. * @param startPoint Defines the start point of the arc
  5378. * @param midPoint Defines the midlle point of the arc
  5379. * @param endPoint Defines the end point of the arc
  5380. */
  5381. constructor(
  5382. /** Defines the start point of the arc */
  5383. startPoint: Vector2,
  5384. /** Defines the mid point of the arc */
  5385. midPoint: Vector2,
  5386. /** Defines the end point of the arc */
  5387. endPoint: Vector2);
  5388. }
  5389. /**
  5390. * Represents a 2D path made up of multiple 2D points
  5391. */
  5392. export class Path2 {
  5393. private _points;
  5394. private _length;
  5395. /**
  5396. * If the path start and end point are the same
  5397. */
  5398. closed: boolean;
  5399. /**
  5400. * Creates a Path2 object from the starting 2D coordinates x and y.
  5401. * @param x the starting points x value
  5402. * @param y the starting points y value
  5403. */
  5404. constructor(x: number, y: number);
  5405. /**
  5406. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5407. * @param x the added points x value
  5408. * @param y the added points y value
  5409. * @returns the updated Path2.
  5410. */
  5411. addLineTo(x: number, y: number): Path2;
  5412. /**
  5413. * 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.
  5414. * @param midX middle point x value
  5415. * @param midY middle point y value
  5416. * @param endX end point x value
  5417. * @param endY end point y value
  5418. * @param numberOfSegments (default: 36)
  5419. * @returns the updated Path2.
  5420. */
  5421. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5422. /**
  5423. * Closes the Path2.
  5424. * @returns the Path2.
  5425. */
  5426. close(): Path2;
  5427. /**
  5428. * Gets the sum of the distance between each sequential point in the path
  5429. * @returns the Path2 total length (float).
  5430. */
  5431. length(): number;
  5432. /**
  5433. * Gets the points which construct the path
  5434. * @returns the Path2 internal array of points.
  5435. */
  5436. getPoints(): Vector2[];
  5437. /**
  5438. * Retreives the point at the distance aways from the starting point
  5439. * @param normalizedLengthPosition the length along the path to retreive the point from
  5440. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5441. */
  5442. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5443. /**
  5444. * Creates a new path starting from an x and y position
  5445. * @param x starting x value
  5446. * @param y starting y value
  5447. * @returns a new Path2 starting at the coordinates (x, y).
  5448. */
  5449. static StartingAt(x: number, y: number): Path2;
  5450. }
  5451. /**
  5452. * Represents a 3D path made up of multiple 3D points
  5453. */
  5454. export class Path3D {
  5455. /**
  5456. * an array of Vector3, the curve axis of the Path3D
  5457. */
  5458. path: Vector3[];
  5459. private _curve;
  5460. private _distances;
  5461. private _tangents;
  5462. private _normals;
  5463. private _binormals;
  5464. private _raw;
  5465. /**
  5466. * new Path3D(path, normal, raw)
  5467. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5468. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5469. * @param path an array of Vector3, the curve axis of the Path3D
  5470. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5471. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5472. */
  5473. constructor(
  5474. /**
  5475. * an array of Vector3, the curve axis of the Path3D
  5476. */
  5477. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5478. /**
  5479. * Returns the Path3D array of successive Vector3 designing its curve.
  5480. * @returns the Path3D array of successive Vector3 designing its curve.
  5481. */
  5482. getCurve(): Vector3[];
  5483. /**
  5484. * Returns an array populated with tangent vectors on each Path3D curve point.
  5485. * @returns an array populated with tangent vectors on each Path3D curve point.
  5486. */
  5487. getTangents(): Vector3[];
  5488. /**
  5489. * Returns an array populated with normal vectors on each Path3D curve point.
  5490. * @returns an array populated with normal vectors on each Path3D curve point.
  5491. */
  5492. getNormals(): Vector3[];
  5493. /**
  5494. * Returns an array populated with binormal vectors on each Path3D curve point.
  5495. * @returns an array populated with binormal vectors on each Path3D curve point.
  5496. */
  5497. getBinormals(): Vector3[];
  5498. /**
  5499. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5500. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5501. */
  5502. getDistances(): number[];
  5503. /**
  5504. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5505. * @param path path which all values are copied into the curves points
  5506. * @param firstNormal which should be projected onto the curve
  5507. * @returns the same object updated.
  5508. */
  5509. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5510. private _compute;
  5511. private _getFirstNonNullVector;
  5512. private _getLastNonNullVector;
  5513. private _normalVector;
  5514. }
  5515. /**
  5516. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5517. * A Curve3 is designed from a series of successive Vector3.
  5518. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5519. */
  5520. export class Curve3 {
  5521. private _points;
  5522. private _length;
  5523. /**
  5524. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5525. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5526. * @param v1 (Vector3) the control point
  5527. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5528. * @param nbPoints (integer) the wanted number of points in the curve
  5529. * @returns the created Curve3
  5530. */
  5531. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5532. /**
  5533. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5534. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5535. * @param v1 (Vector3) the first control point
  5536. * @param v2 (Vector3) the second control point
  5537. * @param v3 (Vector3) the end point of the Cubic Bezier
  5538. * @param nbPoints (integer) the wanted number of points in the curve
  5539. * @returns the created Curve3
  5540. */
  5541. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5542. /**
  5543. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5544. * @param p1 (Vector3) the origin point of the Hermite Spline
  5545. * @param t1 (Vector3) the tangent vector at the origin point
  5546. * @param p2 (Vector3) the end point of the Hermite Spline
  5547. * @param t2 (Vector3) the tangent vector at the end point
  5548. * @param nbPoints (integer) the wanted number of points in the curve
  5549. * @returns the created Curve3
  5550. */
  5551. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5552. /**
  5553. * Returns a Curve3 object along a CatmullRom Spline curve :
  5554. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5555. * @param nbPoints (integer) the wanted number of points between each curve control points
  5556. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5557. * @returns the created Curve3
  5558. */
  5559. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5560. /**
  5561. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5562. * A Curve3 is designed from a series of successive Vector3.
  5563. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5564. * @param points points which make up the curve
  5565. */
  5566. constructor(points: Vector3[]);
  5567. /**
  5568. * @returns the Curve3 stored array of successive Vector3
  5569. */
  5570. getPoints(): Vector3[];
  5571. /**
  5572. * @returns the computed length (float) of the curve.
  5573. */
  5574. length(): number;
  5575. /**
  5576. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5577. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5578. * curveA and curveB keep unchanged.
  5579. * @param curve the curve to continue from this curve
  5580. * @returns the newly constructed curve
  5581. */
  5582. continue(curve: DeepImmutable<Curve3>): Curve3;
  5583. private _computeLength;
  5584. }
  5585. }
  5586. declare module "babylonjs/Animations/easing" {
  5587. /**
  5588. * This represents the main contract an easing function should follow.
  5589. * Easing functions are used throughout the animation system.
  5590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5591. */
  5592. export interface IEasingFunction {
  5593. /**
  5594. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5595. * of the easing function.
  5596. * The link below provides some of the most common examples of easing functions.
  5597. * @see https://easings.net/
  5598. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5599. * @returns the corresponding value on the curve defined by the easing function
  5600. */
  5601. ease(gradient: number): number;
  5602. }
  5603. /**
  5604. * Base class used for every default easing function.
  5605. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5606. */
  5607. export class EasingFunction implements IEasingFunction {
  5608. /**
  5609. * Interpolation follows the mathematical formula associated with the easing function.
  5610. */
  5611. static readonly EASINGMODE_EASEIN: number;
  5612. /**
  5613. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5614. */
  5615. static readonly EASINGMODE_EASEOUT: number;
  5616. /**
  5617. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5618. */
  5619. static readonly EASINGMODE_EASEINOUT: number;
  5620. private _easingMode;
  5621. /**
  5622. * Sets the easing mode of the current function.
  5623. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5624. */
  5625. setEasingMode(easingMode: number): void;
  5626. /**
  5627. * Gets the current easing mode.
  5628. * @returns the easing mode
  5629. */
  5630. getEasingMode(): number;
  5631. /**
  5632. * @hidden
  5633. */
  5634. easeInCore(gradient: number): number;
  5635. /**
  5636. * Given an input gradient between 0 and 1, this returns the corresponding value
  5637. * of the easing function.
  5638. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5639. * @returns the corresponding value on the curve defined by the easing function
  5640. */
  5641. ease(gradient: number): number;
  5642. }
  5643. /**
  5644. * Easing function with a circle shape (see link below).
  5645. * @see https://easings.net/#easeInCirc
  5646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5647. */
  5648. export class CircleEase extends EasingFunction implements IEasingFunction {
  5649. /** @hidden */
  5650. easeInCore(gradient: number): number;
  5651. }
  5652. /**
  5653. * Easing function with a ease back shape (see link below).
  5654. * @see https://easings.net/#easeInBack
  5655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5656. */
  5657. export class BackEase extends EasingFunction implements IEasingFunction {
  5658. /** Defines the amplitude of the function */
  5659. amplitude: number;
  5660. /**
  5661. * Instantiates a back ease easing
  5662. * @see https://easings.net/#easeInBack
  5663. * @param amplitude Defines the amplitude of the function
  5664. */
  5665. constructor(
  5666. /** Defines the amplitude of the function */
  5667. amplitude?: number);
  5668. /** @hidden */
  5669. easeInCore(gradient: number): number;
  5670. }
  5671. /**
  5672. * Easing function with a bouncing shape (see link below).
  5673. * @see https://easings.net/#easeInBounce
  5674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class BounceEase extends EasingFunction implements IEasingFunction {
  5677. /** Defines the number of bounces */
  5678. bounces: number;
  5679. /** Defines the amplitude of the bounce */
  5680. bounciness: number;
  5681. /**
  5682. * Instantiates a bounce easing
  5683. * @see https://easings.net/#easeInBounce
  5684. * @param bounces Defines the number of bounces
  5685. * @param bounciness Defines the amplitude of the bounce
  5686. */
  5687. constructor(
  5688. /** Defines the number of bounces */
  5689. bounces?: number,
  5690. /** Defines the amplitude of the bounce */
  5691. bounciness?: number);
  5692. /** @hidden */
  5693. easeInCore(gradient: number): number;
  5694. }
  5695. /**
  5696. * Easing function with a power of 3 shape (see link below).
  5697. * @see https://easings.net/#easeInCubic
  5698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5699. */
  5700. export class CubicEase extends EasingFunction implements IEasingFunction {
  5701. /** @hidden */
  5702. easeInCore(gradient: number): number;
  5703. }
  5704. /**
  5705. * Easing function with an elastic shape (see link below).
  5706. * @see https://easings.net/#easeInElastic
  5707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5708. */
  5709. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5710. /** Defines the number of oscillations*/
  5711. oscillations: number;
  5712. /** Defines the amplitude of the oscillations*/
  5713. springiness: number;
  5714. /**
  5715. * Instantiates an elastic easing function
  5716. * @see https://easings.net/#easeInElastic
  5717. * @param oscillations Defines the number of oscillations
  5718. * @param springiness Defines the amplitude of the oscillations
  5719. */
  5720. constructor(
  5721. /** Defines the number of oscillations*/
  5722. oscillations?: number,
  5723. /** Defines the amplitude of the oscillations*/
  5724. springiness?: number);
  5725. /** @hidden */
  5726. easeInCore(gradient: number): number;
  5727. }
  5728. /**
  5729. * Easing function with an exponential shape (see link below).
  5730. * @see https://easings.net/#easeInExpo
  5731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5732. */
  5733. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5734. /** Defines the exponent of the function */
  5735. exponent: number;
  5736. /**
  5737. * Instantiates an exponential easing function
  5738. * @see https://easings.net/#easeInExpo
  5739. * @param exponent Defines the exponent of the function
  5740. */
  5741. constructor(
  5742. /** Defines the exponent of the function */
  5743. exponent?: number);
  5744. /** @hidden */
  5745. easeInCore(gradient: number): number;
  5746. }
  5747. /**
  5748. * Easing function with a power shape (see link below).
  5749. * @see https://easings.net/#easeInQuad
  5750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5751. */
  5752. export class PowerEase extends EasingFunction implements IEasingFunction {
  5753. /** Defines the power of the function */
  5754. power: number;
  5755. /**
  5756. * Instantiates an power base easing function
  5757. * @see https://easings.net/#easeInQuad
  5758. * @param power Defines the power of the function
  5759. */
  5760. constructor(
  5761. /** Defines the power of the function */
  5762. power?: number);
  5763. /** @hidden */
  5764. easeInCore(gradient: number): number;
  5765. }
  5766. /**
  5767. * Easing function with a power of 2 shape (see link below).
  5768. * @see https://easings.net/#easeInQuad
  5769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5770. */
  5771. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5772. /** @hidden */
  5773. easeInCore(gradient: number): number;
  5774. }
  5775. /**
  5776. * Easing function with a power of 4 shape (see link below).
  5777. * @see https://easings.net/#easeInQuart
  5778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5779. */
  5780. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with a power of 5 shape (see link below).
  5786. * @see https://easings.net/#easeInQuint
  5787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5790. /** @hidden */
  5791. easeInCore(gradient: number): number;
  5792. }
  5793. /**
  5794. * Easing function with a sin shape (see link below).
  5795. * @see https://easings.net/#easeInSine
  5796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5797. */
  5798. export class SineEase extends EasingFunction implements IEasingFunction {
  5799. /** @hidden */
  5800. easeInCore(gradient: number): number;
  5801. }
  5802. /**
  5803. * Easing function with a bezier shape (see link below).
  5804. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5806. */
  5807. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5808. /** Defines the x component of the start tangent in the bezier curve */
  5809. x1: number;
  5810. /** Defines the y component of the start tangent in the bezier curve */
  5811. y1: number;
  5812. /** Defines the x component of the end tangent in the bezier curve */
  5813. x2: number;
  5814. /** Defines the y component of the end tangent in the bezier curve */
  5815. y2: number;
  5816. /**
  5817. * Instantiates a bezier function
  5818. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5819. * @param x1 Defines the x component of the start tangent in the bezier curve
  5820. * @param y1 Defines the y component of the start tangent in the bezier curve
  5821. * @param x2 Defines the x component of the end tangent in the bezier curve
  5822. * @param y2 Defines the y component of the end tangent in the bezier curve
  5823. */
  5824. constructor(
  5825. /** Defines the x component of the start tangent in the bezier curve */
  5826. x1?: number,
  5827. /** Defines the y component of the start tangent in the bezier curve */
  5828. y1?: number,
  5829. /** Defines the x component of the end tangent in the bezier curve */
  5830. x2?: number,
  5831. /** Defines the y component of the end tangent in the bezier curve */
  5832. y2?: number);
  5833. /** @hidden */
  5834. easeInCore(gradient: number): number;
  5835. }
  5836. }
  5837. declare module "babylonjs/Animations/animationKey" {
  5838. /**
  5839. * Defines an interface which represents an animation key frame
  5840. */
  5841. export interface IAnimationKey {
  5842. /**
  5843. * Frame of the key frame
  5844. */
  5845. frame: number;
  5846. /**
  5847. * Value at the specifies key frame
  5848. */
  5849. value: any;
  5850. /**
  5851. * The input tangent for the cubic hermite spline
  5852. */
  5853. inTangent?: any;
  5854. /**
  5855. * The output tangent for the cubic hermite spline
  5856. */
  5857. outTangent?: any;
  5858. /**
  5859. * The animation interpolation type
  5860. */
  5861. interpolation?: AnimationKeyInterpolation;
  5862. }
  5863. /**
  5864. * Enum for the animation key frame interpolation type
  5865. */
  5866. export enum AnimationKeyInterpolation {
  5867. /**
  5868. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5869. */
  5870. STEP = 1
  5871. }
  5872. }
  5873. declare module "babylonjs/Animations/animationRange" {
  5874. /**
  5875. * Represents the range of an animation
  5876. */
  5877. export class AnimationRange {
  5878. /**The name of the animation range**/
  5879. name: string;
  5880. /**The starting frame of the animation */
  5881. from: number;
  5882. /**The ending frame of the animation*/
  5883. to: number;
  5884. /**
  5885. * Initializes the range of an animation
  5886. * @param name The name of the animation range
  5887. * @param from The starting frame of the animation
  5888. * @param to The ending frame of the animation
  5889. */
  5890. constructor(
  5891. /**The name of the animation range**/
  5892. name: string,
  5893. /**The starting frame of the animation */
  5894. from: number,
  5895. /**The ending frame of the animation*/
  5896. to: number);
  5897. /**
  5898. * Makes a copy of the animation range
  5899. * @returns A copy of the animation range
  5900. */
  5901. clone(): AnimationRange;
  5902. }
  5903. }
  5904. declare module "babylonjs/Animations/animationEvent" {
  5905. /**
  5906. * Composed of a frame, and an action function
  5907. */
  5908. export class AnimationEvent {
  5909. /** The frame for which the event is triggered **/
  5910. frame: number;
  5911. /** The event to perform when triggered **/
  5912. action: (currentFrame: number) => void;
  5913. /** Specifies if the event should be triggered only once**/
  5914. onlyOnce?: boolean | undefined;
  5915. /**
  5916. * Specifies if the animation event is done
  5917. */
  5918. isDone: boolean;
  5919. /**
  5920. * Initializes the animation event
  5921. * @param frame The frame for which the event is triggered
  5922. * @param action The event to perform when triggered
  5923. * @param onlyOnce Specifies if the event should be triggered only once
  5924. */
  5925. constructor(
  5926. /** The frame for which the event is triggered **/
  5927. frame: number,
  5928. /** The event to perform when triggered **/
  5929. action: (currentFrame: number) => void,
  5930. /** Specifies if the event should be triggered only once**/
  5931. onlyOnce?: boolean | undefined);
  5932. /** @hidden */
  5933. _clone(): AnimationEvent;
  5934. }
  5935. }
  5936. declare module "babylonjs/Behaviors/behavior" {
  5937. import { Nullable } from "babylonjs/types";
  5938. /**
  5939. * Interface used to define a behavior
  5940. */
  5941. export interface Behavior<T> {
  5942. /** gets or sets behavior's name */
  5943. name: string;
  5944. /**
  5945. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5946. */
  5947. init(): void;
  5948. /**
  5949. * Called when the behavior is attached to a target
  5950. * @param target defines the target where the behavior is attached to
  5951. */
  5952. attach(target: T): void;
  5953. /**
  5954. * Called when the behavior is detached from its target
  5955. */
  5956. detach(): void;
  5957. }
  5958. /**
  5959. * Interface implemented by classes supporting behaviors
  5960. */
  5961. export interface IBehaviorAware<T> {
  5962. /**
  5963. * Attach a behavior
  5964. * @param behavior defines the behavior to attach
  5965. * @returns the current host
  5966. */
  5967. addBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Remove a behavior from the current object
  5970. * @param behavior defines the behavior to detach
  5971. * @returns the current host
  5972. */
  5973. removeBehavior(behavior: Behavior<T>): T;
  5974. /**
  5975. * Gets a behavior using its name to search
  5976. * @param name defines the name to search
  5977. * @returns the behavior or null if not found
  5978. */
  5979. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/smartArray" {
  5983. /**
  5984. * Defines an array and its length.
  5985. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5986. */
  5987. export interface ISmartArrayLike<T> {
  5988. /**
  5989. * The data of the array.
  5990. */
  5991. data: Array<T>;
  5992. /**
  5993. * The active length of the array.
  5994. */
  5995. length: number;
  5996. }
  5997. /**
  5998. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5999. */
  6000. export class SmartArray<T> implements ISmartArrayLike<T> {
  6001. /**
  6002. * The full set of data from the array.
  6003. */
  6004. data: Array<T>;
  6005. /**
  6006. * The active length of the array.
  6007. */
  6008. length: number;
  6009. protected _id: number;
  6010. /**
  6011. * Instantiates a Smart Array.
  6012. * @param capacity defines the default capacity of the array.
  6013. */
  6014. constructor(capacity: number);
  6015. /**
  6016. * Pushes a value at the end of the active data.
  6017. * @param value defines the object to push in the array.
  6018. */
  6019. push(value: T): void;
  6020. /**
  6021. * Iterates over the active data and apply the lambda to them.
  6022. * @param func defines the action to apply on each value.
  6023. */
  6024. forEach(func: (content: T) => void): void;
  6025. /**
  6026. * Sorts the full sets of data.
  6027. * @param compareFn defines the comparison function to apply.
  6028. */
  6029. sort(compareFn: (a: T, b: T) => number): void;
  6030. /**
  6031. * Resets the active data to an empty array.
  6032. */
  6033. reset(): void;
  6034. /**
  6035. * Releases all the data from the array as well as the array.
  6036. */
  6037. dispose(): void;
  6038. /**
  6039. * Concats the active data with a given array.
  6040. * @param array defines the data to concatenate with.
  6041. */
  6042. concat(array: any): void;
  6043. /**
  6044. * Returns the position of a value in the active data.
  6045. * @param value defines the value to find the index for
  6046. * @returns the index if found in the active data otherwise -1
  6047. */
  6048. indexOf(value: T): number;
  6049. /**
  6050. * Returns whether an element is part of the active data.
  6051. * @param value defines the value to look for
  6052. * @returns true if found in the active data otherwise false
  6053. */
  6054. contains(value: T): boolean;
  6055. private static _GlobalId;
  6056. }
  6057. /**
  6058. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6059. * The data in this array can only be present once
  6060. */
  6061. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6062. private _duplicateId;
  6063. /**
  6064. * Pushes a value at the end of the active data.
  6065. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Pushes a value at the end of the active data.
  6071. * If the data is already present, it won t be added again
  6072. * @param value defines the object to push in the array.
  6073. * @returns true if added false if it was already present
  6074. */
  6075. pushNoDuplicate(value: T): boolean;
  6076. /**
  6077. * Resets the active data to an empty array.
  6078. */
  6079. reset(): void;
  6080. /**
  6081. * Concats the active data with a given array.
  6082. * This ensures no dupplicate will be present in the result.
  6083. * @param array defines the data to concatenate with.
  6084. */
  6085. concatWithNoDuplicate(array: any): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/Cameras/cameraInputsManager" {
  6089. import { Nullable } from "babylonjs/types";
  6090. import { Camera } from "babylonjs/Cameras/camera";
  6091. /**
  6092. * @ignore
  6093. * This is a list of all the different input types that are available in the application.
  6094. * Fo instance: ArcRotateCameraGamepadInput...
  6095. */
  6096. export var CameraInputTypes: {};
  6097. /**
  6098. * This is the contract to implement in order to create a new input class.
  6099. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6100. */
  6101. export interface ICameraInput<TCamera extends Camera> {
  6102. /**
  6103. * Defines the camera the input is attached to.
  6104. */
  6105. camera: Nullable<TCamera>;
  6106. /**
  6107. * Gets the class name of the current intput.
  6108. * @returns the class name
  6109. */
  6110. getClassName(): string;
  6111. /**
  6112. * Get the friendly name associated with the input class.
  6113. * @returns the input friendly name
  6114. */
  6115. getSimpleName(): string;
  6116. /**
  6117. * Attach the input controls to a specific dom element to get the input from.
  6118. * @param element Defines the element the controls should be listened from
  6119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6120. */
  6121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6122. /**
  6123. * Detach the current controls from the specified dom element.
  6124. * @param element Defines the element to stop listening the inputs from
  6125. */
  6126. detachControl(element: Nullable<HTMLElement>): void;
  6127. /**
  6128. * Update the current camera state depending on the inputs that have been used this frame.
  6129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6130. */
  6131. checkInputs?: () => void;
  6132. }
  6133. /**
  6134. * Represents a map of input types to input instance or input index to input instance.
  6135. */
  6136. export interface CameraInputsMap<TCamera extends Camera> {
  6137. /**
  6138. * Accessor to the input by input type.
  6139. */
  6140. [name: string]: ICameraInput<TCamera>;
  6141. /**
  6142. * Accessor to the input by input index.
  6143. */
  6144. [idx: number]: ICameraInput<TCamera>;
  6145. }
  6146. /**
  6147. * This represents the input manager used within a camera.
  6148. * It helps dealing with all the different kind of input attached to a camera.
  6149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6150. */
  6151. export class CameraInputsManager<TCamera extends Camera> {
  6152. /**
  6153. * Defines the list of inputs attahed to the camera.
  6154. */
  6155. attached: CameraInputsMap<TCamera>;
  6156. /**
  6157. * Defines the dom element the camera is collecting inputs from.
  6158. * This is null if the controls have not been attached.
  6159. */
  6160. attachedElement: Nullable<HTMLElement>;
  6161. /**
  6162. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6163. */
  6164. noPreventDefault: boolean;
  6165. /**
  6166. * Defined the camera the input manager belongs to.
  6167. */
  6168. camera: TCamera;
  6169. /**
  6170. * Update the current camera state depending on the inputs that have been used this frame.
  6171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6172. */
  6173. checkInputs: () => void;
  6174. /**
  6175. * Instantiate a new Camera Input Manager.
  6176. * @param camera Defines the camera the input manager blongs to
  6177. */
  6178. constructor(camera: TCamera);
  6179. /**
  6180. * Add an input method to a camera
  6181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6182. * @param input camera input method
  6183. */
  6184. add(input: ICameraInput<TCamera>): void;
  6185. /**
  6186. * Remove a specific input method from a camera
  6187. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6188. * @param inputToRemove camera input method
  6189. */
  6190. remove(inputToRemove: ICameraInput<TCamera>): void;
  6191. /**
  6192. * Remove a specific input type from a camera
  6193. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6194. * @param inputType the type of the input to remove
  6195. */
  6196. removeByType(inputType: string): void;
  6197. private _addCheckInputs;
  6198. /**
  6199. * Attach the input controls to the currently attached dom element to listen the events from.
  6200. * @param input Defines the input to attach
  6201. */
  6202. attachInput(input: ICameraInput<TCamera>): void;
  6203. /**
  6204. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6205. * @param element Defines the dom element to collect the events from
  6206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6207. */
  6208. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6209. /**
  6210. * Detach the current manager inputs controls from a specific dom element.
  6211. * @param element Defines the dom element to collect the events from
  6212. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6213. */
  6214. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6215. /**
  6216. * Rebuild the dynamic inputCheck function from the current list of
  6217. * defined inputs in the manager.
  6218. */
  6219. rebuildInputCheck(): void;
  6220. /**
  6221. * Remove all attached input methods from a camera
  6222. */
  6223. clear(): void;
  6224. /**
  6225. * Serialize the current input manager attached to a camera.
  6226. * This ensures than once parsed,
  6227. * the input associated to the camera will be identical to the current ones
  6228. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6229. */
  6230. serialize(serializedCamera: any): void;
  6231. /**
  6232. * Parses an input manager serialized JSON to restore the previous list of inputs
  6233. * and states associated to a camera.
  6234. * @param parsedCamera Defines the JSON to parse
  6235. */
  6236. parse(parsedCamera: any): void;
  6237. }
  6238. }
  6239. declare module "babylonjs/Meshes/buffer" {
  6240. import { Nullable, DataArray } from "babylonjs/types";
  6241. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6242. /**
  6243. * Class used to store data that will be store in GPU memory
  6244. */
  6245. export class Buffer {
  6246. private _engine;
  6247. private _buffer;
  6248. /** @hidden */
  6249. _data: Nullable<DataArray>;
  6250. private _updatable;
  6251. private _instanced;
  6252. /**
  6253. * Gets the byte stride.
  6254. */
  6255. readonly byteStride: number;
  6256. /**
  6257. * Constructor
  6258. * @param engine the engine
  6259. * @param data the data to use for this buffer
  6260. * @param updatable whether the data is updatable
  6261. * @param stride the stride (optional)
  6262. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6263. * @param instanced whether the buffer is instanced (optional)
  6264. * @param useBytes set to true if the stride in in bytes (optional)
  6265. */
  6266. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6267. /**
  6268. * Create a new VertexBuffer based on the current buffer
  6269. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6270. * @param offset defines offset in the buffer (0 by default)
  6271. * @param size defines the size in floats of attributes (position is 3 for instance)
  6272. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6273. * @param instanced defines if the vertex buffer contains indexed data
  6274. * @param useBytes defines if the offset and stride are in bytes
  6275. * @returns the new vertex buffer
  6276. */
  6277. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6278. /**
  6279. * Gets a boolean indicating if the Buffer is updatable?
  6280. * @returns true if the buffer is updatable
  6281. */
  6282. isUpdatable(): boolean;
  6283. /**
  6284. * Gets current buffer's data
  6285. * @returns a DataArray or null
  6286. */
  6287. getData(): Nullable<DataArray>;
  6288. /**
  6289. * Gets underlying native buffer
  6290. * @returns underlying native buffer
  6291. */
  6292. getBuffer(): Nullable<DataBuffer>;
  6293. /**
  6294. * Gets the stride in float32 units (i.e. byte stride / 4).
  6295. * May not be an integer if the byte stride is not divisible by 4.
  6296. * DEPRECATED. Use byteStride instead.
  6297. * @returns the stride in float32 units
  6298. */
  6299. getStrideSize(): number;
  6300. /**
  6301. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6302. * @param data defines the data to store
  6303. */
  6304. create(data?: Nullable<DataArray>): void;
  6305. /** @hidden */
  6306. _rebuild(): void;
  6307. /**
  6308. * Update current buffer data
  6309. * @param data defines the data to store
  6310. */
  6311. update(data: DataArray): void;
  6312. /**
  6313. * Updates the data directly.
  6314. * @param data the new data
  6315. * @param offset the new offset
  6316. * @param vertexCount the vertex count (optional)
  6317. * @param useBytes set to true if the offset is in bytes
  6318. */
  6319. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6320. /**
  6321. * Release all resources
  6322. */
  6323. dispose(): void;
  6324. }
  6325. /**
  6326. * Specialized buffer used to store vertex data
  6327. */
  6328. export class VertexBuffer {
  6329. /** @hidden */
  6330. _buffer: Buffer;
  6331. private _kind;
  6332. private _size;
  6333. private _ownsBuffer;
  6334. private _instanced;
  6335. private _instanceDivisor;
  6336. /**
  6337. * The byte type.
  6338. */
  6339. static readonly BYTE: number;
  6340. /**
  6341. * The unsigned byte type.
  6342. */
  6343. static readonly UNSIGNED_BYTE: number;
  6344. /**
  6345. * The short type.
  6346. */
  6347. static readonly SHORT: number;
  6348. /**
  6349. * The unsigned short type.
  6350. */
  6351. static readonly UNSIGNED_SHORT: number;
  6352. /**
  6353. * The integer type.
  6354. */
  6355. static readonly INT: number;
  6356. /**
  6357. * The unsigned integer type.
  6358. */
  6359. static readonly UNSIGNED_INT: number;
  6360. /**
  6361. * The float type.
  6362. */
  6363. static readonly FLOAT: number;
  6364. /**
  6365. * Gets or sets the instance divisor when in instanced mode
  6366. */
  6367. instanceDivisor: number;
  6368. /**
  6369. * Gets the byte stride.
  6370. */
  6371. readonly byteStride: number;
  6372. /**
  6373. * Gets the byte offset.
  6374. */
  6375. readonly byteOffset: number;
  6376. /**
  6377. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6378. */
  6379. readonly normalized: boolean;
  6380. /**
  6381. * Gets the data type of each component in the array.
  6382. */
  6383. readonly type: number;
  6384. /**
  6385. * Constructor
  6386. * @param engine the engine
  6387. * @param data the data to use for this vertex buffer
  6388. * @param kind the vertex buffer kind
  6389. * @param updatable whether the data is updatable
  6390. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6391. * @param stride the stride (optional)
  6392. * @param instanced whether the buffer is instanced (optional)
  6393. * @param offset the offset of the data (optional)
  6394. * @param size the number of components (optional)
  6395. * @param type the type of the component (optional)
  6396. * @param normalized whether the data contains normalized data (optional)
  6397. * @param useBytes set to true if stride and offset are in bytes (optional)
  6398. */
  6399. 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);
  6400. /** @hidden */
  6401. _rebuild(): void;
  6402. /**
  6403. * Returns the kind of the VertexBuffer (string)
  6404. * @returns a string
  6405. */
  6406. getKind(): string;
  6407. /**
  6408. * Gets a boolean indicating if the VertexBuffer is updatable?
  6409. * @returns true if the buffer is updatable
  6410. */
  6411. isUpdatable(): boolean;
  6412. /**
  6413. * Gets current buffer's data
  6414. * @returns a DataArray or null
  6415. */
  6416. getData(): Nullable<DataArray>;
  6417. /**
  6418. * Gets underlying native buffer
  6419. * @returns underlying native buffer
  6420. */
  6421. getBuffer(): Nullable<DataBuffer>;
  6422. /**
  6423. * Gets the stride in float32 units (i.e. byte stride / 4).
  6424. * May not be an integer if the byte stride is not divisible by 4.
  6425. * DEPRECATED. Use byteStride instead.
  6426. * @returns the stride in float32 units
  6427. */
  6428. getStrideSize(): number;
  6429. /**
  6430. * Returns the offset as a multiple of the type byte length.
  6431. * DEPRECATED. Use byteOffset instead.
  6432. * @returns the offset in bytes
  6433. */
  6434. getOffset(): number;
  6435. /**
  6436. * Returns the number of components per vertex attribute (integer)
  6437. * @returns the size in float
  6438. */
  6439. getSize(): number;
  6440. /**
  6441. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6442. * @returns true if this buffer is instanced
  6443. */
  6444. getIsInstanced(): boolean;
  6445. /**
  6446. * Returns the instancing divisor, zero for non-instanced (integer).
  6447. * @returns a number
  6448. */
  6449. getInstanceDivisor(): number;
  6450. /**
  6451. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6452. * @param data defines the data to store
  6453. */
  6454. create(data?: DataArray): void;
  6455. /**
  6456. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6457. * This function will create a new buffer if the current one is not updatable
  6458. * @param data defines the data to store
  6459. */
  6460. update(data: DataArray): void;
  6461. /**
  6462. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6463. * Returns the directly updated WebGLBuffer.
  6464. * @param data the new data
  6465. * @param offset the new offset
  6466. * @param useBytes set to true if the offset is in bytes
  6467. */
  6468. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6469. /**
  6470. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6471. */
  6472. dispose(): void;
  6473. /**
  6474. * Enumerates each value of this vertex buffer as numbers.
  6475. * @param count the number of values to enumerate
  6476. * @param callback the callback function called for each value
  6477. */
  6478. forEach(count: number, callback: (value: number, index: number) => void): void;
  6479. /**
  6480. * Positions
  6481. */
  6482. static readonly PositionKind: string;
  6483. /**
  6484. * Normals
  6485. */
  6486. static readonly NormalKind: string;
  6487. /**
  6488. * Tangents
  6489. */
  6490. static readonly TangentKind: string;
  6491. /**
  6492. * Texture coordinates
  6493. */
  6494. static readonly UVKind: string;
  6495. /**
  6496. * Texture coordinates 2
  6497. */
  6498. static readonly UV2Kind: string;
  6499. /**
  6500. * Texture coordinates 3
  6501. */
  6502. static readonly UV3Kind: string;
  6503. /**
  6504. * Texture coordinates 4
  6505. */
  6506. static readonly UV4Kind: string;
  6507. /**
  6508. * Texture coordinates 5
  6509. */
  6510. static readonly UV5Kind: string;
  6511. /**
  6512. * Texture coordinates 6
  6513. */
  6514. static readonly UV6Kind: string;
  6515. /**
  6516. * Colors
  6517. */
  6518. static readonly ColorKind: string;
  6519. /**
  6520. * Matrix indices (for bones)
  6521. */
  6522. static readonly MatricesIndicesKind: string;
  6523. /**
  6524. * Matrix weights (for bones)
  6525. */
  6526. static readonly MatricesWeightsKind: string;
  6527. /**
  6528. * Additional matrix indices (for bones)
  6529. */
  6530. static readonly MatricesIndicesExtraKind: string;
  6531. /**
  6532. * Additional matrix weights (for bones)
  6533. */
  6534. static readonly MatricesWeightsExtraKind: string;
  6535. /**
  6536. * Deduces the stride given a kind.
  6537. * @param kind The kind string to deduce
  6538. * @returns The deduced stride
  6539. */
  6540. static DeduceStride(kind: string): number;
  6541. /**
  6542. * Gets the byte length of the given type.
  6543. * @param type the type
  6544. * @returns the number of bytes
  6545. */
  6546. static GetTypeByteLength(type: number): number;
  6547. /**
  6548. * Enumerates each value of the given parameters as numbers.
  6549. * @param data the data to enumerate
  6550. * @param byteOffset the byte offset of the data
  6551. * @param byteStride the byte stride of the data
  6552. * @param componentCount the number of components per element
  6553. * @param componentType the type of the component
  6554. * @param count the number of values to enumerate
  6555. * @param normalized whether the data is normalized
  6556. * @param callback the callback function called for each value
  6557. */
  6558. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6559. private static _GetFloatValue;
  6560. }
  6561. }
  6562. declare module "babylonjs/Collisions/intersectionInfo" {
  6563. import { Nullable } from "babylonjs/types";
  6564. /**
  6565. * @hidden
  6566. */
  6567. export class IntersectionInfo {
  6568. bu: Nullable<number>;
  6569. bv: Nullable<number>;
  6570. distance: number;
  6571. faceId: number;
  6572. subMeshId: number;
  6573. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6574. }
  6575. }
  6576. declare module "babylonjs/Maths/math.plane" {
  6577. import { DeepImmutable } from "babylonjs/types";
  6578. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6579. /**
  6580. * Represens a plane by the equation ax + by + cz + d = 0
  6581. */
  6582. export class Plane {
  6583. private static _TmpMatrix;
  6584. /**
  6585. * Normal of the plane (a,b,c)
  6586. */
  6587. normal: Vector3;
  6588. /**
  6589. * d component of the plane
  6590. */
  6591. d: number;
  6592. /**
  6593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6594. * @param a a component of the plane
  6595. * @param b b component of the plane
  6596. * @param c c component of the plane
  6597. * @param d d component of the plane
  6598. */
  6599. constructor(a: number, b: number, c: number, d: number);
  6600. /**
  6601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6602. */
  6603. asArray(): number[];
  6604. /**
  6605. * @returns a new plane copied from the current Plane.
  6606. */
  6607. clone(): Plane;
  6608. /**
  6609. * @returns the string "Plane".
  6610. */
  6611. getClassName(): string;
  6612. /**
  6613. * @returns the Plane hash code.
  6614. */
  6615. getHashCode(): number;
  6616. /**
  6617. * Normalize the current Plane in place.
  6618. * @returns the updated Plane.
  6619. */
  6620. normalize(): Plane;
  6621. /**
  6622. * Applies a transformation the plane and returns the result
  6623. * @param transformation the transformation matrix to be applied to the plane
  6624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6625. */
  6626. transform(transformation: DeepImmutable<Matrix>): Plane;
  6627. /**
  6628. * Calcualtte the dot product between the point and the plane normal
  6629. * @param point point to calculate the dot product with
  6630. * @returns the dot product (float) of the point coordinates and the plane normal.
  6631. */
  6632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6633. /**
  6634. * Updates the current Plane from the plane defined by the three given points.
  6635. * @param point1 one of the points used to contruct the plane
  6636. * @param point2 one of the points used to contruct the plane
  6637. * @param point3 one of the points used to contruct the plane
  6638. * @returns the updated Plane.
  6639. */
  6640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6641. /**
  6642. * Checks if the plane is facing a given direction
  6643. * @param direction the direction to check if the plane is facing
  6644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6645. * @returns True is the vector "direction" is the same side than the plane normal.
  6646. */
  6647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6648. /**
  6649. * Calculates the distance to a point
  6650. * @param point point to calculate distance to
  6651. * @returns the signed distance (float) from the given point to the Plane.
  6652. */
  6653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6654. /**
  6655. * Creates a plane from an array
  6656. * @param array the array to create a plane from
  6657. * @returns a new Plane from the given array.
  6658. */
  6659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6660. /**
  6661. * Creates a plane from three points
  6662. * @param point1 point used to create the plane
  6663. * @param point2 point used to create the plane
  6664. * @param point3 point used to create the plane
  6665. * @returns a new Plane defined by the three given points.
  6666. */
  6667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6668. /**
  6669. * Creates a plane from an origin point and a normal
  6670. * @param origin origin of the plane to be constructed
  6671. * @param normal normal of the plane to be constructed
  6672. * @returns a new Plane the normal vector to this plane at the given origin point.
  6673. * Note : the vector "normal" is updated because normalized.
  6674. */
  6675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6676. /**
  6677. * Calculates the distance from a plane and a point
  6678. * @param origin origin of the plane to be constructed
  6679. * @param normal normal of the plane to be constructed
  6680. * @param point point to calculate distance to
  6681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6682. */
  6683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6684. }
  6685. }
  6686. declare module "babylonjs/Culling/boundingSphere" {
  6687. import { DeepImmutable } from "babylonjs/types";
  6688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding sphere information
  6692. */
  6693. export class BoundingSphere {
  6694. /**
  6695. * Gets the center of the bounding sphere in local space
  6696. */
  6697. readonly center: Vector3;
  6698. /**
  6699. * Radius of the bounding sphere in local space
  6700. */
  6701. radius: number;
  6702. /**
  6703. * Gets the center of the bounding sphere in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Radius of the bounding sphere in world space
  6708. */
  6709. radiusWorld: number;
  6710. /**
  6711. * Gets the minimum vector in local space
  6712. */
  6713. readonly minimum: Vector3;
  6714. /**
  6715. * Gets the maximum vector in local space
  6716. */
  6717. readonly maximum: Vector3;
  6718. private _worldMatrix;
  6719. private static readonly TmpVector3;
  6720. /**
  6721. * Creates a new bounding sphere
  6722. * @param min defines the minimum vector (in local space)
  6723. * @param max defines the maximum vector (in local space)
  6724. * @param worldMatrix defines the new world matrix
  6725. */
  6726. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6727. /**
  6728. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6729. * @param min defines the new minimum vector (in local space)
  6730. * @param max defines the new maximum vector (in local space)
  6731. * @param worldMatrix defines the new world matrix
  6732. */
  6733. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6734. /**
  6735. * Scale the current bounding sphere by applying a scale factor
  6736. * @param factor defines the scale factor to apply
  6737. * @returns the current bounding box
  6738. */
  6739. scale(factor: number): BoundingSphere;
  6740. /**
  6741. * Gets the world matrix of the bounding box
  6742. * @returns a matrix
  6743. */
  6744. getWorldMatrix(): DeepImmutable<Matrix>;
  6745. /** @hidden */
  6746. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6747. /**
  6748. * Tests if the bounding sphere is intersecting the frustum planes
  6749. * @param frustumPlanes defines the frustum planes to test
  6750. * @returns true if there is an intersection
  6751. */
  6752. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6753. /**
  6754. * Tests if the bounding sphere center is in between the frustum planes.
  6755. * Used for optimistic fast inclusion.
  6756. * @param frustumPlanes defines the frustum planes to test
  6757. * @returns true if the sphere center is in between the frustum planes
  6758. */
  6759. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6760. /**
  6761. * Tests if a point is inside the bounding sphere
  6762. * @param point defines the point to test
  6763. * @returns true if the point is inside the bounding sphere
  6764. */
  6765. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6766. /**
  6767. * Checks if two sphere intersct
  6768. * @param sphere0 sphere 0
  6769. * @param sphere1 sphere 1
  6770. * @returns true if the speres intersect
  6771. */
  6772. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6773. }
  6774. }
  6775. declare module "babylonjs/Culling/boundingBox" {
  6776. import { DeepImmutable } from "babylonjs/types";
  6777. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6778. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6779. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6780. import { Plane } from "babylonjs/Maths/math.plane";
  6781. /**
  6782. * Class used to store bounding box information
  6783. */
  6784. export class BoundingBox implements ICullable {
  6785. /**
  6786. * Gets the 8 vectors representing the bounding box in local space
  6787. */
  6788. readonly vectors: Vector3[];
  6789. /**
  6790. * Gets the center of the bounding box in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Gets the center of the bounding box in world space
  6795. */
  6796. readonly centerWorld: Vector3;
  6797. /**
  6798. * Gets the extend size in local space
  6799. */
  6800. readonly extendSize: Vector3;
  6801. /**
  6802. * Gets the extend size in world space
  6803. */
  6804. readonly extendSizeWorld: Vector3;
  6805. /**
  6806. * Gets the OBB (object bounding box) directions
  6807. */
  6808. readonly directions: Vector3[];
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in world space
  6811. */
  6812. readonly vectorsWorld: Vector3[];
  6813. /**
  6814. * Gets the minimum vector in world space
  6815. */
  6816. readonly minimumWorld: Vector3;
  6817. /**
  6818. * Gets the maximum vector in world space
  6819. */
  6820. readonly maximumWorld: Vector3;
  6821. /**
  6822. * Gets the minimum vector in local space
  6823. */
  6824. readonly minimum: Vector3;
  6825. /**
  6826. * Gets the maximum vector in local space
  6827. */
  6828. readonly maximum: Vector3;
  6829. private _worldMatrix;
  6830. private static readonly TmpVector3;
  6831. /**
  6832. * @hidden
  6833. */
  6834. _tag: number;
  6835. /**
  6836. * Creates a new bounding box
  6837. * @param min defines the minimum vector (in local space)
  6838. * @param max defines the maximum vector (in local space)
  6839. * @param worldMatrix defines the new world matrix
  6840. */
  6841. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6842. /**
  6843. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6844. * @param min defines the new minimum vector (in local space)
  6845. * @param max defines the new maximum vector (in local space)
  6846. * @param worldMatrix defines the new world matrix
  6847. */
  6848. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6849. /**
  6850. * Scale the current bounding box by applying a scale factor
  6851. * @param factor defines the scale factor to apply
  6852. * @returns the current bounding box
  6853. */
  6854. scale(factor: number): BoundingBox;
  6855. /**
  6856. * Gets the world matrix of the bounding box
  6857. * @returns a matrix
  6858. */
  6859. getWorldMatrix(): DeepImmutable<Matrix>;
  6860. /** @hidden */
  6861. _update(world: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Tests if the bounding box is intersecting the frustum planes
  6864. * @param frustumPlanes defines the frustum planes to test
  6865. * @returns true if there is an intersection
  6866. */
  6867. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6868. /**
  6869. * Tests if the bounding box is entirely inside the frustum planes
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @returns true if there is an inclusion
  6872. */
  6873. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. /**
  6875. * Tests if a point is inside the bounding box
  6876. * @param point defines the point to test
  6877. * @returns true if the point is inside the bounding box
  6878. */
  6879. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6880. /**
  6881. * Tests if the bounding box intersects with a bounding sphere
  6882. * @param sphere defines the sphere to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6886. /**
  6887. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6888. * @param min defines the min vector to use
  6889. * @param max defines the max vector to use
  6890. * @returns true if there is an intersection
  6891. */
  6892. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Tests if two bounding boxes are intersections
  6895. * @param box0 defines the first box to test
  6896. * @param box1 defines the second box to test
  6897. * @returns true if there is an intersection
  6898. */
  6899. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6900. /**
  6901. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6902. * @param minPoint defines the minimum vector of the bounding box
  6903. * @param maxPoint defines the maximum vector of the bounding box
  6904. * @param sphereCenter defines the sphere center
  6905. * @param sphereRadius defines the sphere radius
  6906. * @returns true if there is an intersection
  6907. */
  6908. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6909. /**
  6910. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6911. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6912. * @param frustumPlanes defines the frustum planes to test
  6913. * @return true if there is an inclusion
  6914. */
  6915. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6916. /**
  6917. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6918. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6919. * @param frustumPlanes defines the frustum planes to test
  6920. * @return true if there is an intersection
  6921. */
  6922. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/collider" {
  6926. import { Nullable, IndicesArray } from "babylonjs/types";
  6927. import { Vector3 } from "babylonjs/Maths/math.vector";
  6928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6929. import { Plane } from "babylonjs/Maths/math.plane";
  6930. /** @hidden */
  6931. export class Collider {
  6932. /** Define if a collision was found */
  6933. collisionFound: boolean;
  6934. /**
  6935. * Define last intersection point in local space
  6936. */
  6937. intersectionPoint: Vector3;
  6938. /**
  6939. * Define last collided mesh
  6940. */
  6941. collidedMesh: Nullable<AbstractMesh>;
  6942. private _collisionPoint;
  6943. private _planeIntersectionPoint;
  6944. private _tempVector;
  6945. private _tempVector2;
  6946. private _tempVector3;
  6947. private _tempVector4;
  6948. private _edge;
  6949. private _baseToVertex;
  6950. private _destinationPoint;
  6951. private _slidePlaneNormal;
  6952. private _displacementVector;
  6953. /** @hidden */
  6954. _radius: Vector3;
  6955. /** @hidden */
  6956. _retry: number;
  6957. private _velocity;
  6958. private _basePoint;
  6959. private _epsilon;
  6960. /** @hidden */
  6961. _velocityWorldLength: number;
  6962. /** @hidden */
  6963. _basePointWorld: Vector3;
  6964. private _velocityWorld;
  6965. private _normalizedVelocity;
  6966. /** @hidden */
  6967. _initialVelocity: Vector3;
  6968. /** @hidden */
  6969. _initialPosition: Vector3;
  6970. private _nearestDistance;
  6971. private _collisionMask;
  6972. collisionMask: number;
  6973. /**
  6974. * Gets the plane normal used to compute the sliding response (in local space)
  6975. */
  6976. readonly slidePlaneNormal: Vector3;
  6977. /** @hidden */
  6978. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6979. /** @hidden */
  6980. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6981. /** @hidden */
  6982. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6983. /** @hidden */
  6984. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6987. /** @hidden */
  6988. _getResponse(pos: Vector3, vel: Vector3): void;
  6989. }
  6990. }
  6991. declare module "babylonjs/Culling/boundingInfo" {
  6992. import { DeepImmutable } from "babylonjs/types";
  6993. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6994. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6995. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6996. import { Plane } from "babylonjs/Maths/math.plane";
  6997. import { Collider } from "babylonjs/Collisions/collider";
  6998. /**
  6999. * Interface for cullable objects
  7000. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7001. */
  7002. export interface ICullable {
  7003. /**
  7004. * Checks if the object or part of the object is in the frustum
  7005. * @param frustumPlanes Camera near/planes
  7006. * @returns true if the object is in frustum otherwise false
  7007. */
  7008. isInFrustum(frustumPlanes: Plane[]): boolean;
  7009. /**
  7010. * Checks if a cullable object (mesh...) is in the camera frustum
  7011. * Unlike isInFrustum this cheks the full bounding box
  7012. * @param frustumPlanes Camera near/planes
  7013. * @returns true if the object is in frustum otherwise false
  7014. */
  7015. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7016. }
  7017. /**
  7018. * Info for a bounding data of a mesh
  7019. */
  7020. export class BoundingInfo implements ICullable {
  7021. /**
  7022. * Bounding box for the mesh
  7023. */
  7024. readonly boundingBox: BoundingBox;
  7025. /**
  7026. * Bounding sphere for the mesh
  7027. */
  7028. readonly boundingSphere: BoundingSphere;
  7029. private _isLocked;
  7030. private static readonly TmpVector3;
  7031. /**
  7032. * Constructs bounding info
  7033. * @param minimum min vector of the bounding box/sphere
  7034. * @param maximum max vector of the bounding box/sphere
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7038. /**
  7039. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7040. * @param min defines the new minimum vector (in local space)
  7041. * @param max defines the new maximum vector (in local space)
  7042. * @param worldMatrix defines the new world matrix
  7043. */
  7044. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7045. /**
  7046. * min vector of the bounding box/sphere
  7047. */
  7048. readonly minimum: Vector3;
  7049. /**
  7050. * max vector of the bounding box/sphere
  7051. */
  7052. readonly maximum: Vector3;
  7053. /**
  7054. * If the info is locked and won't be updated to avoid perf overhead
  7055. */
  7056. isLocked: boolean;
  7057. /**
  7058. * Updates the bounding sphere and box
  7059. * @param world world matrix to be used to update
  7060. */
  7061. update(world: DeepImmutable<Matrix>): void;
  7062. /**
  7063. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7064. * @param center New center of the bounding info
  7065. * @param extend New extend of the bounding info
  7066. * @returns the current bounding info
  7067. */
  7068. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7069. /**
  7070. * Scale the current bounding info by applying a scale factor
  7071. * @param factor defines the scale factor to apply
  7072. * @returns the current bounding info
  7073. */
  7074. scale(factor: number): BoundingInfo;
  7075. /**
  7076. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7077. * @param frustumPlanes defines the frustum to test
  7078. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7079. * @returns true if the bounding info is in the frustum planes
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7082. /**
  7083. * Gets the world distance between the min and max points of the bounding box
  7084. */
  7085. readonly diagonalLength: number;
  7086. /**
  7087. * Checks if a cullable object (mesh...) is in the camera frustum
  7088. * Unlike isInFrustum this cheks the full bounding box
  7089. * @param frustumPlanes Camera near/planes
  7090. * @returns true if the object is in frustum otherwise false
  7091. */
  7092. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7093. /** @hidden */
  7094. _checkCollision(collider: Collider): boolean;
  7095. /**
  7096. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7097. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7098. * @param point the point to check intersection with
  7099. * @returns if the point intersects
  7100. */
  7101. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7102. /**
  7103. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7104. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7105. * @param boundingInfo the bounding info to check intersection with
  7106. * @param precise if the intersection should be done using OBB
  7107. * @returns if the bounding info intersects
  7108. */
  7109. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7110. }
  7111. }
  7112. declare module "babylonjs/Maths/math.functions" {
  7113. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7114. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7115. /**
  7116. * Extracts minimum and maximum values from a list of indexed positions
  7117. * @param positions defines the positions to use
  7118. * @param indices defines the indices to the positions
  7119. * @param indexStart defines the start index
  7120. * @param indexCount defines the end index
  7121. * @param bias defines bias value to add to the result
  7122. * @return minimum and maximum values
  7123. */
  7124. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7125. minimum: Vector3;
  7126. maximum: Vector3;
  7127. };
  7128. /**
  7129. * Extracts minimum and maximum values from a list of positions
  7130. * @param positions defines the positions to use
  7131. * @param start defines the start index in the positions array
  7132. * @param count defines the number of positions to handle
  7133. * @param bias defines bias value to add to the result
  7134. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7135. * @return minimum and maximum values
  7136. */
  7137. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7138. minimum: Vector3;
  7139. maximum: Vector3;
  7140. };
  7141. }
  7142. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7143. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7144. /** @hidden */
  7145. export class WebGLDataBuffer extends DataBuffer {
  7146. private _buffer;
  7147. constructor(resource: WebGLBuffer);
  7148. readonly underlyingResource: any;
  7149. }
  7150. }
  7151. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7152. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7153. import { Nullable } from "babylonjs/types";
  7154. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7155. /** @hidden */
  7156. export class WebGLPipelineContext implements IPipelineContext {
  7157. engine: ThinEngine;
  7158. program: Nullable<WebGLProgram>;
  7159. context?: WebGLRenderingContext;
  7160. vertexShader?: WebGLShader;
  7161. fragmentShader?: WebGLShader;
  7162. isParallelCompiled: boolean;
  7163. onCompiled?: () => void;
  7164. transformFeedback?: WebGLTransformFeedback | null;
  7165. readonly isAsync: boolean;
  7166. readonly isReady: boolean;
  7167. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7168. }
  7169. }
  7170. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7171. import { FloatArray, Nullable } from "babylonjs/types";
  7172. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7173. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7174. module "babylonjs/Engines/thinEngine" {
  7175. interface ThinEngine {
  7176. /**
  7177. * Create an uniform buffer
  7178. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7179. * @param elements defines the content of the uniform buffer
  7180. * @returns the webGL uniform buffer
  7181. */
  7182. createUniformBuffer(elements: FloatArray): DataBuffer;
  7183. /**
  7184. * Create a dynamic uniform buffer
  7185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7186. * @param elements defines the content of the uniform buffer
  7187. * @returns the webGL uniform buffer
  7188. */
  7189. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7190. /**
  7191. * Update an existing uniform buffer
  7192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7193. * @param uniformBuffer defines the target uniform buffer
  7194. * @param elements defines the content to update
  7195. * @param offset defines the offset in the uniform buffer where update should start
  7196. * @param count defines the size of the data to update
  7197. */
  7198. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7199. /**
  7200. * Bind an uniform buffer to the current webGL context
  7201. * @param buffer defines the buffer to bind
  7202. */
  7203. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7204. /**
  7205. * Bind a buffer to the current webGL context at a given location
  7206. * @param buffer defines the buffer to bind
  7207. * @param location defines the index where to bind the buffer
  7208. */
  7209. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7210. /**
  7211. * Bind a specific block at a given index in a specific shader program
  7212. * @param pipelineContext defines the pipeline context to use
  7213. * @param blockName defines the block name
  7214. * @param index defines the index where to bind the block
  7215. */
  7216. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7217. }
  7218. }
  7219. }
  7220. declare module "babylonjs/Materials/uniformBuffer" {
  7221. import { Nullable, FloatArray } from "babylonjs/types";
  7222. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7223. import { Engine } from "babylonjs/Engines/engine";
  7224. import { Effect } from "babylonjs/Materials/effect";
  7225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7226. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7227. import { Color3 } from "babylonjs/Maths/math.color";
  7228. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7229. /**
  7230. * Uniform buffer objects.
  7231. *
  7232. * Handles blocks of uniform on the GPU.
  7233. *
  7234. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7235. *
  7236. * For more information, please refer to :
  7237. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7238. */
  7239. export class UniformBuffer {
  7240. private _engine;
  7241. private _buffer;
  7242. private _data;
  7243. private _bufferData;
  7244. private _dynamic?;
  7245. private _uniformLocations;
  7246. private _uniformSizes;
  7247. private _uniformLocationPointer;
  7248. private _needSync;
  7249. private _noUBO;
  7250. private _currentEffect;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. readonly useUbo: boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. readonly isSync: boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module "babylonjs/Misc/iInspectable" {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/timingTools" {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module "babylonjs/Misc/instantiationTools" {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7602. import { Nullable } from "babylonjs/types";
  7603. import { Scene } from "babylonjs/scene";
  7604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7605. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7606. module "babylonjs/Engines/thinEngine" {
  7607. interface ThinEngine {
  7608. /**
  7609. * Creates a depth stencil cube texture.
  7610. * This is only available in WebGL 2.
  7611. * @param size The size of face edge in the cube texture.
  7612. * @param options The options defining the cube texture.
  7613. * @returns The cube texture
  7614. */
  7615. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7616. /**
  7617. * Creates a cube texture
  7618. * @param rootUrl defines the url where the files to load is located
  7619. * @param scene defines the current scene
  7620. * @param files defines the list of files to load (1 per face)
  7621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7622. * @param onLoad defines an optional callback raised when the texture is loaded
  7623. * @param onError defines an optional callback raised if there is an issue to load the texture
  7624. * @param format defines the format of the data
  7625. * @param forcedExtension defines the extension to use to pick the right loader
  7626. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7630. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7631. * @returns the cube texture as an InternalTexture
  7632. */
  7633. 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;
  7634. /**
  7635. * Creates a cube texture
  7636. * @param rootUrl defines the url where the files to load is located
  7637. * @param scene defines the current scene
  7638. * @param files defines the list of files to load (1 per face)
  7639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7640. * @param onLoad defines an optional callback raised when the texture is loaded
  7641. * @param onError defines an optional callback raised if there is an issue to load the texture
  7642. * @param format defines the format of the data
  7643. * @param forcedExtension defines the extension to use to pick the right loader
  7644. * @returns the cube texture as an InternalTexture
  7645. */
  7646. 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;
  7647. /**
  7648. * Creates a cube texture
  7649. * @param rootUrl defines the url where the files to load is located
  7650. * @param scene defines the current scene
  7651. * @param files defines the list of files to load (1 per face)
  7652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7653. * @param onLoad defines an optional callback raised when the texture is loaded
  7654. * @param onError defines an optional callback raised if there is an issue to load the texture
  7655. * @param format defines the format of the data
  7656. * @param forcedExtension defines the extension to use to pick the right loader
  7657. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. 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;
  7663. /** @hidden */
  7664. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7665. /** @hidden */
  7666. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7671. }
  7672. }
  7673. }
  7674. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7675. import { Nullable } from "babylonjs/types";
  7676. import { Scene } from "babylonjs/scene";
  7677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7679. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * The url of the texture
  7687. */
  7688. url: string;
  7689. /**
  7690. * Gets or sets the center of the bounding box associated with the cube texture.
  7691. * It must define where the camera used to render the texture was set
  7692. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7693. */
  7694. boundingBoxPosition: Vector3;
  7695. private _boundingBoxSize;
  7696. /**
  7697. * Gets or sets the size of the bounding box associated with the cube texture
  7698. * When defined, the cubemap will switch to local mode
  7699. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7700. * @example https://www.babylonjs-playground.com/#RNASML
  7701. */
  7702. /**
  7703. * Returns the bounding box size
  7704. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7705. */
  7706. boundingBoxSize: Vector3;
  7707. protected _rotationY: number;
  7708. /**
  7709. * Sets texture matrix rotation angle around Y axis in radians.
  7710. */
  7711. /**
  7712. * Gets texture matrix rotation angle around Y axis radians.
  7713. */
  7714. rotationY: number;
  7715. /**
  7716. * Are mip maps generated for this texture or not.
  7717. */
  7718. readonly noMipmap: boolean;
  7719. private _noMipmap;
  7720. private _files;
  7721. private _extensions;
  7722. private _textureMatrix;
  7723. private _format;
  7724. private _createPolynomials;
  7725. /** @hidden */
  7726. _prefiltered: boolean;
  7727. /**
  7728. * Creates a cube texture from an array of image urls
  7729. * @param files defines an array of image urls
  7730. * @param scene defines the hosting scene
  7731. * @param noMipmap specifies if mip maps are not used
  7732. * @returns a cube texture
  7733. */
  7734. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7735. /**
  7736. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7737. * @param url defines the url of the prefiltered texture
  7738. * @param scene defines the scene the texture is attached to
  7739. * @param forcedExtension defines the extension of the file if different from the url
  7740. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7741. * @return the prefiltered texture
  7742. */
  7743. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7744. /**
  7745. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7746. * as prefiltered data.
  7747. * @param rootUrl defines the url of the texture or the root name of the six images
  7748. * @param scene defines the scene the texture is attached to
  7749. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7750. * @param noMipmap defines if mipmaps should be created or not
  7751. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7752. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7753. * @param onError defines a callback triggered in case of error during load
  7754. * @param format defines the internal format to use for the texture once loaded
  7755. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7756. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7757. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7758. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7759. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7760. * @return the cube texture
  7761. */
  7762. 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);
  7763. /**
  7764. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7765. */
  7766. readonly isPrefiltered: boolean;
  7767. /**
  7768. * Get the current class name of the texture useful for serialization or dynamic coding.
  7769. * @returns "CubeTexture"
  7770. */
  7771. getClassName(): string;
  7772. /**
  7773. * Update the url (and optional buffer) of this texture if url was null during construction.
  7774. * @param url the url of the texture
  7775. * @param forcedExtension defines the extension to use
  7776. * @param onLoad callback called when the texture is loaded (defaults to null)
  7777. */
  7778. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7779. /**
  7780. * Delays loading of the cube texture
  7781. * @param forcedExtension defines the extension to use
  7782. */
  7783. delayLoad(forcedExtension?: string): void;
  7784. /**
  7785. * Returns the reflection texture matrix
  7786. * @returns the reflection texture matrix
  7787. */
  7788. getReflectionTextureMatrix(): Matrix;
  7789. /**
  7790. * Sets the reflection texture matrix
  7791. * @param value Reflection texture matrix
  7792. */
  7793. setReflectionTextureMatrix(value: Matrix): void;
  7794. /**
  7795. * Parses text to create a cube texture
  7796. * @param parsedTexture define the serialized text to read from
  7797. * @param scene defines the hosting scene
  7798. * @param rootUrl defines the root url of the cube texture
  7799. * @returns a cube texture
  7800. */
  7801. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7802. /**
  7803. * Makes a clone, or deep copy, of the cube texture
  7804. * @returns a new cube texture
  7805. */
  7806. clone(): CubeTexture;
  7807. }
  7808. }
  7809. declare module "babylonjs/Materials/materialDefines" {
  7810. /**
  7811. * Manages the defines for the Material
  7812. */
  7813. export class MaterialDefines {
  7814. /** @hidden */
  7815. protected _keys: string[];
  7816. private _isDirty;
  7817. /** @hidden */
  7818. _renderId: number;
  7819. /** @hidden */
  7820. _areLightsDirty: boolean;
  7821. /** @hidden */
  7822. _areLightsDisposed: boolean;
  7823. /** @hidden */
  7824. _areAttributesDirty: boolean;
  7825. /** @hidden */
  7826. _areTexturesDirty: boolean;
  7827. /** @hidden */
  7828. _areFresnelDirty: boolean;
  7829. /** @hidden */
  7830. _areMiscDirty: boolean;
  7831. /** @hidden */
  7832. _areImageProcessingDirty: boolean;
  7833. /** @hidden */
  7834. _normals: boolean;
  7835. /** @hidden */
  7836. _uvs: boolean;
  7837. /** @hidden */
  7838. _needNormals: boolean;
  7839. /** @hidden */
  7840. _needUVs: boolean;
  7841. [id: string]: any;
  7842. /**
  7843. * Specifies if the material needs to be re-calculated
  7844. */
  7845. readonly isDirty: boolean;
  7846. /**
  7847. * Marks the material to indicate that it has been re-calculated
  7848. */
  7849. markAsProcessed(): void;
  7850. /**
  7851. * Marks the material to indicate that it needs to be re-calculated
  7852. */
  7853. markAsUnprocessed(): void;
  7854. /**
  7855. * Marks the material to indicate all of its defines need to be re-calculated
  7856. */
  7857. markAllAsDirty(): void;
  7858. /**
  7859. * Marks the material to indicate that image processing needs to be re-calculated
  7860. */
  7861. markAsImageProcessingDirty(): void;
  7862. /**
  7863. * Marks the material to indicate the lights need to be re-calculated
  7864. * @param disposed Defines whether the light is dirty due to dispose or not
  7865. */
  7866. markAsLightDirty(disposed?: boolean): void;
  7867. /**
  7868. * Marks the attribute state as changed
  7869. */
  7870. markAsAttributesDirty(): void;
  7871. /**
  7872. * Marks the texture state as changed
  7873. */
  7874. markAsTexturesDirty(): void;
  7875. /**
  7876. * Marks the fresnel state as changed
  7877. */
  7878. markAsFresnelDirty(): void;
  7879. /**
  7880. * Marks the misc state as changed
  7881. */
  7882. markAsMiscDirty(): void;
  7883. /**
  7884. * Rebuilds the material defines
  7885. */
  7886. rebuild(): void;
  7887. /**
  7888. * Specifies if two material defines are equal
  7889. * @param other - A material define instance to compare to
  7890. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7891. */
  7892. isEqual(other: MaterialDefines): boolean;
  7893. /**
  7894. * Clones this instance's defines to another instance
  7895. * @param other - material defines to clone values to
  7896. */
  7897. cloneTo(other: MaterialDefines): void;
  7898. /**
  7899. * Resets the material define values
  7900. */
  7901. reset(): void;
  7902. /**
  7903. * Converts the material define values to a string
  7904. * @returns - String of material define information
  7905. */
  7906. toString(): string;
  7907. }
  7908. }
  7909. declare module "babylonjs/Materials/colorCurves" {
  7910. import { Effect } from "babylonjs/Materials/effect";
  7911. /**
  7912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7914. * 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;
  7915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7916. */
  7917. export class ColorCurves {
  7918. private _dirty;
  7919. private _tempColor;
  7920. private _globalCurve;
  7921. private _highlightsCurve;
  7922. private _midtonesCurve;
  7923. private _shadowsCurve;
  7924. private _positiveCurve;
  7925. private _negativeCurve;
  7926. private _globalHue;
  7927. private _globalDensity;
  7928. private _globalSaturation;
  7929. private _globalExposure;
  7930. /**
  7931. * Gets the global 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 global 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. globalHue: number;
  7939. /**
  7940. * Gets the global 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 global 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. globalDensity: number;
  7950. /**
  7951. * Gets the global 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 global 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. globalSaturation: number;
  7959. /**
  7960. * Gets the global 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 global 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. globalExposure: number;
  7968. private _highlightsHue;
  7969. private _highlightsDensity;
  7970. private _highlightsSaturation;
  7971. private _highlightsExposure;
  7972. /**
  7973. * Gets the highlights Hue value.
  7974. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7975. */
  7976. /**
  7977. * Sets the highlights Hue value.
  7978. * 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).
  7979. */
  7980. highlightsHue: number;
  7981. /**
  7982. * Gets the highlights Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. /**
  7987. * Sets the highlights Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. highlightsDensity: number;
  7992. /**
  7993. * Gets the highlights Saturation value.
  7994. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7995. */
  7996. /**
  7997. * Sets the highlights Saturation value.
  7998. * 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.
  7999. */
  8000. highlightsSaturation: number;
  8001. /**
  8002. * Gets the highlights Exposure value.
  8003. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8004. */
  8005. /**
  8006. * Sets the highlights Exposure value.
  8007. * 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.
  8008. */
  8009. highlightsExposure: number;
  8010. private _midtonesHue;
  8011. private _midtonesDensity;
  8012. private _midtonesSaturation;
  8013. private _midtonesExposure;
  8014. /**
  8015. * Gets the midtones Hue value.
  8016. * 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).
  8017. */
  8018. /**
  8019. * Sets the midtones Hue value.
  8020. * 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).
  8021. */
  8022. midtonesHue: number;
  8023. /**
  8024. * Gets the midtones Density value.
  8025. * 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.
  8026. * Values less than zero provide a filter of opposite hue.
  8027. */
  8028. /**
  8029. * Sets the midtones Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. midtonesDensity: number;
  8034. /**
  8035. * Gets the midtones Saturation value.
  8036. * 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.
  8037. */
  8038. /**
  8039. * Sets the midtones Saturation value.
  8040. * 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.
  8041. */
  8042. midtonesSaturation: number;
  8043. /**
  8044. * Gets the midtones Exposure value.
  8045. * 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.
  8046. */
  8047. /**
  8048. * Sets the midtones Exposure value.
  8049. * 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.
  8050. */
  8051. midtonesExposure: number;
  8052. private _shadowsHue;
  8053. private _shadowsDensity;
  8054. private _shadowsSaturation;
  8055. private _shadowsExposure;
  8056. /**
  8057. * Gets the shadows Hue value.
  8058. * 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).
  8059. */
  8060. /**
  8061. * Sets the shadows Hue value.
  8062. * 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).
  8063. */
  8064. shadowsHue: number;
  8065. /**
  8066. * Gets the shadows Density value.
  8067. * 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.
  8068. * Values less than zero provide a filter of opposite hue.
  8069. */
  8070. /**
  8071. * Sets the shadows Density value.
  8072. * 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.
  8073. * Values less than zero provide a filter of opposite hue.
  8074. */
  8075. shadowsDensity: number;
  8076. /**
  8077. * Gets the shadows Saturation value.
  8078. * 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.
  8079. */
  8080. /**
  8081. * Sets the shadows Saturation value.
  8082. * 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.
  8083. */
  8084. shadowsSaturation: number;
  8085. /**
  8086. * Gets the shadows Exposure value.
  8087. * 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.
  8088. */
  8089. /**
  8090. * Sets the shadows Exposure value.
  8091. * 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.
  8092. */
  8093. shadowsExposure: number;
  8094. /**
  8095. * Returns the class name
  8096. * @returns The class name
  8097. */
  8098. getClassName(): string;
  8099. /**
  8100. * Binds the color curves to the shader.
  8101. * @param colorCurves The color curve to bind
  8102. * @param effect The effect to bind to
  8103. * @param positiveUniform The positive uniform shader parameter
  8104. * @param neutralUniform The neutral uniform shader parameter
  8105. * @param negativeUniform The negative uniform shader parameter
  8106. */
  8107. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8108. /**
  8109. * Prepare the list of uniforms associated with the ColorCurves effects.
  8110. * @param uniformsList The list of uniforms used in the effect
  8111. */
  8112. static PrepareUniforms(uniformsList: string[]): void;
  8113. /**
  8114. * Returns color grading data based on a hue, density, saturation and exposure value.
  8115. * @param filterHue The hue of the color filter.
  8116. * @param filterDensity The density of the color filter.
  8117. * @param saturation The saturation.
  8118. * @param exposure The exposure.
  8119. * @param result The result data container.
  8120. */
  8121. private getColorGradingDataToRef;
  8122. /**
  8123. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8124. * @param value The input slider value in range [-100,100].
  8125. * @returns Adjusted value.
  8126. */
  8127. private static applyColorGradingSliderNonlinear;
  8128. /**
  8129. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8130. * @param hue The hue (H) input.
  8131. * @param saturation The saturation (S) input.
  8132. * @param brightness The brightness (B) input.
  8133. * @result An RGBA color represented as Vector4.
  8134. */
  8135. private static fromHSBToRef;
  8136. /**
  8137. * Returns a value clamped between min and max
  8138. * @param value The value to clamp
  8139. * @param min The minimum of value
  8140. * @param max The maximum of value
  8141. * @returns The clamped value.
  8142. */
  8143. private static clamp;
  8144. /**
  8145. * Clones the current color curve instance.
  8146. * @return The cloned curves
  8147. */
  8148. clone(): ColorCurves;
  8149. /**
  8150. * Serializes the current color curve instance to a json representation.
  8151. * @return a JSON representation
  8152. */
  8153. serialize(): any;
  8154. /**
  8155. * Parses the color curve from a json representation.
  8156. * @param source the JSON source to parse
  8157. * @return The parsed curves
  8158. */
  8159. static Parse(source: any): ColorCurves;
  8160. }
  8161. }
  8162. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8163. import { Observable } from "babylonjs/Misc/observable";
  8164. import { Nullable } from "babylonjs/types";
  8165. import { Color4 } from "babylonjs/Maths/math.color";
  8166. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8167. import { Effect } from "babylonjs/Materials/effect";
  8168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8169. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8170. /**
  8171. * Interface to follow in your material defines to integrate easily the
  8172. * Image proccessing functions.
  8173. * @hidden
  8174. */
  8175. export interface IImageProcessingConfigurationDefines {
  8176. IMAGEPROCESSING: boolean;
  8177. VIGNETTE: boolean;
  8178. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8179. VIGNETTEBLENDMODEOPAQUE: boolean;
  8180. TONEMAPPING: boolean;
  8181. TONEMAPPING_ACES: boolean;
  8182. CONTRAST: boolean;
  8183. EXPOSURE: boolean;
  8184. COLORCURVES: boolean;
  8185. COLORGRADING: boolean;
  8186. COLORGRADING3D: boolean;
  8187. SAMPLER3DGREENDEPTH: boolean;
  8188. SAMPLER3DBGRMAP: boolean;
  8189. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8190. }
  8191. /**
  8192. * @hidden
  8193. */
  8194. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8195. IMAGEPROCESSING: boolean;
  8196. VIGNETTE: boolean;
  8197. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8198. VIGNETTEBLENDMODEOPAQUE: boolean;
  8199. TONEMAPPING: boolean;
  8200. TONEMAPPING_ACES: boolean;
  8201. CONTRAST: boolean;
  8202. COLORCURVES: boolean;
  8203. COLORGRADING: boolean;
  8204. COLORGRADING3D: boolean;
  8205. SAMPLER3DGREENDEPTH: boolean;
  8206. SAMPLER3DBGRMAP: boolean;
  8207. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8208. EXPOSURE: boolean;
  8209. constructor();
  8210. }
  8211. /**
  8212. * This groups together the common properties used for image processing either in direct forward pass
  8213. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8214. * or not.
  8215. */
  8216. export class ImageProcessingConfiguration {
  8217. /**
  8218. * Default tone mapping applied in BabylonJS.
  8219. */
  8220. static readonly TONEMAPPING_STANDARD: number;
  8221. /**
  8222. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8223. * to other engines rendering to increase portability.
  8224. */
  8225. static readonly TONEMAPPING_ACES: number;
  8226. /**
  8227. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8228. */
  8229. colorCurves: Nullable<ColorCurves>;
  8230. private _colorCurvesEnabled;
  8231. /**
  8232. * Gets wether the color curves effect is enabled.
  8233. */
  8234. /**
  8235. * Sets wether the color curves effect is enabled.
  8236. */
  8237. colorCurvesEnabled: boolean;
  8238. private _colorGradingTexture;
  8239. /**
  8240. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8241. */
  8242. /**
  8243. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8244. */
  8245. colorGradingTexture: Nullable<BaseTexture>;
  8246. private _colorGradingEnabled;
  8247. /**
  8248. * Gets wether the color grading effect is enabled.
  8249. */
  8250. /**
  8251. * Sets wether the color grading effect is enabled.
  8252. */
  8253. colorGradingEnabled: boolean;
  8254. private _colorGradingWithGreenDepth;
  8255. /**
  8256. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8257. */
  8258. /**
  8259. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8260. */
  8261. colorGradingWithGreenDepth: boolean;
  8262. private _colorGradingBGR;
  8263. /**
  8264. * Gets wether the color grading texture contains BGR values.
  8265. */
  8266. /**
  8267. * Sets wether the color grading texture contains BGR values.
  8268. */
  8269. colorGradingBGR: boolean;
  8270. /** @hidden */
  8271. _exposure: number;
  8272. /**
  8273. * Gets the Exposure used in the effect.
  8274. */
  8275. /**
  8276. * Sets the Exposure used in the effect.
  8277. */
  8278. exposure: number;
  8279. private _toneMappingEnabled;
  8280. /**
  8281. * Gets wether the tone mapping effect is enabled.
  8282. */
  8283. /**
  8284. * Sets wether the tone mapping effect is enabled.
  8285. */
  8286. toneMappingEnabled: boolean;
  8287. private _toneMappingType;
  8288. /**
  8289. * Gets the type of tone mapping effect.
  8290. */
  8291. /**
  8292. * Sets the type of tone mapping effect used in BabylonJS.
  8293. */
  8294. toneMappingType: number;
  8295. protected _contrast: number;
  8296. /**
  8297. * Gets the contrast used in the effect.
  8298. */
  8299. /**
  8300. * Sets the contrast used in the effect.
  8301. */
  8302. contrast: number;
  8303. /**
  8304. * Vignette stretch size.
  8305. */
  8306. vignetteStretch: number;
  8307. /**
  8308. * Vignette centre X Offset.
  8309. */
  8310. vignetteCentreX: number;
  8311. /**
  8312. * Vignette centre Y Offset.
  8313. */
  8314. vignetteCentreY: number;
  8315. /**
  8316. * Vignette weight or intensity of the vignette effect.
  8317. */
  8318. vignetteWeight: number;
  8319. /**
  8320. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8321. * if vignetteEnabled is set to true.
  8322. */
  8323. vignetteColor: Color4;
  8324. /**
  8325. * Camera field of view used by the Vignette effect.
  8326. */
  8327. vignetteCameraFov: number;
  8328. private _vignetteBlendMode;
  8329. /**
  8330. * Gets the vignette blend mode allowing different kind of effect.
  8331. */
  8332. /**
  8333. * Sets the vignette blend mode allowing different kind of effect.
  8334. */
  8335. vignetteBlendMode: number;
  8336. private _vignetteEnabled;
  8337. /**
  8338. * Gets wether the vignette effect is enabled.
  8339. */
  8340. /**
  8341. * Sets wether the vignette effect is enabled.
  8342. */
  8343. vignetteEnabled: boolean;
  8344. private _applyByPostProcess;
  8345. /**
  8346. * Gets wether the image processing is applied through a post process or not.
  8347. */
  8348. /**
  8349. * Sets wether the image processing is applied through a post process or not.
  8350. */
  8351. applyByPostProcess: boolean;
  8352. private _isEnabled;
  8353. /**
  8354. * Gets wether the image processing is enabled or not.
  8355. */
  8356. /**
  8357. * Sets wether the image processing is enabled or not.
  8358. */
  8359. isEnabled: boolean;
  8360. /**
  8361. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8362. */
  8363. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8364. /**
  8365. * Method called each time the image processing information changes requires to recompile the effect.
  8366. */
  8367. protected _updateParameters(): void;
  8368. /**
  8369. * Gets the current class name.
  8370. * @return "ImageProcessingConfiguration"
  8371. */
  8372. getClassName(): string;
  8373. /**
  8374. * Prepare the list of uniforms associated with the Image Processing effects.
  8375. * @param uniforms The list of uniforms used in the effect
  8376. * @param defines the list of defines currently in use
  8377. */
  8378. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8379. /**
  8380. * Prepare the list of samplers associated with the Image Processing effects.
  8381. * @param samplersList The list of uniforms used in the effect
  8382. * @param defines the list of defines currently in use
  8383. */
  8384. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8385. /**
  8386. * Prepare the list of defines associated to the shader.
  8387. * @param defines the list of defines to complete
  8388. * @param forPostProcess Define if we are currently in post process mode or not
  8389. */
  8390. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8391. /**
  8392. * Returns true if all the image processing information are ready.
  8393. * @returns True if ready, otherwise, false
  8394. */
  8395. isReady(): boolean;
  8396. /**
  8397. * Binds the image processing to the shader.
  8398. * @param effect The effect to bind to
  8399. * @param aspectRatio Define the current aspect ratio of the effect
  8400. */
  8401. bind(effect: Effect, aspectRatio?: number): void;
  8402. /**
  8403. * Clones the current image processing instance.
  8404. * @return The cloned image processing
  8405. */
  8406. clone(): ImageProcessingConfiguration;
  8407. /**
  8408. * Serializes the current image processing instance to a json representation.
  8409. * @return a JSON representation
  8410. */
  8411. serialize(): any;
  8412. /**
  8413. * Parses the image processing from a json representation.
  8414. * @param source the JSON source to parse
  8415. * @return The parsed image processing
  8416. */
  8417. static Parse(source: any): ImageProcessingConfiguration;
  8418. private static _VIGNETTEMODE_MULTIPLY;
  8419. private static _VIGNETTEMODE_OPAQUE;
  8420. /**
  8421. * Used to apply the vignette as a mix with the pixel color.
  8422. */
  8423. static readonly VIGNETTEMODE_MULTIPLY: number;
  8424. /**
  8425. * Used to apply the vignette as a replacement of the pixel color.
  8426. */
  8427. static readonly VIGNETTEMODE_OPAQUE: number;
  8428. }
  8429. }
  8430. declare module "babylonjs/Shaders/postprocess.vertex" {
  8431. /** @hidden */
  8432. export var postprocessVertexShader: {
  8433. name: string;
  8434. shader: string;
  8435. };
  8436. }
  8437. declare module "babylonjs/Maths/math.axis" {
  8438. import { Vector3 } from "babylonjs/Maths/math.vector";
  8439. /** Defines supported spaces */
  8440. export enum Space {
  8441. /** Local (object) space */
  8442. LOCAL = 0,
  8443. /** World space */
  8444. WORLD = 1,
  8445. /** Bone space */
  8446. BONE = 2
  8447. }
  8448. /** Defines the 3 main axes */
  8449. export class Axis {
  8450. /** X axis */
  8451. static X: Vector3;
  8452. /** Y axis */
  8453. static Y: Vector3;
  8454. /** Z axis */
  8455. static Z: Vector3;
  8456. }
  8457. }
  8458. declare module "babylonjs/Cameras/targetCamera" {
  8459. import { Nullable } from "babylonjs/types";
  8460. import { Camera } from "babylonjs/Cameras/camera";
  8461. import { Scene } from "babylonjs/scene";
  8462. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8463. /**
  8464. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8465. * This is the base of the follow, arc rotate cameras and Free camera
  8466. * @see http://doc.babylonjs.com/features/cameras
  8467. */
  8468. export class TargetCamera extends Camera {
  8469. private static _RigCamTransformMatrix;
  8470. private static _TargetTransformMatrix;
  8471. private static _TargetFocalPoint;
  8472. /**
  8473. * Define the current direction the camera is moving to
  8474. */
  8475. cameraDirection: Vector3;
  8476. /**
  8477. * Define the current rotation the camera is rotating to
  8478. */
  8479. cameraRotation: Vector2;
  8480. /**
  8481. * When set, the up vector of the camera will be updated by the rotation of the camera
  8482. */
  8483. updateUpVectorFromRotation: boolean;
  8484. private _tmpQuaternion;
  8485. /**
  8486. * Define the current rotation of the camera
  8487. */
  8488. rotation: Vector3;
  8489. /**
  8490. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8491. */
  8492. rotationQuaternion: Quaternion;
  8493. /**
  8494. * Define the current speed of the camera
  8495. */
  8496. speed: number;
  8497. /**
  8498. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8499. * around all axis.
  8500. */
  8501. noRotationConstraint: boolean;
  8502. /**
  8503. * Define the current target of the camera as an object or a position.
  8504. */
  8505. lockedTarget: any;
  8506. /** @hidden */
  8507. _currentTarget: Vector3;
  8508. /** @hidden */
  8509. _initialFocalDistance: number;
  8510. /** @hidden */
  8511. _viewMatrix: Matrix;
  8512. /** @hidden */
  8513. _camMatrix: Matrix;
  8514. /** @hidden */
  8515. _cameraTransformMatrix: Matrix;
  8516. /** @hidden */
  8517. _cameraRotationMatrix: Matrix;
  8518. /** @hidden */
  8519. _referencePoint: Vector3;
  8520. /** @hidden */
  8521. _transformedReferencePoint: Vector3;
  8522. protected _globalCurrentTarget: Vector3;
  8523. protected _globalCurrentUpVector: Vector3;
  8524. /** @hidden */
  8525. _reset: () => void;
  8526. private _defaultUp;
  8527. /**
  8528. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8529. * This is the base of the follow, arc rotate cameras and Free camera
  8530. * @see http://doc.babylonjs.com/features/cameras
  8531. * @param name Defines the name of the camera in the scene
  8532. * @param position Defines the start position of the camera in the scene
  8533. * @param scene Defines the scene the camera belongs to
  8534. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8535. */
  8536. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8537. /**
  8538. * Gets the position in front of the camera at a given distance.
  8539. * @param distance The distance from the camera we want the position to be
  8540. * @returns the position
  8541. */
  8542. getFrontPosition(distance: number): Vector3;
  8543. /** @hidden */
  8544. _getLockedTargetPosition(): Nullable<Vector3>;
  8545. private _storedPosition;
  8546. private _storedRotation;
  8547. private _storedRotationQuaternion;
  8548. /**
  8549. * Store current camera state of the camera (fov, position, rotation, etc..)
  8550. * @returns the camera
  8551. */
  8552. storeState(): Camera;
  8553. /**
  8554. * Restored camera state. You must call storeState() first
  8555. * @returns whether it was successful or not
  8556. * @hidden
  8557. */
  8558. _restoreStateValues(): boolean;
  8559. /** @hidden */
  8560. _initCache(): void;
  8561. /** @hidden */
  8562. _updateCache(ignoreParentClass?: boolean): void;
  8563. /** @hidden */
  8564. _isSynchronizedViewMatrix(): boolean;
  8565. /** @hidden */
  8566. _computeLocalCameraSpeed(): number;
  8567. /**
  8568. * Defines the target the camera should look at.
  8569. * @param target Defines the new target as a Vector or a mesh
  8570. */
  8571. setTarget(target: Vector3): void;
  8572. /**
  8573. * Return the current target position of the camera. This value is expressed in local space.
  8574. * @returns the target position
  8575. */
  8576. getTarget(): Vector3;
  8577. /** @hidden */
  8578. _decideIfNeedsToMove(): boolean;
  8579. /** @hidden */
  8580. _updatePosition(): void;
  8581. /** @hidden */
  8582. _checkInputs(): void;
  8583. protected _updateCameraRotationMatrix(): void;
  8584. /**
  8585. * 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)
  8586. * @returns the current camera
  8587. */
  8588. private _rotateUpVectorWithCameraRotationMatrix;
  8589. private _cachedRotationZ;
  8590. private _cachedQuaternionRotationZ;
  8591. /** @hidden */
  8592. _getViewMatrix(): Matrix;
  8593. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8594. /**
  8595. * @hidden
  8596. */
  8597. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8598. /**
  8599. * @hidden
  8600. */
  8601. _updateRigCameras(): void;
  8602. private _getRigCamPositionAndTarget;
  8603. /**
  8604. * Gets the current object class name.
  8605. * @return the class name
  8606. */
  8607. getClassName(): string;
  8608. }
  8609. }
  8610. declare module "babylonjs/Events/keyboardEvents" {
  8611. /**
  8612. * Gather the list of keyboard event types as constants.
  8613. */
  8614. export class KeyboardEventTypes {
  8615. /**
  8616. * The keydown event is fired when a key becomes active (pressed).
  8617. */
  8618. static readonly KEYDOWN: number;
  8619. /**
  8620. * The keyup event is fired when a key has been released.
  8621. */
  8622. static readonly KEYUP: number;
  8623. }
  8624. /**
  8625. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8626. */
  8627. export class KeyboardInfo {
  8628. /**
  8629. * Defines the type of event (KeyboardEventTypes)
  8630. */
  8631. type: number;
  8632. /**
  8633. * Defines the related dom event
  8634. */
  8635. event: KeyboardEvent;
  8636. /**
  8637. * Instantiates a new keyboard info.
  8638. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8639. * @param type Defines the type of event (KeyboardEventTypes)
  8640. * @param event Defines the related dom event
  8641. */
  8642. constructor(
  8643. /**
  8644. * Defines the type of event (KeyboardEventTypes)
  8645. */
  8646. type: number,
  8647. /**
  8648. * Defines the related dom event
  8649. */
  8650. event: KeyboardEvent);
  8651. }
  8652. /**
  8653. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8654. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8655. */
  8656. export class KeyboardInfoPre extends KeyboardInfo {
  8657. /**
  8658. * Defines the type of event (KeyboardEventTypes)
  8659. */
  8660. type: number;
  8661. /**
  8662. * Defines the related dom event
  8663. */
  8664. event: KeyboardEvent;
  8665. /**
  8666. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8667. */
  8668. skipOnPointerObservable: boolean;
  8669. /**
  8670. * Instantiates a new keyboard pre info.
  8671. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8672. * @param type Defines the type of event (KeyboardEventTypes)
  8673. * @param event Defines the related dom event
  8674. */
  8675. constructor(
  8676. /**
  8677. * Defines the type of event (KeyboardEventTypes)
  8678. */
  8679. type: number,
  8680. /**
  8681. * Defines the related dom event
  8682. */
  8683. event: KeyboardEvent);
  8684. }
  8685. }
  8686. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8687. import { Nullable } from "babylonjs/types";
  8688. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8689. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8690. /**
  8691. * Manage the keyboard inputs to control the movement of a free camera.
  8692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8693. */
  8694. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8695. /**
  8696. * Defines the camera the input is attached to.
  8697. */
  8698. camera: FreeCamera;
  8699. /**
  8700. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8701. */
  8702. keysUp: number[];
  8703. /**
  8704. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8705. */
  8706. keysDown: number[];
  8707. /**
  8708. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8709. */
  8710. keysLeft: number[];
  8711. /**
  8712. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8713. */
  8714. keysRight: number[];
  8715. private _keys;
  8716. private _onCanvasBlurObserver;
  8717. private _onKeyboardObserver;
  8718. private _engine;
  8719. private _scene;
  8720. /**
  8721. * Attach the input controls to a specific dom element to get the input from.
  8722. * @param element Defines the element the controls should be listened from
  8723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8724. */
  8725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8726. /**
  8727. * Detach the current controls from the specified dom element.
  8728. * @param element Defines the element to stop listening the inputs from
  8729. */
  8730. detachControl(element: Nullable<HTMLElement>): void;
  8731. /**
  8732. * Update the current camera state depending on the inputs that have been used this frame.
  8733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8734. */
  8735. checkInputs(): void;
  8736. /**
  8737. * Gets the class name of the current intput.
  8738. * @returns the class name
  8739. */
  8740. getClassName(): string;
  8741. /** @hidden */
  8742. _onLostFocus(): void;
  8743. /**
  8744. * Get the friendly name associated with the input class.
  8745. * @returns the input friendly name
  8746. */
  8747. getSimpleName(): string;
  8748. }
  8749. }
  8750. declare module "babylonjs/Lights/shadowLight" {
  8751. import { Camera } from "babylonjs/Cameras/camera";
  8752. import { Scene } from "babylonjs/scene";
  8753. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8755. import { Light } from "babylonjs/Lights/light";
  8756. /**
  8757. * Interface describing all the common properties and methods a shadow light needs to implement.
  8758. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8759. * as well as binding the different shadow properties to the effects.
  8760. */
  8761. export interface IShadowLight extends Light {
  8762. /**
  8763. * The light id in the scene (used in scene.findLighById for instance)
  8764. */
  8765. id: string;
  8766. /**
  8767. * The position the shdow will be casted from.
  8768. */
  8769. position: Vector3;
  8770. /**
  8771. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8772. */
  8773. direction: Vector3;
  8774. /**
  8775. * The transformed position. Position of the light in world space taking parenting in account.
  8776. */
  8777. transformedPosition: Vector3;
  8778. /**
  8779. * The transformed direction. Direction of the light in world space taking parenting in account.
  8780. */
  8781. transformedDirection: Vector3;
  8782. /**
  8783. * The friendly name of the light in the scene.
  8784. */
  8785. name: string;
  8786. /**
  8787. * Defines the shadow projection clipping minimum z value.
  8788. */
  8789. shadowMinZ: number;
  8790. /**
  8791. * Defines the shadow projection clipping maximum z value.
  8792. */
  8793. shadowMaxZ: number;
  8794. /**
  8795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8797. */
  8798. computeTransformedInformation(): boolean;
  8799. /**
  8800. * Gets the scene the light belongs to.
  8801. * @returns The scene
  8802. */
  8803. getScene(): Scene;
  8804. /**
  8805. * Callback defining a custom Projection Matrix Builder.
  8806. * This can be used to override the default projection matrix computation.
  8807. */
  8808. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8809. /**
  8810. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8811. * @param matrix The materix to updated with the projection information
  8812. * @param viewMatrix The transform matrix of the light
  8813. * @param renderList The list of mesh to render in the map
  8814. * @returns The current light
  8815. */
  8816. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8817. /**
  8818. * Gets the current depth scale used in ESM.
  8819. * @returns The scale
  8820. */
  8821. getDepthScale(): number;
  8822. /**
  8823. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8824. * @returns true if a cube texture needs to be use
  8825. */
  8826. needCube(): boolean;
  8827. /**
  8828. * Detects if the projection matrix requires to be recomputed this frame.
  8829. * @returns true if it requires to be recomputed otherwise, false.
  8830. */
  8831. needProjectionMatrixCompute(): boolean;
  8832. /**
  8833. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8834. */
  8835. forceProjectionMatrixCompute(): void;
  8836. /**
  8837. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8838. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8839. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8840. */
  8841. getShadowDirection(faceIndex?: number): Vector3;
  8842. /**
  8843. * Gets the minZ used for shadow according to both the scene and the light.
  8844. * @param activeCamera The camera we are returning the min for
  8845. * @returns the depth min z
  8846. */
  8847. getDepthMinZ(activeCamera: Camera): number;
  8848. /**
  8849. * Gets the maxZ used for shadow according to both the scene and the light.
  8850. * @param activeCamera The camera we are returning the max for
  8851. * @returns the depth max z
  8852. */
  8853. getDepthMaxZ(activeCamera: Camera): number;
  8854. }
  8855. /**
  8856. * Base implementation IShadowLight
  8857. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8858. */
  8859. export abstract class ShadowLight extends Light implements IShadowLight {
  8860. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8861. protected _position: Vector3;
  8862. protected _setPosition(value: Vector3): void;
  8863. /**
  8864. * Sets the position the shadow will be casted from. Also use as the light position for both
  8865. * point and spot lights.
  8866. */
  8867. /**
  8868. * Sets the position the shadow will be casted from. Also use as the light position for both
  8869. * point and spot lights.
  8870. */
  8871. position: Vector3;
  8872. protected _direction: Vector3;
  8873. protected _setDirection(value: Vector3): void;
  8874. /**
  8875. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8876. * Also use as the light direction on spot and directional lights.
  8877. */
  8878. /**
  8879. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8880. * Also use as the light direction on spot and directional lights.
  8881. */
  8882. direction: Vector3;
  8883. private _shadowMinZ;
  8884. /**
  8885. * Gets the shadow projection clipping minimum z value.
  8886. */
  8887. /**
  8888. * Sets the shadow projection clipping minimum z value.
  8889. */
  8890. shadowMinZ: number;
  8891. private _shadowMaxZ;
  8892. /**
  8893. * Sets the shadow projection clipping maximum z value.
  8894. */
  8895. /**
  8896. * Gets the shadow projection clipping maximum z value.
  8897. */
  8898. shadowMaxZ: number;
  8899. /**
  8900. * Callback defining a custom Projection Matrix Builder.
  8901. * This can be used to override the default projection matrix computation.
  8902. */
  8903. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8904. /**
  8905. * The transformed position. Position of the light in world space taking parenting in account.
  8906. */
  8907. transformedPosition: Vector3;
  8908. /**
  8909. * The transformed direction. Direction of the light in world space taking parenting in account.
  8910. */
  8911. transformedDirection: Vector3;
  8912. private _needProjectionMatrixCompute;
  8913. /**
  8914. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8915. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8916. */
  8917. computeTransformedInformation(): boolean;
  8918. /**
  8919. * Return the depth scale used for the shadow map.
  8920. * @returns the depth scale.
  8921. */
  8922. getDepthScale(): number;
  8923. /**
  8924. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8925. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8926. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8927. */
  8928. getShadowDirection(faceIndex?: number): Vector3;
  8929. /**
  8930. * Returns the ShadowLight absolute position in the World.
  8931. * @returns the position vector in world space
  8932. */
  8933. getAbsolutePosition(): Vector3;
  8934. /**
  8935. * Sets the ShadowLight direction toward the passed target.
  8936. * @param target The point to target in local space
  8937. * @returns the updated ShadowLight direction
  8938. */
  8939. setDirectionToTarget(target: Vector3): Vector3;
  8940. /**
  8941. * Returns the light rotation in euler definition.
  8942. * @returns the x y z rotation in local space.
  8943. */
  8944. getRotation(): Vector3;
  8945. /**
  8946. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8947. * @returns true if a cube texture needs to be use
  8948. */
  8949. needCube(): boolean;
  8950. /**
  8951. * Detects if the projection matrix requires to be recomputed this frame.
  8952. * @returns true if it requires to be recomputed otherwise, false.
  8953. */
  8954. needProjectionMatrixCompute(): boolean;
  8955. /**
  8956. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8957. */
  8958. forceProjectionMatrixCompute(): void;
  8959. /** @hidden */
  8960. _initCache(): void;
  8961. /** @hidden */
  8962. _isSynchronized(): boolean;
  8963. /**
  8964. * Computes the world matrix of the node
  8965. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8966. * @returns the world matrix
  8967. */
  8968. computeWorldMatrix(force?: boolean): Matrix;
  8969. /**
  8970. * Gets the minZ used for shadow according to both the scene and the light.
  8971. * @param activeCamera The camera we are returning the min for
  8972. * @returns the depth min z
  8973. */
  8974. getDepthMinZ(activeCamera: Camera): number;
  8975. /**
  8976. * Gets the maxZ used for shadow according to both the scene and the light.
  8977. * @param activeCamera The camera we are returning the max for
  8978. * @returns the depth max z
  8979. */
  8980. getDepthMaxZ(activeCamera: Camera): number;
  8981. /**
  8982. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8983. * @param matrix The materix to updated with the projection information
  8984. * @param viewMatrix The transform matrix of the light
  8985. * @param renderList The list of mesh to render in the map
  8986. * @returns The current light
  8987. */
  8988. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8989. }
  8990. }
  8991. declare module "babylonjs/Materials/effectFallbacks" {
  8992. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8993. import { Effect } from "babylonjs/Materials/effect";
  8994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8995. /**
  8996. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8997. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8998. */
  8999. export class EffectFallbacks implements IEffectFallbacks {
  9000. private _defines;
  9001. private _currentRank;
  9002. private _maxRank;
  9003. private _mesh;
  9004. /**
  9005. * Removes the fallback from the bound mesh.
  9006. */
  9007. unBindMesh(): void;
  9008. /**
  9009. * Adds a fallback on the specified property.
  9010. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9011. * @param define The name of the define in the shader
  9012. */
  9013. addFallback(rank: number, define: string): void;
  9014. /**
  9015. * Sets the mesh to use CPU skinning when needing to fallback.
  9016. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9017. * @param mesh The mesh to use the fallbacks.
  9018. */
  9019. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9020. /**
  9021. * Checks to see if more fallbacks are still availible.
  9022. */
  9023. readonly hasMoreFallbacks: boolean;
  9024. /**
  9025. * Removes the defines that should be removed when falling back.
  9026. * @param currentDefines defines the current define statements for the shader.
  9027. * @param effect defines the current effect we try to compile
  9028. * @returns The resulting defines with defines of the current rank removed.
  9029. */
  9030. reduce(currentDefines: string, effect: Effect): string;
  9031. }
  9032. }
  9033. declare module "babylonjs/Materials/materialHelper" {
  9034. import { Nullable } from "babylonjs/types";
  9035. import { Scene } from "babylonjs/scene";
  9036. import { Engine } from "babylonjs/Engines/engine";
  9037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9038. import { Light } from "babylonjs/Lights/light";
  9039. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9040. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  9041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9042. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9043. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9044. /**
  9045. * "Static Class" containing the most commonly used helper while dealing with material for
  9046. * rendering purpose.
  9047. *
  9048. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9049. *
  9050. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9051. */
  9052. export class MaterialHelper {
  9053. /**
  9054. * Bind the current view position to an effect.
  9055. * @param effect The effect to be bound
  9056. * @param scene The scene the eyes position is used from
  9057. */
  9058. static BindEyePosition(effect: Effect, scene: Scene): void;
  9059. /**
  9060. * Helps preparing the defines values about the UVs in used in the effect.
  9061. * UVs are shared as much as we can accross channels in the shaders.
  9062. * @param texture The texture we are preparing the UVs for
  9063. * @param defines The defines to update
  9064. * @param key The channel key "diffuse", "specular"... used in the shader
  9065. */
  9066. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9067. /**
  9068. * Binds a texture matrix value to its corrsponding uniform
  9069. * @param texture The texture to bind the matrix for
  9070. * @param uniformBuffer The uniform buffer receivin the data
  9071. * @param key The channel key "diffuse", "specular"... used in the shader
  9072. */
  9073. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9074. /**
  9075. * Gets the current status of the fog (should it be enabled?)
  9076. * @param mesh defines the mesh to evaluate for fog support
  9077. * @param scene defines the hosting scene
  9078. * @returns true if fog must be enabled
  9079. */
  9080. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9081. /**
  9082. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9083. * @param mesh defines the current mesh
  9084. * @param scene defines the current scene
  9085. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9086. * @param pointsCloud defines if point cloud rendering has to be turned on
  9087. * @param fogEnabled defines if fog has to be turned on
  9088. * @param alphaTest defines if alpha testing has to be turned on
  9089. * @param defines defines the current list of defines
  9090. */
  9091. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9092. /**
  9093. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9094. * @param scene defines the current scene
  9095. * @param engine defines the current engine
  9096. * @param defines specifies the list of active defines
  9097. * @param useInstances defines if instances have to be turned on
  9098. * @param useClipPlane defines if clip plane have to be turned on
  9099. */
  9100. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9101. /**
  9102. * Prepares the defines for bones
  9103. * @param mesh The mesh containing the geometry data we will draw
  9104. * @param defines The defines to update
  9105. */
  9106. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9107. /**
  9108. * Prepares the defines for morph targets
  9109. * @param mesh The mesh containing the geometry data we will draw
  9110. * @param defines The defines to update
  9111. */
  9112. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9113. /**
  9114. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9115. * @param mesh The mesh containing the geometry data we will draw
  9116. * @param defines The defines to update
  9117. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9118. * @param useBones Precise whether bones should be used or not (override mesh info)
  9119. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9120. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9121. * @returns false if defines are considered not dirty and have not been checked
  9122. */
  9123. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9124. /**
  9125. * Prepares the defines related to multiview
  9126. * @param scene The scene we are intending to draw
  9127. * @param defines The defines to update
  9128. */
  9129. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9130. /**
  9131. * Prepares the defines related to the light information passed in parameter
  9132. * @param scene The scene we are intending to draw
  9133. * @param mesh The mesh the effect is compiling for
  9134. * @param light The light the effect is compiling for
  9135. * @param lightIndex The index of the light
  9136. * @param defines The defines to update
  9137. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9138. * @param state Defines the current state regarding what is needed (normals, etc...)
  9139. */
  9140. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9141. needNormals: boolean;
  9142. needRebuild: boolean;
  9143. shadowEnabled: boolean;
  9144. specularEnabled: boolean;
  9145. lightmapMode: boolean;
  9146. }): void;
  9147. /**
  9148. * Prepares the defines related to the light information passed in parameter
  9149. * @param scene The scene we are intending to draw
  9150. * @param mesh The mesh the effect is compiling for
  9151. * @param defines The defines to update
  9152. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9153. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9154. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9155. * @returns true if normals will be required for the rest of the effect
  9156. */
  9157. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9158. /**
  9159. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9160. * @param lightIndex defines the light index
  9161. * @param uniformsList The uniform list
  9162. * @param samplersList The sampler list
  9163. * @param projectedLightTexture defines if projected texture must be used
  9164. * @param uniformBuffersList defines an optional list of uniform buffers
  9165. */
  9166. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9167. /**
  9168. * Prepares the uniforms and samplers list to be used in the effect
  9169. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9170. * @param samplersList The sampler list
  9171. * @param defines The defines helping in the list generation
  9172. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9173. */
  9174. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9175. /**
  9176. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9177. * @param defines The defines to update while falling back
  9178. * @param fallbacks The authorized effect fallbacks
  9179. * @param maxSimultaneousLights The maximum number of lights allowed
  9180. * @param rank the current rank of the Effect
  9181. * @returns The newly affected rank
  9182. */
  9183. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9184. private static _TmpMorphInfluencers;
  9185. /**
  9186. * Prepares the list of attributes required for morph targets according to the effect defines.
  9187. * @param attribs The current list of supported attribs
  9188. * @param mesh The mesh to prepare the morph targets attributes for
  9189. * @param influencers The number of influencers
  9190. */
  9191. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9192. /**
  9193. * Prepares the list of attributes required for morph targets according to the effect defines.
  9194. * @param attribs The current list of supported attribs
  9195. * @param mesh The mesh to prepare the morph targets attributes for
  9196. * @param defines The current Defines of the effect
  9197. */
  9198. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9199. /**
  9200. * Prepares the list of attributes required for bones according to the effect defines.
  9201. * @param attribs The current list of supported attribs
  9202. * @param mesh The mesh to prepare the bones attributes for
  9203. * @param defines The current Defines of the effect
  9204. * @param fallbacks The current efffect fallback strategy
  9205. */
  9206. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9207. /**
  9208. * Check and prepare the list of attributes required for instances according to the effect defines.
  9209. * @param attribs The current list of supported attribs
  9210. * @param defines The current MaterialDefines of the effect
  9211. */
  9212. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9213. /**
  9214. * Add the list of attributes required for instances to the attribs array.
  9215. * @param attribs The current list of supported attribs
  9216. */
  9217. static PushAttributesForInstances(attribs: string[]): void;
  9218. /**
  9219. * Binds the light shadow information to the effect for the given mesh.
  9220. * @param light The light containing the generator
  9221. * @param scene The scene the lights belongs to
  9222. * @param mesh The mesh we are binding the information to render
  9223. * @param lightIndex The light index in the effect used to render the mesh
  9224. * @param effect The effect we are binding the data to
  9225. */
  9226. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9227. /**
  9228. * Binds the light information to the effect.
  9229. * @param light The light containing the generator
  9230. * @param effect The effect we are binding the data to
  9231. * @param lightIndex The light index in the effect used to render
  9232. */
  9233. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9234. /**
  9235. * Binds the lights information from the scene to the effect for the given mesh.
  9236. * @param light Light to bind
  9237. * @param lightIndex Light index
  9238. * @param scene The scene where the light belongs to
  9239. * @param mesh The mesh we are binding the information to render
  9240. * @param effect The effect we are binding the data to
  9241. * @param useSpecular Defines if specular is supported
  9242. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9243. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9244. */
  9245. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9246. /**
  9247. * Binds the lights information from the scene to the effect for the given mesh.
  9248. * @param scene The scene the lights belongs to
  9249. * @param mesh The mesh we are binding the information to render
  9250. * @param effect The effect we are binding the data to
  9251. * @param defines The generated defines for the effect
  9252. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9253. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9254. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9255. */
  9256. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9257. private static _tempFogColor;
  9258. /**
  9259. * Binds the fog information from the scene to the effect for the given mesh.
  9260. * @param scene The scene the lights belongs to
  9261. * @param mesh The mesh we are binding the information to render
  9262. * @param effect The effect we are binding the data to
  9263. * @param linearSpace Defines if the fog effect is applied in linear space
  9264. */
  9265. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9266. /**
  9267. * Binds the bones information from the mesh to the effect.
  9268. * @param mesh The mesh we are binding the information to render
  9269. * @param effect The effect we are binding the data to
  9270. */
  9271. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9272. /**
  9273. * Binds the morph targets information from the mesh to the effect.
  9274. * @param abstractMesh The mesh we are binding the information to render
  9275. * @param effect The effect we are binding the data to
  9276. */
  9277. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9278. /**
  9279. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9280. * @param defines The generated defines used in the effect
  9281. * @param effect The effect we are binding the data to
  9282. * @param scene The scene we are willing to render with logarithmic scale for
  9283. */
  9284. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9285. /**
  9286. * Binds the clip plane information from the scene to the effect.
  9287. * @param scene The scene the clip plane information are extracted from
  9288. * @param effect The effect we are binding the data to
  9289. */
  9290. static BindClipPlane(effect: Effect, scene: Scene): void;
  9291. }
  9292. }
  9293. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9294. /** @hidden */
  9295. export var packingFunctions: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9301. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9302. /** @hidden */
  9303. export var shadowMapPixelShader: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9309. /** @hidden */
  9310. export var bonesDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9316. /** @hidden */
  9317. export var morphTargetsVertexGlobalDeclaration: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9323. /** @hidden */
  9324. export var morphTargetsVertexDeclaration: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9330. /** @hidden */
  9331. export var instancesDeclaration: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9337. /** @hidden */
  9338. export var helperFunctions: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9344. /** @hidden */
  9345. export var morphTargetsVertex: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9351. /** @hidden */
  9352. export var instancesVertex: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9358. /** @hidden */
  9359. export var bonesVertex: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9365. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9368. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9369. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9371. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9372. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9373. /** @hidden */
  9374. export var shadowMapVertexShader: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9380. /** @hidden */
  9381. export var depthBoxBlurPixelShader: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9387. import { Nullable } from "babylonjs/types";
  9388. import { Scene } from "babylonjs/scene";
  9389. import { Matrix } from "babylonjs/Maths/math.vector";
  9390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9392. import { Mesh } from "babylonjs/Meshes/mesh";
  9393. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9394. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9395. import { Effect } from "babylonjs/Materials/effect";
  9396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9397. import "babylonjs/Shaders/shadowMap.fragment";
  9398. import "babylonjs/Shaders/shadowMap.vertex";
  9399. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9400. import { Observable } from "babylonjs/Misc/observable";
  9401. /**
  9402. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9403. */
  9404. export interface ICustomShaderOptions {
  9405. /**
  9406. * Gets or sets the custom shader name to use
  9407. */
  9408. shaderName: string;
  9409. /**
  9410. * The list of attribute names used in the shader
  9411. */
  9412. attributes?: string[];
  9413. /**
  9414. * The list of unifrom names used in the shader
  9415. */
  9416. uniforms?: string[];
  9417. /**
  9418. * The list of sampler names used in the shader
  9419. */
  9420. samplers?: string[];
  9421. /**
  9422. * The list of defines used in the shader
  9423. */
  9424. defines?: string[];
  9425. }
  9426. /**
  9427. * Interface to implement to create a shadow generator compatible with BJS.
  9428. */
  9429. export interface IShadowGenerator {
  9430. /**
  9431. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9432. * @returns The render target texture if present otherwise, null
  9433. */
  9434. getShadowMap(): Nullable<RenderTargetTexture>;
  9435. /**
  9436. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9437. * @returns The render target texture if the shadow map is present otherwise, null
  9438. */
  9439. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9440. /**
  9441. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9442. * @param subMesh The submesh we want to render in the shadow map
  9443. * @param useInstances Defines wether will draw in the map using instances
  9444. * @returns true if ready otherwise, false
  9445. */
  9446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9447. /**
  9448. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9449. * @param defines Defines of the material we want to update
  9450. * @param lightIndex Index of the light in the enabled light list of the material
  9451. */
  9452. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9453. /**
  9454. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9455. * defined in the generator but impacting the effect).
  9456. * It implies the unifroms available on the materials are the standard BJS ones.
  9457. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9458. * @param effect The effect we are binfing the information for
  9459. */
  9460. bindShadowLight(lightIndex: string, effect: Effect): void;
  9461. /**
  9462. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9463. * (eq to shadow prjection matrix * light transform matrix)
  9464. * @returns The transform matrix used to create the shadow map
  9465. */
  9466. getTransformMatrix(): Matrix;
  9467. /**
  9468. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9469. * Cube and 2D textures for instance.
  9470. */
  9471. recreateShadowMap(): void;
  9472. /**
  9473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9474. * @param onCompiled Callback triggered at the and of the effects compilation
  9475. * @param options Sets of optional options forcing the compilation with different modes
  9476. */
  9477. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9478. useInstances: boolean;
  9479. }>): void;
  9480. /**
  9481. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9482. * @param options Sets of optional options forcing the compilation with different modes
  9483. * @returns A promise that resolves when the compilation completes
  9484. */
  9485. forceCompilationAsync(options?: Partial<{
  9486. useInstances: boolean;
  9487. }>): Promise<void>;
  9488. /**
  9489. * Serializes the shadow generator setup to a json object.
  9490. * @returns The serialized JSON object
  9491. */
  9492. serialize(): any;
  9493. /**
  9494. * Disposes the Shadow map and related Textures and effects.
  9495. */
  9496. dispose(): void;
  9497. }
  9498. /**
  9499. * Default implementation IShadowGenerator.
  9500. * This is the main object responsible of generating shadows in the framework.
  9501. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9502. */
  9503. export class ShadowGenerator implements IShadowGenerator {
  9504. /**
  9505. * Shadow generator mode None: no filtering applied.
  9506. */
  9507. static readonly FILTER_NONE: number;
  9508. /**
  9509. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9511. */
  9512. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9513. /**
  9514. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9515. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9516. */
  9517. static readonly FILTER_POISSONSAMPLING: number;
  9518. /**
  9519. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9521. */
  9522. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9523. /**
  9524. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9525. * edge artifacts on steep falloff.
  9526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9527. */
  9528. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9529. /**
  9530. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9531. * edge artifacts on steep falloff.
  9532. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9533. */
  9534. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9535. /**
  9536. * Shadow generator mode PCF: Percentage Closer Filtering
  9537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9538. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9539. */
  9540. static readonly FILTER_PCF: number;
  9541. /**
  9542. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9543. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9544. * Contact Hardening
  9545. */
  9546. static readonly FILTER_PCSS: number;
  9547. /**
  9548. * Reserved for PCF and PCSS
  9549. * Highest Quality.
  9550. *
  9551. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9552. *
  9553. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9554. */
  9555. static readonly QUALITY_HIGH: number;
  9556. /**
  9557. * Reserved for PCF and PCSS
  9558. * Good tradeoff for quality/perf cross devices
  9559. *
  9560. * Execute PCF on a 3*3 kernel.
  9561. *
  9562. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9563. */
  9564. static readonly QUALITY_MEDIUM: number;
  9565. /**
  9566. * Reserved for PCF and PCSS
  9567. * The lowest quality but the fastest.
  9568. *
  9569. * Execute PCF on a 1*1 kernel.
  9570. *
  9571. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9572. */
  9573. static readonly QUALITY_LOW: number;
  9574. /** Gets or sets the custom shader name to use */
  9575. customShaderOptions: ICustomShaderOptions;
  9576. /**
  9577. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9578. */
  9579. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9580. /**
  9581. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9582. */
  9583. onAfterShadowMapRenderObservable: Observable<Effect>;
  9584. /**
  9585. * Observable triggered before a mesh is rendered in the shadow map.
  9586. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9587. */
  9588. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9589. /**
  9590. * Observable triggered after a mesh is rendered in the shadow map.
  9591. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9592. */
  9593. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9594. private _bias;
  9595. /**
  9596. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9597. */
  9598. /**
  9599. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9600. */
  9601. bias: number;
  9602. private _normalBias;
  9603. /**
  9604. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9605. */
  9606. /**
  9607. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9608. */
  9609. normalBias: number;
  9610. private _blurBoxOffset;
  9611. /**
  9612. * Gets the blur box offset: offset applied during the blur pass.
  9613. * Only useful if useKernelBlur = false
  9614. */
  9615. /**
  9616. * Sets the blur box offset: offset applied during the blur pass.
  9617. * Only useful if useKernelBlur = false
  9618. */
  9619. blurBoxOffset: number;
  9620. private _blurScale;
  9621. /**
  9622. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9623. * 2 means half of the size.
  9624. */
  9625. /**
  9626. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9627. * 2 means half of the size.
  9628. */
  9629. blurScale: number;
  9630. private _blurKernel;
  9631. /**
  9632. * Gets the blur kernel: kernel size of the blur pass.
  9633. * Only useful if useKernelBlur = true
  9634. */
  9635. /**
  9636. * Sets the blur kernel: kernel size of the blur pass.
  9637. * Only useful if useKernelBlur = true
  9638. */
  9639. blurKernel: number;
  9640. private _useKernelBlur;
  9641. /**
  9642. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9644. */
  9645. /**
  9646. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9648. */
  9649. useKernelBlur: boolean;
  9650. private _depthScale;
  9651. /**
  9652. * Gets the depth scale used in ESM mode.
  9653. */
  9654. /**
  9655. * Sets the depth scale used in ESM mode.
  9656. * This can override the scale stored on the light.
  9657. */
  9658. depthScale: number;
  9659. private _filter;
  9660. /**
  9661. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9662. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9663. */
  9664. /**
  9665. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9666. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9667. */
  9668. filter: number;
  9669. /**
  9670. * Gets if the current filter is set to Poisson Sampling.
  9671. */
  9672. /**
  9673. * Sets the current filter to Poisson Sampling.
  9674. */
  9675. usePoissonSampling: boolean;
  9676. /**
  9677. * Gets if the current filter is set to ESM.
  9678. */
  9679. /**
  9680. * Sets the current filter is to ESM.
  9681. */
  9682. useExponentialShadowMap: boolean;
  9683. /**
  9684. * Gets if the current filter is set to filtered ESM.
  9685. */
  9686. /**
  9687. * Gets if the current filter is set to filtered ESM.
  9688. */
  9689. useBlurExponentialShadowMap: boolean;
  9690. /**
  9691. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9692. * exponential to prevent steep falloff artifacts).
  9693. */
  9694. /**
  9695. * Sets the current filter to "close ESM" (using the inverse of the
  9696. * exponential to prevent steep falloff artifacts).
  9697. */
  9698. useCloseExponentialShadowMap: boolean;
  9699. /**
  9700. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9701. * exponential to prevent steep falloff artifacts).
  9702. */
  9703. /**
  9704. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9705. * exponential to prevent steep falloff artifacts).
  9706. */
  9707. useBlurCloseExponentialShadowMap: boolean;
  9708. /**
  9709. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9710. */
  9711. /**
  9712. * Sets the current filter to "PCF" (percentage closer filtering).
  9713. */
  9714. usePercentageCloserFiltering: boolean;
  9715. private _filteringQuality;
  9716. /**
  9717. * Gets the PCF or PCSS Quality.
  9718. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9719. */
  9720. /**
  9721. * Sets the PCF or PCSS Quality.
  9722. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9723. */
  9724. filteringQuality: number;
  9725. /**
  9726. * Gets if the current filter is set to "PCSS" (contact hardening).
  9727. */
  9728. /**
  9729. * Sets the current filter to "PCSS" (contact hardening).
  9730. */
  9731. useContactHardeningShadow: boolean;
  9732. private _contactHardeningLightSizeUVRatio;
  9733. /**
  9734. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9735. * Using a ratio helps keeping shape stability independently of the map size.
  9736. *
  9737. * It does not account for the light projection as it was having too much
  9738. * instability during the light setup or during light position changes.
  9739. *
  9740. * Only valid if useContactHardeningShadow is true.
  9741. */
  9742. /**
  9743. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9744. * Using a ratio helps keeping shape stability independently of the map size.
  9745. *
  9746. * It does not account for the light projection as it was having too much
  9747. * instability during the light setup or during light position changes.
  9748. *
  9749. * Only valid if useContactHardeningShadow is true.
  9750. */
  9751. contactHardeningLightSizeUVRatio: number;
  9752. private _darkness;
  9753. /** Gets or sets the actual darkness of a shadow */
  9754. darkness: number;
  9755. /**
  9756. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9757. * 0 means strongest and 1 would means no shadow.
  9758. * @returns the darkness.
  9759. */
  9760. getDarkness(): number;
  9761. /**
  9762. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9763. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9764. * @returns the shadow generator allowing fluent coding.
  9765. */
  9766. setDarkness(darkness: number): ShadowGenerator;
  9767. private _transparencyShadow;
  9768. /** Gets or sets the ability to have transparent shadow */
  9769. transparencyShadow: boolean;
  9770. /**
  9771. * Sets the ability to have transparent shadow (boolean).
  9772. * @param transparent True if transparent else False
  9773. * @returns the shadow generator allowing fluent coding
  9774. */
  9775. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9776. private _shadowMap;
  9777. private _shadowMap2;
  9778. /**
  9779. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9780. * @returns The render target texture if present otherwise, null
  9781. */
  9782. getShadowMap(): Nullable<RenderTargetTexture>;
  9783. /**
  9784. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9785. * @returns The render target texture if the shadow map is present otherwise, null
  9786. */
  9787. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9788. /**
  9789. * Gets the class name of that object
  9790. * @returns "ShadowGenerator"
  9791. */
  9792. getClassName(): string;
  9793. /**
  9794. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9795. * @param mesh Mesh to add
  9796. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9797. * @returns the Shadow Generator itself
  9798. */
  9799. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9800. /**
  9801. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9802. * @param mesh Mesh to remove
  9803. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9804. * @returns the Shadow Generator itself
  9805. */
  9806. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9807. /**
  9808. * Controls the extent to which the shadows fade out at the edge of the frustum
  9809. * Used only by directionals and spots
  9810. */
  9811. frustumEdgeFalloff: number;
  9812. private _light;
  9813. /**
  9814. * Returns the associated light object.
  9815. * @returns the light generating the shadow
  9816. */
  9817. getLight(): IShadowLight;
  9818. /**
  9819. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9820. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9821. * It might on the other hand introduce peter panning.
  9822. */
  9823. forceBackFacesOnly: boolean;
  9824. private _scene;
  9825. private _lightDirection;
  9826. private _effect;
  9827. private _viewMatrix;
  9828. private _projectionMatrix;
  9829. private _transformMatrix;
  9830. private _cachedPosition;
  9831. private _cachedDirection;
  9832. private _cachedDefines;
  9833. private _currentRenderID;
  9834. private _boxBlurPostprocess;
  9835. private _kernelBlurXPostprocess;
  9836. private _kernelBlurYPostprocess;
  9837. private _blurPostProcesses;
  9838. private _mapSize;
  9839. private _currentFaceIndex;
  9840. private _currentFaceIndexCache;
  9841. private _textureType;
  9842. private _defaultTextureMatrix;
  9843. /** @hidden */
  9844. static _SceneComponentInitialization: (scene: Scene) => void;
  9845. /**
  9846. * Creates a ShadowGenerator object.
  9847. * A ShadowGenerator is the required tool to use the shadows.
  9848. * Each light casting shadows needs to use its own ShadowGenerator.
  9849. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9850. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9851. * @param light The light object generating the shadows.
  9852. * @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.
  9853. */
  9854. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9855. private _initializeGenerator;
  9856. private _initializeShadowMap;
  9857. private _initializeBlurRTTAndPostProcesses;
  9858. private _renderForShadowMap;
  9859. private _renderSubMeshForShadowMap;
  9860. private _applyFilterValues;
  9861. /**
  9862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9863. * @param onCompiled Callback triggered at the and of the effects compilation
  9864. * @param options Sets of optional options forcing the compilation with different modes
  9865. */
  9866. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9867. useInstances: boolean;
  9868. }>): void;
  9869. /**
  9870. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9871. * @param options Sets of optional options forcing the compilation with different modes
  9872. * @returns A promise that resolves when the compilation completes
  9873. */
  9874. forceCompilationAsync(options?: Partial<{
  9875. useInstances: boolean;
  9876. }>): Promise<void>;
  9877. /**
  9878. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9879. * @param subMesh The submesh we want to render in the shadow map
  9880. * @param useInstances Defines wether will draw in the map using instances
  9881. * @returns true if ready otherwise, false
  9882. */
  9883. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9884. /**
  9885. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9886. * @param defines Defines of the material we want to update
  9887. * @param lightIndex Index of the light in the enabled light list of the material
  9888. */
  9889. prepareDefines(defines: any, lightIndex: number): void;
  9890. /**
  9891. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9892. * defined in the generator but impacting the effect).
  9893. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9894. * @param effect The effect we are binfing the information for
  9895. */
  9896. bindShadowLight(lightIndex: string, effect: Effect): void;
  9897. /**
  9898. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9899. * (eq to shadow prjection matrix * light transform matrix)
  9900. * @returns The transform matrix used to create the shadow map
  9901. */
  9902. getTransformMatrix(): Matrix;
  9903. /**
  9904. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9905. * Cube and 2D textures for instance.
  9906. */
  9907. recreateShadowMap(): void;
  9908. private _disposeBlurPostProcesses;
  9909. private _disposeRTTandPostProcesses;
  9910. /**
  9911. * Disposes the ShadowGenerator.
  9912. * Returns nothing.
  9913. */
  9914. dispose(): void;
  9915. /**
  9916. * Serializes the shadow generator setup to a json object.
  9917. * @returns The serialized JSON object
  9918. */
  9919. serialize(): any;
  9920. /**
  9921. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9922. * @param parsedShadowGenerator The JSON object to parse
  9923. * @param scene The scene to create the shadow map for
  9924. * @returns The parsed shadow generator
  9925. */
  9926. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9927. }
  9928. }
  9929. declare module "babylonjs/Lights/light" {
  9930. import { Nullable } from "babylonjs/types";
  9931. import { Scene } from "babylonjs/scene";
  9932. import { Vector3 } from "babylonjs/Maths/math.vector";
  9933. import { Color3 } from "babylonjs/Maths/math.color";
  9934. import { Node } from "babylonjs/node";
  9935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9936. import { Effect } from "babylonjs/Materials/effect";
  9937. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9938. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9939. /**
  9940. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9941. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9942. * 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.
  9943. */
  9944. export abstract class Light extends Node {
  9945. /**
  9946. * Falloff Default: light is falling off following the material specification:
  9947. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9948. */
  9949. static readonly FALLOFF_DEFAULT: number;
  9950. /**
  9951. * Falloff Physical: light is falling off following the inverse squared distance law.
  9952. */
  9953. static readonly FALLOFF_PHYSICAL: number;
  9954. /**
  9955. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9956. * to enhance interoperability with other engines.
  9957. */
  9958. static readonly FALLOFF_GLTF: number;
  9959. /**
  9960. * Falloff Standard: light is falling off like in the standard material
  9961. * to enhance interoperability with other materials.
  9962. */
  9963. static readonly FALLOFF_STANDARD: number;
  9964. /**
  9965. * If every light affecting the material is in this lightmapMode,
  9966. * material.lightmapTexture adds or multiplies
  9967. * (depends on material.useLightmapAsShadowmap)
  9968. * after every other light calculations.
  9969. */
  9970. static readonly LIGHTMAP_DEFAULT: number;
  9971. /**
  9972. * material.lightmapTexture as only diffuse lighting from this light
  9973. * adds only specular lighting from this light
  9974. * adds dynamic shadows
  9975. */
  9976. static readonly LIGHTMAP_SPECULAR: number;
  9977. /**
  9978. * material.lightmapTexture as only lighting
  9979. * no light calculation from this light
  9980. * only adds dynamic shadows from this light
  9981. */
  9982. static readonly LIGHTMAP_SHADOWSONLY: number;
  9983. /**
  9984. * Each light type uses the default quantity according to its type:
  9985. * point/spot lights use luminous intensity
  9986. * directional lights use illuminance
  9987. */
  9988. static readonly INTENSITYMODE_AUTOMATIC: number;
  9989. /**
  9990. * lumen (lm)
  9991. */
  9992. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9993. /**
  9994. * candela (lm/sr)
  9995. */
  9996. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9997. /**
  9998. * lux (lm/m^2)
  9999. */
  10000. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10001. /**
  10002. * nit (cd/m^2)
  10003. */
  10004. static readonly INTENSITYMODE_LUMINANCE: number;
  10005. /**
  10006. * Light type const id of the point light.
  10007. */
  10008. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10009. /**
  10010. * Light type const id of the directional light.
  10011. */
  10012. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10013. /**
  10014. * Light type const id of the spot light.
  10015. */
  10016. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10017. /**
  10018. * Light type const id of the hemispheric light.
  10019. */
  10020. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10021. /**
  10022. * Diffuse gives the basic color to an object.
  10023. */
  10024. diffuse: Color3;
  10025. /**
  10026. * Specular produces a highlight color on an object.
  10027. * Note: This is note affecting PBR materials.
  10028. */
  10029. specular: Color3;
  10030. /**
  10031. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10032. * falling off base on range or angle.
  10033. * This can be set to any values in Light.FALLOFF_x.
  10034. *
  10035. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10036. * other types of materials.
  10037. */
  10038. falloffType: number;
  10039. /**
  10040. * Strength of the light.
  10041. * Note: By default it is define in the framework own unit.
  10042. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10043. */
  10044. intensity: number;
  10045. private _range;
  10046. protected _inverseSquaredRange: number;
  10047. /**
  10048. * Defines how far from the source the light is impacting in scene units.
  10049. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10050. */
  10051. /**
  10052. * Defines how far from the source the light is impacting in scene units.
  10053. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10054. */
  10055. range: number;
  10056. /**
  10057. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10058. * of light.
  10059. */
  10060. private _photometricScale;
  10061. private _intensityMode;
  10062. /**
  10063. * Gets the photometric scale used to interpret the intensity.
  10064. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10065. */
  10066. /**
  10067. * Sets the photometric scale used to interpret the intensity.
  10068. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10069. */
  10070. intensityMode: number;
  10071. private _radius;
  10072. /**
  10073. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10074. */
  10075. /**
  10076. * sets the light radius used by PBR Materials to simulate soft area lights.
  10077. */
  10078. radius: number;
  10079. private _renderPriority;
  10080. /**
  10081. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10082. * exceeding the number allowed of the materials.
  10083. */
  10084. renderPriority: number;
  10085. private _shadowEnabled;
  10086. /**
  10087. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10088. * the current shadow generator.
  10089. */
  10090. /**
  10091. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10092. * the current shadow generator.
  10093. */
  10094. shadowEnabled: boolean;
  10095. private _includedOnlyMeshes;
  10096. /**
  10097. * Gets the only meshes impacted by this light.
  10098. */
  10099. /**
  10100. * Sets the only meshes impacted by this light.
  10101. */
  10102. includedOnlyMeshes: AbstractMesh[];
  10103. private _excludedMeshes;
  10104. /**
  10105. * Gets the meshes not impacted by this light.
  10106. */
  10107. /**
  10108. * Sets the meshes not impacted by this light.
  10109. */
  10110. excludedMeshes: AbstractMesh[];
  10111. private _excludeWithLayerMask;
  10112. /**
  10113. * Gets the layer id use to find what meshes are not impacted by the light.
  10114. * Inactive if 0
  10115. */
  10116. /**
  10117. * Sets the layer id use to find what meshes are not impacted by the light.
  10118. * Inactive if 0
  10119. */
  10120. excludeWithLayerMask: number;
  10121. private _includeOnlyWithLayerMask;
  10122. /**
  10123. * Gets the layer id use to find what meshes are impacted by the light.
  10124. * Inactive if 0
  10125. */
  10126. /**
  10127. * Sets the layer id use to find what meshes are impacted by the light.
  10128. * Inactive if 0
  10129. */
  10130. includeOnlyWithLayerMask: number;
  10131. private _lightmapMode;
  10132. /**
  10133. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10134. */
  10135. /**
  10136. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10137. */
  10138. lightmapMode: number;
  10139. /**
  10140. * Shadow generator associted to the light.
  10141. * @hidden Internal use only.
  10142. */
  10143. _shadowGenerator: Nullable<IShadowGenerator>;
  10144. /**
  10145. * @hidden Internal use only.
  10146. */
  10147. _excludedMeshesIds: string[];
  10148. /**
  10149. * @hidden Internal use only.
  10150. */
  10151. _includedOnlyMeshesIds: string[];
  10152. /**
  10153. * The current light unifom buffer.
  10154. * @hidden Internal use only.
  10155. */
  10156. _uniformBuffer: UniformBuffer;
  10157. /**
  10158. * Creates a Light object in the scene.
  10159. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10160. * @param name The firendly name of the light
  10161. * @param scene The scene the light belongs too
  10162. */
  10163. constructor(name: string, scene: Scene);
  10164. protected abstract _buildUniformLayout(): void;
  10165. /**
  10166. * Sets the passed Effect "effect" with the Light information.
  10167. * @param effect The effect to update
  10168. * @param lightIndex The index of the light in the effect to update
  10169. * @returns The light
  10170. */
  10171. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10172. /**
  10173. * Sets the passed Effect "effect" with the Light information.
  10174. * @param effect The effect to update
  10175. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10176. * @returns The light
  10177. */
  10178. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10179. /**
  10180. * Returns the string "Light".
  10181. * @returns the class name
  10182. */
  10183. getClassName(): string;
  10184. /** @hidden */
  10185. readonly _isLight: boolean;
  10186. /**
  10187. * Converts the light information to a readable string for debug purpose.
  10188. * @param fullDetails Supports for multiple levels of logging within scene loading
  10189. * @returns the human readable light info
  10190. */
  10191. toString(fullDetails?: boolean): string;
  10192. /** @hidden */
  10193. protected _syncParentEnabledState(): void;
  10194. /**
  10195. * Set the enabled state of this node.
  10196. * @param value - the new enabled state
  10197. */
  10198. setEnabled(value: boolean): void;
  10199. /**
  10200. * Returns the Light associated shadow generator if any.
  10201. * @return the associated shadow generator.
  10202. */
  10203. getShadowGenerator(): Nullable<IShadowGenerator>;
  10204. /**
  10205. * Returns a Vector3, the absolute light position in the World.
  10206. * @returns the world space position of the light
  10207. */
  10208. getAbsolutePosition(): Vector3;
  10209. /**
  10210. * Specifies if the light will affect the passed mesh.
  10211. * @param mesh The mesh to test against the light
  10212. * @return true the mesh is affected otherwise, false.
  10213. */
  10214. canAffectMesh(mesh: AbstractMesh): boolean;
  10215. /**
  10216. * Sort function to order lights for rendering.
  10217. * @param a First Light object to compare to second.
  10218. * @param b Second Light object to compare first.
  10219. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10220. */
  10221. static CompareLightsPriority(a: Light, b: Light): number;
  10222. /**
  10223. * Releases resources associated with this node.
  10224. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10225. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10226. */
  10227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10228. /**
  10229. * Returns the light type ID (integer).
  10230. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10231. */
  10232. getTypeID(): number;
  10233. /**
  10234. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10235. * @returns the scaled intensity in intensity mode unit
  10236. */
  10237. getScaledIntensity(): number;
  10238. /**
  10239. * Returns a new Light object, named "name", from the current one.
  10240. * @param name The name of the cloned light
  10241. * @returns the new created light
  10242. */
  10243. clone(name: string): Nullable<Light>;
  10244. /**
  10245. * Serializes the current light into a Serialization object.
  10246. * @returns the serialized object.
  10247. */
  10248. serialize(): any;
  10249. /**
  10250. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10251. * This new light is named "name" and added to the passed scene.
  10252. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10253. * @param name The friendly name of the light
  10254. * @param scene The scene the new light will belong to
  10255. * @returns the constructor function
  10256. */
  10257. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10258. /**
  10259. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10260. * @param parsedLight The JSON representation of the light
  10261. * @param scene The scene to create the parsed light in
  10262. * @returns the created light after parsing
  10263. */
  10264. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10265. private _hookArrayForExcluded;
  10266. private _hookArrayForIncludedOnly;
  10267. private _resyncMeshes;
  10268. /**
  10269. * Forces the meshes to update their light related information in their rendering used effects
  10270. * @hidden Internal Use Only
  10271. */
  10272. _markMeshesAsLightDirty(): void;
  10273. /**
  10274. * Recomputes the cached photometric scale if needed.
  10275. */
  10276. private _computePhotometricScale;
  10277. /**
  10278. * Returns the Photometric Scale according to the light type and intensity mode.
  10279. */
  10280. private _getPhotometricScale;
  10281. /**
  10282. * Reorder the light in the scene according to their defined priority.
  10283. * @hidden Internal Use Only
  10284. */
  10285. _reorderLightsInScene(): void;
  10286. /**
  10287. * Prepares the list of defines specific to the light type.
  10288. * @param defines the list of defines
  10289. * @param lightIndex defines the index of the light for the effect
  10290. */
  10291. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10292. }
  10293. }
  10294. declare module "babylonjs/Actions/action" {
  10295. import { Observable } from "babylonjs/Misc/observable";
  10296. import { Condition } from "babylonjs/Actions/condition";
  10297. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10298. import { ActionManager } from "babylonjs/Actions/actionManager";
  10299. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10300. /**
  10301. * Interface used to define Action
  10302. */
  10303. export interface IAction {
  10304. /**
  10305. * Trigger for the action
  10306. */
  10307. trigger: number;
  10308. /** Options of the trigger */
  10309. triggerOptions: any;
  10310. /**
  10311. * Gets the trigger parameters
  10312. * @returns the trigger parameters
  10313. */
  10314. getTriggerParameter(): any;
  10315. /**
  10316. * Internal only - executes current action event
  10317. * @hidden
  10318. */
  10319. _executeCurrent(evt?: ActionEvent): void;
  10320. /**
  10321. * Serialize placeholder for child classes
  10322. * @param parent of child
  10323. * @returns the serialized object
  10324. */
  10325. serialize(parent: any): any;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. _prepare(): void;
  10331. /**
  10332. * Internal only - manager for action
  10333. * @hidden
  10334. */
  10335. _actionManager: AbstractActionManager;
  10336. /**
  10337. * Adds action to chain of actions, may be a DoNothingAction
  10338. * @param action defines the next action to execute
  10339. * @returns The action passed in
  10340. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10341. */
  10342. then(action: IAction): IAction;
  10343. }
  10344. /**
  10345. * The action to be carried out following a trigger
  10346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10347. */
  10348. export class Action implements IAction {
  10349. /** the trigger, with or without parameters, for the action */
  10350. triggerOptions: any;
  10351. /**
  10352. * Trigger for the action
  10353. */
  10354. trigger: number;
  10355. /**
  10356. * Internal only - manager for action
  10357. * @hidden
  10358. */
  10359. _actionManager: ActionManager;
  10360. private _nextActiveAction;
  10361. private _child;
  10362. private _condition?;
  10363. private _triggerParameter;
  10364. /**
  10365. * An event triggered prior to action being executed.
  10366. */
  10367. onBeforeExecuteObservable: Observable<Action>;
  10368. /**
  10369. * Creates a new Action
  10370. * @param triggerOptions the trigger, with or without parameters, for the action
  10371. * @param condition an optional determinant of action
  10372. */
  10373. constructor(
  10374. /** the trigger, with or without parameters, for the action */
  10375. triggerOptions: any, condition?: Condition);
  10376. /**
  10377. * Internal only
  10378. * @hidden
  10379. */
  10380. _prepare(): void;
  10381. /**
  10382. * Gets the trigger parameters
  10383. * @returns the trigger parameters
  10384. */
  10385. getTriggerParameter(): any;
  10386. /**
  10387. * Internal only - executes current action event
  10388. * @hidden
  10389. */
  10390. _executeCurrent(evt?: ActionEvent): void;
  10391. /**
  10392. * Execute placeholder for child classes
  10393. * @param evt optional action event
  10394. */
  10395. execute(evt?: ActionEvent): void;
  10396. /**
  10397. * Skips to next active action
  10398. */
  10399. skipToNextActiveAction(): void;
  10400. /**
  10401. * Adds action to chain of actions, may be a DoNothingAction
  10402. * @param action defines the next action to execute
  10403. * @returns The action passed in
  10404. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10405. */
  10406. then(action: Action): Action;
  10407. /**
  10408. * Internal only
  10409. * @hidden
  10410. */
  10411. _getProperty(propertyPath: string): string;
  10412. /**
  10413. * Internal only
  10414. * @hidden
  10415. */
  10416. _getEffectiveTarget(target: any, propertyPath: string): any;
  10417. /**
  10418. * Serialize placeholder for child classes
  10419. * @param parent of child
  10420. * @returns the serialized object
  10421. */
  10422. serialize(parent: any): any;
  10423. /**
  10424. * Internal only called by serialize
  10425. * @hidden
  10426. */
  10427. protected _serialize(serializedAction: any, parent?: any): any;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. static _SerializeValueAsString: (value: any) => string;
  10433. /**
  10434. * Internal only
  10435. * @hidden
  10436. */
  10437. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10438. name: string;
  10439. targetType: string;
  10440. value: string;
  10441. };
  10442. }
  10443. }
  10444. declare module "babylonjs/Actions/condition" {
  10445. import { ActionManager } from "babylonjs/Actions/actionManager";
  10446. /**
  10447. * A Condition applied to an Action
  10448. */
  10449. export class Condition {
  10450. /**
  10451. * Internal only - manager for action
  10452. * @hidden
  10453. */
  10454. _actionManager: ActionManager;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _evaluationId: number;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _currentResult: boolean;
  10465. /**
  10466. * Creates a new Condition
  10467. * @param actionManager the manager of the action the condition is applied to
  10468. */
  10469. constructor(actionManager: ActionManager);
  10470. /**
  10471. * Check if the current condition is valid
  10472. * @returns a boolean
  10473. */
  10474. isValid(): boolean;
  10475. /**
  10476. * Internal only
  10477. * @hidden
  10478. */
  10479. _getProperty(propertyPath: string): string;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. _getEffectiveTarget(target: any, propertyPath: string): any;
  10485. /**
  10486. * Serialize placeholder for child classes
  10487. * @returns the serialized object
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Internal only
  10492. * @hidden
  10493. */
  10494. protected _serialize(serializedCondition: any): any;
  10495. }
  10496. /**
  10497. * Defines specific conditional operators as extensions of Condition
  10498. */
  10499. export class ValueCondition extends Condition {
  10500. /** path to specify the property of the target the conditional operator uses */
  10501. propertyPath: string;
  10502. /** the value compared by the conditional operator against the current value of the property */
  10503. value: any;
  10504. /** the conditional operator, default ValueCondition.IsEqual */
  10505. operator: number;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. private static _IsEqual;
  10511. /**
  10512. * Internal only
  10513. * @hidden
  10514. */
  10515. private static _IsDifferent;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. private static _IsGreater;
  10521. /**
  10522. * Internal only
  10523. * @hidden
  10524. */
  10525. private static _IsLesser;
  10526. /**
  10527. * returns the number for IsEqual
  10528. */
  10529. static readonly IsEqual: number;
  10530. /**
  10531. * Returns the number for IsDifferent
  10532. */
  10533. static readonly IsDifferent: number;
  10534. /**
  10535. * Returns the number for IsGreater
  10536. */
  10537. static readonly IsGreater: number;
  10538. /**
  10539. * Returns the number for IsLesser
  10540. */
  10541. static readonly IsLesser: number;
  10542. /**
  10543. * Internal only The action manager for the condition
  10544. * @hidden
  10545. */
  10546. _actionManager: ActionManager;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private _target;
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. private _effectiveTarget;
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. private _property;
  10562. /**
  10563. * Creates a new ValueCondition
  10564. * @param actionManager manager for the action the condition applies to
  10565. * @param target for the action
  10566. * @param propertyPath path to specify the property of the target the conditional operator uses
  10567. * @param value the value compared by the conditional operator against the current value of the property
  10568. * @param operator the conditional operator, default ValueCondition.IsEqual
  10569. */
  10570. constructor(actionManager: ActionManager, target: any,
  10571. /** path to specify the property of the target the conditional operator uses */
  10572. propertyPath: string,
  10573. /** the value compared by the conditional operator against the current value of the property */
  10574. value: any,
  10575. /** the conditional operator, default ValueCondition.IsEqual */
  10576. operator?: number);
  10577. /**
  10578. * Compares the given value with the property value for the specified conditional operator
  10579. * @returns the result of the comparison
  10580. */
  10581. isValid(): boolean;
  10582. /**
  10583. * Serialize the ValueCondition into a JSON compatible object
  10584. * @returns serialization object
  10585. */
  10586. serialize(): any;
  10587. /**
  10588. * Gets the name of the conditional operator for the ValueCondition
  10589. * @param operator the conditional operator
  10590. * @returns the name
  10591. */
  10592. static GetOperatorName(operator: number): string;
  10593. }
  10594. /**
  10595. * Defines a predicate condition as an extension of Condition
  10596. */
  10597. export class PredicateCondition extends Condition {
  10598. /** defines the predicate function used to validate the condition */
  10599. predicate: () => boolean;
  10600. /**
  10601. * Internal only - manager for action
  10602. * @hidden
  10603. */
  10604. _actionManager: ActionManager;
  10605. /**
  10606. * Creates a new PredicateCondition
  10607. * @param actionManager manager for the action the condition applies to
  10608. * @param predicate defines the predicate function used to validate the condition
  10609. */
  10610. constructor(actionManager: ActionManager,
  10611. /** defines the predicate function used to validate the condition */
  10612. predicate: () => boolean);
  10613. /**
  10614. * @returns the validity of the predicate condition
  10615. */
  10616. isValid(): boolean;
  10617. }
  10618. /**
  10619. * Defines a state condition as an extension of Condition
  10620. */
  10621. export class StateCondition extends Condition {
  10622. /** Value to compare with target state */
  10623. value: string;
  10624. /**
  10625. * Internal only - manager for action
  10626. * @hidden
  10627. */
  10628. _actionManager: ActionManager;
  10629. /**
  10630. * Internal only
  10631. * @hidden
  10632. */
  10633. private _target;
  10634. /**
  10635. * Creates a new StateCondition
  10636. * @param actionManager manager for the action the condition applies to
  10637. * @param target of the condition
  10638. * @param value to compare with target state
  10639. */
  10640. constructor(actionManager: ActionManager, target: any,
  10641. /** Value to compare with target state */
  10642. value: string);
  10643. /**
  10644. * Gets a boolean indicating if the current condition is met
  10645. * @returns the validity of the state
  10646. */
  10647. isValid(): boolean;
  10648. /**
  10649. * Serialize the StateCondition into a JSON compatible object
  10650. * @returns serialization object
  10651. */
  10652. serialize(): any;
  10653. }
  10654. }
  10655. declare module "babylonjs/Actions/directActions" {
  10656. import { Action } from "babylonjs/Actions/action";
  10657. import { Condition } from "babylonjs/Actions/condition";
  10658. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10659. /**
  10660. * This defines an action responsible to toggle a boolean once triggered.
  10661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10662. */
  10663. export class SwitchBooleanAction extends Action {
  10664. /**
  10665. * The path to the boolean property in the target object
  10666. */
  10667. propertyPath: string;
  10668. private _target;
  10669. private _effectiveTarget;
  10670. private _property;
  10671. /**
  10672. * Instantiate the action
  10673. * @param triggerOptions defines the trigger options
  10674. * @param target defines the object containing the boolean
  10675. * @param propertyPath defines the path to the boolean property in the target object
  10676. * @param condition defines the trigger related conditions
  10677. */
  10678. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10679. /** @hidden */
  10680. _prepare(): void;
  10681. /**
  10682. * Execute the action toggle the boolean value.
  10683. */
  10684. execute(): void;
  10685. /**
  10686. * Serializes the actions and its related information.
  10687. * @param parent defines the object to serialize in
  10688. * @returns the serialized object
  10689. */
  10690. serialize(parent: any): any;
  10691. }
  10692. /**
  10693. * This defines an action responsible to set a the state field of the target
  10694. * to a desired value once triggered.
  10695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10696. */
  10697. export class SetStateAction extends Action {
  10698. /**
  10699. * The value to store in the state field.
  10700. */
  10701. value: string;
  10702. private _target;
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param target defines the object containing the state property
  10707. * @param value defines the value to store in the state field
  10708. * @param condition defines the trigger related conditions
  10709. */
  10710. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10711. /**
  10712. * Execute the action and store the value on the target state property.
  10713. */
  10714. execute(): void;
  10715. /**
  10716. * Serializes the actions and its related information.
  10717. * @param parent defines the object to serialize in
  10718. * @returns the serialized object
  10719. */
  10720. serialize(parent: any): any;
  10721. }
  10722. /**
  10723. * This defines an action responsible to set a property of the target
  10724. * to a desired value once triggered.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class SetValueAction extends Action {
  10728. /**
  10729. * The path of the property to set in the target.
  10730. */
  10731. propertyPath: string;
  10732. /**
  10733. * The value to set in the property
  10734. */
  10735. value: any;
  10736. private _target;
  10737. private _effectiveTarget;
  10738. private _property;
  10739. /**
  10740. * Instantiate the action
  10741. * @param triggerOptions defines the trigger options
  10742. * @param target defines the object containing the property
  10743. * @param propertyPath defines the path of the property to set in the target
  10744. * @param value defines the value to set in the property
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10748. /** @hidden */
  10749. _prepare(): void;
  10750. /**
  10751. * Execute the action and set the targetted property to the desired value.
  10752. */
  10753. execute(): void;
  10754. /**
  10755. * Serializes the actions and its related information.
  10756. * @param parent defines the object to serialize in
  10757. * @returns the serialized object
  10758. */
  10759. serialize(parent: any): any;
  10760. }
  10761. /**
  10762. * This defines an action responsible to increment the target value
  10763. * to a desired value once triggered.
  10764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10765. */
  10766. export class IncrementValueAction extends Action {
  10767. /**
  10768. * The path of the property to increment in the target.
  10769. */
  10770. propertyPath: string;
  10771. /**
  10772. * The value we should increment the property by.
  10773. */
  10774. value: any;
  10775. private _target;
  10776. private _effectiveTarget;
  10777. private _property;
  10778. /**
  10779. * Instantiate the action
  10780. * @param triggerOptions defines the trigger options
  10781. * @param target defines the object containing the property
  10782. * @param propertyPath defines the path of the property to increment in the target
  10783. * @param value defines the value value we should increment the property by
  10784. * @param condition defines the trigger related conditions
  10785. */
  10786. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10787. /** @hidden */
  10788. _prepare(): void;
  10789. /**
  10790. * Execute the action and increment the target of the value amount.
  10791. */
  10792. execute(): void;
  10793. /**
  10794. * Serializes the actions and its related information.
  10795. * @param parent defines the object to serialize in
  10796. * @returns the serialized object
  10797. */
  10798. serialize(parent: any): any;
  10799. }
  10800. /**
  10801. * This defines an action responsible to start an animation once triggered.
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10803. */
  10804. export class PlayAnimationAction extends Action {
  10805. /**
  10806. * Where the animation should start (animation frame)
  10807. */
  10808. from: number;
  10809. /**
  10810. * Where the animation should stop (animation frame)
  10811. */
  10812. to: number;
  10813. /**
  10814. * Define if the animation should loop or stop after the first play.
  10815. */
  10816. loop?: boolean;
  10817. private _target;
  10818. /**
  10819. * Instantiate the action
  10820. * @param triggerOptions defines the trigger options
  10821. * @param target defines the target animation or animation name
  10822. * @param from defines from where the animation should start (animation frame)
  10823. * @param end defines where the animation should stop (animation frame)
  10824. * @param loop defines if the animation should loop or stop after the first play
  10825. * @param condition defines the trigger related conditions
  10826. */
  10827. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10828. /** @hidden */
  10829. _prepare(): void;
  10830. /**
  10831. * Execute the action and play the animation.
  10832. */
  10833. execute(): void;
  10834. /**
  10835. * Serializes the actions and its related information.
  10836. * @param parent defines the object to serialize in
  10837. * @returns the serialized object
  10838. */
  10839. serialize(parent: any): any;
  10840. }
  10841. /**
  10842. * This defines an action responsible to stop an animation once triggered.
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10844. */
  10845. export class StopAnimationAction extends Action {
  10846. private _target;
  10847. /**
  10848. * Instantiate the action
  10849. * @param triggerOptions defines the trigger options
  10850. * @param target defines the target animation or animation name
  10851. * @param condition defines the trigger related conditions
  10852. */
  10853. constructor(triggerOptions: any, target: any, condition?: Condition);
  10854. /** @hidden */
  10855. _prepare(): void;
  10856. /**
  10857. * Execute the action and stop the animation.
  10858. */
  10859. execute(): void;
  10860. /**
  10861. * Serializes the actions and its related information.
  10862. * @param parent defines the object to serialize in
  10863. * @returns the serialized object
  10864. */
  10865. serialize(parent: any): any;
  10866. }
  10867. /**
  10868. * This defines an action responsible that does nothing once triggered.
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10870. */
  10871. export class DoNothingAction extends Action {
  10872. /**
  10873. * Instantiate the action
  10874. * @param triggerOptions defines the trigger options
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions?: any, condition?: Condition);
  10878. /**
  10879. * Execute the action and do nothing.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to trigger several actions once triggered.
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10892. */
  10893. export class CombineAction extends Action {
  10894. /**
  10895. * The list of aggregated animations to run.
  10896. */
  10897. children: Action[];
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param children defines the list of aggregated animations to run
  10902. * @param condition defines the trigger related conditions
  10903. */
  10904. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10905. /** @hidden */
  10906. _prepare(): void;
  10907. /**
  10908. * Execute the action and executes all the aggregated actions.
  10909. */
  10910. execute(evt: ActionEvent): void;
  10911. /**
  10912. * Serializes the actions and its related information.
  10913. * @param parent defines the object to serialize in
  10914. * @returns the serialized object
  10915. */
  10916. serialize(parent: any): any;
  10917. }
  10918. /**
  10919. * This defines an action responsible to run code (external event) once triggered.
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10921. */
  10922. export class ExecuteCodeAction extends Action {
  10923. /**
  10924. * The callback function to run.
  10925. */
  10926. func: (evt: ActionEvent) => void;
  10927. /**
  10928. * Instantiate the action
  10929. * @param triggerOptions defines the trigger options
  10930. * @param func defines the callback function to run
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10934. /**
  10935. * Execute the action and run the attached code.
  10936. */
  10937. execute(evt: ActionEvent): void;
  10938. }
  10939. /**
  10940. * This defines an action responsible to set the parent property of the target once triggered.
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10942. */
  10943. export class SetParentAction extends Action {
  10944. private _parent;
  10945. private _target;
  10946. /**
  10947. * Instantiate the action
  10948. * @param triggerOptions defines the trigger options
  10949. * @param target defines the target containing the parent property
  10950. * @param parent defines from where the animation should start (animation frame)
  10951. * @param condition defines the trigger related conditions
  10952. */
  10953. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10954. /** @hidden */
  10955. _prepare(): void;
  10956. /**
  10957. * Execute the action and set the parent property.
  10958. */
  10959. execute(): void;
  10960. /**
  10961. * Serializes the actions and its related information.
  10962. * @param parent defines the object to serialize in
  10963. * @returns the serialized object
  10964. */
  10965. serialize(parent: any): any;
  10966. }
  10967. }
  10968. declare module "babylonjs/Actions/actionManager" {
  10969. import { Nullable } from "babylonjs/types";
  10970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10971. import { Scene } from "babylonjs/scene";
  10972. import { IAction } from "babylonjs/Actions/action";
  10973. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10974. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10975. /**
  10976. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10977. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10979. */
  10980. export class ActionManager extends AbstractActionManager {
  10981. /**
  10982. * Nothing
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly NothingTrigger: number;
  10986. /**
  10987. * On pick
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnPickTrigger: number;
  10991. /**
  10992. * On left pick
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnLeftPickTrigger: number;
  10996. /**
  10997. * On right pick
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnRightPickTrigger: number;
  11001. /**
  11002. * On center pick
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnCenterPickTrigger: number;
  11006. /**
  11007. * On pick down
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnPickDownTrigger: number;
  11011. /**
  11012. * On double pick
  11013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11014. */
  11015. static readonly OnDoublePickTrigger: number;
  11016. /**
  11017. * On pick up
  11018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11019. */
  11020. static readonly OnPickUpTrigger: number;
  11021. /**
  11022. * On pick out.
  11023. * This trigger will only be raised if you also declared a OnPickDown
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly OnPickOutTrigger: number;
  11027. /**
  11028. * On long press
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnLongPressTrigger: number;
  11032. /**
  11033. * On pointer over
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnPointerOverTrigger: number;
  11037. /**
  11038. * On pointer out
  11039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11040. */
  11041. static readonly OnPointerOutTrigger: number;
  11042. /**
  11043. * On every frame
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11045. */
  11046. static readonly OnEveryFrameTrigger: number;
  11047. /**
  11048. * On intersection enter
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11050. */
  11051. static readonly OnIntersectionEnterTrigger: number;
  11052. /**
  11053. * On intersection exit
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11055. */
  11056. static readonly OnIntersectionExitTrigger: number;
  11057. /**
  11058. * On key down
  11059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11060. */
  11061. static readonly OnKeyDownTrigger: number;
  11062. /**
  11063. * On key up
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11065. */
  11066. static readonly OnKeyUpTrigger: number;
  11067. private _scene;
  11068. /**
  11069. * Creates a new action manager
  11070. * @param scene defines the hosting scene
  11071. */
  11072. constructor(scene: Scene);
  11073. /**
  11074. * Releases all associated resources
  11075. */
  11076. dispose(): void;
  11077. /**
  11078. * Gets hosting scene
  11079. * @returns the hosting scene
  11080. */
  11081. getScene(): Scene;
  11082. /**
  11083. * Does this action manager handles actions of any of the given triggers
  11084. * @param triggers defines the triggers to be tested
  11085. * @return a boolean indicating whether one (or more) of the triggers is handled
  11086. */
  11087. hasSpecificTriggers(triggers: number[]): boolean;
  11088. /**
  11089. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11090. * speed.
  11091. * @param triggerA defines the trigger to be tested
  11092. * @param triggerB defines the trigger to be tested
  11093. * @return a boolean indicating whether one (or more) of the triggers is handled
  11094. */
  11095. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11096. /**
  11097. * Does this action manager handles actions of a given trigger
  11098. * @param trigger defines the trigger to be tested
  11099. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11100. * @return whether the trigger is handled
  11101. */
  11102. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11103. /**
  11104. * Does this action manager has pointer triggers
  11105. */
  11106. readonly hasPointerTriggers: boolean;
  11107. /**
  11108. * Does this action manager has pick triggers
  11109. */
  11110. readonly hasPickTriggers: boolean;
  11111. /**
  11112. * Registers an action to this action manager
  11113. * @param action defines the action to be registered
  11114. * @return the action amended (prepared) after registration
  11115. */
  11116. registerAction(action: IAction): Nullable<IAction>;
  11117. /**
  11118. * Unregisters an action to this action manager
  11119. * @param action defines the action to be unregistered
  11120. * @return a boolean indicating whether the action has been unregistered
  11121. */
  11122. unregisterAction(action: IAction): Boolean;
  11123. /**
  11124. * Process a specific trigger
  11125. * @param trigger defines the trigger to process
  11126. * @param evt defines the event details to be processed
  11127. */
  11128. processTrigger(trigger: number, evt?: IActionEvent): void;
  11129. /** @hidden */
  11130. _getEffectiveTarget(target: any, propertyPath: string): any;
  11131. /** @hidden */
  11132. _getProperty(propertyPath: string): string;
  11133. /**
  11134. * Serialize this manager to a JSON object
  11135. * @param name defines the property name to store this manager
  11136. * @returns a JSON representation of this manager
  11137. */
  11138. serialize(name: string): any;
  11139. /**
  11140. * Creates a new ActionManager from a JSON data
  11141. * @param parsedActions defines the JSON data to read from
  11142. * @param object defines the hosting mesh
  11143. * @param scene defines the hosting scene
  11144. */
  11145. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11146. /**
  11147. * Get a trigger name by index
  11148. * @param trigger defines the trigger index
  11149. * @returns a trigger name
  11150. */
  11151. static GetTriggerName(trigger: number): string;
  11152. }
  11153. }
  11154. declare module "babylonjs/Culling/ray" {
  11155. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11156. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11158. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11159. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11160. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11161. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11162. import { Plane } from "babylonjs/Maths/math.plane";
  11163. /**
  11164. * Class representing a ray with position and direction
  11165. */
  11166. export class Ray {
  11167. /** origin point */
  11168. origin: Vector3;
  11169. /** direction */
  11170. direction: Vector3;
  11171. /** length of the ray */
  11172. length: number;
  11173. private static readonly TmpVector3;
  11174. private _tmpRay;
  11175. /**
  11176. * Creates a new ray
  11177. * @param origin origin point
  11178. * @param direction direction
  11179. * @param length length of the ray
  11180. */
  11181. constructor(
  11182. /** origin point */
  11183. origin: Vector3,
  11184. /** direction */
  11185. direction: Vector3,
  11186. /** length of the ray */
  11187. length?: number);
  11188. /**
  11189. * Checks if the ray intersects a box
  11190. * @param minimum bound of the box
  11191. * @param maximum bound of the box
  11192. * @param intersectionTreshold extra extend to be added to the box in all direction
  11193. * @returns if the box was hit
  11194. */
  11195. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11196. /**
  11197. * Checks if the ray intersects a box
  11198. * @param box the bounding box to check
  11199. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11200. * @returns if the box was hit
  11201. */
  11202. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11203. /**
  11204. * If the ray hits a sphere
  11205. * @param sphere the bounding sphere to check
  11206. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11207. * @returns true if it hits the sphere
  11208. */
  11209. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11210. /**
  11211. * If the ray hits a triange
  11212. * @param vertex0 triangle vertex
  11213. * @param vertex1 triangle vertex
  11214. * @param vertex2 triangle vertex
  11215. * @returns intersection information if hit
  11216. */
  11217. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11218. /**
  11219. * Checks if ray intersects a plane
  11220. * @param plane the plane to check
  11221. * @returns the distance away it was hit
  11222. */
  11223. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11224. /**
  11225. * Calculate the intercept of a ray on a given axis
  11226. * @param axis to check 'x' | 'y' | 'z'
  11227. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11228. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11229. */
  11230. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11231. /**
  11232. * Checks if ray intersects a mesh
  11233. * @param mesh the mesh to check
  11234. * @param fastCheck if only the bounding box should checked
  11235. * @returns picking info of the intersecton
  11236. */
  11237. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11238. /**
  11239. * Checks if ray intersects a mesh
  11240. * @param meshes the meshes to check
  11241. * @param fastCheck if only the bounding box should checked
  11242. * @param results array to store result in
  11243. * @returns Array of picking infos
  11244. */
  11245. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11246. private _comparePickingInfo;
  11247. private static smallnum;
  11248. private static rayl;
  11249. /**
  11250. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11251. * @param sega the first point of the segment to test the intersection against
  11252. * @param segb the second point of the segment to test the intersection against
  11253. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11254. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11255. */
  11256. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11257. /**
  11258. * Update the ray from viewport position
  11259. * @param x position
  11260. * @param y y position
  11261. * @param viewportWidth viewport width
  11262. * @param viewportHeight viewport height
  11263. * @param world world matrix
  11264. * @param view view matrix
  11265. * @param projection projection matrix
  11266. * @returns this ray updated
  11267. */
  11268. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11269. /**
  11270. * Creates a ray with origin and direction of 0,0,0
  11271. * @returns the new ray
  11272. */
  11273. static Zero(): Ray;
  11274. /**
  11275. * Creates a new ray from screen space and viewport
  11276. * @param x position
  11277. * @param y y position
  11278. * @param viewportWidth viewport width
  11279. * @param viewportHeight viewport height
  11280. * @param world world matrix
  11281. * @param view view matrix
  11282. * @param projection projection matrix
  11283. * @returns new ray
  11284. */
  11285. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11286. /**
  11287. * 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
  11288. * transformed to the given world matrix.
  11289. * @param origin The origin point
  11290. * @param end The end point
  11291. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11292. * @returns the new ray
  11293. */
  11294. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11295. /**
  11296. * Transforms a ray by a matrix
  11297. * @param ray ray to transform
  11298. * @param matrix matrix to apply
  11299. * @returns the resulting new ray
  11300. */
  11301. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11302. /**
  11303. * Transforms a ray by a matrix
  11304. * @param ray ray to transform
  11305. * @param matrix matrix to apply
  11306. * @param result ray to store result in
  11307. */
  11308. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11309. /**
  11310. * Unproject a ray from screen space to object space
  11311. * @param sourceX defines the screen space x coordinate to use
  11312. * @param sourceY defines the screen space y coordinate to use
  11313. * @param viewportWidth defines the current width of the viewport
  11314. * @param viewportHeight defines the current height of the viewport
  11315. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11316. * @param view defines the view matrix to use
  11317. * @param projection defines the projection matrix to use
  11318. */
  11319. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11320. }
  11321. /**
  11322. * Type used to define predicate used to select faces when a mesh intersection is detected
  11323. */
  11324. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11325. module "babylonjs/scene" {
  11326. interface Scene {
  11327. /** @hidden */
  11328. _tempPickingRay: Nullable<Ray>;
  11329. /** @hidden */
  11330. _cachedRayForTransform: Ray;
  11331. /** @hidden */
  11332. _pickWithRayInverseMatrix: Matrix;
  11333. /** @hidden */
  11334. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11335. /** @hidden */
  11336. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11337. }
  11338. }
  11339. }
  11340. declare module "babylonjs/sceneComponent" {
  11341. import { Scene } from "babylonjs/scene";
  11342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11344. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11345. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11346. import { Nullable } from "babylonjs/types";
  11347. import { Camera } from "babylonjs/Cameras/camera";
  11348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11349. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11350. import { AbstractScene } from "babylonjs/abstractScene";
  11351. /**
  11352. * Groups all the scene component constants in one place to ease maintenance.
  11353. * @hidden
  11354. */
  11355. export class SceneComponentConstants {
  11356. static readonly NAME_EFFECTLAYER: string;
  11357. static readonly NAME_LAYER: string;
  11358. static readonly NAME_LENSFLARESYSTEM: string;
  11359. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11360. static readonly NAME_PARTICLESYSTEM: string;
  11361. static readonly NAME_GAMEPAD: string;
  11362. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11363. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11364. static readonly NAME_DEPTHRENDERER: string;
  11365. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11366. static readonly NAME_SPRITE: string;
  11367. static readonly NAME_OUTLINERENDERER: string;
  11368. static readonly NAME_PROCEDURALTEXTURE: string;
  11369. static readonly NAME_SHADOWGENERATOR: string;
  11370. static readonly NAME_OCTREE: string;
  11371. static readonly NAME_PHYSICSENGINE: string;
  11372. static readonly NAME_AUDIO: string;
  11373. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11374. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11375. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11376. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11377. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11378. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11379. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11380. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11381. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11382. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11383. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11384. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11385. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11386. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11387. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11388. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11389. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11390. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11391. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11392. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11393. static readonly STEP_AFTERRENDER_AUDIO: number;
  11394. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11395. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11396. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11397. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11398. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11399. static readonly STEP_POINTERMOVE_SPRITE: number;
  11400. static readonly STEP_POINTERDOWN_SPRITE: number;
  11401. static readonly STEP_POINTERUP_SPRITE: number;
  11402. }
  11403. /**
  11404. * This represents a scene component.
  11405. *
  11406. * This is used to decouple the dependency the scene is having on the different workloads like
  11407. * layers, post processes...
  11408. */
  11409. export interface ISceneComponent {
  11410. /**
  11411. * The name of the component. Each component must have a unique name.
  11412. */
  11413. name: string;
  11414. /**
  11415. * The scene the component belongs to.
  11416. */
  11417. scene: Scene;
  11418. /**
  11419. * Register the component to one instance of a scene.
  11420. */
  11421. register(): void;
  11422. /**
  11423. * Rebuilds the elements related to this component in case of
  11424. * context lost for instance.
  11425. */
  11426. rebuild(): void;
  11427. /**
  11428. * Disposes the component and the associated ressources.
  11429. */
  11430. dispose(): void;
  11431. }
  11432. /**
  11433. * This represents a SERIALIZABLE scene component.
  11434. *
  11435. * This extends Scene Component to add Serialization methods on top.
  11436. */
  11437. export interface ISceneSerializableComponent extends ISceneComponent {
  11438. /**
  11439. * Adds all the elements from the container to the scene
  11440. * @param container the container holding the elements
  11441. */
  11442. addFromContainer(container: AbstractScene): void;
  11443. /**
  11444. * Removes all the elements in the container from the scene
  11445. * @param container contains the elements to remove
  11446. * @param dispose if the removed element should be disposed (default: false)
  11447. */
  11448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11449. /**
  11450. * Serializes the component data to the specified json object
  11451. * @param serializationObject The object to serialize to
  11452. */
  11453. serialize(serializationObject: any): void;
  11454. }
  11455. /**
  11456. * Strong typing of a Mesh related stage step action
  11457. */
  11458. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11459. /**
  11460. * Strong typing of a Evaluate Sub Mesh related stage step action
  11461. */
  11462. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11463. /**
  11464. * Strong typing of a Active Mesh related stage step action
  11465. */
  11466. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11467. /**
  11468. * Strong typing of a Camera related stage step action
  11469. */
  11470. export type CameraStageAction = (camera: Camera) => void;
  11471. /**
  11472. * Strong typing of a Camera Frame buffer related stage step action
  11473. */
  11474. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11475. /**
  11476. * Strong typing of a Render Target related stage step action
  11477. */
  11478. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11479. /**
  11480. * Strong typing of a RenderingGroup related stage step action
  11481. */
  11482. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11483. /**
  11484. * Strong typing of a Mesh Render related stage step action
  11485. */
  11486. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11487. /**
  11488. * Strong typing of a simple stage step action
  11489. */
  11490. export type SimpleStageAction = () => void;
  11491. /**
  11492. * Strong typing of a render target action.
  11493. */
  11494. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11495. /**
  11496. * Strong typing of a pointer move action.
  11497. */
  11498. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11499. /**
  11500. * Strong typing of a pointer up/down action.
  11501. */
  11502. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11503. /**
  11504. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11505. * @hidden
  11506. */
  11507. export class Stage<T extends Function> extends Array<{
  11508. index: number;
  11509. component: ISceneComponent;
  11510. action: T;
  11511. }> {
  11512. /**
  11513. * Hide ctor from the rest of the world.
  11514. * @param items The items to add.
  11515. */
  11516. private constructor();
  11517. /**
  11518. * Creates a new Stage.
  11519. * @returns A new instance of a Stage
  11520. */
  11521. static Create<T extends Function>(): Stage<T>;
  11522. /**
  11523. * Registers a step in an ordered way in the targeted stage.
  11524. * @param index Defines the position to register the step in
  11525. * @param component Defines the component attached to the step
  11526. * @param action Defines the action to launch during the step
  11527. */
  11528. registerStep(index: number, component: ISceneComponent, action: T): void;
  11529. /**
  11530. * Clears all the steps from the stage.
  11531. */
  11532. clear(): void;
  11533. }
  11534. }
  11535. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11536. import { Nullable } from "babylonjs/types";
  11537. import { Observable } from "babylonjs/Misc/observable";
  11538. import { Scene } from "babylonjs/scene";
  11539. import { Sprite } from "babylonjs/Sprites/sprite";
  11540. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11541. import { Ray } from "babylonjs/Culling/ray";
  11542. import { Camera } from "babylonjs/Cameras/camera";
  11543. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11544. import { ISceneComponent } from "babylonjs/sceneComponent";
  11545. module "babylonjs/scene" {
  11546. interface Scene {
  11547. /** @hidden */
  11548. _pointerOverSprite: Nullable<Sprite>;
  11549. /** @hidden */
  11550. _pickedDownSprite: Nullable<Sprite>;
  11551. /** @hidden */
  11552. _tempSpritePickingRay: Nullable<Ray>;
  11553. /**
  11554. * All of the sprite managers added to this scene
  11555. * @see http://doc.babylonjs.com/babylon101/sprites
  11556. */
  11557. spriteManagers: Array<ISpriteManager>;
  11558. /**
  11559. * An event triggered when sprites rendering is about to start
  11560. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11561. */
  11562. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11563. /**
  11564. * An event triggered when sprites rendering is done
  11565. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11566. */
  11567. onAfterSpritesRenderingObservable: Observable<Scene>;
  11568. /** @hidden */
  11569. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11570. /** Launch a ray to try to pick a sprite in the scene
  11571. * @param x position on screen
  11572. * @param y position on screen
  11573. * @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
  11574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11575. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11576. * @returns a PickingInfo
  11577. */
  11578. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11579. /** Use the given ray to pick a sprite in the scene
  11580. * @param ray The ray (in world space) to use to pick meshes
  11581. * @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
  11582. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11583. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11584. * @returns a PickingInfo
  11585. */
  11586. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11587. /** @hidden */
  11588. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11589. /** Launch a ray to try to pick sprites in the scene
  11590. * @param x position on screen
  11591. * @param y position on screen
  11592. * @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
  11593. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11594. * @returns a PickingInfo array
  11595. */
  11596. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11597. /** Use the given ray to pick sprites in the scene
  11598. * @param ray The ray (in world space) to use to pick meshes
  11599. * @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
  11600. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11601. * @returns a PickingInfo array
  11602. */
  11603. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11604. /**
  11605. * Force the sprite under the pointer
  11606. * @param sprite defines the sprite to use
  11607. */
  11608. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11609. /**
  11610. * Gets the sprite under the pointer
  11611. * @returns a Sprite or null if no sprite is under the pointer
  11612. */
  11613. getPointerOverSprite(): Nullable<Sprite>;
  11614. }
  11615. }
  11616. /**
  11617. * Defines the sprite scene component responsible to manage sprites
  11618. * in a given scene.
  11619. */
  11620. export class SpriteSceneComponent implements ISceneComponent {
  11621. /**
  11622. * The component name helpfull to identify the component in the list of scene components.
  11623. */
  11624. readonly name: string;
  11625. /**
  11626. * The scene the component belongs to.
  11627. */
  11628. scene: Scene;
  11629. /** @hidden */
  11630. private _spritePredicate;
  11631. /**
  11632. * Creates a new instance of the component for the given scene
  11633. * @param scene Defines the scene to register the component in
  11634. */
  11635. constructor(scene: Scene);
  11636. /**
  11637. * Registers the component in a given scene
  11638. */
  11639. register(): void;
  11640. /**
  11641. * Rebuilds the elements related to this component in case of
  11642. * context lost for instance.
  11643. */
  11644. rebuild(): void;
  11645. /**
  11646. * Disposes the component and the associated ressources.
  11647. */
  11648. dispose(): void;
  11649. private _pickSpriteButKeepRay;
  11650. private _pointerMove;
  11651. private _pointerDown;
  11652. private _pointerUp;
  11653. }
  11654. }
  11655. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11656. /** @hidden */
  11657. export var fogFragmentDeclaration: {
  11658. name: string;
  11659. shader: string;
  11660. };
  11661. }
  11662. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11663. /** @hidden */
  11664. export var fogFragment: {
  11665. name: string;
  11666. shader: string;
  11667. };
  11668. }
  11669. declare module "babylonjs/Shaders/sprites.fragment" {
  11670. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11671. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11672. /** @hidden */
  11673. export var spritesPixelShader: {
  11674. name: string;
  11675. shader: string;
  11676. };
  11677. }
  11678. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11679. /** @hidden */
  11680. export var fogVertexDeclaration: {
  11681. name: string;
  11682. shader: string;
  11683. };
  11684. }
  11685. declare module "babylonjs/Shaders/sprites.vertex" {
  11686. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11687. /** @hidden */
  11688. export var spritesVertexShader: {
  11689. name: string;
  11690. shader: string;
  11691. };
  11692. }
  11693. declare module "babylonjs/Sprites/spriteManager" {
  11694. import { IDisposable, Scene } from "babylonjs/scene";
  11695. import { Nullable } from "babylonjs/types";
  11696. import { Observable } from "babylonjs/Misc/observable";
  11697. import { Sprite } from "babylonjs/Sprites/sprite";
  11698. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11699. import { Camera } from "babylonjs/Cameras/camera";
  11700. import { Texture } from "babylonjs/Materials/Textures/texture";
  11701. import "babylonjs/Shaders/sprites.fragment";
  11702. import "babylonjs/Shaders/sprites.vertex";
  11703. import { Ray } from "babylonjs/Culling/ray";
  11704. /**
  11705. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11706. */
  11707. export interface ISpriteManager extends IDisposable {
  11708. /**
  11709. * Restricts the camera to viewing objects with the same layerMask.
  11710. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11711. */
  11712. layerMask: number;
  11713. /**
  11714. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11715. */
  11716. isPickable: boolean;
  11717. /**
  11718. * Specifies the rendering group id for this mesh (0 by default)
  11719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11720. */
  11721. renderingGroupId: number;
  11722. /**
  11723. * Defines the list of sprites managed by the manager.
  11724. */
  11725. sprites: Array<Sprite>;
  11726. /**
  11727. * Tests the intersection of a sprite with a specific ray.
  11728. * @param ray The ray we are sending to test the collision
  11729. * @param camera The camera space we are sending rays in
  11730. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11731. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11732. * @returns picking info or null.
  11733. */
  11734. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11735. /**
  11736. * Intersects the sprites with a ray
  11737. * @param ray defines the ray to intersect with
  11738. * @param camera defines the current active camera
  11739. * @param predicate defines a predicate used to select candidate sprites
  11740. * @returns null if no hit or a PickingInfo array
  11741. */
  11742. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11743. /**
  11744. * Renders the list of sprites on screen.
  11745. */
  11746. render(): void;
  11747. }
  11748. /**
  11749. * Class used to manage multiple sprites on the same spritesheet
  11750. * @see http://doc.babylonjs.com/babylon101/sprites
  11751. */
  11752. export class SpriteManager implements ISpriteManager {
  11753. /** defines the manager's name */
  11754. name: string;
  11755. /** Gets the list of sprites */
  11756. sprites: Sprite[];
  11757. /** Gets or sets the rendering group id (0 by default) */
  11758. renderingGroupId: number;
  11759. /** Gets or sets camera layer mask */
  11760. layerMask: number;
  11761. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11762. fogEnabled: boolean;
  11763. /** Gets or sets a boolean indicating if the sprites are pickable */
  11764. isPickable: boolean;
  11765. /** Defines the default width of a cell in the spritesheet */
  11766. cellWidth: number;
  11767. /** Defines the default height of a cell in the spritesheet */
  11768. cellHeight: number;
  11769. /** Associative array from JSON sprite data file */
  11770. private _cellData;
  11771. /** Array of sprite names from JSON sprite data file */
  11772. private _spriteMap;
  11773. /** True when packed cell data from JSON file is ready*/
  11774. private _packedAndReady;
  11775. /**
  11776. * An event triggered when the manager is disposed.
  11777. */
  11778. onDisposeObservable: Observable<SpriteManager>;
  11779. private _onDisposeObserver;
  11780. /**
  11781. * Callback called when the manager is disposed
  11782. */
  11783. onDispose: () => void;
  11784. private _capacity;
  11785. private _fromPacked;
  11786. private _spriteTexture;
  11787. private _epsilon;
  11788. private _scene;
  11789. private _vertexData;
  11790. private _buffer;
  11791. private _vertexBuffers;
  11792. private _indexBuffer;
  11793. private _effectBase;
  11794. private _effectFog;
  11795. /**
  11796. * Gets or sets the spritesheet texture
  11797. */
  11798. texture: Texture;
  11799. /**
  11800. * Creates a new sprite manager
  11801. * @param name defines the manager's name
  11802. * @param imgUrl defines the sprite sheet url
  11803. * @param capacity defines the maximum allowed number of sprites
  11804. * @param cellSize defines the size of a sprite cell
  11805. * @param scene defines the hosting scene
  11806. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11807. * @param samplingMode defines the smapling mode to use with spritesheet
  11808. * @param fromPacked set to false; do not alter
  11809. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11810. */
  11811. constructor(
  11812. /** defines the manager's name */
  11813. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11814. private _makePacked;
  11815. private _appendSpriteVertex;
  11816. /**
  11817. * Intersects the sprites with a ray
  11818. * @param ray defines the ray to intersect with
  11819. * @param camera defines the current active camera
  11820. * @param predicate defines a predicate used to select candidate sprites
  11821. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11822. * @returns null if no hit or a PickingInfo
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Intersects the sprites with a ray
  11827. * @param ray defines the ray to intersect with
  11828. * @param camera defines the current active camera
  11829. * @param predicate defines a predicate used to select candidate sprites
  11830. * @returns null if no hit or a PickingInfo array
  11831. */
  11832. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11833. /**
  11834. * Render all child sprites
  11835. */
  11836. render(): void;
  11837. /**
  11838. * Release associated resources
  11839. */
  11840. dispose(): void;
  11841. }
  11842. }
  11843. declare module "babylonjs/Sprites/sprite" {
  11844. import { Vector3 } from "babylonjs/Maths/math.vector";
  11845. import { Nullable } from "babylonjs/types";
  11846. import { ActionManager } from "babylonjs/Actions/actionManager";
  11847. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11848. import { Color4 } from "babylonjs/Maths/math.color";
  11849. /**
  11850. * Class used to represent a sprite
  11851. * @see http://doc.babylonjs.com/babylon101/sprites
  11852. */
  11853. export class Sprite {
  11854. /** defines the name */
  11855. name: string;
  11856. /** Gets or sets the current world position */
  11857. position: Vector3;
  11858. /** Gets or sets the main color */
  11859. color: Color4;
  11860. /** Gets or sets the width */
  11861. width: number;
  11862. /** Gets or sets the height */
  11863. height: number;
  11864. /** Gets or sets rotation angle */
  11865. angle: number;
  11866. /** Gets or sets the cell index in the sprite sheet */
  11867. cellIndex: number;
  11868. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11869. cellRef: string;
  11870. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11871. invertU: number;
  11872. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11873. invertV: number;
  11874. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11875. disposeWhenFinishedAnimating: boolean;
  11876. /** Gets the list of attached animations */
  11877. animations: Animation[];
  11878. /** Gets or sets a boolean indicating if the sprite can be picked */
  11879. isPickable: boolean;
  11880. /**
  11881. * Gets or sets the associated action manager
  11882. */
  11883. actionManager: Nullable<ActionManager>;
  11884. private _animationStarted;
  11885. private _loopAnimation;
  11886. private _fromIndex;
  11887. private _toIndex;
  11888. private _delay;
  11889. private _direction;
  11890. private _manager;
  11891. private _time;
  11892. private _onAnimationEnd;
  11893. /**
  11894. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11895. */
  11896. isVisible: boolean;
  11897. /**
  11898. * Gets or sets the sprite size
  11899. */
  11900. size: number;
  11901. /**
  11902. * Creates a new Sprite
  11903. * @param name defines the name
  11904. * @param manager defines the manager
  11905. */
  11906. constructor(
  11907. /** defines the name */
  11908. name: string, manager: ISpriteManager);
  11909. /**
  11910. * Starts an animation
  11911. * @param from defines the initial key
  11912. * @param to defines the end key
  11913. * @param loop defines if the animation must loop
  11914. * @param delay defines the start delay (in ms)
  11915. * @param onAnimationEnd defines a callback to call when animation ends
  11916. */
  11917. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11918. /** Stops current animation (if any) */
  11919. stopAnimation(): void;
  11920. /** @hidden */
  11921. _animate(deltaTime: number): void;
  11922. /** Release associated resources */
  11923. dispose(): void;
  11924. }
  11925. }
  11926. declare module "babylonjs/Collisions/pickingInfo" {
  11927. import { Nullable } from "babylonjs/types";
  11928. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11930. import { Sprite } from "babylonjs/Sprites/sprite";
  11931. import { Ray } from "babylonjs/Culling/ray";
  11932. /**
  11933. * Information about the result of picking within a scene
  11934. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11935. */
  11936. export class PickingInfo {
  11937. /** @hidden */
  11938. _pickingUnavailable: boolean;
  11939. /**
  11940. * If the pick collided with an object
  11941. */
  11942. hit: boolean;
  11943. /**
  11944. * Distance away where the pick collided
  11945. */
  11946. distance: number;
  11947. /**
  11948. * The location of pick collision
  11949. */
  11950. pickedPoint: Nullable<Vector3>;
  11951. /**
  11952. * The mesh corresponding the the pick collision
  11953. */
  11954. pickedMesh: Nullable<AbstractMesh>;
  11955. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11956. bu: number;
  11957. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11958. bv: number;
  11959. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11960. faceId: number;
  11961. /** Id of the the submesh that was picked */
  11962. subMeshId: number;
  11963. /** If a sprite was picked, this will be the sprite the pick collided with */
  11964. pickedSprite: Nullable<Sprite>;
  11965. /**
  11966. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11967. */
  11968. originMesh: Nullable<AbstractMesh>;
  11969. /**
  11970. * The ray that was used to perform the picking.
  11971. */
  11972. ray: Nullable<Ray>;
  11973. /**
  11974. * Gets the normal correspodning to the face the pick collided with
  11975. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11976. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11977. * @returns The normal correspodning to the face the pick collided with
  11978. */
  11979. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11980. /**
  11981. * Gets the texture coordinates of where the pick occured
  11982. * @returns the vector containing the coordnates of the texture
  11983. */
  11984. getTextureCoordinates(): Nullable<Vector2>;
  11985. }
  11986. }
  11987. declare module "babylonjs/Events/pointerEvents" {
  11988. import { Nullable } from "babylonjs/types";
  11989. import { Vector2 } from "babylonjs/Maths/math.vector";
  11990. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11991. import { Ray } from "babylonjs/Culling/ray";
  11992. /**
  11993. * Gather the list of pointer event types as constants.
  11994. */
  11995. export class PointerEventTypes {
  11996. /**
  11997. * 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.
  11998. */
  11999. static readonly POINTERDOWN: number;
  12000. /**
  12001. * The pointerup event is fired when a pointer is no longer active.
  12002. */
  12003. static readonly POINTERUP: number;
  12004. /**
  12005. * The pointermove event is fired when a pointer changes coordinates.
  12006. */
  12007. static readonly POINTERMOVE: number;
  12008. /**
  12009. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12010. */
  12011. static readonly POINTERWHEEL: number;
  12012. /**
  12013. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12014. */
  12015. static readonly POINTERPICK: number;
  12016. /**
  12017. * The pointertap event is fired when a the object has been touched and released without drag.
  12018. */
  12019. static readonly POINTERTAP: number;
  12020. /**
  12021. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12022. */
  12023. static readonly POINTERDOUBLETAP: number;
  12024. }
  12025. /**
  12026. * Base class of pointer info types.
  12027. */
  12028. export class PointerInfoBase {
  12029. /**
  12030. * Defines the type of event (PointerEventTypes)
  12031. */
  12032. type: number;
  12033. /**
  12034. * Defines the related dom event
  12035. */
  12036. event: PointerEvent | MouseWheelEvent;
  12037. /**
  12038. * Instantiates the base class of pointers info.
  12039. * @param type Defines the type of event (PointerEventTypes)
  12040. * @param event Defines the related dom event
  12041. */
  12042. constructor(
  12043. /**
  12044. * Defines the type of event (PointerEventTypes)
  12045. */
  12046. type: number,
  12047. /**
  12048. * Defines the related dom event
  12049. */
  12050. event: PointerEvent | MouseWheelEvent);
  12051. }
  12052. /**
  12053. * This class is used to store pointer related info for the onPrePointerObservable event.
  12054. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12055. */
  12056. export class PointerInfoPre extends PointerInfoBase {
  12057. /**
  12058. * Ray from a pointer if availible (eg. 6dof controller)
  12059. */
  12060. ray: Nullable<Ray>;
  12061. /**
  12062. * Defines the local position of the pointer on the canvas.
  12063. */
  12064. localPosition: Vector2;
  12065. /**
  12066. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12067. */
  12068. skipOnPointerObservable: boolean;
  12069. /**
  12070. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12071. * @param type Defines the type of event (PointerEventTypes)
  12072. * @param event Defines the related dom event
  12073. * @param localX Defines the local x coordinates of the pointer when the event occured
  12074. * @param localY Defines the local y coordinates of the pointer when the event occured
  12075. */
  12076. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12077. }
  12078. /**
  12079. * This type contains all the data related to a pointer event in Babylon.js.
  12080. * 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.
  12081. */
  12082. export class PointerInfo extends PointerInfoBase {
  12083. /**
  12084. * Defines the picking info associated to the info (if any)\
  12085. */
  12086. pickInfo: Nullable<PickingInfo>;
  12087. /**
  12088. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12089. * @param type Defines the type of event (PointerEventTypes)
  12090. * @param event Defines the related dom event
  12091. * @param pickInfo Defines the picking info associated to the info (if any)\
  12092. */
  12093. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12094. /**
  12095. * Defines the picking info associated to the info (if any)\
  12096. */
  12097. pickInfo: Nullable<PickingInfo>);
  12098. }
  12099. /**
  12100. * Data relating to a touch event on the screen.
  12101. */
  12102. export interface PointerTouch {
  12103. /**
  12104. * X coordinate of touch.
  12105. */
  12106. x: number;
  12107. /**
  12108. * Y coordinate of touch.
  12109. */
  12110. y: number;
  12111. /**
  12112. * Id of touch. Unique for each finger.
  12113. */
  12114. pointerId: number;
  12115. /**
  12116. * Event type passed from DOM.
  12117. */
  12118. type: any;
  12119. }
  12120. }
  12121. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12122. import { Observable } from "babylonjs/Misc/observable";
  12123. import { Nullable } from "babylonjs/types";
  12124. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12126. /**
  12127. * Manage the mouse inputs to control the movement of a free camera.
  12128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12129. */
  12130. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12131. /**
  12132. * Define if touch is enabled in the mouse input
  12133. */
  12134. touchEnabled: boolean;
  12135. /**
  12136. * Defines the camera the input is attached to.
  12137. */
  12138. camera: FreeCamera;
  12139. /**
  12140. * Defines the buttons associated with the input to handle camera move.
  12141. */
  12142. buttons: number[];
  12143. /**
  12144. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12145. */
  12146. angularSensibility: number;
  12147. private _pointerInput;
  12148. private _onMouseMove;
  12149. private _observer;
  12150. private previousPosition;
  12151. /**
  12152. * Observable for when a pointer move event occurs containing the move offset
  12153. */
  12154. onPointerMovedObservable: Observable<{
  12155. offsetX: number;
  12156. offsetY: number;
  12157. }>;
  12158. /**
  12159. * @hidden
  12160. * If the camera should be rotated automatically based on pointer movement
  12161. */
  12162. _allowCameraRotation: boolean;
  12163. /**
  12164. * Manage the mouse inputs to control the movement of a free camera.
  12165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12166. * @param touchEnabled Defines if touch is enabled or not
  12167. */
  12168. constructor(
  12169. /**
  12170. * Define if touch is enabled in the mouse input
  12171. */
  12172. touchEnabled?: boolean);
  12173. /**
  12174. * Attach the input controls to a specific dom element to get the input from.
  12175. * @param element Defines the element the controls should be listened from
  12176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12177. */
  12178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12179. /**
  12180. * Called on JS contextmenu event.
  12181. * Override this method to provide functionality.
  12182. */
  12183. protected onContextMenu(evt: PointerEvent): void;
  12184. /**
  12185. * Detach the current controls from the specified dom element.
  12186. * @param element Defines the element to stop listening the inputs from
  12187. */
  12188. detachControl(element: Nullable<HTMLElement>): void;
  12189. /**
  12190. * Gets the class name of the current intput.
  12191. * @returns the class name
  12192. */
  12193. getClassName(): string;
  12194. /**
  12195. * Get the friendly name associated with the input class.
  12196. * @returns the input friendly name
  12197. */
  12198. getSimpleName(): string;
  12199. }
  12200. }
  12201. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12202. import { Nullable } from "babylonjs/types";
  12203. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. /**
  12206. * Manage the touch inputs to control the movement of a free camera.
  12207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12208. */
  12209. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12210. /**
  12211. * Defines the camera the input is attached to.
  12212. */
  12213. camera: FreeCamera;
  12214. /**
  12215. * Defines the touch sensibility for rotation.
  12216. * The higher the faster.
  12217. */
  12218. touchAngularSensibility: number;
  12219. /**
  12220. * Defines the touch sensibility for move.
  12221. * The higher the faster.
  12222. */
  12223. touchMoveSensibility: number;
  12224. private _offsetX;
  12225. private _offsetY;
  12226. private _pointerPressed;
  12227. private _pointerInput;
  12228. private _observer;
  12229. private _onLostFocus;
  12230. /**
  12231. * Attach the input controls to a specific dom element to get the input from.
  12232. * @param element Defines the element the controls should be listened from
  12233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12234. */
  12235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12236. /**
  12237. * Detach the current controls from the specified dom element.
  12238. * @param element Defines the element to stop listening the inputs from
  12239. */
  12240. detachControl(element: Nullable<HTMLElement>): void;
  12241. /**
  12242. * Update the current camera state depending on the inputs that have been used this frame.
  12243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12244. */
  12245. checkInputs(): void;
  12246. /**
  12247. * Gets the class name of the current intput.
  12248. * @returns the class name
  12249. */
  12250. getClassName(): string;
  12251. /**
  12252. * Get the friendly name associated with the input class.
  12253. * @returns the input friendly name
  12254. */
  12255. getSimpleName(): string;
  12256. }
  12257. }
  12258. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12259. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12260. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12261. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12262. import { Nullable } from "babylonjs/types";
  12263. /**
  12264. * Default Inputs manager for the FreeCamera.
  12265. * It groups all the default supported inputs for ease of use.
  12266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12267. */
  12268. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12269. /**
  12270. * @hidden
  12271. */
  12272. _mouseInput: Nullable<FreeCameraMouseInput>;
  12273. /**
  12274. * Instantiates a new FreeCameraInputsManager.
  12275. * @param camera Defines the camera the inputs belong to
  12276. */
  12277. constructor(camera: FreeCamera);
  12278. /**
  12279. * Add keyboard input support to the input manager.
  12280. * @returns the current input manager
  12281. */
  12282. addKeyboard(): FreeCameraInputsManager;
  12283. /**
  12284. * Add mouse input support to the input manager.
  12285. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12286. * @returns the current input manager
  12287. */
  12288. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12289. /**
  12290. * Removes the mouse input support from the manager
  12291. * @returns the current input manager
  12292. */
  12293. removeMouse(): FreeCameraInputsManager;
  12294. /**
  12295. * Add touch input support to the input manager.
  12296. * @returns the current input manager
  12297. */
  12298. addTouch(): FreeCameraInputsManager;
  12299. /**
  12300. * Remove all attached input methods from a camera
  12301. */
  12302. clear(): void;
  12303. }
  12304. }
  12305. declare module "babylonjs/Cameras/freeCamera" {
  12306. import { Vector3 } from "babylonjs/Maths/math.vector";
  12307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12308. import { Scene } from "babylonjs/scene";
  12309. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12310. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12311. /**
  12312. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12313. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12314. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12315. */
  12316. export class FreeCamera extends TargetCamera {
  12317. /**
  12318. * Define the collision ellipsoid of the camera.
  12319. * This is helpful to simulate a camera body like the player body around the camera
  12320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12321. */
  12322. ellipsoid: Vector3;
  12323. /**
  12324. * Define an offset for the position of the ellipsoid around the camera.
  12325. * This can be helpful to determine the center of the body near the gravity center of the body
  12326. * instead of its head.
  12327. */
  12328. ellipsoidOffset: Vector3;
  12329. /**
  12330. * Enable or disable collisions of the camera with the rest of the scene objects.
  12331. */
  12332. checkCollisions: boolean;
  12333. /**
  12334. * Enable or disable gravity on the camera.
  12335. */
  12336. applyGravity: boolean;
  12337. /**
  12338. * Define the input manager associated to the camera.
  12339. */
  12340. inputs: FreeCameraInputsManager;
  12341. /**
  12342. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12343. * Higher values reduce sensitivity.
  12344. */
  12345. /**
  12346. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12347. * Higher values reduce sensitivity.
  12348. */
  12349. angularSensibility: number;
  12350. /**
  12351. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12352. */
  12353. keysUp: number[];
  12354. /**
  12355. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12356. */
  12357. keysDown: number[];
  12358. /**
  12359. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12360. */
  12361. keysLeft: number[];
  12362. /**
  12363. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12364. */
  12365. keysRight: number[];
  12366. /**
  12367. * Event raised when the camera collide with a mesh in the scene.
  12368. */
  12369. onCollide: (collidedMesh: AbstractMesh) => void;
  12370. private _collider;
  12371. private _needMoveForGravity;
  12372. private _oldPosition;
  12373. private _diffPosition;
  12374. private _newPosition;
  12375. /** @hidden */
  12376. _localDirection: Vector3;
  12377. /** @hidden */
  12378. _transformedDirection: Vector3;
  12379. /**
  12380. * Instantiates a Free Camera.
  12381. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12382. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12383. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12384. * @param name Define the name of the camera in the scene
  12385. * @param position Define the start position of the camera in the scene
  12386. * @param scene Define the scene the camera belongs to
  12387. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12388. */
  12389. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12390. /**
  12391. * Attached controls to the current camera.
  12392. * @param element Defines the element the controls should be listened from
  12393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12394. */
  12395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12396. /**
  12397. * Detach the current controls from the camera.
  12398. * The camera will stop reacting to inputs.
  12399. * @param element Defines the element to stop listening the inputs from
  12400. */
  12401. detachControl(element: HTMLElement): void;
  12402. private _collisionMask;
  12403. /**
  12404. * Define a collision mask to limit the list of object the camera can collide with
  12405. */
  12406. collisionMask: number;
  12407. /** @hidden */
  12408. _collideWithWorld(displacement: Vector3): void;
  12409. private _onCollisionPositionChange;
  12410. /** @hidden */
  12411. _checkInputs(): void;
  12412. /** @hidden */
  12413. _decideIfNeedsToMove(): boolean;
  12414. /** @hidden */
  12415. _updatePosition(): void;
  12416. /**
  12417. * Destroy the camera and release the current resources hold by it.
  12418. */
  12419. dispose(): void;
  12420. /**
  12421. * Gets the current object class name.
  12422. * @return the class name
  12423. */
  12424. getClassName(): string;
  12425. }
  12426. }
  12427. declare module "babylonjs/Gamepads/gamepad" {
  12428. import { Observable } from "babylonjs/Misc/observable";
  12429. /**
  12430. * Represents a gamepad control stick position
  12431. */
  12432. export class StickValues {
  12433. /**
  12434. * The x component of the control stick
  12435. */
  12436. x: number;
  12437. /**
  12438. * The y component of the control stick
  12439. */
  12440. y: number;
  12441. /**
  12442. * Initializes the gamepad x and y control stick values
  12443. * @param x The x component of the gamepad control stick value
  12444. * @param y The y component of the gamepad control stick value
  12445. */
  12446. constructor(
  12447. /**
  12448. * The x component of the control stick
  12449. */
  12450. x: number,
  12451. /**
  12452. * The y component of the control stick
  12453. */
  12454. y: number);
  12455. }
  12456. /**
  12457. * An interface which manages callbacks for gamepad button changes
  12458. */
  12459. export interface GamepadButtonChanges {
  12460. /**
  12461. * Called when a gamepad has been changed
  12462. */
  12463. changed: boolean;
  12464. /**
  12465. * Called when a gamepad press event has been triggered
  12466. */
  12467. pressChanged: boolean;
  12468. /**
  12469. * Called when a touch event has been triggered
  12470. */
  12471. touchChanged: boolean;
  12472. /**
  12473. * Called when a value has changed
  12474. */
  12475. valueChanged: boolean;
  12476. }
  12477. /**
  12478. * Represents a gamepad
  12479. */
  12480. export class Gamepad {
  12481. /**
  12482. * The id of the gamepad
  12483. */
  12484. id: string;
  12485. /**
  12486. * The index of the gamepad
  12487. */
  12488. index: number;
  12489. /**
  12490. * The browser gamepad
  12491. */
  12492. browserGamepad: any;
  12493. /**
  12494. * Specifies what type of gamepad this represents
  12495. */
  12496. type: number;
  12497. private _leftStick;
  12498. private _rightStick;
  12499. /** @hidden */
  12500. _isConnected: boolean;
  12501. private _leftStickAxisX;
  12502. private _leftStickAxisY;
  12503. private _rightStickAxisX;
  12504. private _rightStickAxisY;
  12505. /**
  12506. * Triggered when the left control stick has been changed
  12507. */
  12508. private _onleftstickchanged;
  12509. /**
  12510. * Triggered when the right control stick has been changed
  12511. */
  12512. private _onrightstickchanged;
  12513. /**
  12514. * Represents a gamepad controller
  12515. */
  12516. static GAMEPAD: number;
  12517. /**
  12518. * Represents a generic controller
  12519. */
  12520. static GENERIC: number;
  12521. /**
  12522. * Represents an XBox controller
  12523. */
  12524. static XBOX: number;
  12525. /**
  12526. * Represents a pose-enabled controller
  12527. */
  12528. static POSE_ENABLED: number;
  12529. /**
  12530. * Represents an Dual Shock controller
  12531. */
  12532. static DUALSHOCK: number;
  12533. /**
  12534. * Specifies whether the left control stick should be Y-inverted
  12535. */
  12536. protected _invertLeftStickY: boolean;
  12537. /**
  12538. * Specifies if the gamepad has been connected
  12539. */
  12540. readonly isConnected: boolean;
  12541. /**
  12542. * Initializes the gamepad
  12543. * @param id The id of the gamepad
  12544. * @param index The index of the gamepad
  12545. * @param browserGamepad The browser gamepad
  12546. * @param leftStickX The x component of the left joystick
  12547. * @param leftStickY The y component of the left joystick
  12548. * @param rightStickX The x component of the right joystick
  12549. * @param rightStickY The y component of the right joystick
  12550. */
  12551. constructor(
  12552. /**
  12553. * The id of the gamepad
  12554. */
  12555. id: string,
  12556. /**
  12557. * The index of the gamepad
  12558. */
  12559. index: number,
  12560. /**
  12561. * The browser gamepad
  12562. */
  12563. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12564. /**
  12565. * Callback triggered when the left joystick has changed
  12566. * @param callback
  12567. */
  12568. onleftstickchanged(callback: (values: StickValues) => void): void;
  12569. /**
  12570. * Callback triggered when the right joystick has changed
  12571. * @param callback
  12572. */
  12573. onrightstickchanged(callback: (values: StickValues) => void): void;
  12574. /**
  12575. * Gets the left joystick
  12576. */
  12577. /**
  12578. * Sets the left joystick values
  12579. */
  12580. leftStick: StickValues;
  12581. /**
  12582. * Gets the right joystick
  12583. */
  12584. /**
  12585. * Sets the right joystick value
  12586. */
  12587. rightStick: StickValues;
  12588. /**
  12589. * Updates the gamepad joystick positions
  12590. */
  12591. update(): void;
  12592. /**
  12593. * Disposes the gamepad
  12594. */
  12595. dispose(): void;
  12596. }
  12597. /**
  12598. * Represents a generic gamepad
  12599. */
  12600. export class GenericPad extends Gamepad {
  12601. private _buttons;
  12602. private _onbuttondown;
  12603. private _onbuttonup;
  12604. /**
  12605. * Observable triggered when a button has been pressed
  12606. */
  12607. onButtonDownObservable: Observable<number>;
  12608. /**
  12609. * Observable triggered when a button has been released
  12610. */
  12611. onButtonUpObservable: Observable<number>;
  12612. /**
  12613. * Callback triggered when a button has been pressed
  12614. * @param callback Called when a button has been pressed
  12615. */
  12616. onbuttondown(callback: (buttonPressed: number) => void): void;
  12617. /**
  12618. * Callback triggered when a button has been released
  12619. * @param callback Called when a button has been released
  12620. */
  12621. onbuttonup(callback: (buttonReleased: number) => void): void;
  12622. /**
  12623. * Initializes the generic gamepad
  12624. * @param id The id of the generic gamepad
  12625. * @param index The index of the generic gamepad
  12626. * @param browserGamepad The browser gamepad
  12627. */
  12628. constructor(id: string, index: number, browserGamepad: any);
  12629. private _setButtonValue;
  12630. /**
  12631. * Updates the generic gamepad
  12632. */
  12633. update(): void;
  12634. /**
  12635. * Disposes the generic gamepad
  12636. */
  12637. dispose(): void;
  12638. }
  12639. }
  12640. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12641. import { Nullable } from "babylonjs/types";
  12642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12643. import { Scene } from "babylonjs/scene";
  12644. module "babylonjs/Engines/engine" {
  12645. interface Engine {
  12646. /**
  12647. * Creates a raw texture
  12648. * @param data defines the data to store in the texture
  12649. * @param width defines the width of the texture
  12650. * @param height defines the height of the texture
  12651. * @param format defines the format of the data
  12652. * @param generateMipMaps defines if the engine should generate the mip levels
  12653. * @param invertY defines if data must be stored with Y axis inverted
  12654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12655. * @param compression defines the compression used (null by default)
  12656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12657. * @returns the raw texture inside an InternalTexture
  12658. */
  12659. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12660. /**
  12661. * Update a raw texture
  12662. * @param texture defines the texture to update
  12663. * @param data defines the data to store in the texture
  12664. * @param format defines the format of the data
  12665. * @param invertY defines if data must be stored with Y axis inverted
  12666. */
  12667. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12668. /**
  12669. * Update a raw texture
  12670. * @param texture defines the texture to update
  12671. * @param data defines the data to store in the texture
  12672. * @param format defines the format of the data
  12673. * @param invertY defines if data must be stored with Y axis inverted
  12674. * @param compression defines the compression used (null by default)
  12675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12676. */
  12677. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12678. /**
  12679. * Creates a new raw cube texture
  12680. * @param data defines the array of data to use to create each face
  12681. * @param size defines the size of the textures
  12682. * @param format defines the format of the data
  12683. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12684. * @param generateMipMaps defines if the engine should generate the mip levels
  12685. * @param invertY defines if data must be stored with Y axis inverted
  12686. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12687. * @param compression defines the compression used (null by default)
  12688. * @returns the cube texture as an InternalTexture
  12689. */
  12690. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12691. /**
  12692. * Update a raw cube texture
  12693. * @param texture defines the texture to udpdate
  12694. * @param data defines the data to store
  12695. * @param format defines the data format
  12696. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12697. * @param invertY defines if data must be stored with Y axis inverted
  12698. */
  12699. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12700. /**
  12701. * Update a raw cube texture
  12702. * @param texture defines the texture to udpdate
  12703. * @param data defines the data to store
  12704. * @param format defines the data format
  12705. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param compression defines the compression used (null by default)
  12708. */
  12709. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12710. /**
  12711. * Update a raw cube texture
  12712. * @param texture defines the texture to udpdate
  12713. * @param data defines the data to store
  12714. * @param format defines the data format
  12715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12716. * @param invertY defines if data must be stored with Y axis inverted
  12717. * @param compression defines the compression used (null by default)
  12718. * @param level defines which level of the texture to update
  12719. */
  12720. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12721. /**
  12722. * Creates a new raw cube texture from a specified url
  12723. * @param url defines the url where the data is located
  12724. * @param scene defines the current scene
  12725. * @param size defines the size of the textures
  12726. * @param format defines the format of the data
  12727. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12728. * @param noMipmap defines if the engine should avoid generating the mip levels
  12729. * @param callback defines a callback used to extract texture data from loaded data
  12730. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12731. * @param onLoad defines a callback called when texture is loaded
  12732. * @param onError defines a callback called if there is an error
  12733. * @returns the cube texture as an InternalTexture
  12734. */
  12735. 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;
  12736. /**
  12737. * Creates a new raw cube texture from a specified url
  12738. * @param url defines the url where the data is located
  12739. * @param scene defines the current scene
  12740. * @param size defines the size of the textures
  12741. * @param format defines the format of the data
  12742. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12743. * @param noMipmap defines if the engine should avoid generating the mip levels
  12744. * @param callback defines a callback used to extract texture data from loaded data
  12745. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12746. * @param onLoad defines a callback called when texture is loaded
  12747. * @param onError defines a callback called if there is an error
  12748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12749. * @param invertY defines if data must be stored with Y axis inverted
  12750. * @returns the cube texture as an InternalTexture
  12751. */
  12752. 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;
  12753. /**
  12754. * Creates a new raw 3D texture
  12755. * @param data defines the data used to create the texture
  12756. * @param width defines the width of the texture
  12757. * @param height defines the height of the texture
  12758. * @param depth defines the depth of the texture
  12759. * @param format defines the format of the texture
  12760. * @param generateMipMaps defines if the engine must generate mip levels
  12761. * @param invertY defines if data must be stored with Y axis inverted
  12762. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12763. * @param compression defines the compressed used (can be null)
  12764. * @param textureType defines the compressed used (can be null)
  12765. * @returns a new raw 3D texture (stored in an InternalTexture)
  12766. */
  12767. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12768. /**
  12769. * Update a raw 3D texture
  12770. * @param texture defines the texture to update
  12771. * @param data defines the data to store
  12772. * @param format defines the data format
  12773. * @param invertY defines if data must be stored with Y axis inverted
  12774. */
  12775. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12776. /**
  12777. * Update a raw 3D texture
  12778. * @param texture defines the texture to update
  12779. * @param data defines the data to store
  12780. * @param format defines the data format
  12781. * @param invertY defines if data must be stored with Y axis inverted
  12782. * @param compression defines the used compression (can be null)
  12783. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12784. */
  12785. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12786. }
  12787. }
  12788. }
  12789. declare module "babylonjs/Materials/Textures/rawTexture" {
  12790. import { Scene } from "babylonjs/scene";
  12791. import { Texture } from "babylonjs/Materials/Textures/texture";
  12792. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12793. /**
  12794. * Raw texture can help creating a texture directly from an array of data.
  12795. * This can be super useful if you either get the data from an uncompressed source or
  12796. * if you wish to create your texture pixel by pixel.
  12797. */
  12798. export class RawTexture extends Texture {
  12799. /**
  12800. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12801. */
  12802. format: number;
  12803. private _engine;
  12804. /**
  12805. * Instantiates a new RawTexture.
  12806. * Raw texture can help creating a texture directly from an array of data.
  12807. * This can be super useful if you either get the data from an uncompressed source or
  12808. * if you wish to create your texture pixel by pixel.
  12809. * @param data define the array of data to use to create the texture
  12810. * @param width define the width of the texture
  12811. * @param height define the height of the texture
  12812. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12813. * @param scene define the scene the texture belongs to
  12814. * @param generateMipMaps define whether mip maps should be generated or not
  12815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12817. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12818. */
  12819. constructor(data: ArrayBufferView, width: number, height: number,
  12820. /**
  12821. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12822. */
  12823. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12824. /**
  12825. * Updates the texture underlying data.
  12826. * @param data Define the new data of the texture
  12827. */
  12828. update(data: ArrayBufferView): void;
  12829. /**
  12830. * Creates a luminance texture from some data.
  12831. * @param data Define the texture data
  12832. * @param width Define the width of the texture
  12833. * @param height Define the height of the texture
  12834. * @param scene Define the scene the texture belongs to
  12835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12838. * @returns the luminance texture
  12839. */
  12840. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12841. /**
  12842. * Creates a luminance alpha texture from some data.
  12843. * @param data Define the texture data
  12844. * @param width Define the width of the texture
  12845. * @param height Define the height of the texture
  12846. * @param scene Define the scene the texture belongs to
  12847. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12848. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12849. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12850. * @returns the luminance alpha texture
  12851. */
  12852. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12853. /**
  12854. * Creates an alpha texture from some data.
  12855. * @param data Define the texture data
  12856. * @param width Define the width of the texture
  12857. * @param height Define the height of the texture
  12858. * @param scene Define the scene the texture belongs to
  12859. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12860. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12861. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12862. * @returns the alpha texture
  12863. */
  12864. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12865. /**
  12866. * Creates a RGB texture from some data.
  12867. * @param data Define the texture data
  12868. * @param width Define the width of the texture
  12869. * @param height Define the height of the texture
  12870. * @param scene Define the scene the texture belongs to
  12871. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12872. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12873. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12874. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12875. * @returns the RGB alpha texture
  12876. */
  12877. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12878. /**
  12879. * Creates a RGBA texture from some data.
  12880. * @param data Define the texture data
  12881. * @param width Define the width of the texture
  12882. * @param height Define the height of the texture
  12883. * @param scene Define the scene the texture belongs to
  12884. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12885. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12886. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12887. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12888. * @returns the RGBA texture
  12889. */
  12890. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12891. /**
  12892. * Creates a R texture from some data.
  12893. * @param data Define the texture data
  12894. * @param width Define the width of the texture
  12895. * @param height Define the height of the texture
  12896. * @param scene Define the scene the texture belongs to
  12897. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12898. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12899. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12900. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12901. * @returns the R texture
  12902. */
  12903. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12904. }
  12905. }
  12906. declare module "babylonjs/Maths/math.size" {
  12907. /**
  12908. * Interface for the size containing width and height
  12909. */
  12910. export interface ISize {
  12911. /**
  12912. * Width
  12913. */
  12914. width: number;
  12915. /**
  12916. * Heighht
  12917. */
  12918. height: number;
  12919. }
  12920. /**
  12921. * Size containing widht and height
  12922. */
  12923. export class Size implements ISize {
  12924. /**
  12925. * Width
  12926. */
  12927. width: number;
  12928. /**
  12929. * Height
  12930. */
  12931. height: number;
  12932. /**
  12933. * Creates a Size object from the given width and height (floats).
  12934. * @param width width of the new size
  12935. * @param height height of the new size
  12936. */
  12937. constructor(width: number, height: number);
  12938. /**
  12939. * Returns a string with the Size width and height
  12940. * @returns a string with the Size width and height
  12941. */
  12942. toString(): string;
  12943. /**
  12944. * "Size"
  12945. * @returns the string "Size"
  12946. */
  12947. getClassName(): string;
  12948. /**
  12949. * Returns the Size hash code.
  12950. * @returns a hash code for a unique width and height
  12951. */
  12952. getHashCode(): number;
  12953. /**
  12954. * Updates the current size from the given one.
  12955. * @param src the given size
  12956. */
  12957. copyFrom(src: Size): void;
  12958. /**
  12959. * Updates in place the current Size from the given floats.
  12960. * @param width width of the new size
  12961. * @param height height of the new size
  12962. * @returns the updated Size.
  12963. */
  12964. copyFromFloats(width: number, height: number): Size;
  12965. /**
  12966. * Updates in place the current Size from the given floats.
  12967. * @param width width to set
  12968. * @param height height to set
  12969. * @returns the updated Size.
  12970. */
  12971. set(width: number, height: number): Size;
  12972. /**
  12973. * Multiplies the width and height by numbers
  12974. * @param w factor to multiple the width by
  12975. * @param h factor to multiple the height by
  12976. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12977. */
  12978. multiplyByFloats(w: number, h: number): Size;
  12979. /**
  12980. * Clones the size
  12981. * @returns a new Size copied from the given one.
  12982. */
  12983. clone(): Size;
  12984. /**
  12985. * True if the current Size and the given one width and height are strictly equal.
  12986. * @param other the other size to compare against
  12987. * @returns True if the current Size and the given one width and height are strictly equal.
  12988. */
  12989. equals(other: Size): boolean;
  12990. /**
  12991. * The surface of the Size : width * height (float).
  12992. */
  12993. readonly surface: number;
  12994. /**
  12995. * Create a new size of zero
  12996. * @returns a new Size set to (0.0, 0.0)
  12997. */
  12998. static Zero(): Size;
  12999. /**
  13000. * Sums the width and height of two sizes
  13001. * @param otherSize size to add to this size
  13002. * @returns a new Size set as the addition result of the current Size and the given one.
  13003. */
  13004. add(otherSize: Size): Size;
  13005. /**
  13006. * Subtracts the width and height of two
  13007. * @param otherSize size to subtract to this size
  13008. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13009. */
  13010. subtract(otherSize: Size): Size;
  13011. /**
  13012. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13013. * @param start starting size to lerp between
  13014. * @param end end size to lerp between
  13015. * @param amount amount to lerp between the start and end values
  13016. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13017. */
  13018. static Lerp(start: Size, end: Size, amount: number): Size;
  13019. }
  13020. }
  13021. declare module "babylonjs/Animations/runtimeAnimation" {
  13022. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13023. import { Animatable } from "babylonjs/Animations/animatable";
  13024. import { Scene } from "babylonjs/scene";
  13025. /**
  13026. * Defines a runtime animation
  13027. */
  13028. export class RuntimeAnimation {
  13029. private _events;
  13030. /**
  13031. * The current frame of the runtime animation
  13032. */
  13033. private _currentFrame;
  13034. /**
  13035. * The animation used by the runtime animation
  13036. */
  13037. private _animation;
  13038. /**
  13039. * The target of the runtime animation
  13040. */
  13041. private _target;
  13042. /**
  13043. * The initiating animatable
  13044. */
  13045. private _host;
  13046. /**
  13047. * The original value of the runtime animation
  13048. */
  13049. private _originalValue;
  13050. /**
  13051. * The original blend value of the runtime animation
  13052. */
  13053. private _originalBlendValue;
  13054. /**
  13055. * The offsets cache of the runtime animation
  13056. */
  13057. private _offsetsCache;
  13058. /**
  13059. * The high limits cache of the runtime animation
  13060. */
  13061. private _highLimitsCache;
  13062. /**
  13063. * Specifies if the runtime animation has been stopped
  13064. */
  13065. private _stopped;
  13066. /**
  13067. * The blending factor of the runtime animation
  13068. */
  13069. private _blendingFactor;
  13070. /**
  13071. * The BabylonJS scene
  13072. */
  13073. private _scene;
  13074. /**
  13075. * The current value of the runtime animation
  13076. */
  13077. private _currentValue;
  13078. /** @hidden */
  13079. _animationState: _IAnimationState;
  13080. /**
  13081. * The active target of the runtime animation
  13082. */
  13083. private _activeTargets;
  13084. private _currentActiveTarget;
  13085. private _directTarget;
  13086. /**
  13087. * The target path of the runtime animation
  13088. */
  13089. private _targetPath;
  13090. /**
  13091. * The weight of the runtime animation
  13092. */
  13093. private _weight;
  13094. /**
  13095. * The ratio offset of the runtime animation
  13096. */
  13097. private _ratioOffset;
  13098. /**
  13099. * The previous delay of the runtime animation
  13100. */
  13101. private _previousDelay;
  13102. /**
  13103. * The previous ratio of the runtime animation
  13104. */
  13105. private _previousRatio;
  13106. private _enableBlending;
  13107. private _keys;
  13108. private _minFrame;
  13109. private _maxFrame;
  13110. private _minValue;
  13111. private _maxValue;
  13112. private _targetIsArray;
  13113. /**
  13114. * Gets the current frame of the runtime animation
  13115. */
  13116. readonly currentFrame: number;
  13117. /**
  13118. * Gets the weight of the runtime animation
  13119. */
  13120. readonly weight: number;
  13121. /**
  13122. * Gets the current value of the runtime animation
  13123. */
  13124. readonly currentValue: any;
  13125. /**
  13126. * Gets the target path of the runtime animation
  13127. */
  13128. readonly targetPath: string;
  13129. /**
  13130. * Gets the actual target of the runtime animation
  13131. */
  13132. readonly target: any;
  13133. /** @hidden */
  13134. _onLoop: () => void;
  13135. /**
  13136. * Create a new RuntimeAnimation object
  13137. * @param target defines the target of the animation
  13138. * @param animation defines the source animation object
  13139. * @param scene defines the hosting scene
  13140. * @param host defines the initiating Animatable
  13141. */
  13142. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13143. private _preparePath;
  13144. /**
  13145. * Gets the animation from the runtime animation
  13146. */
  13147. readonly animation: Animation;
  13148. /**
  13149. * Resets the runtime animation to the beginning
  13150. * @param restoreOriginal defines whether to restore the target property to the original value
  13151. */
  13152. reset(restoreOriginal?: boolean): void;
  13153. /**
  13154. * Specifies if the runtime animation is stopped
  13155. * @returns Boolean specifying if the runtime animation is stopped
  13156. */
  13157. isStopped(): boolean;
  13158. /**
  13159. * Disposes of the runtime animation
  13160. */
  13161. dispose(): void;
  13162. /**
  13163. * Apply the interpolated value to the target
  13164. * @param currentValue defines the value computed by the animation
  13165. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13166. */
  13167. setValue(currentValue: any, weight: number): void;
  13168. private _getOriginalValues;
  13169. private _setValue;
  13170. /**
  13171. * Gets the loop pmode of the runtime animation
  13172. * @returns Loop Mode
  13173. */
  13174. private _getCorrectLoopMode;
  13175. /**
  13176. * Move the current animation to a given frame
  13177. * @param frame defines the frame to move to
  13178. */
  13179. goToFrame(frame: number): void;
  13180. /**
  13181. * @hidden Internal use only
  13182. */
  13183. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13184. /**
  13185. * Execute the current animation
  13186. * @param delay defines the delay to add to the current frame
  13187. * @param from defines the lower bound of the animation range
  13188. * @param to defines the upper bound of the animation range
  13189. * @param loop defines if the current animation must loop
  13190. * @param speedRatio defines the current speed ratio
  13191. * @param weight defines the weight of the animation (default is -1 so no weight)
  13192. * @param onLoop optional callback called when animation loops
  13193. * @returns a boolean indicating if the animation is running
  13194. */
  13195. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13196. }
  13197. }
  13198. declare module "babylonjs/Animations/animatable" {
  13199. import { Animation } from "babylonjs/Animations/animation";
  13200. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13201. import { Nullable } from "babylonjs/types";
  13202. import { Observable } from "babylonjs/Misc/observable";
  13203. import { Scene } from "babylonjs/scene";
  13204. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13205. import { Node } from "babylonjs/node";
  13206. /**
  13207. * Class used to store an actual running animation
  13208. */
  13209. export class Animatable {
  13210. /** defines the target object */
  13211. target: any;
  13212. /** defines the starting frame number (default is 0) */
  13213. fromFrame: number;
  13214. /** defines the ending frame number (default is 100) */
  13215. toFrame: number;
  13216. /** defines if the animation must loop (default is false) */
  13217. loopAnimation: boolean;
  13218. /** defines a callback to call when animation ends if it is not looping */
  13219. onAnimationEnd?: (() => void) | null | undefined;
  13220. /** defines a callback to call when animation loops */
  13221. onAnimationLoop?: (() => void) | null | undefined;
  13222. private _localDelayOffset;
  13223. private _pausedDelay;
  13224. private _runtimeAnimations;
  13225. private _paused;
  13226. private _scene;
  13227. private _speedRatio;
  13228. private _weight;
  13229. private _syncRoot;
  13230. /**
  13231. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13232. * This will only apply for non looping animation (default is true)
  13233. */
  13234. disposeOnEnd: boolean;
  13235. /**
  13236. * Gets a boolean indicating if the animation has started
  13237. */
  13238. animationStarted: boolean;
  13239. /**
  13240. * Observer raised when the animation ends
  13241. */
  13242. onAnimationEndObservable: Observable<Animatable>;
  13243. /**
  13244. * Observer raised when the animation loops
  13245. */
  13246. onAnimationLoopObservable: Observable<Animatable>;
  13247. /**
  13248. * Gets the root Animatable used to synchronize and normalize animations
  13249. */
  13250. readonly syncRoot: Nullable<Animatable>;
  13251. /**
  13252. * Gets the current frame of the first RuntimeAnimation
  13253. * Used to synchronize Animatables
  13254. */
  13255. readonly masterFrame: number;
  13256. /**
  13257. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13258. */
  13259. weight: number;
  13260. /**
  13261. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13262. */
  13263. speedRatio: number;
  13264. /**
  13265. * Creates a new Animatable
  13266. * @param scene defines the hosting scene
  13267. * @param target defines the target object
  13268. * @param fromFrame defines the starting frame number (default is 0)
  13269. * @param toFrame defines the ending frame number (default is 100)
  13270. * @param loopAnimation defines if the animation must loop (default is false)
  13271. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13272. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13273. * @param animations defines a group of animation to add to the new Animatable
  13274. * @param onAnimationLoop defines a callback to call when animation loops
  13275. */
  13276. constructor(scene: Scene,
  13277. /** defines the target object */
  13278. target: any,
  13279. /** defines the starting frame number (default is 0) */
  13280. fromFrame?: number,
  13281. /** defines the ending frame number (default is 100) */
  13282. toFrame?: number,
  13283. /** defines if the animation must loop (default is false) */
  13284. loopAnimation?: boolean, speedRatio?: number,
  13285. /** defines a callback to call when animation ends if it is not looping */
  13286. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13287. /** defines a callback to call when animation loops */
  13288. onAnimationLoop?: (() => void) | null | undefined);
  13289. /**
  13290. * Synchronize and normalize current Animatable with a source Animatable
  13291. * This is useful when using animation weights and when animations are not of the same length
  13292. * @param root defines the root Animatable to synchronize with
  13293. * @returns the current Animatable
  13294. */
  13295. syncWith(root: Animatable): Animatable;
  13296. /**
  13297. * Gets the list of runtime animations
  13298. * @returns an array of RuntimeAnimation
  13299. */
  13300. getAnimations(): RuntimeAnimation[];
  13301. /**
  13302. * Adds more animations to the current animatable
  13303. * @param target defines the target of the animations
  13304. * @param animations defines the new animations to add
  13305. */
  13306. appendAnimations(target: any, animations: Animation[]): void;
  13307. /**
  13308. * Gets the source animation for a specific property
  13309. * @param property defines the propertyu to look for
  13310. * @returns null or the source animation for the given property
  13311. */
  13312. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13313. /**
  13314. * Gets the runtime animation for a specific property
  13315. * @param property defines the propertyu to look for
  13316. * @returns null or the runtime animation for the given property
  13317. */
  13318. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13319. /**
  13320. * Resets the animatable to its original state
  13321. */
  13322. reset(): void;
  13323. /**
  13324. * Allows the animatable to blend with current running animations
  13325. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13326. * @param blendingSpeed defines the blending speed to use
  13327. */
  13328. enableBlending(blendingSpeed: number): void;
  13329. /**
  13330. * Disable animation blending
  13331. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13332. */
  13333. disableBlending(): void;
  13334. /**
  13335. * Jump directly to a given frame
  13336. * @param frame defines the frame to jump to
  13337. */
  13338. goToFrame(frame: number): void;
  13339. /**
  13340. * Pause the animation
  13341. */
  13342. pause(): void;
  13343. /**
  13344. * Restart the animation
  13345. */
  13346. restart(): void;
  13347. private _raiseOnAnimationEnd;
  13348. /**
  13349. * Stop and delete the current animation
  13350. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13351. * @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)
  13352. */
  13353. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13354. /**
  13355. * Wait asynchronously for the animation to end
  13356. * @returns a promise which will be fullfilled when the animation ends
  13357. */
  13358. waitAsync(): Promise<Animatable>;
  13359. /** @hidden */
  13360. _animate(delay: number): boolean;
  13361. }
  13362. module "babylonjs/scene" {
  13363. interface Scene {
  13364. /** @hidden */
  13365. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13366. /** @hidden */
  13367. _processLateAnimationBindingsForMatrices(holder: {
  13368. totalWeight: number;
  13369. animations: RuntimeAnimation[];
  13370. originalValue: Matrix;
  13371. }): any;
  13372. /** @hidden */
  13373. _processLateAnimationBindingsForQuaternions(holder: {
  13374. totalWeight: number;
  13375. animations: RuntimeAnimation[];
  13376. originalValue: Quaternion;
  13377. }, refQuaternion: Quaternion): Quaternion;
  13378. /** @hidden */
  13379. _processLateAnimationBindings(): void;
  13380. /**
  13381. * Will start the animation sequence of a given target
  13382. * @param target defines the target
  13383. * @param from defines from which frame should animation start
  13384. * @param to defines until which frame should animation run.
  13385. * @param weight defines the weight to apply to the animation (1.0 by default)
  13386. * @param loop defines if the animation loops
  13387. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13388. * @param onAnimationEnd defines the function to be executed when the animation ends
  13389. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13390. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13391. * @param onAnimationLoop defines the callback to call when an animation loops
  13392. * @returns the animatable object created for this animation
  13393. */
  13394. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13395. /**
  13396. * Will start the animation sequence of a given target
  13397. * @param target defines the target
  13398. * @param from defines from which frame should animation start
  13399. * @param to defines until which frame should animation run.
  13400. * @param loop defines if the animation loops
  13401. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13402. * @param onAnimationEnd defines the function to be executed when the animation ends
  13403. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13404. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13405. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13406. * @param onAnimationLoop defines the callback to call when an animation loops
  13407. * @returns the animatable object created for this animation
  13408. */
  13409. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13410. /**
  13411. * Will start the animation sequence of a given target and its hierarchy
  13412. * @param target defines the target
  13413. * @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.
  13414. * @param from defines from which frame should animation start
  13415. * @param to defines until which frame should animation run.
  13416. * @param loop defines if the animation loops
  13417. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13418. * @param onAnimationEnd defines the function to be executed when the animation ends
  13419. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13420. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13421. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13422. * @param onAnimationLoop defines the callback to call when an animation loops
  13423. * @returns the list of created animatables
  13424. */
  13425. 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[];
  13426. /**
  13427. * Begin a new animation on a given node
  13428. * @param target defines the target where the animation will take place
  13429. * @param animations defines the list of animations to start
  13430. * @param from defines the initial value
  13431. * @param to defines the final value
  13432. * @param loop defines if you want animation to loop (off by default)
  13433. * @param speedRatio defines the speed ratio to apply to all animations
  13434. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13435. * @param onAnimationLoop defines the callback to call when an animation loops
  13436. * @returns the list of created animatables
  13437. */
  13438. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13439. /**
  13440. * Begin a new animation on a given node and its hierarchy
  13441. * @param target defines the root node where the animation will take place
  13442. * @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.
  13443. * @param animations defines the list of animations to start
  13444. * @param from defines the initial value
  13445. * @param to defines the final value
  13446. * @param loop defines if you want animation to loop (off by default)
  13447. * @param speedRatio defines the speed ratio to apply to all animations
  13448. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13449. * @param onAnimationLoop defines the callback to call when an animation loops
  13450. * @returns the list of animatables created for all nodes
  13451. */
  13452. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13453. /**
  13454. * Gets the animatable associated with a specific target
  13455. * @param target defines the target of the animatable
  13456. * @returns the required animatable if found
  13457. */
  13458. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13459. /**
  13460. * Gets all animatables associated with a given target
  13461. * @param target defines the target to look animatables for
  13462. * @returns an array of Animatables
  13463. */
  13464. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13465. /**
  13466. * Stops and removes all animations that have been applied to the scene
  13467. */
  13468. stopAllAnimations(): void;
  13469. /**
  13470. * Gets the current delta time used by animation engine
  13471. */
  13472. deltaTime: number;
  13473. }
  13474. }
  13475. module "babylonjs/Bones/bone" {
  13476. interface Bone {
  13477. /**
  13478. * Copy an animation range from another bone
  13479. * @param source defines the source bone
  13480. * @param rangeName defines the range name to copy
  13481. * @param frameOffset defines the frame offset
  13482. * @param rescaleAsRequired defines if rescaling must be applied if required
  13483. * @param skelDimensionsRatio defines the scaling ratio
  13484. * @returns true if operation was successful
  13485. */
  13486. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13487. }
  13488. }
  13489. }
  13490. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13491. /**
  13492. * Class used to override all child animations of a given target
  13493. */
  13494. export class AnimationPropertiesOverride {
  13495. /**
  13496. * Gets or sets a value indicating if animation blending must be used
  13497. */
  13498. enableBlending: boolean;
  13499. /**
  13500. * Gets or sets the blending speed to use when enableBlending is true
  13501. */
  13502. blendingSpeed: number;
  13503. /**
  13504. * Gets or sets the default loop mode to use
  13505. */
  13506. loopMode: number;
  13507. }
  13508. }
  13509. declare module "babylonjs/Bones/skeleton" {
  13510. import { Bone } from "babylonjs/Bones/bone";
  13511. import { Observable } from "babylonjs/Misc/observable";
  13512. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13513. import { Scene } from "babylonjs/scene";
  13514. import { Nullable } from "babylonjs/types";
  13515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13516. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13517. import { Animatable } from "babylonjs/Animations/animatable";
  13518. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13519. import { Animation } from "babylonjs/Animations/animation";
  13520. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13521. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13522. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13523. /**
  13524. * Class used to handle skinning animations
  13525. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13526. */
  13527. export class Skeleton implements IAnimatable {
  13528. /** defines the skeleton name */
  13529. name: string;
  13530. /** defines the skeleton Id */
  13531. id: string;
  13532. /**
  13533. * Defines the list of child bones
  13534. */
  13535. bones: Bone[];
  13536. /**
  13537. * Defines an estimate of the dimension of the skeleton at rest
  13538. */
  13539. dimensionsAtRest: Vector3;
  13540. /**
  13541. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13542. */
  13543. needInitialSkinMatrix: boolean;
  13544. /**
  13545. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13546. */
  13547. overrideMesh: Nullable<AbstractMesh>;
  13548. /**
  13549. * Gets the list of animations attached to this skeleton
  13550. */
  13551. animations: Array<Animation>;
  13552. private _scene;
  13553. private _isDirty;
  13554. private _transformMatrices;
  13555. private _transformMatrixTexture;
  13556. private _meshesWithPoseMatrix;
  13557. private _animatables;
  13558. private _identity;
  13559. private _synchronizedWithMesh;
  13560. private _ranges;
  13561. private _lastAbsoluteTransformsUpdateId;
  13562. private _canUseTextureForBones;
  13563. private _uniqueId;
  13564. /** @hidden */
  13565. _numBonesWithLinkedTransformNode: number;
  13566. /** @hidden */
  13567. _hasWaitingData: Nullable<boolean>;
  13568. /**
  13569. * Specifies if the skeleton should be serialized
  13570. */
  13571. doNotSerialize: boolean;
  13572. private _useTextureToStoreBoneMatrices;
  13573. /**
  13574. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13575. * Please note that this option is not available if the hardware does not support it
  13576. */
  13577. useTextureToStoreBoneMatrices: boolean;
  13578. private _animationPropertiesOverride;
  13579. /**
  13580. * Gets or sets the animation properties override
  13581. */
  13582. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13583. /**
  13584. * List of inspectable custom properties (used by the Inspector)
  13585. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13586. */
  13587. inspectableCustomProperties: IInspectable[];
  13588. /**
  13589. * An observable triggered before computing the skeleton's matrices
  13590. */
  13591. onBeforeComputeObservable: Observable<Skeleton>;
  13592. /**
  13593. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13594. */
  13595. readonly isUsingTextureForMatrices: boolean;
  13596. /**
  13597. * Gets the unique ID of this skeleton
  13598. */
  13599. readonly uniqueId: number;
  13600. /**
  13601. * Creates a new skeleton
  13602. * @param name defines the skeleton name
  13603. * @param id defines the skeleton Id
  13604. * @param scene defines the hosting scene
  13605. */
  13606. constructor(
  13607. /** defines the skeleton name */
  13608. name: string,
  13609. /** defines the skeleton Id */
  13610. id: string, scene: Scene);
  13611. /**
  13612. * Gets the current object class name.
  13613. * @return the class name
  13614. */
  13615. getClassName(): string;
  13616. /**
  13617. * Returns an array containing the root bones
  13618. * @returns an array containing the root bones
  13619. */
  13620. getChildren(): Array<Bone>;
  13621. /**
  13622. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13623. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13624. * @returns a Float32Array containing matrices data
  13625. */
  13626. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13627. /**
  13628. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13629. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13630. * @returns a raw texture containing the data
  13631. */
  13632. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13633. /**
  13634. * Gets the current hosting scene
  13635. * @returns a scene object
  13636. */
  13637. getScene(): Scene;
  13638. /**
  13639. * Gets a string representing the current skeleton data
  13640. * @param fullDetails defines a boolean indicating if we want a verbose version
  13641. * @returns a string representing the current skeleton data
  13642. */
  13643. toString(fullDetails?: boolean): string;
  13644. /**
  13645. * Get bone's index searching by name
  13646. * @param name defines bone's name to search for
  13647. * @return the indice of the bone. Returns -1 if not found
  13648. */
  13649. getBoneIndexByName(name: string): number;
  13650. /**
  13651. * Creater a new animation range
  13652. * @param name defines the name of the range
  13653. * @param from defines the start key
  13654. * @param to defines the end key
  13655. */
  13656. createAnimationRange(name: string, from: number, to: number): void;
  13657. /**
  13658. * Delete a specific animation range
  13659. * @param name defines the name of the range
  13660. * @param deleteFrames defines if frames must be removed as well
  13661. */
  13662. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13663. /**
  13664. * Gets a specific animation range
  13665. * @param name defines the name of the range to look for
  13666. * @returns the requested animation range or null if not found
  13667. */
  13668. getAnimationRange(name: string): Nullable<AnimationRange>;
  13669. /**
  13670. * Gets the list of all animation ranges defined on this skeleton
  13671. * @returns an array
  13672. */
  13673. getAnimationRanges(): Nullable<AnimationRange>[];
  13674. /**
  13675. * Copy animation range from a source skeleton.
  13676. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13677. * @param source defines the source skeleton
  13678. * @param name defines the name of the range to copy
  13679. * @param rescaleAsRequired defines if rescaling must be applied if required
  13680. * @returns true if operation was successful
  13681. */
  13682. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13683. /**
  13684. * Forces the skeleton to go to rest pose
  13685. */
  13686. returnToRest(): void;
  13687. private _getHighestAnimationFrame;
  13688. /**
  13689. * Begin a specific animation range
  13690. * @param name defines the name of the range to start
  13691. * @param loop defines if looping must be turned on (false by default)
  13692. * @param speedRatio defines the speed ratio to apply (1 by default)
  13693. * @param onAnimationEnd defines a callback which will be called when animation will end
  13694. * @returns a new animatable
  13695. */
  13696. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13697. /** @hidden */
  13698. _markAsDirty(): void;
  13699. /** @hidden */
  13700. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13701. /** @hidden */
  13702. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13703. private _computeTransformMatrices;
  13704. /**
  13705. * Build all resources required to render a skeleton
  13706. */
  13707. prepare(): void;
  13708. /**
  13709. * Gets the list of animatables currently running for this skeleton
  13710. * @returns an array of animatables
  13711. */
  13712. getAnimatables(): IAnimatable[];
  13713. /**
  13714. * Clone the current skeleton
  13715. * @param name defines the name of the new skeleton
  13716. * @param id defines the id of the new skeleton
  13717. * @returns the new skeleton
  13718. */
  13719. clone(name: string, id: string): Skeleton;
  13720. /**
  13721. * Enable animation blending for this skeleton
  13722. * @param blendingSpeed defines the blending speed to apply
  13723. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13724. */
  13725. enableBlending(blendingSpeed?: number): void;
  13726. /**
  13727. * Releases all resources associated with the current skeleton
  13728. */
  13729. dispose(): void;
  13730. /**
  13731. * Serialize the skeleton in a JSON object
  13732. * @returns a JSON object
  13733. */
  13734. serialize(): any;
  13735. /**
  13736. * Creates a new skeleton from serialized data
  13737. * @param parsedSkeleton defines the serialized data
  13738. * @param scene defines the hosting scene
  13739. * @returns a new skeleton
  13740. */
  13741. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13742. /**
  13743. * Compute all node absolute transforms
  13744. * @param forceUpdate defines if computation must be done even if cache is up to date
  13745. */
  13746. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13747. /**
  13748. * Gets the root pose matrix
  13749. * @returns a matrix
  13750. */
  13751. getPoseMatrix(): Nullable<Matrix>;
  13752. /**
  13753. * Sorts bones per internal index
  13754. */
  13755. sortBones(): void;
  13756. private _sortBones;
  13757. }
  13758. }
  13759. declare module "babylonjs/Bones/bone" {
  13760. import { Skeleton } from "babylonjs/Bones/skeleton";
  13761. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13762. import { Nullable } from "babylonjs/types";
  13763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13764. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13765. import { Node } from "babylonjs/node";
  13766. import { Space } from "babylonjs/Maths/math.axis";
  13767. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13768. /**
  13769. * Class used to store bone information
  13770. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13771. */
  13772. export class Bone extends Node {
  13773. /**
  13774. * defines the bone name
  13775. */
  13776. name: string;
  13777. private static _tmpVecs;
  13778. private static _tmpQuat;
  13779. private static _tmpMats;
  13780. /**
  13781. * Gets the list of child bones
  13782. */
  13783. children: Bone[];
  13784. /** Gets the animations associated with this bone */
  13785. animations: import("babylonjs/Animations/animation").Animation[];
  13786. /**
  13787. * Gets or sets bone length
  13788. */
  13789. length: number;
  13790. /**
  13791. * @hidden Internal only
  13792. * Set this value to map this bone to a different index in the transform matrices
  13793. * Set this value to -1 to exclude the bone from the transform matrices
  13794. */
  13795. _index: Nullable<number>;
  13796. private _skeleton;
  13797. private _localMatrix;
  13798. private _restPose;
  13799. private _baseMatrix;
  13800. private _absoluteTransform;
  13801. private _invertedAbsoluteTransform;
  13802. private _parent;
  13803. private _scalingDeterminant;
  13804. private _worldTransform;
  13805. private _localScaling;
  13806. private _localRotation;
  13807. private _localPosition;
  13808. private _needToDecompose;
  13809. private _needToCompose;
  13810. /** @hidden */
  13811. _linkedTransformNode: Nullable<TransformNode>;
  13812. /** @hidden */
  13813. _waitingTransformNodeId: Nullable<string>;
  13814. /** @hidden */
  13815. /** @hidden */
  13816. _matrix: Matrix;
  13817. /**
  13818. * Create a new bone
  13819. * @param name defines the bone name
  13820. * @param skeleton defines the parent skeleton
  13821. * @param parentBone defines the parent (can be null if the bone is the root)
  13822. * @param localMatrix defines the local matrix
  13823. * @param restPose defines the rest pose matrix
  13824. * @param baseMatrix defines the base matrix
  13825. * @param index defines index of the bone in the hiearchy
  13826. */
  13827. constructor(
  13828. /**
  13829. * defines the bone name
  13830. */
  13831. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13832. /**
  13833. * Gets the current object class name.
  13834. * @return the class name
  13835. */
  13836. getClassName(): string;
  13837. /**
  13838. * Gets the parent skeleton
  13839. * @returns a skeleton
  13840. */
  13841. getSkeleton(): Skeleton;
  13842. /**
  13843. * Gets parent bone
  13844. * @returns a bone or null if the bone is the root of the bone hierarchy
  13845. */
  13846. getParent(): Nullable<Bone>;
  13847. /**
  13848. * Returns an array containing the root bones
  13849. * @returns an array containing the root bones
  13850. */
  13851. getChildren(): Array<Bone>;
  13852. /**
  13853. * Sets the parent bone
  13854. * @param parent defines the parent (can be null if the bone is the root)
  13855. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13856. */
  13857. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13858. /**
  13859. * Gets the local matrix
  13860. * @returns a matrix
  13861. */
  13862. getLocalMatrix(): Matrix;
  13863. /**
  13864. * Gets the base matrix (initial matrix which remains unchanged)
  13865. * @returns a matrix
  13866. */
  13867. getBaseMatrix(): Matrix;
  13868. /**
  13869. * Gets the rest pose matrix
  13870. * @returns a matrix
  13871. */
  13872. getRestPose(): Matrix;
  13873. /**
  13874. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13875. */
  13876. getWorldMatrix(): Matrix;
  13877. /**
  13878. * Sets the local matrix to rest pose matrix
  13879. */
  13880. returnToRest(): void;
  13881. /**
  13882. * Gets the inverse of the absolute transform matrix.
  13883. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13884. * @returns a matrix
  13885. */
  13886. getInvertedAbsoluteTransform(): Matrix;
  13887. /**
  13888. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13889. * @returns a matrix
  13890. */
  13891. getAbsoluteTransform(): Matrix;
  13892. /**
  13893. * Links with the given transform node.
  13894. * The local matrix of this bone is copied from the transform node every frame.
  13895. * @param transformNode defines the transform node to link to
  13896. */
  13897. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13898. /**
  13899. * Gets the node used to drive the bone's transformation
  13900. * @returns a transform node or null
  13901. */
  13902. getTransformNode(): Nullable<TransformNode>;
  13903. /** Gets or sets current position (in local space) */
  13904. position: Vector3;
  13905. /** Gets or sets current rotation (in local space) */
  13906. rotation: Vector3;
  13907. /** Gets or sets current rotation quaternion (in local space) */
  13908. rotationQuaternion: Quaternion;
  13909. /** Gets or sets current scaling (in local space) */
  13910. scaling: Vector3;
  13911. /**
  13912. * Gets the animation properties override
  13913. */
  13914. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13915. private _decompose;
  13916. private _compose;
  13917. /**
  13918. * Update the base and local matrices
  13919. * @param matrix defines the new base or local matrix
  13920. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13921. * @param updateLocalMatrix defines if the local matrix should be updated
  13922. */
  13923. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13924. /** @hidden */
  13925. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13926. /**
  13927. * Flag the bone as dirty (Forcing it to update everything)
  13928. */
  13929. markAsDirty(): void;
  13930. /** @hidden */
  13931. _markAsDirtyAndCompose(): void;
  13932. private _markAsDirtyAndDecompose;
  13933. /**
  13934. * Translate the bone in local or world space
  13935. * @param vec The amount to translate the bone
  13936. * @param space The space that the translation is in
  13937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13938. */
  13939. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13940. /**
  13941. * Set the postion of the bone in local or world space
  13942. * @param position The position to set the bone
  13943. * @param space The space that the position is in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. */
  13946. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13947. /**
  13948. * Set the absolute position of the bone (world space)
  13949. * @param position The position to set the bone
  13950. * @param mesh The mesh that this bone is attached to
  13951. */
  13952. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13953. /**
  13954. * Scale the bone on the x, y and z axes (in local space)
  13955. * @param x The amount to scale the bone on the x axis
  13956. * @param y The amount to scale the bone on the y axis
  13957. * @param z The amount to scale the bone on the z axis
  13958. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13959. */
  13960. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13961. /**
  13962. * Set the bone scaling in local space
  13963. * @param scale defines the scaling vector
  13964. */
  13965. setScale(scale: Vector3): void;
  13966. /**
  13967. * Gets the current scaling in local space
  13968. * @returns the current scaling vector
  13969. */
  13970. getScale(): Vector3;
  13971. /**
  13972. * Gets the current scaling in local space and stores it in a target vector
  13973. * @param result defines the target vector
  13974. */
  13975. getScaleToRef(result: Vector3): void;
  13976. /**
  13977. * Set the yaw, pitch, and roll of the bone in local or world space
  13978. * @param yaw The rotation of the bone on the y axis
  13979. * @param pitch The rotation of the bone on the x axis
  13980. * @param roll The rotation of the bone on the z axis
  13981. * @param space The space that the axes of rotation are in
  13982. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13983. */
  13984. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13985. /**
  13986. * Add a rotation to the bone on an axis in local or world space
  13987. * @param axis The axis to rotate the bone on
  13988. * @param amount The amount to rotate the bone
  13989. * @param space The space that the axis is in
  13990. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13991. */
  13992. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13993. /**
  13994. * Set the rotation of the bone to a particular axis angle in local or world space
  13995. * @param axis The axis to rotate the bone on
  13996. * @param angle The angle that the bone should be rotated to
  13997. * @param space The space that the axis is in
  13998. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13999. */
  14000. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14001. /**
  14002. * Set the euler rotation of the bone in local of world space
  14003. * @param rotation The euler rotation that the bone should be set to
  14004. * @param space The space that the rotation is in
  14005. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14006. */
  14007. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14008. /**
  14009. * Set the quaternion rotation of the bone in local of world space
  14010. * @param quat The quaternion rotation that the bone should be set to
  14011. * @param space The space that the rotation is in
  14012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14013. */
  14014. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14015. /**
  14016. * Set the rotation matrix of the bone in local of world space
  14017. * @param rotMat The rotation matrix that the bone should be set to
  14018. * @param space The space that the rotation is in
  14019. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14020. */
  14021. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14022. private _rotateWithMatrix;
  14023. private _getNegativeRotationToRef;
  14024. /**
  14025. * Get the position of the bone in local or world space
  14026. * @param space The space that the returned position is in
  14027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14028. * @returns The position of the bone
  14029. */
  14030. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14031. /**
  14032. * Copy the position of the bone to a vector3 in local or world space
  14033. * @param space The space that the returned position is in
  14034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14035. * @param result The vector3 to copy the position to
  14036. */
  14037. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14038. /**
  14039. * Get the absolute position of the bone (world space)
  14040. * @param mesh The mesh that this bone is attached to
  14041. * @returns The absolute position of the bone
  14042. */
  14043. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14044. /**
  14045. * Copy the absolute position of the bone (world space) to the result param
  14046. * @param mesh The mesh that this bone is attached to
  14047. * @param result The vector3 to copy the absolute position to
  14048. */
  14049. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14050. /**
  14051. * Compute the absolute transforms of this bone and its children
  14052. */
  14053. computeAbsoluteTransforms(): void;
  14054. /**
  14055. * Get the world direction from an axis that is in the local space of the bone
  14056. * @param localAxis The local direction that is used to compute the world direction
  14057. * @param mesh The mesh that this bone is attached to
  14058. * @returns The world direction
  14059. */
  14060. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14061. /**
  14062. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14063. * @param localAxis The local direction that is used to compute the world direction
  14064. * @param mesh The mesh that this bone is attached to
  14065. * @param result The vector3 that the world direction will be copied to
  14066. */
  14067. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14068. /**
  14069. * Get the euler rotation of the bone in local or world space
  14070. * @param space The space that the rotation should be in
  14071. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14072. * @returns The euler rotation
  14073. */
  14074. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14075. /**
  14076. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14077. * @param space The space that the rotation should be in
  14078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14079. * @param result The vector3 that the rotation should be copied to
  14080. */
  14081. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14082. /**
  14083. * Get the quaternion rotation of the bone in either local or world space
  14084. * @param space The space that the rotation should be in
  14085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14086. * @returns The quaternion rotation
  14087. */
  14088. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14089. /**
  14090. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14091. * @param space The space that the rotation should be in
  14092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14093. * @param result The quaternion that the rotation should be copied to
  14094. */
  14095. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14096. /**
  14097. * Get the rotation matrix of the bone in local or world space
  14098. * @param space The space that the rotation should be in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. * @returns The rotation matrix
  14101. */
  14102. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14103. /**
  14104. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14105. * @param space The space that the rotation should be in
  14106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14107. * @param result The quaternion that the rotation should be copied to
  14108. */
  14109. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14110. /**
  14111. * Get the world position of a point that is in the local space of the bone
  14112. * @param position The local position
  14113. * @param mesh The mesh that this bone is attached to
  14114. * @returns The world position
  14115. */
  14116. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14117. /**
  14118. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14119. * @param position The local position
  14120. * @param mesh The mesh that this bone is attached to
  14121. * @param result The vector3 that the world position should be copied to
  14122. */
  14123. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14124. /**
  14125. * Get the local position of a point that is in world space
  14126. * @param position The world position
  14127. * @param mesh The mesh that this bone is attached to
  14128. * @returns The local position
  14129. */
  14130. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14131. /**
  14132. * Get the local position of a point that is in world space and copy it to the result param
  14133. * @param position The world position
  14134. * @param mesh The mesh that this bone is attached to
  14135. * @param result The vector3 that the local position should be copied to
  14136. */
  14137. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14138. }
  14139. }
  14140. declare module "babylonjs/Meshes/transformNode" {
  14141. import { DeepImmutable } from "babylonjs/types";
  14142. import { Observable } from "babylonjs/Misc/observable";
  14143. import { Nullable } from "babylonjs/types";
  14144. import { Camera } from "babylonjs/Cameras/camera";
  14145. import { Scene } from "babylonjs/scene";
  14146. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14147. import { Node } from "babylonjs/node";
  14148. import { Bone } from "babylonjs/Bones/bone";
  14149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14150. import { Space } from "babylonjs/Maths/math.axis";
  14151. /**
  14152. * 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.
  14153. * @see https://doc.babylonjs.com/how_to/transformnode
  14154. */
  14155. export class TransformNode extends Node {
  14156. /**
  14157. * Object will not rotate to face the camera
  14158. */
  14159. static BILLBOARDMODE_NONE: number;
  14160. /**
  14161. * Object will rotate to face the camera but only on the x axis
  14162. */
  14163. static BILLBOARDMODE_X: number;
  14164. /**
  14165. * Object will rotate to face the camera but only on the y axis
  14166. */
  14167. static BILLBOARDMODE_Y: number;
  14168. /**
  14169. * Object will rotate to face the camera but only on the z axis
  14170. */
  14171. static BILLBOARDMODE_Z: number;
  14172. /**
  14173. * Object will rotate to face the camera
  14174. */
  14175. static BILLBOARDMODE_ALL: number;
  14176. /**
  14177. * Object will rotate to face the camera's position instead of orientation
  14178. */
  14179. static BILLBOARDMODE_USE_POSITION: number;
  14180. private _forward;
  14181. private _forwardInverted;
  14182. private _up;
  14183. private _right;
  14184. private _rightInverted;
  14185. private _position;
  14186. private _rotation;
  14187. private _rotationQuaternion;
  14188. protected _scaling: Vector3;
  14189. protected _isDirty: boolean;
  14190. private _transformToBoneReferal;
  14191. private _isAbsoluteSynced;
  14192. private _billboardMode;
  14193. /**
  14194. * Gets or sets the billboard mode. Default is 0.
  14195. *
  14196. * | Value | Type | Description |
  14197. * | --- | --- | --- |
  14198. * | 0 | BILLBOARDMODE_NONE | |
  14199. * | 1 | BILLBOARDMODE_X | |
  14200. * | 2 | BILLBOARDMODE_Y | |
  14201. * | 4 | BILLBOARDMODE_Z | |
  14202. * | 7 | BILLBOARDMODE_ALL | |
  14203. *
  14204. */
  14205. billboardMode: number;
  14206. private _preserveParentRotationForBillboard;
  14207. /**
  14208. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14209. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14210. */
  14211. preserveParentRotationForBillboard: boolean;
  14212. /**
  14213. * 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
  14214. */
  14215. scalingDeterminant: number;
  14216. private _infiniteDistance;
  14217. /**
  14218. * Gets or sets the distance of the object to max, often used by skybox
  14219. */
  14220. infiniteDistance: boolean;
  14221. /**
  14222. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14223. * By default the system will update normals to compensate
  14224. */
  14225. ignoreNonUniformScaling: boolean;
  14226. /**
  14227. * 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
  14228. */
  14229. reIntegrateRotationIntoRotationQuaternion: boolean;
  14230. /** @hidden */
  14231. _poseMatrix: Nullable<Matrix>;
  14232. /** @hidden */
  14233. _localMatrix: Matrix;
  14234. private _usePivotMatrix;
  14235. private _absolutePosition;
  14236. private _absoluteScaling;
  14237. private _absoluteRotationQuaternion;
  14238. private _pivotMatrix;
  14239. private _pivotMatrixInverse;
  14240. protected _postMultiplyPivotMatrix: boolean;
  14241. protected _isWorldMatrixFrozen: boolean;
  14242. /** @hidden */
  14243. _indexInSceneTransformNodesArray: number;
  14244. /**
  14245. * An event triggered after the world matrix is updated
  14246. */
  14247. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14248. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14249. /**
  14250. * Gets a string identifying the name of the class
  14251. * @returns "TransformNode" string
  14252. */
  14253. getClassName(): string;
  14254. /**
  14255. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14256. */
  14257. position: Vector3;
  14258. /**
  14259. * 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)).
  14260. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14261. */
  14262. rotation: Vector3;
  14263. /**
  14264. * 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)).
  14265. */
  14266. scaling: Vector3;
  14267. /**
  14268. * 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).
  14269. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14270. */
  14271. rotationQuaternion: Nullable<Quaternion>;
  14272. /**
  14273. * The forward direction of that transform in world space.
  14274. */
  14275. readonly forward: Vector3;
  14276. /**
  14277. * The up direction of that transform in world space.
  14278. */
  14279. readonly up: Vector3;
  14280. /**
  14281. * The right direction of that transform in world space.
  14282. */
  14283. readonly right: Vector3;
  14284. /**
  14285. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14286. * @param matrix the matrix to copy the pose from
  14287. * @returns this TransformNode.
  14288. */
  14289. updatePoseMatrix(matrix: Matrix): TransformNode;
  14290. /**
  14291. * Returns the mesh Pose matrix.
  14292. * @returns the pose matrix
  14293. */
  14294. getPoseMatrix(): Matrix;
  14295. /** @hidden */
  14296. _isSynchronized(): boolean;
  14297. /** @hidden */
  14298. _initCache(): void;
  14299. /**
  14300. * Flag the transform node as dirty (Forcing it to update everything)
  14301. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14302. * @returns this transform node
  14303. */
  14304. markAsDirty(property: string): TransformNode;
  14305. /**
  14306. * Returns the current mesh absolute position.
  14307. * Returns a Vector3.
  14308. */
  14309. readonly absolutePosition: Vector3;
  14310. /**
  14311. * Returns the current mesh absolute scaling.
  14312. * Returns a Vector3.
  14313. */
  14314. readonly absoluteScaling: Vector3;
  14315. /**
  14316. * Returns the current mesh absolute rotation.
  14317. * Returns a Quaternion.
  14318. */
  14319. readonly absoluteRotationQuaternion: Quaternion;
  14320. /**
  14321. * Sets a new matrix to apply before all other transformation
  14322. * @param matrix defines the transform matrix
  14323. * @returns the current TransformNode
  14324. */
  14325. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14326. /**
  14327. * Sets a new pivot matrix to the current node
  14328. * @param matrix defines the new pivot matrix to use
  14329. * @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
  14330. * @returns the current TransformNode
  14331. */
  14332. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14333. /**
  14334. * Returns the mesh pivot matrix.
  14335. * Default : Identity.
  14336. * @returns the matrix
  14337. */
  14338. getPivotMatrix(): Matrix;
  14339. /**
  14340. * Instantiate (when possible) or clone that node with its hierarchy
  14341. * @param newParent defines the new parent to use for the instance (or clone)
  14342. * @returns an instance (or a clone) of the current node with its hiearchy
  14343. */
  14344. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14345. /**
  14346. * Prevents the World matrix to be computed any longer
  14347. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14348. * @returns the TransformNode.
  14349. */
  14350. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14351. /**
  14352. * Allows back the World matrix computation.
  14353. * @returns the TransformNode.
  14354. */
  14355. unfreezeWorldMatrix(): this;
  14356. /**
  14357. * True if the World matrix has been frozen.
  14358. */
  14359. readonly isWorldMatrixFrozen: boolean;
  14360. /**
  14361. * Retuns the mesh absolute position in the World.
  14362. * @returns a Vector3.
  14363. */
  14364. getAbsolutePosition(): Vector3;
  14365. /**
  14366. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14367. * @param absolutePosition the absolute position to set
  14368. * @returns the TransformNode.
  14369. */
  14370. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14371. /**
  14372. * Sets the mesh position in its local space.
  14373. * @param vector3 the position to set in localspace
  14374. * @returns the TransformNode.
  14375. */
  14376. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14377. /**
  14378. * Returns the mesh position in the local space from the current World matrix values.
  14379. * @returns a new Vector3.
  14380. */
  14381. getPositionExpressedInLocalSpace(): Vector3;
  14382. /**
  14383. * Translates the mesh along the passed Vector3 in its local space.
  14384. * @param vector3 the distance to translate in localspace
  14385. * @returns the TransformNode.
  14386. */
  14387. locallyTranslate(vector3: Vector3): TransformNode;
  14388. private static _lookAtVectorCache;
  14389. /**
  14390. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14391. * @param targetPoint the position (must be in same space as current mesh) to look at
  14392. * @param yawCor optional yaw (y-axis) correction in radians
  14393. * @param pitchCor optional pitch (x-axis) correction in radians
  14394. * @param rollCor optional roll (z-axis) correction in radians
  14395. * @param space the choosen space of the target
  14396. * @returns the TransformNode.
  14397. */
  14398. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14399. /**
  14400. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14401. * This Vector3 is expressed in the World space.
  14402. * @param localAxis axis to rotate
  14403. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14404. */
  14405. getDirection(localAxis: Vector3): Vector3;
  14406. /**
  14407. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14408. * localAxis is expressed in the mesh local space.
  14409. * result is computed in the Wordl space from the mesh World matrix.
  14410. * @param localAxis axis to rotate
  14411. * @param result the resulting transformnode
  14412. * @returns this TransformNode.
  14413. */
  14414. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14415. /**
  14416. * Sets this transform node rotation to the given local axis.
  14417. * @param localAxis the axis in local space
  14418. * @param yawCor optional yaw (y-axis) correction in radians
  14419. * @param pitchCor optional pitch (x-axis) correction in radians
  14420. * @param rollCor optional roll (z-axis) correction in radians
  14421. * @returns this TransformNode
  14422. */
  14423. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14424. /**
  14425. * Sets a new pivot point to the current node
  14426. * @param point defines the new pivot point to use
  14427. * @param space defines if the point is in world or local space (local by default)
  14428. * @returns the current TransformNode
  14429. */
  14430. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14431. /**
  14432. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14433. * @returns the pivot point
  14434. */
  14435. getPivotPoint(): Vector3;
  14436. /**
  14437. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14438. * @param result the vector3 to store the result
  14439. * @returns this TransformNode.
  14440. */
  14441. getPivotPointToRef(result: Vector3): TransformNode;
  14442. /**
  14443. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14444. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14445. */
  14446. getAbsolutePivotPoint(): Vector3;
  14447. /**
  14448. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14449. * @param result vector3 to store the result
  14450. * @returns this TransformNode.
  14451. */
  14452. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14453. /**
  14454. * Defines the passed node as the parent of the current node.
  14455. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14456. * @see https://doc.babylonjs.com/how_to/parenting
  14457. * @param node the node ot set as the parent
  14458. * @returns this TransformNode.
  14459. */
  14460. setParent(node: Nullable<Node>): TransformNode;
  14461. private _nonUniformScaling;
  14462. /**
  14463. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14464. */
  14465. readonly nonUniformScaling: boolean;
  14466. /** @hidden */
  14467. _updateNonUniformScalingState(value: boolean): boolean;
  14468. /**
  14469. * Attach the current TransformNode to another TransformNode associated with a bone
  14470. * @param bone Bone affecting the TransformNode
  14471. * @param affectedTransformNode TransformNode associated with the bone
  14472. * @returns this object
  14473. */
  14474. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14475. /**
  14476. * Detach the transform node if its associated with a bone
  14477. * @returns this object
  14478. */
  14479. detachFromBone(): TransformNode;
  14480. private static _rotationAxisCache;
  14481. /**
  14482. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14483. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14484. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14485. * The passed axis is also normalized.
  14486. * @param axis the axis to rotate around
  14487. * @param amount the amount to rotate in radians
  14488. * @param space Space to rotate in (Default: local)
  14489. * @returns the TransformNode.
  14490. */
  14491. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14492. /**
  14493. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14494. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14495. * The passed axis is also normalized. .
  14496. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14497. * @param point the point to rotate around
  14498. * @param axis the axis to rotate around
  14499. * @param amount the amount to rotate in radians
  14500. * @returns the TransformNode
  14501. */
  14502. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14503. /**
  14504. * Translates the mesh along the axis vector for the passed distance in the given space.
  14505. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14506. * @param axis the axis to translate in
  14507. * @param distance the distance to translate
  14508. * @param space Space to rotate in (Default: local)
  14509. * @returns the TransformNode.
  14510. */
  14511. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14512. /**
  14513. * Adds a rotation step to the mesh current rotation.
  14514. * x, y, z are Euler angles expressed in radians.
  14515. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14516. * This means this rotation is made in the mesh local space only.
  14517. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14518. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14519. * ```javascript
  14520. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14521. * ```
  14522. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14523. * 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.
  14524. * @param x Rotation to add
  14525. * @param y Rotation to add
  14526. * @param z Rotation to add
  14527. * @returns the TransformNode.
  14528. */
  14529. addRotation(x: number, y: number, z: number): TransformNode;
  14530. /**
  14531. * @hidden
  14532. */
  14533. protected _getEffectiveParent(): Nullable<Node>;
  14534. /**
  14535. * Computes the world matrix of the node
  14536. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14537. * @returns the world matrix
  14538. */
  14539. computeWorldMatrix(force?: boolean): Matrix;
  14540. protected _afterComputeWorldMatrix(): void;
  14541. /**
  14542. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14543. * @param func callback function to add
  14544. *
  14545. * @returns the TransformNode.
  14546. */
  14547. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14548. /**
  14549. * Removes a registered callback function.
  14550. * @param func callback function to remove
  14551. * @returns the TransformNode.
  14552. */
  14553. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14554. /**
  14555. * Gets the position of the current mesh in camera space
  14556. * @param camera defines the camera to use
  14557. * @returns a position
  14558. */
  14559. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14560. /**
  14561. * Returns the distance from the mesh to the active camera
  14562. * @param camera defines the camera to use
  14563. * @returns the distance
  14564. */
  14565. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14566. /**
  14567. * Clone the current transform node
  14568. * @param name Name of the new clone
  14569. * @param newParent New parent for the clone
  14570. * @param doNotCloneChildren Do not clone children hierarchy
  14571. * @returns the new transform node
  14572. */
  14573. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14574. /**
  14575. * Serializes the objects information.
  14576. * @param currentSerializationObject defines the object to serialize in
  14577. * @returns the serialized object
  14578. */
  14579. serialize(currentSerializationObject?: any): any;
  14580. /**
  14581. * Returns a new TransformNode object parsed from the source provided.
  14582. * @param parsedTransformNode is the source.
  14583. * @param scene the scne the object belongs to
  14584. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14585. * @returns a new TransformNode object parsed from the source provided.
  14586. */
  14587. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14588. /**
  14589. * Get all child-transformNodes of this node
  14590. * @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
  14591. * @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
  14592. * @returns an array of TransformNode
  14593. */
  14594. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14595. /**
  14596. * Releases resources associated with this transform node.
  14597. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14598. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14599. */
  14600. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14601. /**
  14602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14606. * @returns the current mesh
  14607. */
  14608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14609. private _syncAbsoluteScalingAndRotation;
  14610. }
  14611. }
  14612. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14613. import { Observable } from "babylonjs/Misc/observable";
  14614. import { Nullable } from "babylonjs/types";
  14615. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14616. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14618. import { Ray } from "babylonjs/Culling/ray";
  14619. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14620. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14621. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14622. /**
  14623. * Defines the types of pose enabled controllers that are supported
  14624. */
  14625. export enum PoseEnabledControllerType {
  14626. /**
  14627. * HTC Vive
  14628. */
  14629. VIVE = 0,
  14630. /**
  14631. * Oculus Rift
  14632. */
  14633. OCULUS = 1,
  14634. /**
  14635. * Windows mixed reality
  14636. */
  14637. WINDOWS = 2,
  14638. /**
  14639. * Samsung gear VR
  14640. */
  14641. GEAR_VR = 3,
  14642. /**
  14643. * Google Daydream
  14644. */
  14645. DAYDREAM = 4,
  14646. /**
  14647. * Generic
  14648. */
  14649. GENERIC = 5
  14650. }
  14651. /**
  14652. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14653. */
  14654. export interface MutableGamepadButton {
  14655. /**
  14656. * Value of the button/trigger
  14657. */
  14658. value: number;
  14659. /**
  14660. * If the button/trigger is currently touched
  14661. */
  14662. touched: boolean;
  14663. /**
  14664. * If the button/trigger is currently pressed
  14665. */
  14666. pressed: boolean;
  14667. }
  14668. /**
  14669. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14670. * @hidden
  14671. */
  14672. export interface ExtendedGamepadButton extends GamepadButton {
  14673. /**
  14674. * If the button/trigger is currently pressed
  14675. */
  14676. readonly pressed: boolean;
  14677. /**
  14678. * If the button/trigger is currently touched
  14679. */
  14680. readonly touched: boolean;
  14681. /**
  14682. * Value of the button/trigger
  14683. */
  14684. readonly value: number;
  14685. }
  14686. /** @hidden */
  14687. export interface _GamePadFactory {
  14688. /**
  14689. * Returns wether or not the current gamepad can be created for this type of controller.
  14690. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14691. * @returns true if it can be created, otherwise false
  14692. */
  14693. canCreate(gamepadInfo: any): boolean;
  14694. /**
  14695. * Creates a new instance of the Gamepad.
  14696. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14697. * @returns the new gamepad instance
  14698. */
  14699. create(gamepadInfo: any): Gamepad;
  14700. }
  14701. /**
  14702. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14703. */
  14704. export class PoseEnabledControllerHelper {
  14705. /** @hidden */
  14706. static _ControllerFactories: _GamePadFactory[];
  14707. /** @hidden */
  14708. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14709. /**
  14710. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14711. * @param vrGamepad the gamepad to initialized
  14712. * @returns a vr controller of the type the gamepad identified as
  14713. */
  14714. static InitiateController(vrGamepad: any): Gamepad;
  14715. }
  14716. /**
  14717. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14718. */
  14719. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14720. /**
  14721. * If the controller is used in a webXR session
  14722. */
  14723. isXR: boolean;
  14724. private _deviceRoomPosition;
  14725. private _deviceRoomRotationQuaternion;
  14726. /**
  14727. * The device position in babylon space
  14728. */
  14729. devicePosition: Vector3;
  14730. /**
  14731. * The device rotation in babylon space
  14732. */
  14733. deviceRotationQuaternion: Quaternion;
  14734. /**
  14735. * The scale factor of the device in babylon space
  14736. */
  14737. deviceScaleFactor: number;
  14738. /**
  14739. * (Likely devicePosition should be used instead) The device position in its room space
  14740. */
  14741. position: Vector3;
  14742. /**
  14743. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14744. */
  14745. rotationQuaternion: Quaternion;
  14746. /**
  14747. * The type of controller (Eg. Windows mixed reality)
  14748. */
  14749. controllerType: PoseEnabledControllerType;
  14750. protected _calculatedPosition: Vector3;
  14751. private _calculatedRotation;
  14752. /**
  14753. * The raw pose from the device
  14754. */
  14755. rawPose: DevicePose;
  14756. private _trackPosition;
  14757. private _maxRotationDistFromHeadset;
  14758. private _draggedRoomRotation;
  14759. /**
  14760. * @hidden
  14761. */
  14762. _disableTrackPosition(fixedPosition: Vector3): void;
  14763. /**
  14764. * Internal, the mesh attached to the controller
  14765. * @hidden
  14766. */
  14767. _mesh: Nullable<AbstractMesh>;
  14768. private _poseControlledCamera;
  14769. private _leftHandSystemQuaternion;
  14770. /**
  14771. * Internal, matrix used to convert room space to babylon space
  14772. * @hidden
  14773. */
  14774. _deviceToWorld: Matrix;
  14775. /**
  14776. * Node to be used when casting a ray from the controller
  14777. * @hidden
  14778. */
  14779. _pointingPoseNode: Nullable<TransformNode>;
  14780. /**
  14781. * Name of the child mesh that can be used to cast a ray from the controller
  14782. */
  14783. static readonly POINTING_POSE: string;
  14784. /**
  14785. * Creates a new PoseEnabledController from a gamepad
  14786. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14787. */
  14788. constructor(browserGamepad: any);
  14789. private _workingMatrix;
  14790. /**
  14791. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14792. */
  14793. update(): void;
  14794. /**
  14795. * Updates only the pose device and mesh without doing any button event checking
  14796. */
  14797. protected _updatePoseAndMesh(): void;
  14798. /**
  14799. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14800. * @param poseData raw pose fromthe device
  14801. */
  14802. updateFromDevice(poseData: DevicePose): void;
  14803. /**
  14804. * @hidden
  14805. */
  14806. _meshAttachedObservable: Observable<AbstractMesh>;
  14807. /**
  14808. * Attaches a mesh to the controller
  14809. * @param mesh the mesh to be attached
  14810. */
  14811. attachToMesh(mesh: AbstractMesh): void;
  14812. /**
  14813. * Attaches the controllers mesh to a camera
  14814. * @param camera the camera the mesh should be attached to
  14815. */
  14816. attachToPoseControlledCamera(camera: TargetCamera): void;
  14817. /**
  14818. * Disposes of the controller
  14819. */
  14820. dispose(): void;
  14821. /**
  14822. * The mesh that is attached to the controller
  14823. */
  14824. readonly mesh: Nullable<AbstractMesh>;
  14825. /**
  14826. * Gets the ray of the controller in the direction the controller is pointing
  14827. * @param length the length the resulting ray should be
  14828. * @returns a ray in the direction the controller is pointing
  14829. */
  14830. getForwardRay(length?: number): Ray;
  14831. }
  14832. }
  14833. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14834. import { Observable } from "babylonjs/Misc/observable";
  14835. import { Scene } from "babylonjs/scene";
  14836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14837. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14838. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14839. import { Nullable } from "babylonjs/types";
  14840. /**
  14841. * Defines the WebVRController object that represents controllers tracked in 3D space
  14842. */
  14843. export abstract class WebVRController extends PoseEnabledController {
  14844. /**
  14845. * Internal, the default controller model for the controller
  14846. */
  14847. protected _defaultModel: Nullable<AbstractMesh>;
  14848. /**
  14849. * Fired when the trigger state has changed
  14850. */
  14851. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14852. /**
  14853. * Fired when the main button state has changed
  14854. */
  14855. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14856. /**
  14857. * Fired when the secondary button state has changed
  14858. */
  14859. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14860. /**
  14861. * Fired when the pad state has changed
  14862. */
  14863. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14864. /**
  14865. * Fired when controllers stick values have changed
  14866. */
  14867. onPadValuesChangedObservable: Observable<StickValues>;
  14868. /**
  14869. * Array of button availible on the controller
  14870. */
  14871. protected _buttons: Array<MutableGamepadButton>;
  14872. private _onButtonStateChange;
  14873. /**
  14874. * Fired when a controller button's state has changed
  14875. * @param callback the callback containing the button that was modified
  14876. */
  14877. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14878. /**
  14879. * X and Y axis corresponding to the controllers joystick
  14880. */
  14881. pad: StickValues;
  14882. /**
  14883. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14884. */
  14885. hand: string;
  14886. /**
  14887. * The default controller model for the controller
  14888. */
  14889. readonly defaultModel: Nullable<AbstractMesh>;
  14890. /**
  14891. * Creates a new WebVRController from a gamepad
  14892. * @param vrGamepad the gamepad that the WebVRController should be created from
  14893. */
  14894. constructor(vrGamepad: any);
  14895. /**
  14896. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14897. */
  14898. update(): void;
  14899. /**
  14900. * Function to be called when a button is modified
  14901. */
  14902. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14903. /**
  14904. * Loads a mesh and attaches it to the controller
  14905. * @param scene the scene the mesh should be added to
  14906. * @param meshLoaded callback for when the mesh has been loaded
  14907. */
  14908. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14909. private _setButtonValue;
  14910. private _changes;
  14911. private _checkChanges;
  14912. /**
  14913. * Disposes of th webVRCOntroller
  14914. */
  14915. dispose(): void;
  14916. }
  14917. }
  14918. declare module "babylonjs/Lights/hemisphericLight" {
  14919. import { Nullable } from "babylonjs/types";
  14920. import { Scene } from "babylonjs/scene";
  14921. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14922. import { Color3 } from "babylonjs/Maths/math.color";
  14923. import { Effect } from "babylonjs/Materials/effect";
  14924. import { Light } from "babylonjs/Lights/light";
  14925. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14926. /**
  14927. * The HemisphericLight simulates the ambient environment light,
  14928. * so the passed direction is the light reflection direction, not the incoming direction.
  14929. */
  14930. export class HemisphericLight extends Light {
  14931. /**
  14932. * The groundColor is the light in the opposite direction to the one specified during creation.
  14933. * 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.
  14934. */
  14935. groundColor: Color3;
  14936. /**
  14937. * The light reflection direction, not the incoming direction.
  14938. */
  14939. direction: Vector3;
  14940. /**
  14941. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14942. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14943. * The HemisphericLight can't cast shadows.
  14944. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14945. * @param name The friendly name of the light
  14946. * @param direction The direction of the light reflection
  14947. * @param scene The scene the light belongs to
  14948. */
  14949. constructor(name: string, direction: Vector3, scene: Scene);
  14950. protected _buildUniformLayout(): void;
  14951. /**
  14952. * Returns the string "HemisphericLight".
  14953. * @return The class name
  14954. */
  14955. getClassName(): string;
  14956. /**
  14957. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14958. * Returns the updated direction.
  14959. * @param target The target the direction should point to
  14960. * @return The computed direction
  14961. */
  14962. setDirectionToTarget(target: Vector3): Vector3;
  14963. /**
  14964. * Returns the shadow generator associated to the light.
  14965. * @returns Always null for hemispheric lights because it does not support shadows.
  14966. */
  14967. getShadowGenerator(): Nullable<IShadowGenerator>;
  14968. /**
  14969. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14970. * @param effect The effect to update
  14971. * @param lightIndex The index of the light in the effect to update
  14972. * @returns The hemispheric light
  14973. */
  14974. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14975. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14976. /**
  14977. * Computes the world matrix of the node
  14978. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14979. * @param useWasUpdatedFlag defines a reserved property
  14980. * @returns the world matrix
  14981. */
  14982. computeWorldMatrix(): Matrix;
  14983. /**
  14984. * Returns the integer 3.
  14985. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14986. */
  14987. getTypeID(): number;
  14988. /**
  14989. * Prepares the list of defines specific to the light type.
  14990. * @param defines the list of defines
  14991. * @param lightIndex defines the index of the light for the effect
  14992. */
  14993. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14994. }
  14995. }
  14996. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14997. /** @hidden */
  14998. export var vrMultiviewToSingleviewPixelShader: {
  14999. name: string;
  15000. shader: string;
  15001. };
  15002. }
  15003. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15005. import { Scene } from "babylonjs/scene";
  15006. /**
  15007. * Renders to multiple views with a single draw call
  15008. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15009. */
  15010. export class MultiviewRenderTarget extends RenderTargetTexture {
  15011. /**
  15012. * Creates a multiview render target
  15013. * @param scene scene used with the render target
  15014. * @param size the size of the render target (used for each view)
  15015. */
  15016. constructor(scene: Scene, size?: number | {
  15017. width: number;
  15018. height: number;
  15019. } | {
  15020. ratio: number;
  15021. });
  15022. /**
  15023. * @hidden
  15024. * @param faceIndex the face index, if its a cube texture
  15025. */
  15026. _bindFrameBuffer(faceIndex?: number): void;
  15027. /**
  15028. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15029. * @returns the view count
  15030. */
  15031. getViewCount(): number;
  15032. }
  15033. }
  15034. declare module "babylonjs/Maths/math.frustum" {
  15035. import { Matrix } from "babylonjs/Maths/math.vector";
  15036. import { DeepImmutable } from "babylonjs/types";
  15037. import { Plane } from "babylonjs/Maths/math.plane";
  15038. /**
  15039. * Represents a camera frustum
  15040. */
  15041. export class Frustum {
  15042. /**
  15043. * Gets the planes representing the frustum
  15044. * @param transform matrix to be applied to the returned planes
  15045. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15046. */
  15047. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15048. /**
  15049. * Gets the near frustum plane transformed by the transform matrix
  15050. * @param transform transformation matrix to be applied to the resulting frustum plane
  15051. * @param frustumPlane the resuling frustum plane
  15052. */
  15053. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15054. /**
  15055. * Gets the far frustum plane transformed by the transform matrix
  15056. * @param transform transformation matrix to be applied to the resulting frustum plane
  15057. * @param frustumPlane the resuling frustum plane
  15058. */
  15059. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15060. /**
  15061. * Gets the left frustum plane transformed by the transform matrix
  15062. * @param transform transformation matrix to be applied to the resulting frustum plane
  15063. * @param frustumPlane the resuling frustum plane
  15064. */
  15065. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15066. /**
  15067. * Gets the right frustum plane transformed by the transform matrix
  15068. * @param transform transformation matrix to be applied to the resulting frustum plane
  15069. * @param frustumPlane the resuling frustum plane
  15070. */
  15071. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15072. /**
  15073. * Gets the top frustum plane transformed by the transform matrix
  15074. * @param transform transformation matrix to be applied to the resulting frustum plane
  15075. * @param frustumPlane the resuling frustum plane
  15076. */
  15077. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15078. /**
  15079. * Gets the bottom frustum plane transformed by the transform matrix
  15080. * @param transform transformation matrix to be applied to the resulting frustum plane
  15081. * @param frustumPlane the resuling frustum plane
  15082. */
  15083. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15084. /**
  15085. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15086. * @param transform transformation matrix to be applied to the resulting frustum planes
  15087. * @param frustumPlanes the resuling frustum planes
  15088. */
  15089. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15090. }
  15091. }
  15092. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15093. import { Camera } from "babylonjs/Cameras/camera";
  15094. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15095. import { Nullable } from "babylonjs/types";
  15096. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15097. import { Matrix } from "babylonjs/Maths/math.vector";
  15098. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15099. module "babylonjs/Engines/engine" {
  15100. interface Engine {
  15101. /**
  15102. * Creates a new multiview render target
  15103. * @param width defines the width of the texture
  15104. * @param height defines the height of the texture
  15105. * @returns the created multiview texture
  15106. */
  15107. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15108. /**
  15109. * Binds a multiview framebuffer to be drawn to
  15110. * @param multiviewTexture texture to bind
  15111. */
  15112. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15113. }
  15114. }
  15115. module "babylonjs/Cameras/camera" {
  15116. interface Camera {
  15117. /**
  15118. * @hidden
  15119. * 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)
  15120. */
  15121. _useMultiviewToSingleView: boolean;
  15122. /**
  15123. * @hidden
  15124. * 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)
  15125. */
  15126. _multiviewTexture: Nullable<RenderTargetTexture>;
  15127. /**
  15128. * @hidden
  15129. * ensures the multiview texture of the camera exists and has the specified width/height
  15130. * @param width height to set on the multiview texture
  15131. * @param height width to set on the multiview texture
  15132. */
  15133. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15134. }
  15135. }
  15136. module "babylonjs/scene" {
  15137. interface Scene {
  15138. /** @hidden */
  15139. _transformMatrixR: Matrix;
  15140. /** @hidden */
  15141. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15142. /** @hidden */
  15143. _createMultiviewUbo(): void;
  15144. /** @hidden */
  15145. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15146. /** @hidden */
  15147. _renderMultiviewToSingleView(camera: Camera): void;
  15148. }
  15149. }
  15150. }
  15151. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15152. import { Camera } from "babylonjs/Cameras/camera";
  15153. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15154. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15155. import "babylonjs/Engines/Extensions/engine.multiview";
  15156. /**
  15157. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15158. * This will not be used for webXR as it supports displaying texture arrays directly
  15159. */
  15160. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15161. /**
  15162. * Initializes a VRMultiviewToSingleview
  15163. * @param name name of the post process
  15164. * @param camera camera to be applied to
  15165. * @param scaleFactor scaling factor to the size of the output texture
  15166. */
  15167. constructor(name: string, camera: Camera, scaleFactor: number);
  15168. }
  15169. }
  15170. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15171. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15172. import { Nullable } from "babylonjs/types";
  15173. import { Size } from "babylonjs/Maths/math.size";
  15174. import { Observable } from "babylonjs/Misc/observable";
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /** @hidden */
  15178. _vrDisplay: any;
  15179. /** @hidden */
  15180. _vrSupported: boolean;
  15181. /** @hidden */
  15182. _oldSize: Size;
  15183. /** @hidden */
  15184. _oldHardwareScaleFactor: number;
  15185. /** @hidden */
  15186. _vrExclusivePointerMode: boolean;
  15187. /** @hidden */
  15188. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15189. /** @hidden */
  15190. _onVRDisplayPointerRestricted: () => void;
  15191. /** @hidden */
  15192. _onVRDisplayPointerUnrestricted: () => void;
  15193. /** @hidden */
  15194. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15195. /** @hidden */
  15196. _onVrDisplayDisconnect: Nullable<() => void>;
  15197. /** @hidden */
  15198. _onVrDisplayPresentChange: Nullable<() => void>;
  15199. /**
  15200. * Observable signaled when VR display mode changes
  15201. */
  15202. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15203. /**
  15204. * Observable signaled when VR request present is complete
  15205. */
  15206. onVRRequestPresentComplete: Observable<boolean>;
  15207. /**
  15208. * Observable signaled when VR request present starts
  15209. */
  15210. onVRRequestPresentStart: Observable<Engine>;
  15211. /**
  15212. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15213. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15214. */
  15215. isInVRExclusivePointerMode: boolean;
  15216. /**
  15217. * Gets a boolean indicating if a webVR device was detected
  15218. * @returns true if a webVR device was detected
  15219. */
  15220. isVRDevicePresent(): boolean;
  15221. /**
  15222. * Gets the current webVR device
  15223. * @returns the current webVR device (or null)
  15224. */
  15225. getVRDevice(): any;
  15226. /**
  15227. * Initializes a webVR display and starts listening to display change events
  15228. * The onVRDisplayChangedObservable will be notified upon these changes
  15229. * @returns A promise containing a VRDisplay and if vr is supported
  15230. */
  15231. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15232. /** @hidden */
  15233. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15234. /**
  15235. * Call this function to switch to webVR mode
  15236. * Will do nothing if webVR is not supported or if there is no webVR device
  15237. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15238. */
  15239. enableVR(): void;
  15240. /** @hidden */
  15241. _onVRFullScreenTriggered(): void;
  15242. }
  15243. }
  15244. }
  15245. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15246. import { Nullable } from "babylonjs/types";
  15247. import { Observable } from "babylonjs/Misc/observable";
  15248. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15249. import { Scene } from "babylonjs/scene";
  15250. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15251. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15252. import { Node } from "babylonjs/node";
  15253. import { Ray } from "babylonjs/Culling/ray";
  15254. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15255. import "babylonjs/Engines/Extensions/engine.webVR";
  15256. /**
  15257. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15258. * IMPORTANT!! The data is right-hand data.
  15259. * @export
  15260. * @interface DevicePose
  15261. */
  15262. export interface DevicePose {
  15263. /**
  15264. * The position of the device, values in array are [x,y,z].
  15265. */
  15266. readonly position: Nullable<Float32Array>;
  15267. /**
  15268. * The linearVelocity of the device, values in array are [x,y,z].
  15269. */
  15270. readonly linearVelocity: Nullable<Float32Array>;
  15271. /**
  15272. * The linearAcceleration of the device, values in array are [x,y,z].
  15273. */
  15274. readonly linearAcceleration: Nullable<Float32Array>;
  15275. /**
  15276. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15277. */
  15278. readonly orientation: Nullable<Float32Array>;
  15279. /**
  15280. * The angularVelocity of the device, values in array are [x,y,z].
  15281. */
  15282. readonly angularVelocity: Nullable<Float32Array>;
  15283. /**
  15284. * The angularAcceleration of the device, values in array are [x,y,z].
  15285. */
  15286. readonly angularAcceleration: Nullable<Float32Array>;
  15287. }
  15288. /**
  15289. * Interface representing a pose controlled object in Babylon.
  15290. * A pose controlled object has both regular pose values as well as pose values
  15291. * from an external device such as a VR head mounted display
  15292. */
  15293. export interface PoseControlled {
  15294. /**
  15295. * The position of the object in babylon space.
  15296. */
  15297. position: Vector3;
  15298. /**
  15299. * The rotation quaternion of the object in babylon space.
  15300. */
  15301. rotationQuaternion: Quaternion;
  15302. /**
  15303. * The position of the device in babylon space.
  15304. */
  15305. devicePosition?: Vector3;
  15306. /**
  15307. * The rotation quaternion of the device in babylon space.
  15308. */
  15309. deviceRotationQuaternion: Quaternion;
  15310. /**
  15311. * The raw pose coming from the device.
  15312. */
  15313. rawPose: Nullable<DevicePose>;
  15314. /**
  15315. * The scale of the device to be used when translating from device space to babylon space.
  15316. */
  15317. deviceScaleFactor: number;
  15318. /**
  15319. * Updates the poseControlled values based on the input device pose.
  15320. * @param poseData the pose data to update the object with
  15321. */
  15322. updateFromDevice(poseData: DevicePose): void;
  15323. }
  15324. /**
  15325. * Set of options to customize the webVRCamera
  15326. */
  15327. export interface WebVROptions {
  15328. /**
  15329. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15330. */
  15331. trackPosition?: boolean;
  15332. /**
  15333. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15334. */
  15335. positionScale?: number;
  15336. /**
  15337. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15338. */
  15339. displayName?: string;
  15340. /**
  15341. * Should the native controller meshes be initialized. (default: true)
  15342. */
  15343. controllerMeshes?: boolean;
  15344. /**
  15345. * Creating a default HemiLight only on controllers. (default: true)
  15346. */
  15347. defaultLightingOnControllers?: boolean;
  15348. /**
  15349. * If you don't want to use the default VR button of the helper. (default: false)
  15350. */
  15351. useCustomVRButton?: boolean;
  15352. /**
  15353. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15354. */
  15355. customVRButton?: HTMLButtonElement;
  15356. /**
  15357. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15358. */
  15359. rayLength?: number;
  15360. /**
  15361. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15362. */
  15363. defaultHeight?: number;
  15364. /**
  15365. * If multiview should be used if availible (default: false)
  15366. */
  15367. useMultiview?: boolean;
  15368. }
  15369. /**
  15370. * This represents a WebVR camera.
  15371. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15372. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15373. */
  15374. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15375. private webVROptions;
  15376. /**
  15377. * @hidden
  15378. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15379. */
  15380. _vrDevice: any;
  15381. /**
  15382. * The rawPose of the vrDevice.
  15383. */
  15384. rawPose: Nullable<DevicePose>;
  15385. private _onVREnabled;
  15386. private _specsVersion;
  15387. private _attached;
  15388. private _frameData;
  15389. protected _descendants: Array<Node>;
  15390. private _deviceRoomPosition;
  15391. /** @hidden */
  15392. _deviceRoomRotationQuaternion: Quaternion;
  15393. private _standingMatrix;
  15394. /**
  15395. * Represents device position in babylon space.
  15396. */
  15397. devicePosition: Vector3;
  15398. /**
  15399. * Represents device rotation in babylon space.
  15400. */
  15401. deviceRotationQuaternion: Quaternion;
  15402. /**
  15403. * The scale of the device to be used when translating from device space to babylon space.
  15404. */
  15405. deviceScaleFactor: number;
  15406. private _deviceToWorld;
  15407. private _worldToDevice;
  15408. /**
  15409. * References to the webVR controllers for the vrDevice.
  15410. */
  15411. controllers: Array<WebVRController>;
  15412. /**
  15413. * Emits an event when a controller is attached.
  15414. */
  15415. onControllersAttachedObservable: Observable<WebVRController[]>;
  15416. /**
  15417. * Emits an event when a controller's mesh has been loaded;
  15418. */
  15419. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15420. /**
  15421. * Emits an event when the HMD's pose has been updated.
  15422. */
  15423. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15424. private _poseSet;
  15425. /**
  15426. * If the rig cameras be used as parent instead of this camera.
  15427. */
  15428. rigParenting: boolean;
  15429. private _lightOnControllers;
  15430. private _defaultHeight?;
  15431. /**
  15432. * Instantiates a WebVRFreeCamera.
  15433. * @param name The name of the WebVRFreeCamera
  15434. * @param position The starting anchor position for the camera
  15435. * @param scene The scene the camera belongs to
  15436. * @param webVROptions a set of customizable options for the webVRCamera
  15437. */
  15438. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15439. /**
  15440. * Gets the device distance from the ground in meters.
  15441. * @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.
  15442. */
  15443. deviceDistanceToRoomGround(): number;
  15444. /**
  15445. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15446. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15447. */
  15448. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15449. /**
  15450. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15451. * @returns A promise with a boolean set to if the standing matrix is supported.
  15452. */
  15453. useStandingMatrixAsync(): Promise<boolean>;
  15454. /**
  15455. * Disposes the camera
  15456. */
  15457. dispose(): void;
  15458. /**
  15459. * Gets a vrController by name.
  15460. * @param name The name of the controller to retreive
  15461. * @returns the controller matching the name specified or null if not found
  15462. */
  15463. getControllerByName(name: string): Nullable<WebVRController>;
  15464. private _leftController;
  15465. /**
  15466. * The controller corresponding to the users left hand.
  15467. */
  15468. readonly leftController: Nullable<WebVRController>;
  15469. private _rightController;
  15470. /**
  15471. * The controller corresponding to the users right hand.
  15472. */
  15473. readonly rightController: Nullable<WebVRController>;
  15474. /**
  15475. * Casts a ray forward from the vrCamera's gaze.
  15476. * @param length Length of the ray (default: 100)
  15477. * @returns the ray corresponding to the gaze
  15478. */
  15479. getForwardRay(length?: number): Ray;
  15480. /**
  15481. * @hidden
  15482. * Updates the camera based on device's frame data
  15483. */
  15484. _checkInputs(): void;
  15485. /**
  15486. * Updates the poseControlled values based on the input device pose.
  15487. * @param poseData Pose coming from the device
  15488. */
  15489. updateFromDevice(poseData: DevicePose): void;
  15490. private _htmlElementAttached;
  15491. private _detachIfAttached;
  15492. /**
  15493. * WebVR's attach control will start broadcasting frames to the device.
  15494. * Note that in certain browsers (chrome for example) this function must be called
  15495. * within a user-interaction callback. Example:
  15496. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15497. *
  15498. * @param element html element to attach the vrDevice to
  15499. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15500. */
  15501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15502. /**
  15503. * Detaches the camera from the html element and disables VR
  15504. *
  15505. * @param element html element to detach from
  15506. */
  15507. detachControl(element: HTMLElement): void;
  15508. /**
  15509. * @returns the name of this class
  15510. */
  15511. getClassName(): string;
  15512. /**
  15513. * Calls resetPose on the vrDisplay
  15514. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15515. */
  15516. resetToCurrentRotation(): void;
  15517. /**
  15518. * @hidden
  15519. * Updates the rig cameras (left and right eye)
  15520. */
  15521. _updateRigCameras(): void;
  15522. private _workingVector;
  15523. private _oneVector;
  15524. private _workingMatrix;
  15525. private updateCacheCalled;
  15526. private _correctPositionIfNotTrackPosition;
  15527. /**
  15528. * @hidden
  15529. * Updates the cached values of the camera
  15530. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15531. */
  15532. _updateCache(ignoreParentClass?: boolean): void;
  15533. /**
  15534. * @hidden
  15535. * Get current device position in babylon world
  15536. */
  15537. _computeDevicePosition(): void;
  15538. /**
  15539. * Updates the current device position and rotation in the babylon world
  15540. */
  15541. update(): void;
  15542. /**
  15543. * @hidden
  15544. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15545. * @returns an identity matrix
  15546. */
  15547. _getViewMatrix(): Matrix;
  15548. private _tmpMatrix;
  15549. /**
  15550. * This function is called by the two RIG cameras.
  15551. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15552. * @hidden
  15553. */
  15554. _getWebVRViewMatrix(): Matrix;
  15555. /** @hidden */
  15556. _getWebVRProjectionMatrix(): Matrix;
  15557. private _onGamepadConnectedObserver;
  15558. private _onGamepadDisconnectedObserver;
  15559. private _updateCacheWhenTrackingDisabledObserver;
  15560. /**
  15561. * Initializes the controllers and their meshes
  15562. */
  15563. initControllers(): void;
  15564. }
  15565. }
  15566. declare module "babylonjs/PostProcesses/postProcess" {
  15567. import { Nullable } from "babylonjs/types";
  15568. import { SmartArray } from "babylonjs/Misc/smartArray";
  15569. import { Observable } from "babylonjs/Misc/observable";
  15570. import { Vector2 } from "babylonjs/Maths/math.vector";
  15571. import { Camera } from "babylonjs/Cameras/camera";
  15572. import { Effect } from "babylonjs/Materials/effect";
  15573. import "babylonjs/Shaders/postprocess.vertex";
  15574. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15575. import { Engine } from "babylonjs/Engines/engine";
  15576. import { Color4 } from "babylonjs/Maths/math.color";
  15577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15578. /**
  15579. * Size options for a post process
  15580. */
  15581. export type PostProcessOptions = {
  15582. width: number;
  15583. height: number;
  15584. };
  15585. /**
  15586. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15587. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15588. */
  15589. export class PostProcess {
  15590. /** Name of the PostProcess. */
  15591. name: string;
  15592. /**
  15593. * Gets or sets the unique id of the post process
  15594. */
  15595. uniqueId: number;
  15596. /**
  15597. * Width of the texture to apply the post process on
  15598. */
  15599. width: number;
  15600. /**
  15601. * Height of the texture to apply the post process on
  15602. */
  15603. height: number;
  15604. /**
  15605. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15606. * @hidden
  15607. */
  15608. _outputTexture: Nullable<InternalTexture>;
  15609. /**
  15610. * Sampling mode used by the shader
  15611. * See https://doc.babylonjs.com/classes/3.1/texture
  15612. */
  15613. renderTargetSamplingMode: number;
  15614. /**
  15615. * Clear color to use when screen clearing
  15616. */
  15617. clearColor: Color4;
  15618. /**
  15619. * If the buffer needs to be cleared before applying the post process. (default: true)
  15620. * Should be set to false if shader will overwrite all previous pixels.
  15621. */
  15622. autoClear: boolean;
  15623. /**
  15624. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15625. */
  15626. alphaMode: number;
  15627. /**
  15628. * Sets the setAlphaBlendConstants of the babylon engine
  15629. */
  15630. alphaConstants: Color4;
  15631. /**
  15632. * Animations to be used for the post processing
  15633. */
  15634. animations: import("babylonjs/Animations/animation").Animation[];
  15635. /**
  15636. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15637. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15638. */
  15639. enablePixelPerfectMode: boolean;
  15640. /**
  15641. * Force the postprocess to be applied without taking in account viewport
  15642. */
  15643. forceFullscreenViewport: boolean;
  15644. /**
  15645. * List of inspectable custom properties (used by the Inspector)
  15646. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15647. */
  15648. inspectableCustomProperties: IInspectable[];
  15649. /**
  15650. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15651. *
  15652. * | Value | Type | Description |
  15653. * | ----- | ----------------------------------- | ----------- |
  15654. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15655. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15656. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15657. *
  15658. */
  15659. scaleMode: number;
  15660. /**
  15661. * Force textures to be a power of two (default: false)
  15662. */
  15663. alwaysForcePOT: boolean;
  15664. private _samples;
  15665. /**
  15666. * Number of sample textures (default: 1)
  15667. */
  15668. samples: number;
  15669. /**
  15670. * Modify the scale of the post process to be the same as the viewport (default: false)
  15671. */
  15672. adaptScaleToCurrentViewport: boolean;
  15673. private _camera;
  15674. private _scene;
  15675. private _engine;
  15676. private _options;
  15677. private _reusable;
  15678. private _textureType;
  15679. /**
  15680. * Smart array of input and output textures for the post process.
  15681. * @hidden
  15682. */
  15683. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15684. /**
  15685. * The index in _textures that corresponds to the output texture.
  15686. * @hidden
  15687. */
  15688. _currentRenderTextureInd: number;
  15689. private _effect;
  15690. private _samplers;
  15691. private _fragmentUrl;
  15692. private _vertexUrl;
  15693. private _parameters;
  15694. private _scaleRatio;
  15695. protected _indexParameters: any;
  15696. private _shareOutputWithPostProcess;
  15697. private _texelSize;
  15698. private _forcedOutputTexture;
  15699. /**
  15700. * Returns the fragment url or shader name used in the post process.
  15701. * @returns the fragment url or name in the shader store.
  15702. */
  15703. getEffectName(): string;
  15704. /**
  15705. * An event triggered when the postprocess is activated.
  15706. */
  15707. onActivateObservable: Observable<Camera>;
  15708. private _onActivateObserver;
  15709. /**
  15710. * A function that is added to the onActivateObservable
  15711. */
  15712. onActivate: Nullable<(camera: Camera) => void>;
  15713. /**
  15714. * An event triggered when the postprocess changes its size.
  15715. */
  15716. onSizeChangedObservable: Observable<PostProcess>;
  15717. private _onSizeChangedObserver;
  15718. /**
  15719. * A function that is added to the onSizeChangedObservable
  15720. */
  15721. onSizeChanged: (postProcess: PostProcess) => void;
  15722. /**
  15723. * An event triggered when the postprocess applies its effect.
  15724. */
  15725. onApplyObservable: Observable<Effect>;
  15726. private _onApplyObserver;
  15727. /**
  15728. * A function that is added to the onApplyObservable
  15729. */
  15730. onApply: (effect: Effect) => void;
  15731. /**
  15732. * An event triggered before rendering the postprocess
  15733. */
  15734. onBeforeRenderObservable: Observable<Effect>;
  15735. private _onBeforeRenderObserver;
  15736. /**
  15737. * A function that is added to the onBeforeRenderObservable
  15738. */
  15739. onBeforeRender: (effect: Effect) => void;
  15740. /**
  15741. * An event triggered after rendering the postprocess
  15742. */
  15743. onAfterRenderObservable: Observable<Effect>;
  15744. private _onAfterRenderObserver;
  15745. /**
  15746. * A function that is added to the onAfterRenderObservable
  15747. */
  15748. onAfterRender: (efect: Effect) => void;
  15749. /**
  15750. * 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
  15751. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15752. */
  15753. inputTexture: InternalTexture;
  15754. /**
  15755. * Gets the camera which post process is applied to.
  15756. * @returns The camera the post process is applied to.
  15757. */
  15758. getCamera(): Camera;
  15759. /**
  15760. * Gets the texel size of the postprocess.
  15761. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15762. */
  15763. readonly texelSize: Vector2;
  15764. /**
  15765. * Creates a new instance PostProcess
  15766. * @param name The name of the PostProcess.
  15767. * @param fragmentUrl The url of the fragment shader to be used.
  15768. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15769. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15770. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15771. * @param camera The camera to apply the render pass to.
  15772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15773. * @param engine The engine which the post process will be applied. (default: current engine)
  15774. * @param reusable If the post process can be reused on the same frame. (default: false)
  15775. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15776. * @param textureType Type of textures used when performing the post process. (default: 0)
  15777. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15778. * @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
  15779. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15780. */
  15781. constructor(
  15782. /** Name of the PostProcess. */
  15783. 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);
  15784. /**
  15785. * Gets a string idenfifying the name of the class
  15786. * @returns "PostProcess" string
  15787. */
  15788. getClassName(): string;
  15789. /**
  15790. * Gets the engine which this post process belongs to.
  15791. * @returns The engine the post process was enabled with.
  15792. */
  15793. getEngine(): Engine;
  15794. /**
  15795. * The effect that is created when initializing the post process.
  15796. * @returns The created effect corresponding the the postprocess.
  15797. */
  15798. getEffect(): Effect;
  15799. /**
  15800. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15801. * @param postProcess The post process to share the output with.
  15802. * @returns This post process.
  15803. */
  15804. shareOutputWith(postProcess: PostProcess): PostProcess;
  15805. /**
  15806. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15807. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15808. */
  15809. useOwnOutput(): void;
  15810. /**
  15811. * Updates the effect with the current post process compile time values and recompiles the shader.
  15812. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15813. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15814. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15815. * @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
  15816. * @param onCompiled Called when the shader has been compiled.
  15817. * @param onError Called if there is an error when compiling a shader.
  15818. */
  15819. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15820. /**
  15821. * The post process is reusable if it can be used multiple times within one frame.
  15822. * @returns If the post process is reusable
  15823. */
  15824. isReusable(): boolean;
  15825. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15826. markTextureDirty(): void;
  15827. /**
  15828. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15829. * 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.
  15830. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15831. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15832. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15833. * @returns The target texture that was bound to be written to.
  15834. */
  15835. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15836. /**
  15837. * If the post process is supported.
  15838. */
  15839. readonly isSupported: boolean;
  15840. /**
  15841. * The aspect ratio of the output texture.
  15842. */
  15843. readonly aspectRatio: number;
  15844. /**
  15845. * Get a value indicating if the post-process is ready to be used
  15846. * @returns true if the post-process is ready (shader is compiled)
  15847. */
  15848. isReady(): boolean;
  15849. /**
  15850. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15851. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15852. */
  15853. apply(): Nullable<Effect>;
  15854. private _disposeTextures;
  15855. /**
  15856. * Disposes the post process.
  15857. * @param camera The camera to dispose the post process on.
  15858. */
  15859. dispose(camera?: Camera): void;
  15860. }
  15861. }
  15862. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15863. /** @hidden */
  15864. export var kernelBlurVaryingDeclaration: {
  15865. name: string;
  15866. shader: string;
  15867. };
  15868. }
  15869. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15870. /** @hidden */
  15871. export var kernelBlurFragment: {
  15872. name: string;
  15873. shader: string;
  15874. };
  15875. }
  15876. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15877. /** @hidden */
  15878. export var kernelBlurFragment2: {
  15879. name: string;
  15880. shader: string;
  15881. };
  15882. }
  15883. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15884. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15885. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15886. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15887. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15888. /** @hidden */
  15889. export var kernelBlurPixelShader: {
  15890. name: string;
  15891. shader: string;
  15892. };
  15893. }
  15894. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15895. /** @hidden */
  15896. export var kernelBlurVertex: {
  15897. name: string;
  15898. shader: string;
  15899. };
  15900. }
  15901. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15902. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15903. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15904. /** @hidden */
  15905. export var kernelBlurVertexShader: {
  15906. name: string;
  15907. shader: string;
  15908. };
  15909. }
  15910. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15911. import { Vector2 } from "babylonjs/Maths/math.vector";
  15912. import { Nullable } from "babylonjs/types";
  15913. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15914. import { Camera } from "babylonjs/Cameras/camera";
  15915. import { Effect } from "babylonjs/Materials/effect";
  15916. import { Engine } from "babylonjs/Engines/engine";
  15917. import "babylonjs/Shaders/kernelBlur.fragment";
  15918. import "babylonjs/Shaders/kernelBlur.vertex";
  15919. /**
  15920. * The Blur Post Process which blurs an image based on a kernel and direction.
  15921. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15922. */
  15923. export class BlurPostProcess extends PostProcess {
  15924. /** The direction in which to blur the image. */
  15925. direction: Vector2;
  15926. private blockCompilation;
  15927. protected _kernel: number;
  15928. protected _idealKernel: number;
  15929. protected _packedFloat: boolean;
  15930. private _staticDefines;
  15931. /**
  15932. * Sets the length in pixels of the blur sample region
  15933. */
  15934. /**
  15935. * Gets the length in pixels of the blur sample region
  15936. */
  15937. kernel: number;
  15938. /**
  15939. * Sets wether or not the blur needs to unpack/repack floats
  15940. */
  15941. /**
  15942. * Gets wether or not the blur is unpacking/repacking floats
  15943. */
  15944. packedFloat: boolean;
  15945. /**
  15946. * Creates a new instance BlurPostProcess
  15947. * @param name The name of the effect.
  15948. * @param direction The direction in which to blur the image.
  15949. * @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.
  15950. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15951. * @param camera The camera to apply the render pass to.
  15952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15953. * @param engine The engine which the post process will be applied. (default: current engine)
  15954. * @param reusable If the post process can be reused on the same frame. (default: false)
  15955. * @param textureType Type of textures used when performing the post process. (default: 0)
  15956. * @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)
  15957. */
  15958. constructor(name: string,
  15959. /** The direction in which to blur the image. */
  15960. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15961. /**
  15962. * Updates the effect with the current post process compile time values and recompiles the shader.
  15963. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15964. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15965. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15966. * @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
  15967. * @param onCompiled Called when the shader has been compiled.
  15968. * @param onError Called if there is an error when compiling a shader.
  15969. */
  15970. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15971. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15972. /**
  15973. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15974. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15975. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15976. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15977. * The gaps between physical kernels are compensated for in the weighting of the samples
  15978. * @param idealKernel Ideal blur kernel.
  15979. * @return Nearest best kernel.
  15980. */
  15981. protected _nearestBestKernel(idealKernel: number): number;
  15982. /**
  15983. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15984. * @param x The point on the Gaussian distribution to sample.
  15985. * @return the value of the Gaussian function at x.
  15986. */
  15987. protected _gaussianWeight(x: number): number;
  15988. /**
  15989. * Generates a string that can be used as a floating point number in GLSL.
  15990. * @param x Value to print.
  15991. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15992. * @return GLSL float string.
  15993. */
  15994. protected _glslFloat(x: number, decimalFigures?: number): string;
  15995. }
  15996. }
  15997. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15998. import { Scene } from "babylonjs/scene";
  15999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16000. import { Plane } from "babylonjs/Maths/math.plane";
  16001. /**
  16002. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16003. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16004. * You can then easily use it as a reflectionTexture on a flat surface.
  16005. * In case the surface is not a plane, please consider relying on reflection probes.
  16006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16007. */
  16008. export class MirrorTexture extends RenderTargetTexture {
  16009. private scene;
  16010. /**
  16011. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16012. * 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.
  16013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16014. */
  16015. mirrorPlane: Plane;
  16016. /**
  16017. * Define the blur ratio used to blur the reflection if needed.
  16018. */
  16019. blurRatio: number;
  16020. /**
  16021. * Define the adaptive blur kernel used to blur the reflection if needed.
  16022. * This will autocompute the closest best match for the `blurKernel`
  16023. */
  16024. adaptiveBlurKernel: number;
  16025. /**
  16026. * Define the blur kernel used to blur the reflection if needed.
  16027. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16028. */
  16029. blurKernel: number;
  16030. /**
  16031. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16032. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16033. */
  16034. blurKernelX: number;
  16035. /**
  16036. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16037. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16038. */
  16039. blurKernelY: number;
  16040. private _autoComputeBlurKernel;
  16041. protected _onRatioRescale(): void;
  16042. private _updateGammaSpace;
  16043. private _imageProcessingConfigChangeObserver;
  16044. private _transformMatrix;
  16045. private _mirrorMatrix;
  16046. private _savedViewMatrix;
  16047. private _blurX;
  16048. private _blurY;
  16049. private _adaptiveBlurKernel;
  16050. private _blurKernelX;
  16051. private _blurKernelY;
  16052. private _blurRatio;
  16053. /**
  16054. * Instantiates a Mirror Texture.
  16055. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16056. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16057. * You can then easily use it as a reflectionTexture on a flat surface.
  16058. * In case the surface is not a plane, please consider relying on reflection probes.
  16059. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16060. * @param name
  16061. * @param size
  16062. * @param scene
  16063. * @param generateMipMaps
  16064. * @param type
  16065. * @param samplingMode
  16066. * @param generateDepthBuffer
  16067. */
  16068. constructor(name: string, size: number | {
  16069. width: number;
  16070. height: number;
  16071. } | {
  16072. ratio: number;
  16073. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16074. private _preparePostProcesses;
  16075. /**
  16076. * Clone the mirror texture.
  16077. * @returns the cloned texture
  16078. */
  16079. clone(): MirrorTexture;
  16080. /**
  16081. * Serialize the texture to a JSON representation you could use in Parse later on
  16082. * @returns the serialized JSON representation
  16083. */
  16084. serialize(): any;
  16085. /**
  16086. * Dispose the texture and release its associated resources.
  16087. */
  16088. dispose(): void;
  16089. }
  16090. }
  16091. declare module "babylonjs/Materials/Textures/texture" {
  16092. import { Observable } from "babylonjs/Misc/observable";
  16093. import { Nullable } from "babylonjs/types";
  16094. import { Scene } from "babylonjs/scene";
  16095. import { Matrix } from "babylonjs/Maths/math.vector";
  16096. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16097. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16098. import { Engine } from "babylonjs/Engines/engine";
  16099. /**
  16100. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16101. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16102. */
  16103. export class Texture extends BaseTexture {
  16104. /**
  16105. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16106. */
  16107. static SerializeBuffers: boolean;
  16108. /** @hidden */
  16109. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16110. /** @hidden */
  16111. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16112. /** @hidden */
  16113. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16114. /** nearest is mag = nearest and min = nearest and mip = linear */
  16115. static readonly NEAREST_SAMPLINGMODE: number;
  16116. /** nearest is mag = nearest and min = nearest and mip = linear */
  16117. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16118. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16119. static readonly BILINEAR_SAMPLINGMODE: number;
  16120. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16121. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16122. /** Trilinear is mag = linear and min = linear and mip = linear */
  16123. static readonly TRILINEAR_SAMPLINGMODE: number;
  16124. /** Trilinear is mag = linear and min = linear and mip = linear */
  16125. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16126. /** mag = nearest and min = nearest and mip = nearest */
  16127. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16128. /** mag = nearest and min = linear and mip = nearest */
  16129. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16130. /** mag = nearest and min = linear and mip = linear */
  16131. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16132. /** mag = nearest and min = linear and mip = none */
  16133. static readonly NEAREST_LINEAR: number;
  16134. /** mag = nearest and min = nearest and mip = none */
  16135. static readonly NEAREST_NEAREST: number;
  16136. /** mag = linear and min = nearest and mip = nearest */
  16137. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16138. /** mag = linear and min = nearest and mip = linear */
  16139. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16140. /** mag = linear and min = linear and mip = none */
  16141. static readonly LINEAR_LINEAR: number;
  16142. /** mag = linear and min = nearest and mip = none */
  16143. static readonly LINEAR_NEAREST: number;
  16144. /** Explicit coordinates mode */
  16145. static readonly EXPLICIT_MODE: number;
  16146. /** Spherical coordinates mode */
  16147. static readonly SPHERICAL_MODE: number;
  16148. /** Planar coordinates mode */
  16149. static readonly PLANAR_MODE: number;
  16150. /** Cubic coordinates mode */
  16151. static readonly CUBIC_MODE: number;
  16152. /** Projection coordinates mode */
  16153. static readonly PROJECTION_MODE: number;
  16154. /** Inverse Cubic coordinates mode */
  16155. static readonly SKYBOX_MODE: number;
  16156. /** Inverse Cubic coordinates mode */
  16157. static readonly INVCUBIC_MODE: number;
  16158. /** Equirectangular coordinates mode */
  16159. static readonly EQUIRECTANGULAR_MODE: number;
  16160. /** Equirectangular Fixed coordinates mode */
  16161. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16162. /** Equirectangular Fixed Mirrored coordinates mode */
  16163. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16164. /** Texture is not repeating outside of 0..1 UVs */
  16165. static readonly CLAMP_ADDRESSMODE: number;
  16166. /** Texture is repeating outside of 0..1 UVs */
  16167. static readonly WRAP_ADDRESSMODE: number;
  16168. /** Texture is repeating and mirrored */
  16169. static readonly MIRROR_ADDRESSMODE: number;
  16170. /**
  16171. * 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
  16172. */
  16173. static UseSerializedUrlIfAny: boolean;
  16174. /**
  16175. * Define the url of the texture.
  16176. */
  16177. url: Nullable<string>;
  16178. /**
  16179. * Define an offset on the texture to offset the u coordinates of the UVs
  16180. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16181. */
  16182. uOffset: number;
  16183. /**
  16184. * Define an offset on the texture to offset the v coordinates of the UVs
  16185. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16186. */
  16187. vOffset: number;
  16188. /**
  16189. * Define an offset on the texture to scale the u coordinates of the UVs
  16190. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16191. */
  16192. uScale: number;
  16193. /**
  16194. * Define an offset on the texture to scale the v coordinates of the UVs
  16195. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16196. */
  16197. vScale: number;
  16198. /**
  16199. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16200. * @see http://doc.babylonjs.com/how_to/more_materials
  16201. */
  16202. uAng: number;
  16203. /**
  16204. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16205. * @see http://doc.babylonjs.com/how_to/more_materials
  16206. */
  16207. vAng: number;
  16208. /**
  16209. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16210. * @see http://doc.babylonjs.com/how_to/more_materials
  16211. */
  16212. wAng: number;
  16213. /**
  16214. * Defines the center of rotation (U)
  16215. */
  16216. uRotationCenter: number;
  16217. /**
  16218. * Defines the center of rotation (V)
  16219. */
  16220. vRotationCenter: number;
  16221. /**
  16222. * Defines the center of rotation (W)
  16223. */
  16224. wRotationCenter: number;
  16225. /**
  16226. * Are mip maps generated for this texture or not.
  16227. */
  16228. readonly noMipmap: boolean;
  16229. /**
  16230. * List of inspectable custom properties (used by the Inspector)
  16231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16232. */
  16233. inspectableCustomProperties: Nullable<IInspectable[]>;
  16234. private _noMipmap;
  16235. /** @hidden */
  16236. _invertY: boolean;
  16237. private _rowGenerationMatrix;
  16238. private _cachedTextureMatrix;
  16239. private _projectionModeMatrix;
  16240. private _t0;
  16241. private _t1;
  16242. private _t2;
  16243. private _cachedUOffset;
  16244. private _cachedVOffset;
  16245. private _cachedUScale;
  16246. private _cachedVScale;
  16247. private _cachedUAng;
  16248. private _cachedVAng;
  16249. private _cachedWAng;
  16250. private _cachedProjectionMatrixId;
  16251. private _cachedCoordinatesMode;
  16252. /** @hidden */
  16253. protected _initialSamplingMode: number;
  16254. /** @hidden */
  16255. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16256. private _deleteBuffer;
  16257. protected _format: Nullable<number>;
  16258. private _delayedOnLoad;
  16259. private _delayedOnError;
  16260. /**
  16261. * Observable triggered once the texture has been loaded.
  16262. */
  16263. onLoadObservable: Observable<Texture>;
  16264. protected _isBlocking: boolean;
  16265. /**
  16266. * Is the texture preventing material to render while loading.
  16267. * If false, a default texture will be used instead of the loading one during the preparation step.
  16268. */
  16269. isBlocking: boolean;
  16270. /**
  16271. * Get the current sampling mode associated with the texture.
  16272. */
  16273. readonly samplingMode: number;
  16274. /**
  16275. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16276. */
  16277. readonly invertY: boolean;
  16278. /**
  16279. * Instantiates a new texture.
  16280. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16281. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16282. * @param url define the url of the picture to load as a texture
  16283. * @param scene define the scene or engine the texture will belong to
  16284. * @param noMipmap define if the texture will require mip maps or not
  16285. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16286. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16287. * @param onLoad define a callback triggered when the texture has been loaded
  16288. * @param onError define a callback triggered when an error occurred during the loading session
  16289. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16290. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16291. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16292. */
  16293. 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);
  16294. /**
  16295. * Update the url (and optional buffer) of this texture if url was null during construction.
  16296. * @param url the url of the texture
  16297. * @param buffer the buffer of the texture (defaults to null)
  16298. * @param onLoad callback called when the texture is loaded (defaults to null)
  16299. */
  16300. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16301. /**
  16302. * Finish the loading sequence of a texture flagged as delayed load.
  16303. * @hidden
  16304. */
  16305. delayLoad(): void;
  16306. private _prepareRowForTextureGeneration;
  16307. /**
  16308. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16309. * @returns the transform matrix of the texture.
  16310. */
  16311. getTextureMatrix(): Matrix;
  16312. /**
  16313. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16314. * @returns The reflection texture transform
  16315. */
  16316. getReflectionTextureMatrix(): Matrix;
  16317. /**
  16318. * Clones the texture.
  16319. * @returns the cloned texture
  16320. */
  16321. clone(): Texture;
  16322. /**
  16323. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16324. * @returns The JSON representation of the texture
  16325. */
  16326. serialize(): any;
  16327. /**
  16328. * Get the current class name of the texture useful for serialization or dynamic coding.
  16329. * @returns "Texture"
  16330. */
  16331. getClassName(): string;
  16332. /**
  16333. * Dispose the texture and release its associated resources.
  16334. */
  16335. dispose(): void;
  16336. /**
  16337. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16338. * @param parsedTexture Define the JSON representation of the texture
  16339. * @param scene Define the scene the parsed texture should be instantiated in
  16340. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16341. * @returns The parsed texture if successful
  16342. */
  16343. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16344. /**
  16345. * Creates a texture from its base 64 representation.
  16346. * @param data Define the base64 payload without the data: prefix
  16347. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16348. * @param scene Define the scene the texture should belong to
  16349. * @param noMipmap Forces the texture to not create mip map information if true
  16350. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16351. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16352. * @param onLoad define a callback triggered when the texture has been loaded
  16353. * @param onError define a callback triggered when an error occurred during the loading session
  16354. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16355. * @returns the created texture
  16356. */
  16357. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16358. /**
  16359. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16360. * @param data Define the base64 payload without the data: prefix
  16361. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16362. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16363. * @param scene Define the scene the texture should belong to
  16364. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16365. * @param noMipmap Forces the texture to not create mip map information if true
  16366. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16367. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16368. * @param onLoad define a callback triggered when the texture has been loaded
  16369. * @param onError define a callback triggered when an error occurred during the loading session
  16370. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16371. * @returns the created texture
  16372. */
  16373. 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;
  16374. }
  16375. }
  16376. declare module "babylonjs/PostProcesses/postProcessManager" {
  16377. import { Nullable } from "babylonjs/types";
  16378. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16379. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16380. import { Scene } from "babylonjs/scene";
  16381. /**
  16382. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16383. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16384. */
  16385. export class PostProcessManager {
  16386. private _scene;
  16387. private _indexBuffer;
  16388. private _vertexBuffers;
  16389. /**
  16390. * Creates a new instance PostProcess
  16391. * @param scene The scene that the post process is associated with.
  16392. */
  16393. constructor(scene: Scene);
  16394. private _prepareBuffers;
  16395. private _buildIndexBuffer;
  16396. /**
  16397. * Rebuilds the vertex buffers of the manager.
  16398. * @hidden
  16399. */
  16400. _rebuild(): void;
  16401. /**
  16402. * Prepares a frame to be run through a post process.
  16403. * @param sourceTexture The input texture to the post procesess. (default: null)
  16404. * @param postProcesses An array of post processes to be run. (default: null)
  16405. * @returns True if the post processes were able to be run.
  16406. * @hidden
  16407. */
  16408. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16409. /**
  16410. * Manually render a set of post processes to a texture.
  16411. * @param postProcesses An array of post processes to be run.
  16412. * @param targetTexture The target texture to render to.
  16413. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16414. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16415. * @param lodLevel defines which lod of the texture to render to
  16416. */
  16417. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16418. /**
  16419. * Finalize the result of the output of the postprocesses.
  16420. * @param doNotPresent If true the result will not be displayed to the screen.
  16421. * @param targetTexture The target texture to render to.
  16422. * @param faceIndex The index of the face to bind the target texture to.
  16423. * @param postProcesses The array of post processes to render.
  16424. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16425. * @hidden
  16426. */
  16427. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16428. /**
  16429. * Disposes of the post process manager.
  16430. */
  16431. dispose(): void;
  16432. }
  16433. }
  16434. declare module "babylonjs/Misc/gradients" {
  16435. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16436. /** Interface used by value gradients (color, factor, ...) */
  16437. export interface IValueGradient {
  16438. /**
  16439. * Gets or sets the gradient value (between 0 and 1)
  16440. */
  16441. gradient: number;
  16442. }
  16443. /** Class used to store color4 gradient */
  16444. export class ColorGradient implements IValueGradient {
  16445. /**
  16446. * Gets or sets the gradient value (between 0 and 1)
  16447. */
  16448. gradient: number;
  16449. /**
  16450. * Gets or sets first associated color
  16451. */
  16452. color1: Color4;
  16453. /**
  16454. * Gets or sets second associated color
  16455. */
  16456. color2?: Color4;
  16457. /**
  16458. * Will get a color picked randomly between color1 and color2.
  16459. * If color2 is undefined then color1 will be used
  16460. * @param result defines the target Color4 to store the result in
  16461. */
  16462. getColorToRef(result: Color4): void;
  16463. }
  16464. /** Class used to store color 3 gradient */
  16465. export class Color3Gradient implements IValueGradient {
  16466. /**
  16467. * Gets or sets the gradient value (between 0 and 1)
  16468. */
  16469. gradient: number;
  16470. /**
  16471. * Gets or sets the associated color
  16472. */
  16473. color: Color3;
  16474. }
  16475. /** Class used to store factor gradient */
  16476. export class FactorGradient implements IValueGradient {
  16477. /**
  16478. * Gets or sets the gradient value (between 0 and 1)
  16479. */
  16480. gradient: number;
  16481. /**
  16482. * Gets or sets first associated factor
  16483. */
  16484. factor1: number;
  16485. /**
  16486. * Gets or sets second associated factor
  16487. */
  16488. factor2?: number;
  16489. /**
  16490. * Will get a number picked randomly between factor1 and factor2.
  16491. * If factor2 is undefined then factor1 will be used
  16492. * @returns the picked number
  16493. */
  16494. getFactor(): number;
  16495. }
  16496. /**
  16497. * Helper used to simplify some generic gradient tasks
  16498. */
  16499. export class GradientHelper {
  16500. /**
  16501. * Gets the current gradient from an array of IValueGradient
  16502. * @param ratio defines the current ratio to get
  16503. * @param gradients defines the array of IValueGradient
  16504. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16505. */
  16506. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16507. }
  16508. }
  16509. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16510. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16511. import { Nullable } from "babylonjs/types";
  16512. module "babylonjs/Engines/thinEngine" {
  16513. interface ThinEngine {
  16514. /**
  16515. * Creates a dynamic texture
  16516. * @param width defines the width of the texture
  16517. * @param height defines the height of the texture
  16518. * @param generateMipMaps defines if the engine should generate the mip levels
  16519. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16520. * @returns the dynamic texture inside an InternalTexture
  16521. */
  16522. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16523. /**
  16524. * Update the content of a dynamic texture
  16525. * @param texture defines the texture to update
  16526. * @param canvas defines the canvas containing the source
  16527. * @param invertY defines if data must be stored with Y axis inverted
  16528. * @param premulAlpha defines if alpha is stored as premultiplied
  16529. * @param format defines the format of the data
  16530. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16531. */
  16532. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16533. }
  16534. }
  16535. }
  16536. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16537. import { Scene } from "babylonjs/scene";
  16538. import { Texture } from "babylonjs/Materials/Textures/texture";
  16539. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16540. /**
  16541. * A class extending Texture allowing drawing on a texture
  16542. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16543. */
  16544. export class DynamicTexture extends Texture {
  16545. private _generateMipMaps;
  16546. private _canvas;
  16547. private _context;
  16548. private _engine;
  16549. /**
  16550. * Creates a DynamicTexture
  16551. * @param name defines the name of the texture
  16552. * @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
  16553. * @param scene defines the scene where you want the texture
  16554. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16555. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16556. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16557. */
  16558. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16559. /**
  16560. * Get the current class name of the texture useful for serialization or dynamic coding.
  16561. * @returns "DynamicTexture"
  16562. */
  16563. getClassName(): string;
  16564. /**
  16565. * Gets the current state of canRescale
  16566. */
  16567. readonly canRescale: boolean;
  16568. private _recreate;
  16569. /**
  16570. * Scales the texture
  16571. * @param ratio the scale factor to apply to both width and height
  16572. */
  16573. scale(ratio: number): void;
  16574. /**
  16575. * Resizes the texture
  16576. * @param width the new width
  16577. * @param height the new height
  16578. */
  16579. scaleTo(width: number, height: number): void;
  16580. /**
  16581. * Gets the context of the canvas used by the texture
  16582. * @returns the canvas context of the dynamic texture
  16583. */
  16584. getContext(): CanvasRenderingContext2D;
  16585. /**
  16586. * Clears the texture
  16587. */
  16588. clear(): void;
  16589. /**
  16590. * Updates the texture
  16591. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16592. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16593. */
  16594. update(invertY?: boolean, premulAlpha?: boolean): void;
  16595. /**
  16596. * Draws text onto the texture
  16597. * @param text defines the text to be drawn
  16598. * @param x defines the placement of the text from the left
  16599. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16600. * @param font defines the font to be used with font-style, font-size, font-name
  16601. * @param color defines the color used for the text
  16602. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16603. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16604. * @param update defines whether texture is immediately update (default is true)
  16605. */
  16606. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16607. /**
  16608. * Clones the texture
  16609. * @returns the clone of the texture.
  16610. */
  16611. clone(): DynamicTexture;
  16612. /**
  16613. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16614. * @returns a serialized dynamic texture object
  16615. */
  16616. serialize(): any;
  16617. /** @hidden */
  16618. _rebuild(): void;
  16619. }
  16620. }
  16621. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16622. import { Scene } from "babylonjs/scene";
  16623. import { ISceneComponent } from "babylonjs/sceneComponent";
  16624. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16625. module "babylonjs/abstractScene" {
  16626. interface AbstractScene {
  16627. /**
  16628. * The list of procedural textures added to the scene
  16629. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16630. */
  16631. proceduralTextures: Array<ProceduralTexture>;
  16632. }
  16633. }
  16634. /**
  16635. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16636. * in a given scene.
  16637. */
  16638. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16639. /**
  16640. * The component name helpfull to identify the component in the list of scene components.
  16641. */
  16642. readonly name: string;
  16643. /**
  16644. * The scene the component belongs to.
  16645. */
  16646. scene: Scene;
  16647. /**
  16648. * Creates a new instance of the component for the given scene
  16649. * @param scene Defines the scene to register the component in
  16650. */
  16651. constructor(scene: Scene);
  16652. /**
  16653. * Registers the component in a given scene
  16654. */
  16655. register(): void;
  16656. /**
  16657. * Rebuilds the elements related to this component in case of
  16658. * context lost for instance.
  16659. */
  16660. rebuild(): void;
  16661. /**
  16662. * Disposes the component and the associated ressources.
  16663. */
  16664. dispose(): void;
  16665. private _beforeClear;
  16666. }
  16667. }
  16668. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16669. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16670. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16671. module "babylonjs/Engines/thinEngine" {
  16672. interface ThinEngine {
  16673. /**
  16674. * Creates a new render target cube texture
  16675. * @param size defines the size of the texture
  16676. * @param options defines the options used to create the texture
  16677. * @returns a new render target cube texture stored in an InternalTexture
  16678. */
  16679. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16680. }
  16681. }
  16682. }
  16683. declare module "babylonjs/Shaders/procedural.vertex" {
  16684. /** @hidden */
  16685. export var proceduralVertexShader: {
  16686. name: string;
  16687. shader: string;
  16688. };
  16689. }
  16690. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16691. import { Observable } from "babylonjs/Misc/observable";
  16692. import { Nullable } from "babylonjs/types";
  16693. import { Scene } from "babylonjs/scene";
  16694. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16695. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16696. import { Effect } from "babylonjs/Materials/effect";
  16697. import { Texture } from "babylonjs/Materials/Textures/texture";
  16698. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16699. import "babylonjs/Shaders/procedural.vertex";
  16700. /**
  16701. * 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.
  16702. * This is the base class of any Procedural texture and contains most of the shareable code.
  16703. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16704. */
  16705. export class ProceduralTexture extends Texture {
  16706. isCube: boolean;
  16707. /**
  16708. * Define if the texture is enabled or not (disabled texture will not render)
  16709. */
  16710. isEnabled: boolean;
  16711. /**
  16712. * Define if the texture must be cleared before rendering (default is true)
  16713. */
  16714. autoClear: boolean;
  16715. /**
  16716. * Callback called when the texture is generated
  16717. */
  16718. onGenerated: () => void;
  16719. /**
  16720. * Event raised when the texture is generated
  16721. */
  16722. onGeneratedObservable: Observable<ProceduralTexture>;
  16723. /** @hidden */
  16724. _generateMipMaps: boolean;
  16725. /** @hidden **/
  16726. _effect: Effect;
  16727. /** @hidden */
  16728. _textures: {
  16729. [key: string]: Texture;
  16730. };
  16731. private _size;
  16732. private _currentRefreshId;
  16733. private _refreshRate;
  16734. private _vertexBuffers;
  16735. private _indexBuffer;
  16736. private _uniforms;
  16737. private _samplers;
  16738. private _fragment;
  16739. private _floats;
  16740. private _ints;
  16741. private _floatsArrays;
  16742. private _colors3;
  16743. private _colors4;
  16744. private _vectors2;
  16745. private _vectors3;
  16746. private _matrices;
  16747. private _fallbackTexture;
  16748. private _fallbackTextureUsed;
  16749. private _engine;
  16750. private _cachedDefines;
  16751. private _contentUpdateId;
  16752. private _contentData;
  16753. /**
  16754. * Instantiates a new procedural texture.
  16755. * 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.
  16756. * This is the base class of any Procedural texture and contains most of the shareable code.
  16757. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16758. * @param name Define the name of the texture
  16759. * @param size Define the size of the texture to create
  16760. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16761. * @param scene Define the scene the texture belongs to
  16762. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16763. * @param generateMipMaps Define if the texture should creates mip maps or not
  16764. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16765. */
  16766. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16767. /**
  16768. * The effect that is created when initializing the post process.
  16769. * @returns The created effect corresponding the the postprocess.
  16770. */
  16771. getEffect(): Effect;
  16772. /**
  16773. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16774. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16775. */
  16776. getContent(): Nullable<ArrayBufferView>;
  16777. private _createIndexBuffer;
  16778. /** @hidden */
  16779. _rebuild(): void;
  16780. /**
  16781. * Resets the texture in order to recreate its associated resources.
  16782. * This can be called in case of context loss
  16783. */
  16784. reset(): void;
  16785. protected _getDefines(): string;
  16786. /**
  16787. * Is the texture ready to be used ? (rendered at least once)
  16788. * @returns true if ready, otherwise, false.
  16789. */
  16790. isReady(): boolean;
  16791. /**
  16792. * Resets the refresh counter of the texture and start bak from scratch.
  16793. * Could be useful to regenerate the texture if it is setup to render only once.
  16794. */
  16795. resetRefreshCounter(): void;
  16796. /**
  16797. * Set the fragment shader to use in order to render the texture.
  16798. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16799. */
  16800. setFragment(fragment: any): void;
  16801. /**
  16802. * Define the refresh rate of the texture or the rendering frequency.
  16803. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16804. */
  16805. refreshRate: number;
  16806. /** @hidden */
  16807. _shouldRender(): boolean;
  16808. /**
  16809. * Get the size the texture is rendering at.
  16810. * @returns the size (texture is always squared)
  16811. */
  16812. getRenderSize(): number;
  16813. /**
  16814. * Resize the texture to new value.
  16815. * @param size Define the new size the texture should have
  16816. * @param generateMipMaps Define whether the new texture should create mip maps
  16817. */
  16818. resize(size: number, generateMipMaps: boolean): void;
  16819. private _checkUniform;
  16820. /**
  16821. * Set a texture in the shader program used to render.
  16822. * @param name Define the name of the uniform samplers as defined in the shader
  16823. * @param texture Define the texture to bind to this sampler
  16824. * @return the texture itself allowing "fluent" like uniform updates
  16825. */
  16826. setTexture(name: string, texture: Texture): ProceduralTexture;
  16827. /**
  16828. * Set a float in the shader.
  16829. * @param name Define the name of the uniform as defined in the shader
  16830. * @param value Define the value to give to the uniform
  16831. * @return the texture itself allowing "fluent" like uniform updates
  16832. */
  16833. setFloat(name: string, value: number): ProceduralTexture;
  16834. /**
  16835. * Set a int in the shader.
  16836. * @param name Define the name of the uniform as defined in the shader
  16837. * @param value Define the value to give to the uniform
  16838. * @return the texture itself allowing "fluent" like uniform updates
  16839. */
  16840. setInt(name: string, value: number): ProceduralTexture;
  16841. /**
  16842. * Set an array of floats in the shader.
  16843. * @param name Define the name of the uniform as defined in the shader
  16844. * @param value Define the value to give to the uniform
  16845. * @return the texture itself allowing "fluent" like uniform updates
  16846. */
  16847. setFloats(name: string, value: number[]): ProceduralTexture;
  16848. /**
  16849. * Set a vec3 in the shader from a Color3.
  16850. * @param name Define the name of the uniform as defined in the shader
  16851. * @param value Define the value to give to the uniform
  16852. * @return the texture itself allowing "fluent" like uniform updates
  16853. */
  16854. setColor3(name: string, value: Color3): ProceduralTexture;
  16855. /**
  16856. * Set a vec4 in the shader from a Color4.
  16857. * @param name Define the name of the uniform as defined in the shader
  16858. * @param value Define the value to give to the uniform
  16859. * @return the texture itself allowing "fluent" like uniform updates
  16860. */
  16861. setColor4(name: string, value: Color4): ProceduralTexture;
  16862. /**
  16863. * Set a vec2 in the shader from a Vector2.
  16864. * @param name Define the name of the uniform as defined in the shader
  16865. * @param value Define the value to give to the uniform
  16866. * @return the texture itself allowing "fluent" like uniform updates
  16867. */
  16868. setVector2(name: string, value: Vector2): ProceduralTexture;
  16869. /**
  16870. * Set a vec3 in the shader from a Vector3.
  16871. * @param name Define the name of the uniform as defined in the shader
  16872. * @param value Define the value to give to the uniform
  16873. * @return the texture itself allowing "fluent" like uniform updates
  16874. */
  16875. setVector3(name: string, value: Vector3): ProceduralTexture;
  16876. /**
  16877. * Set a mat4 in the shader from a MAtrix.
  16878. * @param name Define the name of the uniform as defined in the shader
  16879. * @param value Define the value to give to the uniform
  16880. * @return the texture itself allowing "fluent" like uniform updates
  16881. */
  16882. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16883. /**
  16884. * Render the texture to its associated render target.
  16885. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16886. */
  16887. render(useCameraPostProcess?: boolean): void;
  16888. /**
  16889. * Clone the texture.
  16890. * @returns the cloned texture
  16891. */
  16892. clone(): ProceduralTexture;
  16893. /**
  16894. * Dispose the texture and release its asoociated resources.
  16895. */
  16896. dispose(): void;
  16897. }
  16898. }
  16899. declare module "babylonjs/Particles/baseParticleSystem" {
  16900. import { Nullable } from "babylonjs/types";
  16901. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16903. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16904. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16905. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16906. import { Scene } from "babylonjs/scene";
  16907. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16908. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16909. import { Texture } from "babylonjs/Materials/Textures/texture";
  16910. import { Color4 } from "babylonjs/Maths/math.color";
  16911. import { Animation } from "babylonjs/Animations/animation";
  16912. /**
  16913. * This represents the base class for particle system in Babylon.
  16914. * 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.
  16915. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16916. * @example https://doc.babylonjs.com/babylon101/particles
  16917. */
  16918. export class BaseParticleSystem {
  16919. /**
  16920. * Source color is added to the destination color without alpha affecting the result
  16921. */
  16922. static BLENDMODE_ONEONE: number;
  16923. /**
  16924. * Blend current color and particle color using particle’s alpha
  16925. */
  16926. static BLENDMODE_STANDARD: number;
  16927. /**
  16928. * Add current color and particle color multiplied by particle’s alpha
  16929. */
  16930. static BLENDMODE_ADD: number;
  16931. /**
  16932. * Multiply current color with particle color
  16933. */
  16934. static BLENDMODE_MULTIPLY: number;
  16935. /**
  16936. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16937. */
  16938. static BLENDMODE_MULTIPLYADD: number;
  16939. /**
  16940. * List of animations used by the particle system.
  16941. */
  16942. animations: Animation[];
  16943. /**
  16944. * The id of the Particle system.
  16945. */
  16946. id: string;
  16947. /**
  16948. * The friendly name of the Particle system.
  16949. */
  16950. name: string;
  16951. /**
  16952. * The rendering group used by the Particle system to chose when to render.
  16953. */
  16954. renderingGroupId: number;
  16955. /**
  16956. * The emitter represents the Mesh or position we are attaching the particle system to.
  16957. */
  16958. emitter: Nullable<AbstractMesh | Vector3>;
  16959. /**
  16960. * The maximum number of particles to emit per frame
  16961. */
  16962. emitRate: number;
  16963. /**
  16964. * If you want to launch only a few particles at once, that can be done, as well.
  16965. */
  16966. manualEmitCount: number;
  16967. /**
  16968. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16969. */
  16970. updateSpeed: number;
  16971. /**
  16972. * The amount of time the particle system is running (depends of the overall update speed).
  16973. */
  16974. targetStopDuration: number;
  16975. /**
  16976. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16977. */
  16978. disposeOnStop: boolean;
  16979. /**
  16980. * Minimum power of emitting particles.
  16981. */
  16982. minEmitPower: number;
  16983. /**
  16984. * Maximum power of emitting particles.
  16985. */
  16986. maxEmitPower: number;
  16987. /**
  16988. * Minimum life time of emitting particles.
  16989. */
  16990. minLifeTime: number;
  16991. /**
  16992. * Maximum life time of emitting particles.
  16993. */
  16994. maxLifeTime: number;
  16995. /**
  16996. * Minimum Size of emitting particles.
  16997. */
  16998. minSize: number;
  16999. /**
  17000. * Maximum Size of emitting particles.
  17001. */
  17002. maxSize: number;
  17003. /**
  17004. * Minimum scale of emitting particles on X axis.
  17005. */
  17006. minScaleX: number;
  17007. /**
  17008. * Maximum scale of emitting particles on X axis.
  17009. */
  17010. maxScaleX: number;
  17011. /**
  17012. * Minimum scale of emitting particles on Y axis.
  17013. */
  17014. minScaleY: number;
  17015. /**
  17016. * Maximum scale of emitting particles on Y axis.
  17017. */
  17018. maxScaleY: number;
  17019. /**
  17020. * Gets or sets the minimal initial rotation in radians.
  17021. */
  17022. minInitialRotation: number;
  17023. /**
  17024. * Gets or sets the maximal initial rotation in radians.
  17025. */
  17026. maxInitialRotation: number;
  17027. /**
  17028. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17029. */
  17030. minAngularSpeed: number;
  17031. /**
  17032. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17033. */
  17034. maxAngularSpeed: number;
  17035. /**
  17036. * The texture used to render each particle. (this can be a spritesheet)
  17037. */
  17038. particleTexture: Nullable<Texture>;
  17039. /**
  17040. * The layer mask we are rendering the particles through.
  17041. */
  17042. layerMask: number;
  17043. /**
  17044. * This can help using your own shader to render the particle system.
  17045. * The according effect will be created
  17046. */
  17047. customShader: any;
  17048. /**
  17049. * By default particle system starts as soon as they are created. This prevents the
  17050. * automatic start to happen and let you decide when to start emitting particles.
  17051. */
  17052. preventAutoStart: boolean;
  17053. private _noiseTexture;
  17054. /**
  17055. * Gets or sets a texture used to add random noise to particle positions
  17056. */
  17057. noiseTexture: Nullable<ProceduralTexture>;
  17058. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17059. noiseStrength: Vector3;
  17060. /**
  17061. * Callback triggered when the particle animation is ending.
  17062. */
  17063. onAnimationEnd: Nullable<() => void>;
  17064. /**
  17065. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17066. */
  17067. blendMode: number;
  17068. /**
  17069. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17070. * to override the particles.
  17071. */
  17072. forceDepthWrite: boolean;
  17073. /** 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 */
  17074. preWarmCycles: number;
  17075. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17076. preWarmStepOffset: number;
  17077. /**
  17078. * 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)
  17079. */
  17080. spriteCellChangeSpeed: number;
  17081. /**
  17082. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17083. */
  17084. startSpriteCellID: number;
  17085. /**
  17086. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17087. */
  17088. endSpriteCellID: number;
  17089. /**
  17090. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17091. */
  17092. spriteCellWidth: number;
  17093. /**
  17094. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17095. */
  17096. spriteCellHeight: number;
  17097. /**
  17098. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17099. */
  17100. spriteRandomStartCell: boolean;
  17101. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17102. translationPivot: Vector2;
  17103. /** @hidden */
  17104. protected _isAnimationSheetEnabled: boolean;
  17105. /**
  17106. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17107. */
  17108. beginAnimationOnStart: boolean;
  17109. /**
  17110. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17111. */
  17112. beginAnimationFrom: number;
  17113. /**
  17114. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17115. */
  17116. beginAnimationTo: number;
  17117. /**
  17118. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17119. */
  17120. beginAnimationLoop: boolean;
  17121. /**
  17122. * Gets or sets a world offset applied to all particles
  17123. */
  17124. worldOffset: Vector3;
  17125. /**
  17126. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17127. */
  17128. isAnimationSheetEnabled: boolean;
  17129. /**
  17130. * Get hosting scene
  17131. * @returns the scene
  17132. */
  17133. getScene(): Scene;
  17134. /**
  17135. * You can use gravity if you want to give an orientation to your particles.
  17136. */
  17137. gravity: Vector3;
  17138. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17139. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17140. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17141. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17142. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17143. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17144. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17145. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17146. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17147. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17148. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17149. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17150. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17151. /**
  17152. * Defines the delay in milliseconds before starting the system (0 by default)
  17153. */
  17154. startDelay: number;
  17155. /**
  17156. * Gets the current list of drag gradients.
  17157. * You must use addDragGradient and removeDragGradient to udpate this list
  17158. * @returns the list of drag gradients
  17159. */
  17160. getDragGradients(): Nullable<Array<FactorGradient>>;
  17161. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17162. limitVelocityDamping: number;
  17163. /**
  17164. * Gets the current list of limit velocity gradients.
  17165. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17166. * @returns the list of limit velocity gradients
  17167. */
  17168. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17169. /**
  17170. * Gets the current list of color gradients.
  17171. * You must use addColorGradient and removeColorGradient to udpate this list
  17172. * @returns the list of color gradients
  17173. */
  17174. getColorGradients(): Nullable<Array<ColorGradient>>;
  17175. /**
  17176. * Gets the current list of size gradients.
  17177. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17178. * @returns the list of size gradients
  17179. */
  17180. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17181. /**
  17182. * Gets the current list of color remap gradients.
  17183. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17184. * @returns the list of color remap gradients
  17185. */
  17186. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17187. /**
  17188. * Gets the current list of alpha remap gradients.
  17189. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17190. * @returns the list of alpha remap gradients
  17191. */
  17192. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17193. /**
  17194. * Gets the current list of life time gradients.
  17195. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17196. * @returns the list of life time gradients
  17197. */
  17198. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17199. /**
  17200. * Gets the current list of angular speed gradients.
  17201. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17202. * @returns the list of angular speed gradients
  17203. */
  17204. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17205. /**
  17206. * Gets the current list of velocity gradients.
  17207. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17208. * @returns the list of velocity gradients
  17209. */
  17210. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17211. /**
  17212. * Gets the current list of start size gradients.
  17213. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17214. * @returns the list of start size gradients
  17215. */
  17216. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17217. /**
  17218. * Gets the current list of emit rate gradients.
  17219. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17220. * @returns the list of emit rate gradients
  17221. */
  17222. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17223. /**
  17224. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17225. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17226. */
  17227. direction1: Vector3;
  17228. /**
  17229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17230. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17231. */
  17232. direction2: Vector3;
  17233. /**
  17234. * 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.
  17235. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17236. */
  17237. minEmitBox: Vector3;
  17238. /**
  17239. * 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.
  17240. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17241. */
  17242. maxEmitBox: Vector3;
  17243. /**
  17244. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17245. */
  17246. color1: Color4;
  17247. /**
  17248. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17249. */
  17250. color2: Color4;
  17251. /**
  17252. * Color the particle will have at the end of its lifetime
  17253. */
  17254. colorDead: Color4;
  17255. /**
  17256. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17257. */
  17258. textureMask: Color4;
  17259. /**
  17260. * The particle emitter type defines the emitter used by the particle system.
  17261. * It can be for example box, sphere, or cone...
  17262. */
  17263. particleEmitterType: IParticleEmitterType;
  17264. /** @hidden */
  17265. _isSubEmitter: boolean;
  17266. /**
  17267. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17268. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17269. */
  17270. billboardMode: number;
  17271. protected _isBillboardBased: boolean;
  17272. /**
  17273. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17274. */
  17275. isBillboardBased: boolean;
  17276. /**
  17277. * The scene the particle system belongs to.
  17278. */
  17279. protected _scene: Scene;
  17280. /**
  17281. * Local cache of defines for image processing.
  17282. */
  17283. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17284. /**
  17285. * Default configuration related to image processing available in the standard Material.
  17286. */
  17287. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17288. /**
  17289. * Gets the image processing configuration used either in this material.
  17290. */
  17291. /**
  17292. * Sets the Default image processing configuration used either in the this material.
  17293. *
  17294. * If sets to null, the scene one is in use.
  17295. */
  17296. imageProcessingConfiguration: ImageProcessingConfiguration;
  17297. /**
  17298. * Attaches a new image processing configuration to the Standard Material.
  17299. * @param configuration
  17300. */
  17301. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17302. /** @hidden */
  17303. protected _reset(): void;
  17304. /** @hidden */
  17305. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17306. /**
  17307. * Instantiates a particle system.
  17308. * 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.
  17309. * @param name The name of the particle system
  17310. */
  17311. constructor(name: string);
  17312. /**
  17313. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17316. * @returns the emitter
  17317. */
  17318. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17319. /**
  17320. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17321. * @param radius The radius of the hemisphere to emit from
  17322. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17323. * @returns the emitter
  17324. */
  17325. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17326. /**
  17327. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17328. * @param radius The radius of the sphere to emit from
  17329. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17330. * @returns the emitter
  17331. */
  17332. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17333. /**
  17334. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17335. * @param radius The radius of the sphere to emit from
  17336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17338. * @returns the emitter
  17339. */
  17340. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17341. /**
  17342. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17343. * @param radius The radius of the emission cylinder
  17344. * @param height The height of the emission cylinder
  17345. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17346. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17347. * @returns the emitter
  17348. */
  17349. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17350. /**
  17351. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17352. * @param radius The radius of the cylinder to emit from
  17353. * @param height The height of the emission cylinder
  17354. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17355. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17356. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17357. * @returns the emitter
  17358. */
  17359. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17360. /**
  17361. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17362. * @param radius The radius of the cone to emit from
  17363. * @param angle The base angle of the cone
  17364. * @returns the emitter
  17365. */
  17366. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17367. /**
  17368. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17371. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17372. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17373. * @returns the emitter
  17374. */
  17375. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17376. }
  17377. }
  17378. declare module "babylonjs/Particles/subEmitter" {
  17379. import { Scene } from "babylonjs/scene";
  17380. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17381. /**
  17382. * Type of sub emitter
  17383. */
  17384. export enum SubEmitterType {
  17385. /**
  17386. * Attached to the particle over it's lifetime
  17387. */
  17388. ATTACHED = 0,
  17389. /**
  17390. * Created when the particle dies
  17391. */
  17392. END = 1
  17393. }
  17394. /**
  17395. * Sub emitter class used to emit particles from an existing particle
  17396. */
  17397. export class SubEmitter {
  17398. /**
  17399. * the particle system to be used by the sub emitter
  17400. */
  17401. particleSystem: ParticleSystem;
  17402. /**
  17403. * Type of the submitter (Default: END)
  17404. */
  17405. type: SubEmitterType;
  17406. /**
  17407. * 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)
  17408. * Note: This only is supported when using an emitter of type Mesh
  17409. */
  17410. inheritDirection: boolean;
  17411. /**
  17412. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17413. */
  17414. inheritedVelocityAmount: number;
  17415. /**
  17416. * Creates a sub emitter
  17417. * @param particleSystem the particle system to be used by the sub emitter
  17418. */
  17419. constructor(
  17420. /**
  17421. * the particle system to be used by the sub emitter
  17422. */
  17423. particleSystem: ParticleSystem);
  17424. /**
  17425. * Clones the sub emitter
  17426. * @returns the cloned sub emitter
  17427. */
  17428. clone(): SubEmitter;
  17429. /**
  17430. * Serialize current object to a JSON object
  17431. * @returns the serialized object
  17432. */
  17433. serialize(): any;
  17434. /** @hidden */
  17435. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17436. /**
  17437. * Creates a new SubEmitter from a serialized JSON version
  17438. * @param serializationObject defines the JSON object to read from
  17439. * @param scene defines the hosting scene
  17440. * @param rootUrl defines the rootUrl for data loading
  17441. * @returns a new SubEmitter
  17442. */
  17443. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17444. /** Release associated resources */
  17445. dispose(): void;
  17446. }
  17447. }
  17448. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17449. /** @hidden */
  17450. export var clipPlaneFragmentDeclaration: {
  17451. name: string;
  17452. shader: string;
  17453. };
  17454. }
  17455. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17456. /** @hidden */
  17457. export var imageProcessingDeclaration: {
  17458. name: string;
  17459. shader: string;
  17460. };
  17461. }
  17462. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17463. /** @hidden */
  17464. export var imageProcessingFunctions: {
  17465. name: string;
  17466. shader: string;
  17467. };
  17468. }
  17469. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17470. /** @hidden */
  17471. export var clipPlaneFragment: {
  17472. name: string;
  17473. shader: string;
  17474. };
  17475. }
  17476. declare module "babylonjs/Shaders/particles.fragment" {
  17477. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17478. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17479. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17480. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17481. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17482. /** @hidden */
  17483. export var particlesPixelShader: {
  17484. name: string;
  17485. shader: string;
  17486. };
  17487. }
  17488. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17489. /** @hidden */
  17490. export var clipPlaneVertexDeclaration: {
  17491. name: string;
  17492. shader: string;
  17493. };
  17494. }
  17495. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17496. /** @hidden */
  17497. export var clipPlaneVertex: {
  17498. name: string;
  17499. shader: string;
  17500. };
  17501. }
  17502. declare module "babylonjs/Shaders/particles.vertex" {
  17503. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17504. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17505. /** @hidden */
  17506. export var particlesVertexShader: {
  17507. name: string;
  17508. shader: string;
  17509. };
  17510. }
  17511. declare module "babylonjs/Particles/particleSystem" {
  17512. import { Nullable } from "babylonjs/types";
  17513. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17514. import { Observable } from "babylonjs/Misc/observable";
  17515. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17516. import { Effect } from "babylonjs/Materials/effect";
  17517. import { Scene, IDisposable } from "babylonjs/scene";
  17518. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17519. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17520. import { Particle } from "babylonjs/Particles/particle";
  17521. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17522. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17523. import "babylonjs/Shaders/particles.fragment";
  17524. import "babylonjs/Shaders/particles.vertex";
  17525. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17526. /**
  17527. * This represents a particle system in Babylon.
  17528. * 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.
  17529. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17530. * @example https://doc.babylonjs.com/babylon101/particles
  17531. */
  17532. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17533. /**
  17534. * Billboard mode will only apply to Y axis
  17535. */
  17536. static readonly BILLBOARDMODE_Y: number;
  17537. /**
  17538. * Billboard mode will apply to all axes
  17539. */
  17540. static readonly BILLBOARDMODE_ALL: number;
  17541. /**
  17542. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17543. */
  17544. static readonly BILLBOARDMODE_STRETCHED: number;
  17545. /**
  17546. * This function can be defined to provide custom update for active particles.
  17547. * This function will be called instead of regular update (age, position, color, etc.).
  17548. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17549. */
  17550. updateFunction: (particles: Particle[]) => void;
  17551. private _emitterWorldMatrix;
  17552. /**
  17553. * This function can be defined to specify initial direction for every new particle.
  17554. * It by default use the emitterType defined function
  17555. */
  17556. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17557. /**
  17558. * This function can be defined to specify initial position for every new particle.
  17559. * It by default use the emitterType defined function
  17560. */
  17561. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17562. /**
  17563. * @hidden
  17564. */
  17565. _inheritedVelocityOffset: Vector3;
  17566. /**
  17567. * An event triggered when the system is disposed
  17568. */
  17569. onDisposeObservable: Observable<ParticleSystem>;
  17570. private _onDisposeObserver;
  17571. /**
  17572. * Sets a callback that will be triggered when the system is disposed
  17573. */
  17574. onDispose: () => void;
  17575. private _particles;
  17576. private _epsilon;
  17577. private _capacity;
  17578. private _stockParticles;
  17579. private _newPartsExcess;
  17580. private _vertexData;
  17581. private _vertexBuffer;
  17582. private _vertexBuffers;
  17583. private _spriteBuffer;
  17584. private _indexBuffer;
  17585. private _effect;
  17586. private _customEffect;
  17587. private _cachedDefines;
  17588. private _scaledColorStep;
  17589. private _colorDiff;
  17590. private _scaledDirection;
  17591. private _scaledGravity;
  17592. private _currentRenderId;
  17593. private _alive;
  17594. private _useInstancing;
  17595. private _started;
  17596. private _stopped;
  17597. private _actualFrame;
  17598. private _scaledUpdateSpeed;
  17599. private _vertexBufferSize;
  17600. /** @hidden */
  17601. _currentEmitRateGradient: Nullable<FactorGradient>;
  17602. /** @hidden */
  17603. _currentEmitRate1: number;
  17604. /** @hidden */
  17605. _currentEmitRate2: number;
  17606. /** @hidden */
  17607. _currentStartSizeGradient: Nullable<FactorGradient>;
  17608. /** @hidden */
  17609. _currentStartSize1: number;
  17610. /** @hidden */
  17611. _currentStartSize2: number;
  17612. private readonly _rawTextureWidth;
  17613. private _rampGradientsTexture;
  17614. private _useRampGradients;
  17615. /** Gets or sets a boolean indicating that ramp gradients must be used
  17616. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17617. */
  17618. useRampGradients: boolean;
  17619. /**
  17620. * 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.
  17621. * 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: [])
  17622. */
  17623. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17624. private _subEmitters;
  17625. /**
  17626. * @hidden
  17627. * If the particle systems emitter should be disposed when the particle system is disposed
  17628. */
  17629. _disposeEmitterOnDispose: boolean;
  17630. /**
  17631. * The current active Sub-systems, this property is used by the root particle system only.
  17632. */
  17633. activeSubSystems: Array<ParticleSystem>;
  17634. private _rootParticleSystem;
  17635. /**
  17636. * Gets the current list of active particles
  17637. */
  17638. readonly particles: Particle[];
  17639. /**
  17640. * Returns the string "ParticleSystem"
  17641. * @returns a string containing the class name
  17642. */
  17643. getClassName(): string;
  17644. /**
  17645. * Instantiates a particle system.
  17646. * 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.
  17647. * @param name The name of the particle system
  17648. * @param capacity The max number of particles alive at the same time
  17649. * @param scene The scene the particle system belongs to
  17650. * @param customEffect a custom effect used to change the way particles are rendered by default
  17651. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17652. * @param epsilon Offset used to render the particles
  17653. */
  17654. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17655. private _addFactorGradient;
  17656. private _removeFactorGradient;
  17657. /**
  17658. * Adds a new life time gradient
  17659. * @param gradient defines the gradient to use (between 0 and 1)
  17660. * @param factor defines the life time factor to affect to the specified gradient
  17661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17662. * @returns the current particle system
  17663. */
  17664. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17665. /**
  17666. * Remove a specific life time gradient
  17667. * @param gradient defines the gradient to remove
  17668. * @returns the current particle system
  17669. */
  17670. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17671. /**
  17672. * Adds a new size gradient
  17673. * @param gradient defines the gradient to use (between 0 and 1)
  17674. * @param factor defines the size factor to affect to the specified gradient
  17675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17676. * @returns the current particle system
  17677. */
  17678. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17679. /**
  17680. * Remove a specific size gradient
  17681. * @param gradient defines the gradient to remove
  17682. * @returns the current particle system
  17683. */
  17684. removeSizeGradient(gradient: number): IParticleSystem;
  17685. /**
  17686. * Adds a new color remap gradient
  17687. * @param gradient defines the gradient to use (between 0 and 1)
  17688. * @param min defines the color remap minimal range
  17689. * @param max defines the color remap maximal range
  17690. * @returns the current particle system
  17691. */
  17692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17693. /**
  17694. * Remove a specific color remap gradient
  17695. * @param gradient defines the gradient to remove
  17696. * @returns the current particle system
  17697. */
  17698. removeColorRemapGradient(gradient: number): IParticleSystem;
  17699. /**
  17700. * Adds a new alpha remap gradient
  17701. * @param gradient defines the gradient to use (between 0 and 1)
  17702. * @param min defines the alpha remap minimal range
  17703. * @param max defines the alpha remap maximal range
  17704. * @returns the current particle system
  17705. */
  17706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17707. /**
  17708. * Remove a specific alpha remap gradient
  17709. * @param gradient defines the gradient to remove
  17710. * @returns the current particle system
  17711. */
  17712. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17713. /**
  17714. * Adds a new angular speed gradient
  17715. * @param gradient defines the gradient to use (between 0 and 1)
  17716. * @param factor defines the angular speed to affect to the specified gradient
  17717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17718. * @returns the current particle system
  17719. */
  17720. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17721. /**
  17722. * Remove a specific angular speed gradient
  17723. * @param gradient defines the gradient to remove
  17724. * @returns the current particle system
  17725. */
  17726. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17727. /**
  17728. * Adds a new velocity gradient
  17729. * @param gradient defines the gradient to use (between 0 and 1)
  17730. * @param factor defines the velocity to affect to the specified gradient
  17731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17732. * @returns the current particle system
  17733. */
  17734. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17735. /**
  17736. * Remove a specific velocity gradient
  17737. * @param gradient defines the gradient to remove
  17738. * @returns the current particle system
  17739. */
  17740. removeVelocityGradient(gradient: number): IParticleSystem;
  17741. /**
  17742. * Adds a new limit velocity gradient
  17743. * @param gradient defines the gradient to use (between 0 and 1)
  17744. * @param factor defines the limit velocity value to affect to the specified gradient
  17745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17746. * @returns the current particle system
  17747. */
  17748. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17749. /**
  17750. * Remove a specific limit velocity gradient
  17751. * @param gradient defines the gradient to remove
  17752. * @returns the current particle system
  17753. */
  17754. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17755. /**
  17756. * Adds a new drag gradient
  17757. * @param gradient defines the gradient to use (between 0 and 1)
  17758. * @param factor defines the drag value to affect to the specified gradient
  17759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17760. * @returns the current particle system
  17761. */
  17762. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17763. /**
  17764. * Remove a specific drag gradient
  17765. * @param gradient defines the gradient to remove
  17766. * @returns the current particle system
  17767. */
  17768. removeDragGradient(gradient: number): IParticleSystem;
  17769. /**
  17770. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17771. * @param gradient defines the gradient to use (between 0 and 1)
  17772. * @param factor defines the emit rate value to affect to the specified gradient
  17773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17774. * @returns the current particle system
  17775. */
  17776. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17777. /**
  17778. * Remove a specific emit rate gradient
  17779. * @param gradient defines the gradient to remove
  17780. * @returns the current particle system
  17781. */
  17782. removeEmitRateGradient(gradient: number): IParticleSystem;
  17783. /**
  17784. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17785. * @param gradient defines the gradient to use (between 0 and 1)
  17786. * @param factor defines the start size value to affect to the specified gradient
  17787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17788. * @returns the current particle system
  17789. */
  17790. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17791. /**
  17792. * Remove a specific start size gradient
  17793. * @param gradient defines the gradient to remove
  17794. * @returns the current particle system
  17795. */
  17796. removeStartSizeGradient(gradient: number): IParticleSystem;
  17797. private _createRampGradientTexture;
  17798. /**
  17799. * Gets the current list of ramp gradients.
  17800. * You must use addRampGradient and removeRampGradient to udpate this list
  17801. * @returns the list of ramp gradients
  17802. */
  17803. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17804. /**
  17805. * Adds a new ramp gradient used to remap particle colors
  17806. * @param gradient defines the gradient to use (between 0 and 1)
  17807. * @param color defines the color to affect to the specified gradient
  17808. * @returns the current particle system
  17809. */
  17810. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17811. /**
  17812. * Remove a specific ramp gradient
  17813. * @param gradient defines the gradient to remove
  17814. * @returns the current particle system
  17815. */
  17816. removeRampGradient(gradient: number): ParticleSystem;
  17817. /**
  17818. * Adds a new color gradient
  17819. * @param gradient defines the gradient to use (between 0 and 1)
  17820. * @param color1 defines the color to affect to the specified gradient
  17821. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17822. * @returns this particle system
  17823. */
  17824. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17825. /**
  17826. * Remove a specific color gradient
  17827. * @param gradient defines the gradient to remove
  17828. * @returns this particle system
  17829. */
  17830. removeColorGradient(gradient: number): IParticleSystem;
  17831. private _fetchR;
  17832. protected _reset(): void;
  17833. private _resetEffect;
  17834. private _createVertexBuffers;
  17835. private _createIndexBuffer;
  17836. /**
  17837. * Gets the maximum number of particles active at the same time.
  17838. * @returns The max number of active particles.
  17839. */
  17840. getCapacity(): number;
  17841. /**
  17842. * Gets whether there are still active particles in the system.
  17843. * @returns True if it is alive, otherwise false.
  17844. */
  17845. isAlive(): boolean;
  17846. /**
  17847. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17848. * @returns True if it has been started, otherwise false.
  17849. */
  17850. isStarted(): boolean;
  17851. private _prepareSubEmitterInternalArray;
  17852. /**
  17853. * Starts the particle system and begins to emit
  17854. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17855. */
  17856. start(delay?: number): void;
  17857. /**
  17858. * Stops the particle system.
  17859. * @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.
  17860. */
  17861. stop(stopSubEmitters?: boolean): void;
  17862. /**
  17863. * Remove all active particles
  17864. */
  17865. reset(): void;
  17866. /**
  17867. * @hidden (for internal use only)
  17868. */
  17869. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17870. /**
  17871. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17872. * Its lifetime will start back at 0.
  17873. */
  17874. recycleParticle: (particle: Particle) => void;
  17875. private _stopSubEmitters;
  17876. private _createParticle;
  17877. private _removeFromRoot;
  17878. private _emitFromParticle;
  17879. private _update;
  17880. /** @hidden */
  17881. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17882. /** @hidden */
  17883. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17884. /** @hidden */
  17885. private _getEffect;
  17886. /**
  17887. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17888. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17889. */
  17890. animate(preWarmOnly?: boolean): void;
  17891. private _appendParticleVertices;
  17892. /**
  17893. * Rebuilds the particle system.
  17894. */
  17895. rebuild(): void;
  17896. /**
  17897. * Is this system ready to be used/rendered
  17898. * @return true if the system is ready
  17899. */
  17900. isReady(): boolean;
  17901. private _render;
  17902. /**
  17903. * Renders the particle system in its current state.
  17904. * @returns the current number of particles
  17905. */
  17906. render(): number;
  17907. /**
  17908. * Disposes the particle system and free the associated resources
  17909. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17910. */
  17911. dispose(disposeTexture?: boolean): void;
  17912. /**
  17913. * Clones the particle system.
  17914. * @param name The name of the cloned object
  17915. * @param newEmitter The new emitter to use
  17916. * @returns the cloned particle system
  17917. */
  17918. clone(name: string, newEmitter: any): ParticleSystem;
  17919. /**
  17920. * Serializes the particle system to a JSON object.
  17921. * @returns the JSON object
  17922. */
  17923. serialize(): any;
  17924. /** @hidden */
  17925. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17926. /** @hidden */
  17927. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17928. /**
  17929. * Parses a JSON object to create a particle system.
  17930. * @param parsedParticleSystem The JSON object to parse
  17931. * @param scene The scene to create the particle system in
  17932. * @param rootUrl The root url to use to load external dependencies like texture
  17933. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17934. * @returns the Parsed particle system
  17935. */
  17936. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17937. }
  17938. }
  17939. declare module "babylonjs/Particles/particle" {
  17940. import { Nullable } from "babylonjs/types";
  17941. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17942. import { Color4 } from "babylonjs/Maths/math.color";
  17943. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17944. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17945. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17946. /**
  17947. * A particle represents one of the element emitted by a particle system.
  17948. * This is mainly define by its coordinates, direction, velocity and age.
  17949. */
  17950. export class Particle {
  17951. /**
  17952. * The particle system the particle belongs to.
  17953. */
  17954. particleSystem: ParticleSystem;
  17955. private static _Count;
  17956. /**
  17957. * Unique ID of the particle
  17958. */
  17959. id: number;
  17960. /**
  17961. * The world position of the particle in the scene.
  17962. */
  17963. position: Vector3;
  17964. /**
  17965. * The world direction of the particle in the scene.
  17966. */
  17967. direction: Vector3;
  17968. /**
  17969. * The color of the particle.
  17970. */
  17971. color: Color4;
  17972. /**
  17973. * The color change of the particle per step.
  17974. */
  17975. colorStep: Color4;
  17976. /**
  17977. * Defines how long will the life of the particle be.
  17978. */
  17979. lifeTime: number;
  17980. /**
  17981. * The current age of the particle.
  17982. */
  17983. age: number;
  17984. /**
  17985. * The current size of the particle.
  17986. */
  17987. size: number;
  17988. /**
  17989. * The current scale of the particle.
  17990. */
  17991. scale: Vector2;
  17992. /**
  17993. * The current angle of the particle.
  17994. */
  17995. angle: number;
  17996. /**
  17997. * Defines how fast is the angle changing.
  17998. */
  17999. angularSpeed: number;
  18000. /**
  18001. * Defines the cell index used by the particle to be rendered from a sprite.
  18002. */
  18003. cellIndex: number;
  18004. /**
  18005. * The information required to support color remapping
  18006. */
  18007. remapData: Vector4;
  18008. /** @hidden */
  18009. _randomCellOffset?: number;
  18010. /** @hidden */
  18011. _initialDirection: Nullable<Vector3>;
  18012. /** @hidden */
  18013. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18014. /** @hidden */
  18015. _initialStartSpriteCellID: number;
  18016. /** @hidden */
  18017. _initialEndSpriteCellID: number;
  18018. /** @hidden */
  18019. _currentColorGradient: Nullable<ColorGradient>;
  18020. /** @hidden */
  18021. _currentColor1: Color4;
  18022. /** @hidden */
  18023. _currentColor2: Color4;
  18024. /** @hidden */
  18025. _currentSizeGradient: Nullable<FactorGradient>;
  18026. /** @hidden */
  18027. _currentSize1: number;
  18028. /** @hidden */
  18029. _currentSize2: number;
  18030. /** @hidden */
  18031. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18032. /** @hidden */
  18033. _currentAngularSpeed1: number;
  18034. /** @hidden */
  18035. _currentAngularSpeed2: number;
  18036. /** @hidden */
  18037. _currentVelocityGradient: Nullable<FactorGradient>;
  18038. /** @hidden */
  18039. _currentVelocity1: number;
  18040. /** @hidden */
  18041. _currentVelocity2: number;
  18042. /** @hidden */
  18043. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18044. /** @hidden */
  18045. _currentLimitVelocity1: number;
  18046. /** @hidden */
  18047. _currentLimitVelocity2: number;
  18048. /** @hidden */
  18049. _currentDragGradient: Nullable<FactorGradient>;
  18050. /** @hidden */
  18051. _currentDrag1: number;
  18052. /** @hidden */
  18053. _currentDrag2: number;
  18054. /** @hidden */
  18055. _randomNoiseCoordinates1: Vector3;
  18056. /** @hidden */
  18057. _randomNoiseCoordinates2: Vector3;
  18058. /**
  18059. * Creates a new instance Particle
  18060. * @param particleSystem the particle system the particle belongs to
  18061. */
  18062. constructor(
  18063. /**
  18064. * The particle system the particle belongs to.
  18065. */
  18066. particleSystem: ParticleSystem);
  18067. private updateCellInfoFromSystem;
  18068. /**
  18069. * Defines how the sprite cell index is updated for the particle
  18070. */
  18071. updateCellIndex(): void;
  18072. /** @hidden */
  18073. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18074. /** @hidden */
  18075. _inheritParticleInfoToSubEmitters(): void;
  18076. /** @hidden */
  18077. _reset(): void;
  18078. /**
  18079. * Copy the properties of particle to another one.
  18080. * @param other the particle to copy the information to.
  18081. */
  18082. copyTo(other: Particle): void;
  18083. }
  18084. }
  18085. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18086. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18087. import { Effect } from "babylonjs/Materials/effect";
  18088. import { Particle } from "babylonjs/Particles/particle";
  18089. /**
  18090. * Particle emitter represents a volume emitting particles.
  18091. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18092. */
  18093. export interface IParticleEmitterType {
  18094. /**
  18095. * Called by the particle System when the direction is computed for the created particle.
  18096. * @param worldMatrix is the world matrix of the particle system
  18097. * @param directionToUpdate is the direction vector to update with the result
  18098. * @param particle is the particle we are computed the direction for
  18099. */
  18100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18101. /**
  18102. * Called by the particle System when the position is computed for the created particle.
  18103. * @param worldMatrix is the world matrix of the particle system
  18104. * @param positionToUpdate is the position vector to update with the result
  18105. * @param particle is the particle we are computed the position for
  18106. */
  18107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18108. /**
  18109. * Clones the current emitter and returns a copy of it
  18110. * @returns the new emitter
  18111. */
  18112. clone(): IParticleEmitterType;
  18113. /**
  18114. * Called by the GPUParticleSystem to setup the update shader
  18115. * @param effect defines the update shader
  18116. */
  18117. applyToShader(effect: Effect): void;
  18118. /**
  18119. * Returns a string to use to update the GPU particles update shader
  18120. * @returns the effect defines string
  18121. */
  18122. getEffectDefines(): string;
  18123. /**
  18124. * Returns a string representing the class name
  18125. * @returns a string containing the class name
  18126. */
  18127. getClassName(): string;
  18128. /**
  18129. * Serializes the particle system to a JSON object.
  18130. * @returns the JSON object
  18131. */
  18132. serialize(): any;
  18133. /**
  18134. * Parse properties from a JSON object
  18135. * @param serializationObject defines the JSON object
  18136. */
  18137. parse(serializationObject: any): void;
  18138. }
  18139. }
  18140. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18141. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18142. import { Effect } from "babylonjs/Materials/effect";
  18143. import { Particle } from "babylonjs/Particles/particle";
  18144. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18145. /**
  18146. * Particle emitter emitting particles from the inside of a box.
  18147. * It emits the particles randomly between 2 given directions.
  18148. */
  18149. export class BoxParticleEmitter implements IParticleEmitterType {
  18150. /**
  18151. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18152. */
  18153. direction1: Vector3;
  18154. /**
  18155. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18156. */
  18157. direction2: Vector3;
  18158. /**
  18159. * 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.
  18160. */
  18161. minEmitBox: Vector3;
  18162. /**
  18163. * 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.
  18164. */
  18165. maxEmitBox: Vector3;
  18166. /**
  18167. * Creates a new instance BoxParticleEmitter
  18168. */
  18169. constructor();
  18170. /**
  18171. * Called by the particle System when the direction is computed for the created particle.
  18172. * @param worldMatrix is the world matrix of the particle system
  18173. * @param directionToUpdate is the direction vector to update with the result
  18174. * @param particle is the particle we are computed the direction for
  18175. */
  18176. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18177. /**
  18178. * Called by the particle System when the position is computed for the created particle.
  18179. * @param worldMatrix is the world matrix of the particle system
  18180. * @param positionToUpdate is the position vector to update with the result
  18181. * @param particle is the particle we are computed the position for
  18182. */
  18183. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18184. /**
  18185. * Clones the current emitter and returns a copy of it
  18186. * @returns the new emitter
  18187. */
  18188. clone(): BoxParticleEmitter;
  18189. /**
  18190. * Called by the GPUParticleSystem to setup the update shader
  18191. * @param effect defines the update shader
  18192. */
  18193. applyToShader(effect: Effect): void;
  18194. /**
  18195. * Returns a string to use to update the GPU particles update shader
  18196. * @returns a string containng the defines string
  18197. */
  18198. getEffectDefines(): string;
  18199. /**
  18200. * Returns the string "BoxParticleEmitter"
  18201. * @returns a string containing the class name
  18202. */
  18203. getClassName(): string;
  18204. /**
  18205. * Serializes the particle system to a JSON object.
  18206. * @returns the JSON object
  18207. */
  18208. serialize(): any;
  18209. /**
  18210. * Parse properties from a JSON object
  18211. * @param serializationObject defines the JSON object
  18212. */
  18213. parse(serializationObject: any): void;
  18214. }
  18215. }
  18216. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18217. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18218. import { Effect } from "babylonjs/Materials/effect";
  18219. import { Particle } from "babylonjs/Particles/particle";
  18220. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18221. /**
  18222. * Particle emitter emitting particles from the inside of a cone.
  18223. * It emits the particles alongside the cone volume from the base to the particle.
  18224. * The emission direction might be randomized.
  18225. */
  18226. export class ConeParticleEmitter implements IParticleEmitterType {
  18227. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18228. directionRandomizer: number;
  18229. private _radius;
  18230. private _angle;
  18231. private _height;
  18232. /**
  18233. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18234. */
  18235. radiusRange: number;
  18236. /**
  18237. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18238. */
  18239. heightRange: number;
  18240. /**
  18241. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18242. */
  18243. emitFromSpawnPointOnly: boolean;
  18244. /**
  18245. * Gets or sets the radius of the emission cone
  18246. */
  18247. radius: number;
  18248. /**
  18249. * Gets or sets the angle of the emission cone
  18250. */
  18251. angle: number;
  18252. private _buildHeight;
  18253. /**
  18254. * Creates a new instance ConeParticleEmitter
  18255. * @param radius the radius of the emission cone (1 by default)
  18256. * @param angle the cone base angle (PI by default)
  18257. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18258. */
  18259. constructor(radius?: number, angle?: number,
  18260. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18261. directionRandomizer?: number);
  18262. /**
  18263. * Called by the particle System when the direction is computed for the created particle.
  18264. * @param worldMatrix is the world matrix of the particle system
  18265. * @param directionToUpdate is the direction vector to update with the result
  18266. * @param particle is the particle we are computed the direction for
  18267. */
  18268. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18269. /**
  18270. * Called by the particle System when the position is computed for the created particle.
  18271. * @param worldMatrix is the world matrix of the particle system
  18272. * @param positionToUpdate is the position vector to update with the result
  18273. * @param particle is the particle we are computed the position for
  18274. */
  18275. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18276. /**
  18277. * Clones the current emitter and returns a copy of it
  18278. * @returns the new emitter
  18279. */
  18280. clone(): ConeParticleEmitter;
  18281. /**
  18282. * Called by the GPUParticleSystem to setup the update shader
  18283. * @param effect defines the update shader
  18284. */
  18285. applyToShader(effect: Effect): void;
  18286. /**
  18287. * Returns a string to use to update the GPU particles update shader
  18288. * @returns a string containng the defines string
  18289. */
  18290. getEffectDefines(): string;
  18291. /**
  18292. * Returns the string "ConeParticleEmitter"
  18293. * @returns a string containing the class name
  18294. */
  18295. getClassName(): string;
  18296. /**
  18297. * Serializes the particle system to a JSON object.
  18298. * @returns the JSON object
  18299. */
  18300. serialize(): any;
  18301. /**
  18302. * Parse properties from a JSON object
  18303. * @param serializationObject defines the JSON object
  18304. */
  18305. parse(serializationObject: any): void;
  18306. }
  18307. }
  18308. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18309. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18310. import { Effect } from "babylonjs/Materials/effect";
  18311. import { Particle } from "babylonjs/Particles/particle";
  18312. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18313. /**
  18314. * Particle emitter emitting particles from the inside of a cylinder.
  18315. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18316. */
  18317. export class CylinderParticleEmitter implements IParticleEmitterType {
  18318. /**
  18319. * The radius of the emission cylinder.
  18320. */
  18321. radius: number;
  18322. /**
  18323. * The height of the emission cylinder.
  18324. */
  18325. height: number;
  18326. /**
  18327. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18328. */
  18329. radiusRange: number;
  18330. /**
  18331. * How much to randomize the particle direction [0-1].
  18332. */
  18333. directionRandomizer: number;
  18334. /**
  18335. * Creates a new instance CylinderParticleEmitter
  18336. * @param radius the radius of the emission cylinder (1 by default)
  18337. * @param height the height of the emission cylinder (1 by default)
  18338. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18339. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18340. */
  18341. constructor(
  18342. /**
  18343. * The radius of the emission cylinder.
  18344. */
  18345. radius?: number,
  18346. /**
  18347. * The height of the emission cylinder.
  18348. */
  18349. height?: number,
  18350. /**
  18351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18352. */
  18353. radiusRange?: number,
  18354. /**
  18355. * How much to randomize the particle direction [0-1].
  18356. */
  18357. directionRandomizer?: number);
  18358. /**
  18359. * Called by the particle System when the direction is computed for the created particle.
  18360. * @param worldMatrix is the world matrix of the particle system
  18361. * @param directionToUpdate is the direction vector to update with the result
  18362. * @param particle is the particle we are computed the direction for
  18363. */
  18364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18365. /**
  18366. * Called by the particle System when the position is computed for the created particle.
  18367. * @param worldMatrix is the world matrix of the particle system
  18368. * @param positionToUpdate is the position vector to update with the result
  18369. * @param particle is the particle we are computed the position for
  18370. */
  18371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18372. /**
  18373. * Clones the current emitter and returns a copy of it
  18374. * @returns the new emitter
  18375. */
  18376. clone(): CylinderParticleEmitter;
  18377. /**
  18378. * Called by the GPUParticleSystem to setup the update shader
  18379. * @param effect defines the update shader
  18380. */
  18381. applyToShader(effect: Effect): void;
  18382. /**
  18383. * Returns a string to use to update the GPU particles update shader
  18384. * @returns a string containng the defines string
  18385. */
  18386. getEffectDefines(): string;
  18387. /**
  18388. * Returns the string "CylinderParticleEmitter"
  18389. * @returns a string containing the class name
  18390. */
  18391. getClassName(): string;
  18392. /**
  18393. * Serializes the particle system to a JSON object.
  18394. * @returns the JSON object
  18395. */
  18396. serialize(): any;
  18397. /**
  18398. * Parse properties from a JSON object
  18399. * @param serializationObject defines the JSON object
  18400. */
  18401. parse(serializationObject: any): void;
  18402. }
  18403. /**
  18404. * Particle emitter emitting particles from the inside of a cylinder.
  18405. * It emits the particles randomly between two vectors.
  18406. */
  18407. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18408. /**
  18409. * The min limit of the emission direction.
  18410. */
  18411. direction1: Vector3;
  18412. /**
  18413. * The max limit of the emission direction.
  18414. */
  18415. direction2: Vector3;
  18416. /**
  18417. * Creates a new instance CylinderDirectedParticleEmitter
  18418. * @param radius the radius of the emission cylinder (1 by default)
  18419. * @param height the height of the emission cylinder (1 by default)
  18420. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18421. * @param direction1 the min limit of the emission direction (up vector by default)
  18422. * @param direction2 the max limit of the emission direction (up vector by default)
  18423. */
  18424. constructor(radius?: number, height?: number, radiusRange?: number,
  18425. /**
  18426. * The min limit of the emission direction.
  18427. */
  18428. direction1?: Vector3,
  18429. /**
  18430. * The max limit of the emission direction.
  18431. */
  18432. direction2?: Vector3);
  18433. /**
  18434. * Called by the particle System when the direction is computed for the created particle.
  18435. * @param worldMatrix is the world matrix of the particle system
  18436. * @param directionToUpdate is the direction vector to update with the result
  18437. * @param particle is the particle we are computed the direction for
  18438. */
  18439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18440. /**
  18441. * Clones the current emitter and returns a copy of it
  18442. * @returns the new emitter
  18443. */
  18444. clone(): CylinderDirectedParticleEmitter;
  18445. /**
  18446. * Called by the GPUParticleSystem to setup the update shader
  18447. * @param effect defines the update shader
  18448. */
  18449. applyToShader(effect: Effect): void;
  18450. /**
  18451. * Returns a string to use to update the GPU particles update shader
  18452. * @returns a string containng the defines string
  18453. */
  18454. getEffectDefines(): string;
  18455. /**
  18456. * Returns the string "CylinderDirectedParticleEmitter"
  18457. * @returns a string containing the class name
  18458. */
  18459. getClassName(): string;
  18460. /**
  18461. * Serializes the particle system to a JSON object.
  18462. * @returns the JSON object
  18463. */
  18464. serialize(): any;
  18465. /**
  18466. * Parse properties from a JSON object
  18467. * @param serializationObject defines the JSON object
  18468. */
  18469. parse(serializationObject: any): void;
  18470. }
  18471. }
  18472. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18473. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18474. import { Effect } from "babylonjs/Materials/effect";
  18475. import { Particle } from "babylonjs/Particles/particle";
  18476. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18477. /**
  18478. * Particle emitter emitting particles from the inside of a hemisphere.
  18479. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18480. */
  18481. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18482. /**
  18483. * The radius of the emission hemisphere.
  18484. */
  18485. radius: number;
  18486. /**
  18487. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18488. */
  18489. radiusRange: number;
  18490. /**
  18491. * How much to randomize the particle direction [0-1].
  18492. */
  18493. directionRandomizer: number;
  18494. /**
  18495. * Creates a new instance HemisphericParticleEmitter
  18496. * @param radius the radius of the emission hemisphere (1 by default)
  18497. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18498. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18499. */
  18500. constructor(
  18501. /**
  18502. * The radius of the emission hemisphere.
  18503. */
  18504. radius?: number,
  18505. /**
  18506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18507. */
  18508. radiusRange?: number,
  18509. /**
  18510. * How much to randomize the particle direction [0-1].
  18511. */
  18512. directionRandomizer?: number);
  18513. /**
  18514. * Called by the particle System when the direction is computed for the created particle.
  18515. * @param worldMatrix is the world matrix of the particle system
  18516. * @param directionToUpdate is the direction vector to update with the result
  18517. * @param particle is the particle we are computed the direction for
  18518. */
  18519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18520. /**
  18521. * Called by the particle System when the position is computed for the created particle.
  18522. * @param worldMatrix is the world matrix of the particle system
  18523. * @param positionToUpdate is the position vector to update with the result
  18524. * @param particle is the particle we are computed the position for
  18525. */
  18526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18527. /**
  18528. * Clones the current emitter and returns a copy of it
  18529. * @returns the new emitter
  18530. */
  18531. clone(): HemisphericParticleEmitter;
  18532. /**
  18533. * Called by the GPUParticleSystem to setup the update shader
  18534. * @param effect defines the update shader
  18535. */
  18536. applyToShader(effect: Effect): void;
  18537. /**
  18538. * Returns a string to use to update the GPU particles update shader
  18539. * @returns a string containng the defines string
  18540. */
  18541. getEffectDefines(): string;
  18542. /**
  18543. * Returns the string "HemisphericParticleEmitter"
  18544. * @returns a string containing the class name
  18545. */
  18546. getClassName(): string;
  18547. /**
  18548. * Serializes the particle system to a JSON object.
  18549. * @returns the JSON object
  18550. */
  18551. serialize(): any;
  18552. /**
  18553. * Parse properties from a JSON object
  18554. * @param serializationObject defines the JSON object
  18555. */
  18556. parse(serializationObject: any): void;
  18557. }
  18558. }
  18559. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18560. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18561. import { Effect } from "babylonjs/Materials/effect";
  18562. import { Particle } from "babylonjs/Particles/particle";
  18563. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18564. /**
  18565. * Particle emitter emitting particles from a point.
  18566. * It emits the particles randomly between 2 given directions.
  18567. */
  18568. export class PointParticleEmitter implements IParticleEmitterType {
  18569. /**
  18570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18571. */
  18572. direction1: Vector3;
  18573. /**
  18574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18575. */
  18576. direction2: Vector3;
  18577. /**
  18578. * Creates a new instance PointParticleEmitter
  18579. */
  18580. constructor();
  18581. /**
  18582. * Called by the particle System when the direction is computed for the created particle.
  18583. * @param worldMatrix is the world matrix of the particle system
  18584. * @param directionToUpdate is the direction vector to update with the result
  18585. * @param particle is the particle we are computed the direction for
  18586. */
  18587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18588. /**
  18589. * Called by the particle System when the position is computed for the created particle.
  18590. * @param worldMatrix is the world matrix of the particle system
  18591. * @param positionToUpdate is the position vector to update with the result
  18592. * @param particle is the particle we are computed the position for
  18593. */
  18594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18595. /**
  18596. * Clones the current emitter and returns a copy of it
  18597. * @returns the new emitter
  18598. */
  18599. clone(): PointParticleEmitter;
  18600. /**
  18601. * Called by the GPUParticleSystem to setup the update shader
  18602. * @param effect defines the update shader
  18603. */
  18604. applyToShader(effect: Effect): void;
  18605. /**
  18606. * Returns a string to use to update the GPU particles update shader
  18607. * @returns a string containng the defines string
  18608. */
  18609. getEffectDefines(): string;
  18610. /**
  18611. * Returns the string "PointParticleEmitter"
  18612. * @returns a string containing the class name
  18613. */
  18614. getClassName(): string;
  18615. /**
  18616. * Serializes the particle system to a JSON object.
  18617. * @returns the JSON object
  18618. */
  18619. serialize(): any;
  18620. /**
  18621. * Parse properties from a JSON object
  18622. * @param serializationObject defines the JSON object
  18623. */
  18624. parse(serializationObject: any): void;
  18625. }
  18626. }
  18627. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18628. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18629. import { Effect } from "babylonjs/Materials/effect";
  18630. import { Particle } from "babylonjs/Particles/particle";
  18631. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18632. /**
  18633. * Particle emitter emitting particles from the inside of a sphere.
  18634. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18635. */
  18636. export class SphereParticleEmitter implements IParticleEmitterType {
  18637. /**
  18638. * The radius of the emission sphere.
  18639. */
  18640. radius: number;
  18641. /**
  18642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18643. */
  18644. radiusRange: number;
  18645. /**
  18646. * How much to randomize the particle direction [0-1].
  18647. */
  18648. directionRandomizer: number;
  18649. /**
  18650. * Creates a new instance SphereParticleEmitter
  18651. * @param radius the radius of the emission sphere (1 by default)
  18652. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18653. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18654. */
  18655. constructor(
  18656. /**
  18657. * The radius of the emission sphere.
  18658. */
  18659. radius?: number,
  18660. /**
  18661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18662. */
  18663. radiusRange?: number,
  18664. /**
  18665. * How much to randomize the particle direction [0-1].
  18666. */
  18667. directionRandomizer?: number);
  18668. /**
  18669. * Called by the particle System when the direction is computed for the created particle.
  18670. * @param worldMatrix is the world matrix of the particle system
  18671. * @param directionToUpdate is the direction vector to update with the result
  18672. * @param particle is the particle we are computed the direction for
  18673. */
  18674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18675. /**
  18676. * Called by the particle System when the position is computed for the created particle.
  18677. * @param worldMatrix is the world matrix of the particle system
  18678. * @param positionToUpdate is the position vector to update with the result
  18679. * @param particle is the particle we are computed the position for
  18680. */
  18681. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18682. /**
  18683. * Clones the current emitter and returns a copy of it
  18684. * @returns the new emitter
  18685. */
  18686. clone(): SphereParticleEmitter;
  18687. /**
  18688. * Called by the GPUParticleSystem to setup the update shader
  18689. * @param effect defines the update shader
  18690. */
  18691. applyToShader(effect: Effect): void;
  18692. /**
  18693. * Returns a string to use to update the GPU particles update shader
  18694. * @returns a string containng the defines string
  18695. */
  18696. getEffectDefines(): string;
  18697. /**
  18698. * Returns the string "SphereParticleEmitter"
  18699. * @returns a string containing the class name
  18700. */
  18701. getClassName(): string;
  18702. /**
  18703. * Serializes the particle system to a JSON object.
  18704. * @returns the JSON object
  18705. */
  18706. serialize(): any;
  18707. /**
  18708. * Parse properties from a JSON object
  18709. * @param serializationObject defines the JSON object
  18710. */
  18711. parse(serializationObject: any): void;
  18712. }
  18713. /**
  18714. * Particle emitter emitting particles from the inside of a sphere.
  18715. * It emits the particles randomly between two vectors.
  18716. */
  18717. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18718. /**
  18719. * The min limit of the emission direction.
  18720. */
  18721. direction1: Vector3;
  18722. /**
  18723. * The max limit of the emission direction.
  18724. */
  18725. direction2: Vector3;
  18726. /**
  18727. * Creates a new instance SphereDirectedParticleEmitter
  18728. * @param radius the radius of the emission sphere (1 by default)
  18729. * @param direction1 the min limit of the emission direction (up vector by default)
  18730. * @param direction2 the max limit of the emission direction (up vector by default)
  18731. */
  18732. constructor(radius?: number,
  18733. /**
  18734. * The min limit of the emission direction.
  18735. */
  18736. direction1?: Vector3,
  18737. /**
  18738. * The max limit of the emission direction.
  18739. */
  18740. direction2?: Vector3);
  18741. /**
  18742. * Called by the particle System when the direction is computed for the created particle.
  18743. * @param worldMatrix is the world matrix of the particle system
  18744. * @param directionToUpdate is the direction vector to update with the result
  18745. * @param particle is the particle we are computed the direction for
  18746. */
  18747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18748. /**
  18749. * Clones the current emitter and returns a copy of it
  18750. * @returns the new emitter
  18751. */
  18752. clone(): SphereDirectedParticleEmitter;
  18753. /**
  18754. * Called by the GPUParticleSystem to setup the update shader
  18755. * @param effect defines the update shader
  18756. */
  18757. applyToShader(effect: Effect): void;
  18758. /**
  18759. * Returns a string to use to update the GPU particles update shader
  18760. * @returns a string containng the defines string
  18761. */
  18762. getEffectDefines(): string;
  18763. /**
  18764. * Returns the string "SphereDirectedParticleEmitter"
  18765. * @returns a string containing the class name
  18766. */
  18767. getClassName(): string;
  18768. /**
  18769. * Serializes the particle system to a JSON object.
  18770. * @returns the JSON object
  18771. */
  18772. serialize(): any;
  18773. /**
  18774. * Parse properties from a JSON object
  18775. * @param serializationObject defines the JSON object
  18776. */
  18777. parse(serializationObject: any): void;
  18778. }
  18779. }
  18780. declare module "babylonjs/Particles/EmitterTypes/index" {
  18781. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18782. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18783. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18784. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18785. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18786. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18787. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18788. }
  18789. declare module "babylonjs/Particles/IParticleSystem" {
  18790. import { Nullable } from "babylonjs/types";
  18791. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18792. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18795. import { Texture } from "babylonjs/Materials/Textures/texture";
  18796. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18797. import { Scene } from "babylonjs/scene";
  18798. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18799. import { Animation } from "babylonjs/Animations/animation";
  18800. /**
  18801. * Interface representing a particle system in Babylon.js.
  18802. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18803. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18804. */
  18805. export interface IParticleSystem {
  18806. /**
  18807. * List of animations used by the particle system.
  18808. */
  18809. animations: Animation[];
  18810. /**
  18811. * The id of the Particle system.
  18812. */
  18813. id: string;
  18814. /**
  18815. * The name of the Particle system.
  18816. */
  18817. name: string;
  18818. /**
  18819. * The emitter represents the Mesh or position we are attaching the particle system to.
  18820. */
  18821. emitter: Nullable<AbstractMesh | Vector3>;
  18822. /**
  18823. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18824. */
  18825. isBillboardBased: boolean;
  18826. /**
  18827. * The rendering group used by the Particle system to chose when to render.
  18828. */
  18829. renderingGroupId: number;
  18830. /**
  18831. * The layer mask we are rendering the particles through.
  18832. */
  18833. layerMask: number;
  18834. /**
  18835. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18836. */
  18837. updateSpeed: number;
  18838. /**
  18839. * The amount of time the particle system is running (depends of the overall update speed).
  18840. */
  18841. targetStopDuration: number;
  18842. /**
  18843. * The texture used to render each particle. (this can be a spritesheet)
  18844. */
  18845. particleTexture: Nullable<Texture>;
  18846. /**
  18847. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18848. */
  18849. blendMode: number;
  18850. /**
  18851. * Minimum life time of emitting particles.
  18852. */
  18853. minLifeTime: number;
  18854. /**
  18855. * Maximum life time of emitting particles.
  18856. */
  18857. maxLifeTime: number;
  18858. /**
  18859. * Minimum Size of emitting particles.
  18860. */
  18861. minSize: number;
  18862. /**
  18863. * Maximum Size of emitting particles.
  18864. */
  18865. maxSize: number;
  18866. /**
  18867. * Minimum scale of emitting particles on X axis.
  18868. */
  18869. minScaleX: number;
  18870. /**
  18871. * Maximum scale of emitting particles on X axis.
  18872. */
  18873. maxScaleX: number;
  18874. /**
  18875. * Minimum scale of emitting particles on Y axis.
  18876. */
  18877. minScaleY: number;
  18878. /**
  18879. * Maximum scale of emitting particles on Y axis.
  18880. */
  18881. maxScaleY: number;
  18882. /**
  18883. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18884. */
  18885. color1: Color4;
  18886. /**
  18887. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18888. */
  18889. color2: Color4;
  18890. /**
  18891. * Color the particle will have at the end of its lifetime.
  18892. */
  18893. colorDead: Color4;
  18894. /**
  18895. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18896. */
  18897. emitRate: number;
  18898. /**
  18899. * You can use gravity if you want to give an orientation to your particles.
  18900. */
  18901. gravity: Vector3;
  18902. /**
  18903. * Minimum power of emitting particles.
  18904. */
  18905. minEmitPower: number;
  18906. /**
  18907. * Maximum power of emitting particles.
  18908. */
  18909. maxEmitPower: number;
  18910. /**
  18911. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18912. */
  18913. minAngularSpeed: number;
  18914. /**
  18915. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18916. */
  18917. maxAngularSpeed: number;
  18918. /**
  18919. * Gets or sets the minimal initial rotation in radians.
  18920. */
  18921. minInitialRotation: number;
  18922. /**
  18923. * Gets or sets the maximal initial rotation in radians.
  18924. */
  18925. maxInitialRotation: number;
  18926. /**
  18927. * The particle emitter type defines the emitter used by the particle system.
  18928. * It can be for example box, sphere, or cone...
  18929. */
  18930. particleEmitterType: Nullable<IParticleEmitterType>;
  18931. /**
  18932. * Defines the delay in milliseconds before starting the system (0 by default)
  18933. */
  18934. startDelay: number;
  18935. /**
  18936. * 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
  18937. */
  18938. preWarmCycles: number;
  18939. /**
  18940. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18941. */
  18942. preWarmStepOffset: number;
  18943. /**
  18944. * 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)
  18945. */
  18946. spriteCellChangeSpeed: number;
  18947. /**
  18948. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18949. */
  18950. startSpriteCellID: number;
  18951. /**
  18952. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18953. */
  18954. endSpriteCellID: number;
  18955. /**
  18956. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18957. */
  18958. spriteCellWidth: number;
  18959. /**
  18960. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18961. */
  18962. spriteCellHeight: number;
  18963. /**
  18964. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18965. */
  18966. spriteRandomStartCell: boolean;
  18967. /**
  18968. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18969. */
  18970. isAnimationSheetEnabled: boolean;
  18971. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18972. translationPivot: Vector2;
  18973. /**
  18974. * Gets or sets a texture used to add random noise to particle positions
  18975. */
  18976. noiseTexture: Nullable<BaseTexture>;
  18977. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18978. noiseStrength: Vector3;
  18979. /**
  18980. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18981. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18982. */
  18983. billboardMode: number;
  18984. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18985. limitVelocityDamping: number;
  18986. /**
  18987. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18988. */
  18989. beginAnimationOnStart: boolean;
  18990. /**
  18991. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18992. */
  18993. beginAnimationFrom: number;
  18994. /**
  18995. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18996. */
  18997. beginAnimationTo: number;
  18998. /**
  18999. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19000. */
  19001. beginAnimationLoop: boolean;
  19002. /**
  19003. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19004. */
  19005. disposeOnStop: boolean;
  19006. /**
  19007. * Gets the maximum number of particles active at the same time.
  19008. * @returns The max number of active particles.
  19009. */
  19010. getCapacity(): number;
  19011. /**
  19012. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19013. * @returns True if it has been started, otherwise false.
  19014. */
  19015. isStarted(): boolean;
  19016. /**
  19017. * Animates the particle system for this frame.
  19018. */
  19019. animate(): void;
  19020. /**
  19021. * Renders the particle system in its current state.
  19022. * @returns the current number of particles
  19023. */
  19024. render(): number;
  19025. /**
  19026. * Dispose the particle system and frees its associated resources.
  19027. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19028. */
  19029. dispose(disposeTexture?: boolean): void;
  19030. /**
  19031. * Clones the particle system.
  19032. * @param name The name of the cloned object
  19033. * @param newEmitter The new emitter to use
  19034. * @returns the cloned particle system
  19035. */
  19036. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19037. /**
  19038. * Serializes the particle system to a JSON object.
  19039. * @returns the JSON object
  19040. */
  19041. serialize(): any;
  19042. /**
  19043. * Rebuild the particle system
  19044. */
  19045. rebuild(): void;
  19046. /**
  19047. * Starts the particle system and begins to emit
  19048. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19049. */
  19050. start(delay?: number): void;
  19051. /**
  19052. * Stops the particle system.
  19053. */
  19054. stop(): void;
  19055. /**
  19056. * Remove all active particles
  19057. */
  19058. reset(): void;
  19059. /**
  19060. * Is this system ready to be used/rendered
  19061. * @return true if the system is ready
  19062. */
  19063. isReady(): boolean;
  19064. /**
  19065. * Adds a new color gradient
  19066. * @param gradient defines the gradient to use (between 0 and 1)
  19067. * @param color1 defines the color to affect to the specified gradient
  19068. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19069. * @returns the current particle system
  19070. */
  19071. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19072. /**
  19073. * Remove a specific color gradient
  19074. * @param gradient defines the gradient to remove
  19075. * @returns the current particle system
  19076. */
  19077. removeColorGradient(gradient: number): IParticleSystem;
  19078. /**
  19079. * Adds a new size gradient
  19080. * @param gradient defines the gradient to use (between 0 and 1)
  19081. * @param factor defines the size factor to affect to the specified gradient
  19082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19083. * @returns the current particle system
  19084. */
  19085. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19086. /**
  19087. * Remove a specific size gradient
  19088. * @param gradient defines the gradient to remove
  19089. * @returns the current particle system
  19090. */
  19091. removeSizeGradient(gradient: number): IParticleSystem;
  19092. /**
  19093. * Gets the current list of color gradients.
  19094. * You must use addColorGradient and removeColorGradient to udpate this list
  19095. * @returns the list of color gradients
  19096. */
  19097. getColorGradients(): Nullable<Array<ColorGradient>>;
  19098. /**
  19099. * Gets the current list of size gradients.
  19100. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19101. * @returns the list of size gradients
  19102. */
  19103. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19104. /**
  19105. * Gets the current list of angular speed gradients.
  19106. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19107. * @returns the list of angular speed gradients
  19108. */
  19109. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19110. /**
  19111. * Adds a new angular speed gradient
  19112. * @param gradient defines the gradient to use (between 0 and 1)
  19113. * @param factor defines the angular speed to affect to the specified gradient
  19114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19115. * @returns the current particle system
  19116. */
  19117. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19118. /**
  19119. * Remove a specific angular speed gradient
  19120. * @param gradient defines the gradient to remove
  19121. * @returns the current particle system
  19122. */
  19123. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19124. /**
  19125. * Gets the current list of velocity gradients.
  19126. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19127. * @returns the list of velocity gradients
  19128. */
  19129. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19130. /**
  19131. * Adds a new velocity gradient
  19132. * @param gradient defines the gradient to use (between 0 and 1)
  19133. * @param factor defines the velocity to affect to the specified gradient
  19134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19135. * @returns the current particle system
  19136. */
  19137. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19138. /**
  19139. * Remove a specific velocity gradient
  19140. * @param gradient defines the gradient to remove
  19141. * @returns the current particle system
  19142. */
  19143. removeVelocityGradient(gradient: number): IParticleSystem;
  19144. /**
  19145. * Gets the current list of limit velocity gradients.
  19146. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19147. * @returns the list of limit velocity gradients
  19148. */
  19149. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19150. /**
  19151. * Adds a new limit velocity gradient
  19152. * @param gradient defines the gradient to use (between 0 and 1)
  19153. * @param factor defines the limit velocity to affect to the specified gradient
  19154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19155. * @returns the current particle system
  19156. */
  19157. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19158. /**
  19159. * Remove a specific limit velocity gradient
  19160. * @param gradient defines the gradient to remove
  19161. * @returns the current particle system
  19162. */
  19163. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19164. /**
  19165. * Adds a new drag gradient
  19166. * @param gradient defines the gradient to use (between 0 and 1)
  19167. * @param factor defines the drag to affect to the specified gradient
  19168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19169. * @returns the current particle system
  19170. */
  19171. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19172. /**
  19173. * Remove a specific drag gradient
  19174. * @param gradient defines the gradient to remove
  19175. * @returns the current particle system
  19176. */
  19177. removeDragGradient(gradient: number): IParticleSystem;
  19178. /**
  19179. * Gets the current list of drag gradients.
  19180. * You must use addDragGradient and removeDragGradient to udpate this list
  19181. * @returns the list of drag gradients
  19182. */
  19183. getDragGradients(): Nullable<Array<FactorGradient>>;
  19184. /**
  19185. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19186. * @param gradient defines the gradient to use (between 0 and 1)
  19187. * @param factor defines the emit rate to affect to the specified gradient
  19188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19189. * @returns the current particle system
  19190. */
  19191. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19192. /**
  19193. * Remove a specific emit rate gradient
  19194. * @param gradient defines the gradient to remove
  19195. * @returns the current particle system
  19196. */
  19197. removeEmitRateGradient(gradient: number): IParticleSystem;
  19198. /**
  19199. * Gets the current list of emit rate gradients.
  19200. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19201. * @returns the list of emit rate gradients
  19202. */
  19203. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19204. /**
  19205. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19206. * @param gradient defines the gradient to use (between 0 and 1)
  19207. * @param factor defines the start size to affect to the specified gradient
  19208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19209. * @returns the current particle system
  19210. */
  19211. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19212. /**
  19213. * Remove a specific start size gradient
  19214. * @param gradient defines the gradient to remove
  19215. * @returns the current particle system
  19216. */
  19217. removeStartSizeGradient(gradient: number): IParticleSystem;
  19218. /**
  19219. * Gets the current list of start size gradients.
  19220. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19221. * @returns the list of start size gradients
  19222. */
  19223. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19224. /**
  19225. * Adds a new life time gradient
  19226. * @param gradient defines the gradient to use (between 0 and 1)
  19227. * @param factor defines the life time factor to affect to the specified gradient
  19228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19229. * @returns the current particle system
  19230. */
  19231. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19232. /**
  19233. * Remove a specific life time gradient
  19234. * @param gradient defines the gradient to remove
  19235. * @returns the current particle system
  19236. */
  19237. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19238. /**
  19239. * Gets the current list of life time gradients.
  19240. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19241. * @returns the list of life time gradients
  19242. */
  19243. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19244. /**
  19245. * Gets the current list of color gradients.
  19246. * You must use addColorGradient and removeColorGradient to udpate this list
  19247. * @returns the list of color gradients
  19248. */
  19249. getColorGradients(): Nullable<Array<ColorGradient>>;
  19250. /**
  19251. * Adds a new ramp gradient used to remap particle colors
  19252. * @param gradient defines the gradient to use (between 0 and 1)
  19253. * @param color defines the color to affect to the specified gradient
  19254. * @returns the current particle system
  19255. */
  19256. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19257. /**
  19258. * Gets the current list of ramp gradients.
  19259. * You must use addRampGradient and removeRampGradient to udpate this list
  19260. * @returns the list of ramp gradients
  19261. */
  19262. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19263. /** Gets or sets a boolean indicating that ramp gradients must be used
  19264. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19265. */
  19266. useRampGradients: boolean;
  19267. /**
  19268. * Adds a new color remap gradient
  19269. * @param gradient defines the gradient to use (between 0 and 1)
  19270. * @param min defines the color remap minimal range
  19271. * @param max defines the color remap maximal range
  19272. * @returns the current particle system
  19273. */
  19274. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19275. /**
  19276. * Gets the current list of color remap gradients.
  19277. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19278. * @returns the list of color remap gradients
  19279. */
  19280. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19281. /**
  19282. * Adds a new alpha remap gradient
  19283. * @param gradient defines the gradient to use (between 0 and 1)
  19284. * @param min defines the alpha remap minimal range
  19285. * @param max defines the alpha remap maximal range
  19286. * @returns the current particle system
  19287. */
  19288. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19289. /**
  19290. * Gets the current list of alpha remap gradients.
  19291. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19292. * @returns the list of alpha remap gradients
  19293. */
  19294. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19295. /**
  19296. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19297. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19298. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19299. * @returns the emitter
  19300. */
  19301. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19302. /**
  19303. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19304. * @param radius The radius of the hemisphere to emit from
  19305. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19306. * @returns the emitter
  19307. */
  19308. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19309. /**
  19310. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19311. * @param radius The radius of the sphere to emit from
  19312. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19313. * @returns the emitter
  19314. */
  19315. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19316. /**
  19317. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19318. * @param radius The radius of the sphere to emit from
  19319. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19320. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19321. * @returns the emitter
  19322. */
  19323. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19324. /**
  19325. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19326. * @param radius The radius of the emission cylinder
  19327. * @param height The height of the emission cylinder
  19328. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19329. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19330. * @returns the emitter
  19331. */
  19332. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19333. /**
  19334. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19335. * @param radius The radius of the cylinder to emit from
  19336. * @param height The height of the emission cylinder
  19337. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19340. * @returns the emitter
  19341. */
  19342. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19343. /**
  19344. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19345. * @param radius The radius of the cone to emit from
  19346. * @param angle The base angle of the cone
  19347. * @returns the emitter
  19348. */
  19349. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19350. /**
  19351. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19352. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19353. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19354. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19355. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19356. * @returns the emitter
  19357. */
  19358. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19359. /**
  19360. * Get hosting scene
  19361. * @returns the scene
  19362. */
  19363. getScene(): Scene;
  19364. }
  19365. }
  19366. declare module "babylonjs/Meshes/instancedMesh" {
  19367. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19368. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19369. import { Camera } from "babylonjs/Cameras/camera";
  19370. import { Node } from "babylonjs/node";
  19371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19372. import { Mesh } from "babylonjs/Meshes/mesh";
  19373. import { Material } from "babylonjs/Materials/material";
  19374. import { Skeleton } from "babylonjs/Bones/skeleton";
  19375. import { Light } from "babylonjs/Lights/light";
  19376. /**
  19377. * Creates an instance based on a source mesh.
  19378. */
  19379. export class InstancedMesh extends AbstractMesh {
  19380. private _sourceMesh;
  19381. private _currentLOD;
  19382. /** @hidden */
  19383. _indexInSourceMeshInstanceArray: number;
  19384. constructor(name: string, source: Mesh);
  19385. /**
  19386. * Returns the string "InstancedMesh".
  19387. */
  19388. getClassName(): string;
  19389. /** Gets the list of lights affecting that mesh */
  19390. readonly lightSources: Light[];
  19391. _resyncLightSources(): void;
  19392. _resyncLighSource(light: Light): void;
  19393. _removeLightSource(light: Light, dispose: boolean): void;
  19394. /**
  19395. * If the source mesh receives shadows
  19396. */
  19397. readonly receiveShadows: boolean;
  19398. /**
  19399. * The material of the source mesh
  19400. */
  19401. readonly material: Nullable<Material>;
  19402. /**
  19403. * Visibility of the source mesh
  19404. */
  19405. readonly visibility: number;
  19406. /**
  19407. * Skeleton of the source mesh
  19408. */
  19409. readonly skeleton: Nullable<Skeleton>;
  19410. /**
  19411. * Rendering ground id of the source mesh
  19412. */
  19413. renderingGroupId: number;
  19414. /**
  19415. * Returns the total number of vertices (integer).
  19416. */
  19417. getTotalVertices(): number;
  19418. /**
  19419. * Returns a positive integer : the total number of indices in this mesh geometry.
  19420. * @returns the numner of indices or zero if the mesh has no geometry.
  19421. */
  19422. getTotalIndices(): number;
  19423. /**
  19424. * The source mesh of the instance
  19425. */
  19426. readonly sourceMesh: Mesh;
  19427. /**
  19428. * Is this node ready to be used/rendered
  19429. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19430. * @return {boolean} is it ready
  19431. */
  19432. isReady(completeCheck?: boolean): boolean;
  19433. /**
  19434. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19435. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19436. * @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.
  19437. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19438. */
  19439. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19440. /**
  19441. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19442. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19443. * The `data` are either a numeric array either a Float32Array.
  19444. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19445. * 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).
  19446. * Note that a new underlying VertexBuffer object is created each call.
  19447. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19448. *
  19449. * Possible `kind` values :
  19450. * - VertexBuffer.PositionKind
  19451. * - VertexBuffer.UVKind
  19452. * - VertexBuffer.UV2Kind
  19453. * - VertexBuffer.UV3Kind
  19454. * - VertexBuffer.UV4Kind
  19455. * - VertexBuffer.UV5Kind
  19456. * - VertexBuffer.UV6Kind
  19457. * - VertexBuffer.ColorKind
  19458. * - VertexBuffer.MatricesIndicesKind
  19459. * - VertexBuffer.MatricesIndicesExtraKind
  19460. * - VertexBuffer.MatricesWeightsKind
  19461. * - VertexBuffer.MatricesWeightsExtraKind
  19462. *
  19463. * Returns the Mesh.
  19464. */
  19465. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19466. /**
  19467. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19468. * If the mesh has no geometry, it is simply returned as it is.
  19469. * The `data` are either a numeric array either a Float32Array.
  19470. * No new underlying VertexBuffer object is created.
  19471. * 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.
  19472. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19473. *
  19474. * Possible `kind` values :
  19475. * - VertexBuffer.PositionKind
  19476. * - VertexBuffer.UVKind
  19477. * - VertexBuffer.UV2Kind
  19478. * - VertexBuffer.UV3Kind
  19479. * - VertexBuffer.UV4Kind
  19480. * - VertexBuffer.UV5Kind
  19481. * - VertexBuffer.UV6Kind
  19482. * - VertexBuffer.ColorKind
  19483. * - VertexBuffer.MatricesIndicesKind
  19484. * - VertexBuffer.MatricesIndicesExtraKind
  19485. * - VertexBuffer.MatricesWeightsKind
  19486. * - VertexBuffer.MatricesWeightsExtraKind
  19487. *
  19488. * Returns the Mesh.
  19489. */
  19490. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19491. /**
  19492. * Sets the mesh indices.
  19493. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19494. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19495. * This method creates a new index buffer each call.
  19496. * Returns the Mesh.
  19497. */
  19498. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19499. /**
  19500. * Boolean : True if the mesh owns the requested kind of data.
  19501. */
  19502. isVerticesDataPresent(kind: string): boolean;
  19503. /**
  19504. * Returns an array of indices (IndicesArray).
  19505. */
  19506. getIndices(): Nullable<IndicesArray>;
  19507. readonly _positions: Nullable<Vector3[]>;
  19508. /**
  19509. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19510. * This means the mesh underlying bounding box and sphere are recomputed.
  19511. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19512. * @returns the current mesh
  19513. */
  19514. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19515. /** @hidden */
  19516. _preActivate(): InstancedMesh;
  19517. /** @hidden */
  19518. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19519. /** @hidden */
  19520. _postActivate(): void;
  19521. getWorldMatrix(): Matrix;
  19522. readonly isAnInstance: boolean;
  19523. /**
  19524. * Returns the current associated LOD AbstractMesh.
  19525. */
  19526. getLOD(camera: Camera): AbstractMesh;
  19527. /** @hidden */
  19528. _syncSubMeshes(): InstancedMesh;
  19529. /** @hidden */
  19530. _generatePointsArray(): boolean;
  19531. /**
  19532. * Creates a new InstancedMesh from the current mesh.
  19533. * - name (string) : the cloned mesh name
  19534. * - newParent (optional Node) : the optional Node to parent the clone to.
  19535. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19536. *
  19537. * Returns the clone.
  19538. */
  19539. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19540. /**
  19541. * Disposes the InstancedMesh.
  19542. * Returns nothing.
  19543. */
  19544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19545. }
  19546. }
  19547. declare module "babylonjs/Materials/shaderMaterial" {
  19548. import { Scene } from "babylonjs/scene";
  19549. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19551. import { Mesh } from "babylonjs/Meshes/mesh";
  19552. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19554. import { Texture } from "babylonjs/Materials/Textures/texture";
  19555. import { Material } from "babylonjs/Materials/material";
  19556. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19557. /**
  19558. * Defines the options associated with the creation of a shader material.
  19559. */
  19560. export interface IShaderMaterialOptions {
  19561. /**
  19562. * Does the material work in alpha blend mode
  19563. */
  19564. needAlphaBlending: boolean;
  19565. /**
  19566. * Does the material work in alpha test mode
  19567. */
  19568. needAlphaTesting: boolean;
  19569. /**
  19570. * The list of attribute names used in the shader
  19571. */
  19572. attributes: string[];
  19573. /**
  19574. * The list of unifrom names used in the shader
  19575. */
  19576. uniforms: string[];
  19577. /**
  19578. * The list of UBO names used in the shader
  19579. */
  19580. uniformBuffers: string[];
  19581. /**
  19582. * The list of sampler names used in the shader
  19583. */
  19584. samplers: string[];
  19585. /**
  19586. * The list of defines used in the shader
  19587. */
  19588. defines: string[];
  19589. }
  19590. /**
  19591. * 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.
  19592. *
  19593. * This returned material effects how the mesh will look based on the code in the shaders.
  19594. *
  19595. * @see http://doc.babylonjs.com/how_to/shader_material
  19596. */
  19597. export class ShaderMaterial extends Material {
  19598. private _shaderPath;
  19599. private _options;
  19600. private _textures;
  19601. private _textureArrays;
  19602. private _floats;
  19603. private _ints;
  19604. private _floatsArrays;
  19605. private _colors3;
  19606. private _colors3Arrays;
  19607. private _colors4;
  19608. private _colors4Arrays;
  19609. private _vectors2;
  19610. private _vectors3;
  19611. private _vectors4;
  19612. private _matrices;
  19613. private _matrices3x3;
  19614. private _matrices2x2;
  19615. private _vectors2Arrays;
  19616. private _vectors3Arrays;
  19617. private _vectors4Arrays;
  19618. private _cachedWorldViewMatrix;
  19619. private _cachedWorldViewProjectionMatrix;
  19620. private _renderId;
  19621. /**
  19622. * Instantiate a new shader material.
  19623. * 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.
  19624. * This returned material effects how the mesh will look based on the code in the shaders.
  19625. * @see http://doc.babylonjs.com/how_to/shader_material
  19626. * @param name Define the name of the material in the scene
  19627. * @param scene Define the scene the material belongs to
  19628. * @param shaderPath Defines the route to the shader code in one of three ways:
  19629. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19630. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19631. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19632. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19633. * @param options Define the options used to create the shader
  19634. */
  19635. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19636. /**
  19637. * Gets the options used to compile the shader.
  19638. * They can be modified to trigger a new compilation
  19639. */
  19640. readonly options: IShaderMaterialOptions;
  19641. /**
  19642. * Gets the current class name of the material e.g. "ShaderMaterial"
  19643. * Mainly use in serialization.
  19644. * @returns the class name
  19645. */
  19646. getClassName(): string;
  19647. /**
  19648. * Specifies if the material will require alpha blending
  19649. * @returns a boolean specifying if alpha blending is needed
  19650. */
  19651. needAlphaBlending(): boolean;
  19652. /**
  19653. * Specifies if this material should be rendered in alpha test mode
  19654. * @returns a boolean specifying if an alpha test is needed.
  19655. */
  19656. needAlphaTesting(): boolean;
  19657. private _checkUniform;
  19658. /**
  19659. * Set a texture in the shader.
  19660. * @param name Define the name of the uniform samplers as defined in the shader
  19661. * @param texture Define the texture to bind to this sampler
  19662. * @return the material itself allowing "fluent" like uniform updates
  19663. */
  19664. setTexture(name: string, texture: Texture): ShaderMaterial;
  19665. /**
  19666. * Set a texture array in the shader.
  19667. * @param name Define the name of the uniform sampler array as defined in the shader
  19668. * @param textures Define the list of textures to bind to this sampler
  19669. * @return the material itself allowing "fluent" like uniform updates
  19670. */
  19671. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19672. /**
  19673. * Set a float in the shader.
  19674. * @param name Define the name of the uniform as defined in the shader
  19675. * @param value Define the value to give to the uniform
  19676. * @return the material itself allowing "fluent" like uniform updates
  19677. */
  19678. setFloat(name: string, value: number): ShaderMaterial;
  19679. /**
  19680. * Set a int in the shader.
  19681. * @param name Define the name of the uniform as defined in the shader
  19682. * @param value Define the value to give to the uniform
  19683. * @return the material itself allowing "fluent" like uniform updates
  19684. */
  19685. setInt(name: string, value: number): ShaderMaterial;
  19686. /**
  19687. * Set an array of floats in the shader.
  19688. * @param name Define the name of the uniform as defined in the shader
  19689. * @param value Define the value to give to the uniform
  19690. * @return the material itself allowing "fluent" like uniform updates
  19691. */
  19692. setFloats(name: string, value: number[]): ShaderMaterial;
  19693. /**
  19694. * Set a vec3 in the shader from a Color3.
  19695. * @param name Define the name of the uniform as defined in the shader
  19696. * @param value Define the value to give to the uniform
  19697. * @return the material itself allowing "fluent" like uniform updates
  19698. */
  19699. setColor3(name: string, value: Color3): ShaderMaterial;
  19700. /**
  19701. * Set a vec3 array in the shader from a Color3 array.
  19702. * @param name Define the name of the uniform as defined in the shader
  19703. * @param value Define the value to give to the uniform
  19704. * @return the material itself allowing "fluent" like uniform updates
  19705. */
  19706. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19707. /**
  19708. * Set a vec4 in the shader from a Color4.
  19709. * @param name Define the name of the uniform as defined in the shader
  19710. * @param value Define the value to give to the uniform
  19711. * @return the material itself allowing "fluent" like uniform updates
  19712. */
  19713. setColor4(name: string, value: Color4): ShaderMaterial;
  19714. /**
  19715. * Set a vec4 array in the shader from a Color4 array.
  19716. * @param name Define the name of the uniform as defined in the shader
  19717. * @param value Define the value to give to the uniform
  19718. * @return the material itself allowing "fluent" like uniform updates
  19719. */
  19720. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19721. /**
  19722. * Set a vec2 in the shader from a Vector2.
  19723. * @param name Define the name of the uniform as defined in the shader
  19724. * @param value Define the value to give to the uniform
  19725. * @return the material itself allowing "fluent" like uniform updates
  19726. */
  19727. setVector2(name: string, value: Vector2): ShaderMaterial;
  19728. /**
  19729. * Set a vec3 in the shader from a Vector3.
  19730. * @param name Define the name of the uniform as defined in the shader
  19731. * @param value Define the value to give to the uniform
  19732. * @return the material itself allowing "fluent" like uniform updates
  19733. */
  19734. setVector3(name: string, value: Vector3): ShaderMaterial;
  19735. /**
  19736. * Set a vec4 in the shader from a Vector4.
  19737. * @param name Define the name of the uniform as defined in the shader
  19738. * @param value Define the value to give to the uniform
  19739. * @return the material itself allowing "fluent" like uniform updates
  19740. */
  19741. setVector4(name: string, value: Vector4): ShaderMaterial;
  19742. /**
  19743. * Set a mat4 in the shader from a Matrix.
  19744. * @param name Define the name of the uniform as defined in the shader
  19745. * @param value Define the value to give to the uniform
  19746. * @return the material itself allowing "fluent" like uniform updates
  19747. */
  19748. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19749. /**
  19750. * Set a mat3 in the shader from a Float32Array.
  19751. * @param name Define the name of the uniform as defined in the shader
  19752. * @param value Define the value to give to the uniform
  19753. * @return the material itself allowing "fluent" like uniform updates
  19754. */
  19755. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19756. /**
  19757. * Set a mat2 in the shader from a Float32Array.
  19758. * @param name Define the name of the uniform as defined in the shader
  19759. * @param value Define the value to give to the uniform
  19760. * @return the material itself allowing "fluent" like uniform updates
  19761. */
  19762. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19763. /**
  19764. * Set a vec2 array in the shader from a number array.
  19765. * @param name Define the name of the uniform as defined in the shader
  19766. * @param value Define the value to give to the uniform
  19767. * @return the material itself allowing "fluent" like uniform updates
  19768. */
  19769. setArray2(name: string, value: number[]): ShaderMaterial;
  19770. /**
  19771. * Set a vec3 array in the shader from a number array.
  19772. * @param name Define the name of the uniform as defined in the shader
  19773. * @param value Define the value to give to the uniform
  19774. * @return the material itself allowing "fluent" like uniform updates
  19775. */
  19776. setArray3(name: string, value: number[]): ShaderMaterial;
  19777. /**
  19778. * Set a vec4 array in the shader from a number array.
  19779. * @param name Define the name of the uniform as defined in the shader
  19780. * @param value Define the value to give to the uniform
  19781. * @return the material itself allowing "fluent" like uniform updates
  19782. */
  19783. setArray4(name: string, value: number[]): ShaderMaterial;
  19784. private _checkCache;
  19785. /**
  19786. * Specifies that the submesh is ready to be used
  19787. * @param mesh defines the mesh to check
  19788. * @param subMesh defines which submesh to check
  19789. * @param useInstances specifies that instances should be used
  19790. * @returns a boolean indicating that the submesh is ready or not
  19791. */
  19792. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19793. /**
  19794. * Checks if the material is ready to render the requested mesh
  19795. * @param mesh Define the mesh to render
  19796. * @param useInstances Define whether or not the material is used with instances
  19797. * @returns true if ready, otherwise false
  19798. */
  19799. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19800. /**
  19801. * Binds the world matrix to the material
  19802. * @param world defines the world transformation matrix
  19803. */
  19804. bindOnlyWorldMatrix(world: Matrix): void;
  19805. /**
  19806. * Binds the material to the mesh
  19807. * @param world defines the world transformation matrix
  19808. * @param mesh defines the mesh to bind the material to
  19809. */
  19810. bind(world: Matrix, mesh?: Mesh): void;
  19811. /**
  19812. * Gets the active textures from the material
  19813. * @returns an array of textures
  19814. */
  19815. getActiveTextures(): BaseTexture[];
  19816. /**
  19817. * Specifies if the material uses a texture
  19818. * @param texture defines the texture to check against the material
  19819. * @returns a boolean specifying if the material uses the texture
  19820. */
  19821. hasTexture(texture: BaseTexture): boolean;
  19822. /**
  19823. * Makes a duplicate of the material, and gives it a new name
  19824. * @param name defines the new name for the duplicated material
  19825. * @returns the cloned material
  19826. */
  19827. clone(name: string): ShaderMaterial;
  19828. /**
  19829. * Disposes the material
  19830. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19831. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19832. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19833. */
  19834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19835. /**
  19836. * Serializes this material in a JSON representation
  19837. * @returns the serialized material object
  19838. */
  19839. serialize(): any;
  19840. /**
  19841. * Creates a shader material from parsed shader material data
  19842. * @param source defines the JSON represnetation of the material
  19843. * @param scene defines the hosting scene
  19844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19845. * @returns a new material
  19846. */
  19847. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19848. }
  19849. }
  19850. declare module "babylonjs/Shaders/color.fragment" {
  19851. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19852. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19853. /** @hidden */
  19854. export var colorPixelShader: {
  19855. name: string;
  19856. shader: string;
  19857. };
  19858. }
  19859. declare module "babylonjs/Shaders/color.vertex" {
  19860. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19861. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19862. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19863. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19864. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19865. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19866. /** @hidden */
  19867. export var colorVertexShader: {
  19868. name: string;
  19869. shader: string;
  19870. };
  19871. }
  19872. declare module "babylonjs/Meshes/linesMesh" {
  19873. import { Nullable } from "babylonjs/types";
  19874. import { Scene } from "babylonjs/scene";
  19875. import { Color3 } from "babylonjs/Maths/math.color";
  19876. import { Node } from "babylonjs/node";
  19877. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19878. import { Mesh } from "babylonjs/Meshes/mesh";
  19879. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19880. import { Effect } from "babylonjs/Materials/effect";
  19881. import { Material } from "babylonjs/Materials/material";
  19882. import "babylonjs/Shaders/color.fragment";
  19883. import "babylonjs/Shaders/color.vertex";
  19884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19885. /**
  19886. * Line mesh
  19887. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19888. */
  19889. export class LinesMesh extends Mesh {
  19890. /**
  19891. * If vertex color should be applied to the mesh
  19892. */
  19893. readonly useVertexColor?: boolean | undefined;
  19894. /**
  19895. * If vertex alpha should be applied to the mesh
  19896. */
  19897. readonly useVertexAlpha?: boolean | undefined;
  19898. /**
  19899. * Color of the line (Default: White)
  19900. */
  19901. color: Color3;
  19902. /**
  19903. * Alpha of the line (Default: 1)
  19904. */
  19905. alpha: number;
  19906. /**
  19907. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19908. * This margin is expressed in world space coordinates, so its value may vary.
  19909. * Default value is 0.1
  19910. */
  19911. intersectionThreshold: number;
  19912. private _colorShader;
  19913. private color4;
  19914. /**
  19915. * Creates a new LinesMesh
  19916. * @param name defines the name
  19917. * @param scene defines the hosting scene
  19918. * @param parent defines the parent mesh if any
  19919. * @param source defines the optional source LinesMesh used to clone data from
  19920. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19921. * When false, achieved by calling a clone(), also passing False.
  19922. * This will make creation of children, recursive.
  19923. * @param useVertexColor defines if this LinesMesh supports vertex color
  19924. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19925. */
  19926. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19927. /**
  19928. * If vertex color should be applied to the mesh
  19929. */
  19930. useVertexColor?: boolean | undefined,
  19931. /**
  19932. * If vertex alpha should be applied to the mesh
  19933. */
  19934. useVertexAlpha?: boolean | undefined);
  19935. private _addClipPlaneDefine;
  19936. private _removeClipPlaneDefine;
  19937. isReady(): boolean;
  19938. /**
  19939. * Returns the string "LineMesh"
  19940. */
  19941. getClassName(): string;
  19942. /**
  19943. * @hidden
  19944. */
  19945. /**
  19946. * @hidden
  19947. */
  19948. material: Material;
  19949. /**
  19950. * @hidden
  19951. */
  19952. readonly checkCollisions: boolean;
  19953. /** @hidden */
  19954. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19955. /** @hidden */
  19956. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19957. /**
  19958. * Disposes of the line mesh
  19959. * @param doNotRecurse If children should be disposed
  19960. */
  19961. dispose(doNotRecurse?: boolean): void;
  19962. /**
  19963. * Returns a new LineMesh object cloned from the current one.
  19964. */
  19965. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19966. /**
  19967. * Creates a new InstancedLinesMesh object from the mesh model.
  19968. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19969. * @param name defines the name of the new instance
  19970. * @returns a new InstancedLinesMesh
  19971. */
  19972. createInstance(name: string): InstancedLinesMesh;
  19973. }
  19974. /**
  19975. * Creates an instance based on a source LinesMesh
  19976. */
  19977. export class InstancedLinesMesh extends InstancedMesh {
  19978. /**
  19979. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19980. * This margin is expressed in world space coordinates, so its value may vary.
  19981. * Initilized with the intersectionThreshold value of the source LinesMesh
  19982. */
  19983. intersectionThreshold: number;
  19984. constructor(name: string, source: LinesMesh);
  19985. /**
  19986. * Returns the string "InstancedLinesMesh".
  19987. */
  19988. getClassName(): string;
  19989. }
  19990. }
  19991. declare module "babylonjs/Shaders/line.fragment" {
  19992. /** @hidden */
  19993. export var linePixelShader: {
  19994. name: string;
  19995. shader: string;
  19996. };
  19997. }
  19998. declare module "babylonjs/Shaders/line.vertex" {
  19999. /** @hidden */
  20000. export var lineVertexShader: {
  20001. name: string;
  20002. shader: string;
  20003. };
  20004. }
  20005. declare module "babylonjs/Rendering/edgesRenderer" {
  20006. import { Nullable } from "babylonjs/types";
  20007. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20009. import { Vector3 } from "babylonjs/Maths/math.vector";
  20010. import { IDisposable } from "babylonjs/scene";
  20011. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20012. import "babylonjs/Shaders/line.fragment";
  20013. import "babylonjs/Shaders/line.vertex";
  20014. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20015. module "babylonjs/Meshes/abstractMesh" {
  20016. interface AbstractMesh {
  20017. /**
  20018. * Gets the edgesRenderer associated with the mesh
  20019. */
  20020. edgesRenderer: Nullable<EdgesRenderer>;
  20021. }
  20022. }
  20023. module "babylonjs/Meshes/linesMesh" {
  20024. interface LinesMesh {
  20025. /**
  20026. * Enables the edge rendering mode on the mesh.
  20027. * This mode makes the mesh edges visible
  20028. * @param epsilon defines the maximal distance between two angles to detect a face
  20029. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20030. * @returns the currentAbstractMesh
  20031. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20032. */
  20033. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20034. }
  20035. }
  20036. module "babylonjs/Meshes/linesMesh" {
  20037. interface InstancedLinesMesh {
  20038. /**
  20039. * Enables the edge rendering mode on the mesh.
  20040. * This mode makes the mesh edges visible
  20041. * @param epsilon defines the maximal distance between two angles to detect a face
  20042. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20043. * @returns the current InstancedLinesMesh
  20044. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20045. */
  20046. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20047. }
  20048. }
  20049. /**
  20050. * Defines the minimum contract an Edges renderer should follow.
  20051. */
  20052. export interface IEdgesRenderer extends IDisposable {
  20053. /**
  20054. * Gets or sets a boolean indicating if the edgesRenderer is active
  20055. */
  20056. isEnabled: boolean;
  20057. /**
  20058. * Renders the edges of the attached mesh,
  20059. */
  20060. render(): void;
  20061. /**
  20062. * Checks wether or not the edges renderer is ready to render.
  20063. * @return true if ready, otherwise false.
  20064. */
  20065. isReady(): boolean;
  20066. }
  20067. /**
  20068. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20069. */
  20070. export class EdgesRenderer implements IEdgesRenderer {
  20071. /**
  20072. * Define the size of the edges with an orthographic camera
  20073. */
  20074. edgesWidthScalerForOrthographic: number;
  20075. /**
  20076. * Define the size of the edges with a perspective camera
  20077. */
  20078. edgesWidthScalerForPerspective: number;
  20079. protected _source: AbstractMesh;
  20080. protected _linesPositions: number[];
  20081. protected _linesNormals: number[];
  20082. protected _linesIndices: number[];
  20083. protected _epsilon: number;
  20084. protected _indicesCount: number;
  20085. protected _lineShader: ShaderMaterial;
  20086. protected _ib: DataBuffer;
  20087. protected _buffers: {
  20088. [key: string]: Nullable<VertexBuffer>;
  20089. };
  20090. protected _checkVerticesInsteadOfIndices: boolean;
  20091. private _meshRebuildObserver;
  20092. private _meshDisposeObserver;
  20093. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20094. isEnabled: boolean;
  20095. /**
  20096. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20097. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20098. * @param source Mesh used to create edges
  20099. * @param epsilon sum of angles in adjacency to check for edge
  20100. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20101. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20102. */
  20103. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20104. protected _prepareRessources(): void;
  20105. /** @hidden */
  20106. _rebuild(): void;
  20107. /**
  20108. * Releases the required resources for the edges renderer
  20109. */
  20110. dispose(): void;
  20111. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20112. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20113. /**
  20114. * Checks if the pair of p0 and p1 is en edge
  20115. * @param faceIndex
  20116. * @param edge
  20117. * @param faceNormals
  20118. * @param p0
  20119. * @param p1
  20120. * @private
  20121. */
  20122. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20123. /**
  20124. * push line into the position, normal and index buffer
  20125. * @protected
  20126. */
  20127. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20128. /**
  20129. * Generates lines edges from adjacencjes
  20130. * @private
  20131. */
  20132. _generateEdgesLines(): void;
  20133. /**
  20134. * Checks wether or not the edges renderer is ready to render.
  20135. * @return true if ready, otherwise false.
  20136. */
  20137. isReady(): boolean;
  20138. /**
  20139. * Renders the edges of the attached mesh,
  20140. */
  20141. render(): void;
  20142. }
  20143. /**
  20144. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20145. */
  20146. export class LineEdgesRenderer extends EdgesRenderer {
  20147. /**
  20148. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20149. * @param source LineMesh used to generate edges
  20150. * @param epsilon not important (specified angle for edge detection)
  20151. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20152. */
  20153. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20154. /**
  20155. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20156. */
  20157. _generateEdgesLines(): void;
  20158. }
  20159. }
  20160. declare module "babylonjs/Rendering/renderingGroup" {
  20161. import { SmartArray } from "babylonjs/Misc/smartArray";
  20162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20164. import { Nullable } from "babylonjs/types";
  20165. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20166. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20167. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20168. import { Material } from "babylonjs/Materials/material";
  20169. import { Scene } from "babylonjs/scene";
  20170. /**
  20171. * This represents the object necessary to create a rendering group.
  20172. * This is exclusively used and created by the rendering manager.
  20173. * To modify the behavior, you use the available helpers in your scene or meshes.
  20174. * @hidden
  20175. */
  20176. export class RenderingGroup {
  20177. index: number;
  20178. private static _zeroVector;
  20179. private _scene;
  20180. private _opaqueSubMeshes;
  20181. private _transparentSubMeshes;
  20182. private _alphaTestSubMeshes;
  20183. private _depthOnlySubMeshes;
  20184. private _particleSystems;
  20185. private _spriteManagers;
  20186. private _opaqueSortCompareFn;
  20187. private _alphaTestSortCompareFn;
  20188. private _transparentSortCompareFn;
  20189. private _renderOpaque;
  20190. private _renderAlphaTest;
  20191. private _renderTransparent;
  20192. /** @hidden */
  20193. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20194. onBeforeTransparentRendering: () => void;
  20195. /**
  20196. * Set the opaque sort comparison function.
  20197. * If null the sub meshes will be render in the order they were created
  20198. */
  20199. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20200. /**
  20201. * Set the alpha test sort comparison function.
  20202. * If null the sub meshes will be render in the order they were created
  20203. */
  20204. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20205. /**
  20206. * Set the transparent sort comparison function.
  20207. * If null the sub meshes will be render in the order they were created
  20208. */
  20209. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20210. /**
  20211. * Creates a new rendering group.
  20212. * @param index The rendering group index
  20213. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20214. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20215. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20216. */
  20217. 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>);
  20218. /**
  20219. * Render all the sub meshes contained in the group.
  20220. * @param customRenderFunction Used to override the default render behaviour of the group.
  20221. * @returns true if rendered some submeshes.
  20222. */
  20223. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20224. /**
  20225. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20226. * @param subMeshes The submeshes to render
  20227. */
  20228. private renderOpaqueSorted;
  20229. /**
  20230. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20231. * @param subMeshes The submeshes to render
  20232. */
  20233. private renderAlphaTestSorted;
  20234. /**
  20235. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20236. * @param subMeshes The submeshes to render
  20237. */
  20238. private renderTransparentSorted;
  20239. /**
  20240. * Renders the submeshes in a specified order.
  20241. * @param subMeshes The submeshes to sort before render
  20242. * @param sortCompareFn The comparison function use to sort
  20243. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20244. * @param transparent Specifies to activate blending if true
  20245. */
  20246. private static renderSorted;
  20247. /**
  20248. * Renders the submeshes in the order they were dispatched (no sort applied).
  20249. * @param subMeshes The submeshes to render
  20250. */
  20251. private static renderUnsorted;
  20252. /**
  20253. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20254. * are rendered back to front if in the same alpha index.
  20255. *
  20256. * @param a The first submesh
  20257. * @param b The second submesh
  20258. * @returns The result of the comparison
  20259. */
  20260. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20261. /**
  20262. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20263. * are rendered back to front.
  20264. *
  20265. * @param a The first submesh
  20266. * @param b The second submesh
  20267. * @returns The result of the comparison
  20268. */
  20269. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20270. /**
  20271. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20272. * are rendered front to back (prevent overdraw).
  20273. *
  20274. * @param a The first submesh
  20275. * @param b The second submesh
  20276. * @returns The result of the comparison
  20277. */
  20278. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20279. /**
  20280. * Resets the different lists of submeshes to prepare a new frame.
  20281. */
  20282. prepare(): void;
  20283. dispose(): void;
  20284. /**
  20285. * Inserts the submesh in its correct queue depending on its material.
  20286. * @param subMesh The submesh to dispatch
  20287. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20288. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20289. */
  20290. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20291. dispatchSprites(spriteManager: ISpriteManager): void;
  20292. dispatchParticles(particleSystem: IParticleSystem): void;
  20293. private _renderParticles;
  20294. private _renderSprites;
  20295. }
  20296. }
  20297. declare module "babylonjs/Rendering/renderingManager" {
  20298. import { Nullable } from "babylonjs/types";
  20299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20300. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20301. import { SmartArray } from "babylonjs/Misc/smartArray";
  20302. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20303. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20304. import { Material } from "babylonjs/Materials/material";
  20305. import { Scene } from "babylonjs/scene";
  20306. import { Camera } from "babylonjs/Cameras/camera";
  20307. /**
  20308. * Interface describing the different options available in the rendering manager
  20309. * regarding Auto Clear between groups.
  20310. */
  20311. export interface IRenderingManagerAutoClearSetup {
  20312. /**
  20313. * Defines whether or not autoclear is enable.
  20314. */
  20315. autoClear: boolean;
  20316. /**
  20317. * Defines whether or not to autoclear the depth buffer.
  20318. */
  20319. depth: boolean;
  20320. /**
  20321. * Defines whether or not to autoclear the stencil buffer.
  20322. */
  20323. stencil: boolean;
  20324. }
  20325. /**
  20326. * This class is used by the onRenderingGroupObservable
  20327. */
  20328. export class RenderingGroupInfo {
  20329. /**
  20330. * The Scene that being rendered
  20331. */
  20332. scene: Scene;
  20333. /**
  20334. * The camera currently used for the rendering pass
  20335. */
  20336. camera: Nullable<Camera>;
  20337. /**
  20338. * The ID of the renderingGroup being processed
  20339. */
  20340. renderingGroupId: number;
  20341. }
  20342. /**
  20343. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20344. * It is enable to manage the different groups as well as the different necessary sort functions.
  20345. * This should not be used directly aside of the few static configurations
  20346. */
  20347. export class RenderingManager {
  20348. /**
  20349. * The max id used for rendering groups (not included)
  20350. */
  20351. static MAX_RENDERINGGROUPS: number;
  20352. /**
  20353. * The min id used for rendering groups (included)
  20354. */
  20355. static MIN_RENDERINGGROUPS: number;
  20356. /**
  20357. * Used to globally prevent autoclearing scenes.
  20358. */
  20359. static AUTOCLEAR: boolean;
  20360. /**
  20361. * @hidden
  20362. */
  20363. _useSceneAutoClearSetup: boolean;
  20364. private _scene;
  20365. private _renderingGroups;
  20366. private _depthStencilBufferAlreadyCleaned;
  20367. private _autoClearDepthStencil;
  20368. private _customOpaqueSortCompareFn;
  20369. private _customAlphaTestSortCompareFn;
  20370. private _customTransparentSortCompareFn;
  20371. private _renderingGroupInfo;
  20372. /**
  20373. * Instantiates a new rendering group for a particular scene
  20374. * @param scene Defines the scene the groups belongs to
  20375. */
  20376. constructor(scene: Scene);
  20377. private _clearDepthStencilBuffer;
  20378. /**
  20379. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20380. * @hidden
  20381. */
  20382. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20383. /**
  20384. * Resets the different information of the group to prepare a new frame
  20385. * @hidden
  20386. */
  20387. reset(): void;
  20388. /**
  20389. * Dispose and release the group and its associated resources.
  20390. * @hidden
  20391. */
  20392. dispose(): void;
  20393. /**
  20394. * Clear the info related to rendering groups preventing retention points during dispose.
  20395. */
  20396. freeRenderingGroups(): void;
  20397. private _prepareRenderingGroup;
  20398. /**
  20399. * Add a sprite manager to the rendering manager in order to render it this frame.
  20400. * @param spriteManager Define the sprite manager to render
  20401. */
  20402. dispatchSprites(spriteManager: ISpriteManager): void;
  20403. /**
  20404. * Add a particle system to the rendering manager in order to render it this frame.
  20405. * @param particleSystem Define the particle system to render
  20406. */
  20407. dispatchParticles(particleSystem: IParticleSystem): void;
  20408. /**
  20409. * Add a submesh to the manager in order to render it this frame
  20410. * @param subMesh The submesh to dispatch
  20411. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20412. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20413. */
  20414. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20415. /**
  20416. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20417. * This allowed control for front to back rendering or reversly depending of the special needs.
  20418. *
  20419. * @param renderingGroupId The rendering group id corresponding to its index
  20420. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20421. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20422. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20423. */
  20424. 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;
  20425. /**
  20426. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20427. *
  20428. * @param renderingGroupId The rendering group id corresponding to its index
  20429. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20430. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20431. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20432. */
  20433. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20434. /**
  20435. * Gets the current auto clear configuration for one rendering group of the rendering
  20436. * manager.
  20437. * @param index the rendering group index to get the information for
  20438. * @returns The auto clear setup for the requested rendering group
  20439. */
  20440. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20441. }
  20442. }
  20443. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20444. import { Observable } from "babylonjs/Misc/observable";
  20445. import { SmartArray } from "babylonjs/Misc/smartArray";
  20446. import { Nullable } from "babylonjs/types";
  20447. import { Camera } from "babylonjs/Cameras/camera";
  20448. import { Scene } from "babylonjs/scene";
  20449. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20450. import { Color4 } from "babylonjs/Maths/math.color";
  20451. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20454. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20455. import { Texture } from "babylonjs/Materials/Textures/texture";
  20456. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20457. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20458. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20459. import { Engine } from "babylonjs/Engines/engine";
  20460. /**
  20461. * This Helps creating a texture that will be created from a camera in your scene.
  20462. * It is basically a dynamic texture that could be used to create special effects for instance.
  20463. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20464. */
  20465. export class RenderTargetTexture extends Texture {
  20466. isCube: boolean;
  20467. /**
  20468. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20469. */
  20470. static readonly REFRESHRATE_RENDER_ONCE: number;
  20471. /**
  20472. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20473. */
  20474. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20475. /**
  20476. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20477. * the central point of your effect and can save a lot of performances.
  20478. */
  20479. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20480. /**
  20481. * Use this predicate to dynamically define the list of mesh you want to render.
  20482. * If set, the renderList property will be overwritten.
  20483. */
  20484. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20485. private _renderList;
  20486. /**
  20487. * Use this list to define the list of mesh you want to render.
  20488. */
  20489. renderList: Nullable<Array<AbstractMesh>>;
  20490. private _hookArray;
  20491. /**
  20492. * Define if particles should be rendered in your texture.
  20493. */
  20494. renderParticles: boolean;
  20495. /**
  20496. * Define if sprites should be rendered in your texture.
  20497. */
  20498. renderSprites: boolean;
  20499. /**
  20500. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20501. */
  20502. coordinatesMode: number;
  20503. /**
  20504. * Define the camera used to render the texture.
  20505. */
  20506. activeCamera: Nullable<Camera>;
  20507. /**
  20508. * Override the render function of the texture with your own one.
  20509. */
  20510. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20511. /**
  20512. * Define if camera post processes should be use while rendering the texture.
  20513. */
  20514. useCameraPostProcesses: boolean;
  20515. /**
  20516. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20517. */
  20518. ignoreCameraViewport: boolean;
  20519. private _postProcessManager;
  20520. private _postProcesses;
  20521. private _resizeObserver;
  20522. /**
  20523. * An event triggered when the texture is unbind.
  20524. */
  20525. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20526. /**
  20527. * An event triggered when the texture is unbind.
  20528. */
  20529. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20530. private _onAfterUnbindObserver;
  20531. /**
  20532. * Set a after unbind callback in the texture.
  20533. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20534. */
  20535. onAfterUnbind: () => void;
  20536. /**
  20537. * An event triggered before rendering the texture
  20538. */
  20539. onBeforeRenderObservable: Observable<number>;
  20540. private _onBeforeRenderObserver;
  20541. /**
  20542. * Set a before render callback in the texture.
  20543. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20544. */
  20545. onBeforeRender: (faceIndex: number) => void;
  20546. /**
  20547. * An event triggered after rendering the texture
  20548. */
  20549. onAfterRenderObservable: Observable<number>;
  20550. private _onAfterRenderObserver;
  20551. /**
  20552. * Set a after render callback in the texture.
  20553. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20554. */
  20555. onAfterRender: (faceIndex: number) => void;
  20556. /**
  20557. * An event triggered after the texture clear
  20558. */
  20559. onClearObservable: Observable<Engine>;
  20560. private _onClearObserver;
  20561. /**
  20562. * Set a clear callback in the texture.
  20563. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20564. */
  20565. onClear: (Engine: Engine) => void;
  20566. /**
  20567. * An event triggered when the texture is resized.
  20568. */
  20569. onResizeObservable: Observable<RenderTargetTexture>;
  20570. /**
  20571. * Define the clear color of the Render Target if it should be different from the scene.
  20572. */
  20573. clearColor: Color4;
  20574. protected _size: number | {
  20575. width: number;
  20576. height: number;
  20577. };
  20578. protected _initialSizeParameter: number | {
  20579. width: number;
  20580. height: number;
  20581. } | {
  20582. ratio: number;
  20583. };
  20584. protected _sizeRatio: Nullable<number>;
  20585. /** @hidden */
  20586. _generateMipMaps: boolean;
  20587. protected _renderingManager: RenderingManager;
  20588. /** @hidden */
  20589. _waitingRenderList: string[];
  20590. protected _doNotChangeAspectRatio: boolean;
  20591. protected _currentRefreshId: number;
  20592. protected _refreshRate: number;
  20593. protected _textureMatrix: Matrix;
  20594. protected _samples: number;
  20595. protected _renderTargetOptions: RenderTargetCreationOptions;
  20596. /**
  20597. * Gets render target creation options that were used.
  20598. */
  20599. readonly renderTargetOptions: RenderTargetCreationOptions;
  20600. protected _engine: Engine;
  20601. protected _onRatioRescale(): void;
  20602. /**
  20603. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20604. * It must define where the camera used to render the texture is set
  20605. */
  20606. boundingBoxPosition: Vector3;
  20607. private _boundingBoxSize;
  20608. /**
  20609. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20610. * When defined, the cubemap will switch to local mode
  20611. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20612. * @example https://www.babylonjs-playground.com/#RNASML
  20613. */
  20614. boundingBoxSize: Vector3;
  20615. /**
  20616. * In case the RTT has been created with a depth texture, get the associated
  20617. * depth texture.
  20618. * Otherwise, return null.
  20619. */
  20620. depthStencilTexture: Nullable<InternalTexture>;
  20621. /**
  20622. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20623. * or used a shadow, depth texture...
  20624. * @param name The friendly name of the texture
  20625. * @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)
  20626. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20627. * @param generateMipMaps True if mip maps need to be generated after render.
  20628. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20629. * @param type The type of the buffer in the RTT (int, half float, float...)
  20630. * @param isCube True if a cube texture needs to be created
  20631. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20632. * @param generateDepthBuffer True to generate a depth buffer
  20633. * @param generateStencilBuffer True to generate a stencil buffer
  20634. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20635. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20636. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20637. */
  20638. constructor(name: string, size: number | {
  20639. width: number;
  20640. height: number;
  20641. } | {
  20642. ratio: number;
  20643. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20644. /**
  20645. * Creates a depth stencil texture.
  20646. * This is only available in WebGL 2 or with the depth texture extension available.
  20647. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20648. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20649. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20650. */
  20651. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20652. private _processSizeParameter;
  20653. /**
  20654. * Define the number of samples to use in case of MSAA.
  20655. * It defaults to one meaning no MSAA has been enabled.
  20656. */
  20657. samples: number;
  20658. /**
  20659. * Resets the refresh counter of the texture and start bak from scratch.
  20660. * Could be useful to regenerate the texture if it is setup to render only once.
  20661. */
  20662. resetRefreshCounter(): void;
  20663. /**
  20664. * Define the refresh rate of the texture or the rendering frequency.
  20665. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20666. */
  20667. refreshRate: number;
  20668. /**
  20669. * Adds a post process to the render target rendering passes.
  20670. * @param postProcess define the post process to add
  20671. */
  20672. addPostProcess(postProcess: PostProcess): void;
  20673. /**
  20674. * Clear all the post processes attached to the render target
  20675. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20676. */
  20677. clearPostProcesses(dispose?: boolean): void;
  20678. /**
  20679. * Remove one of the post process from the list of attached post processes to the texture
  20680. * @param postProcess define the post process to remove from the list
  20681. */
  20682. removePostProcess(postProcess: PostProcess): void;
  20683. /** @hidden */
  20684. _shouldRender(): boolean;
  20685. /**
  20686. * Gets the actual render size of the texture.
  20687. * @returns the width of the render size
  20688. */
  20689. getRenderSize(): number;
  20690. /**
  20691. * Gets the actual render width of the texture.
  20692. * @returns the width of the render size
  20693. */
  20694. getRenderWidth(): number;
  20695. /**
  20696. * Gets the actual render height of the texture.
  20697. * @returns the height of the render size
  20698. */
  20699. getRenderHeight(): number;
  20700. /**
  20701. * Get if the texture can be rescaled or not.
  20702. */
  20703. readonly canRescale: boolean;
  20704. /**
  20705. * Resize the texture using a ratio.
  20706. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20707. */
  20708. scale(ratio: number): void;
  20709. /**
  20710. * Get the texture reflection matrix used to rotate/transform the reflection.
  20711. * @returns the reflection matrix
  20712. */
  20713. getReflectionTextureMatrix(): Matrix;
  20714. /**
  20715. * Resize the texture to a new desired size.
  20716. * Be carrefull as it will recreate all the data in the new texture.
  20717. * @param size Define the new size. It can be:
  20718. * - a number for squared texture,
  20719. * - an object containing { width: number, height: number }
  20720. * - or an object containing a ratio { ratio: number }
  20721. */
  20722. resize(size: number | {
  20723. width: number;
  20724. height: number;
  20725. } | {
  20726. ratio: number;
  20727. }): void;
  20728. /**
  20729. * Renders all the objects from the render list into the texture.
  20730. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20731. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20732. */
  20733. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20734. private _bestReflectionRenderTargetDimension;
  20735. /**
  20736. * @hidden
  20737. * @param faceIndex face index to bind to if this is a cubetexture
  20738. */
  20739. _bindFrameBuffer(faceIndex?: number): void;
  20740. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20741. private renderToTarget;
  20742. /**
  20743. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20744. * This allowed control for front to back rendering or reversly depending of the special needs.
  20745. *
  20746. * @param renderingGroupId The rendering group id corresponding to its index
  20747. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20748. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20749. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20750. */
  20751. 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;
  20752. /**
  20753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20754. *
  20755. * @param renderingGroupId The rendering group id corresponding to its index
  20756. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20757. */
  20758. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20759. /**
  20760. * Clones the texture.
  20761. * @returns the cloned texture
  20762. */
  20763. clone(): RenderTargetTexture;
  20764. /**
  20765. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20766. * @returns The JSON representation of the texture
  20767. */
  20768. serialize(): any;
  20769. /**
  20770. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20771. */
  20772. disposeFramebufferObjects(): void;
  20773. /**
  20774. * Dispose the texture and release its associated resources.
  20775. */
  20776. dispose(): void;
  20777. /** @hidden */
  20778. _rebuild(): void;
  20779. /**
  20780. * Clear the info related to rendering groups preventing retention point in material dispose.
  20781. */
  20782. freeRenderingGroups(): void;
  20783. /**
  20784. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20785. * @returns the view count
  20786. */
  20787. getViewCount(): number;
  20788. }
  20789. }
  20790. declare module "babylonjs/Materials/material" {
  20791. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20792. import { SmartArray } from "babylonjs/Misc/smartArray";
  20793. import { Observable } from "babylonjs/Misc/observable";
  20794. import { Nullable } from "babylonjs/types";
  20795. import { Scene } from "babylonjs/scene";
  20796. import { Matrix } from "babylonjs/Maths/math.vector";
  20797. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20799. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20800. import { Effect } from "babylonjs/Materials/effect";
  20801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20802. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20803. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20804. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20805. import { Mesh } from "babylonjs/Meshes/mesh";
  20806. import { Animation } from "babylonjs/Animations/animation";
  20807. /**
  20808. * Base class for the main features of a material in Babylon.js
  20809. */
  20810. export class Material implements IAnimatable {
  20811. /**
  20812. * Returns the triangle fill mode
  20813. */
  20814. static readonly TriangleFillMode: number;
  20815. /**
  20816. * Returns the wireframe mode
  20817. */
  20818. static readonly WireFrameFillMode: number;
  20819. /**
  20820. * Returns the point fill mode
  20821. */
  20822. static readonly PointFillMode: number;
  20823. /**
  20824. * Returns the point list draw mode
  20825. */
  20826. static readonly PointListDrawMode: number;
  20827. /**
  20828. * Returns the line list draw mode
  20829. */
  20830. static readonly LineListDrawMode: number;
  20831. /**
  20832. * Returns the line loop draw mode
  20833. */
  20834. static readonly LineLoopDrawMode: number;
  20835. /**
  20836. * Returns the line strip draw mode
  20837. */
  20838. static readonly LineStripDrawMode: number;
  20839. /**
  20840. * Returns the triangle strip draw mode
  20841. */
  20842. static readonly TriangleStripDrawMode: number;
  20843. /**
  20844. * Returns the triangle fan draw mode
  20845. */
  20846. static readonly TriangleFanDrawMode: number;
  20847. /**
  20848. * Stores the clock-wise side orientation
  20849. */
  20850. static readonly ClockWiseSideOrientation: number;
  20851. /**
  20852. * Stores the counter clock-wise side orientation
  20853. */
  20854. static readonly CounterClockWiseSideOrientation: number;
  20855. /**
  20856. * The dirty texture flag value
  20857. */
  20858. static readonly TextureDirtyFlag: number;
  20859. /**
  20860. * The dirty light flag value
  20861. */
  20862. static readonly LightDirtyFlag: number;
  20863. /**
  20864. * The dirty fresnel flag value
  20865. */
  20866. static readonly FresnelDirtyFlag: number;
  20867. /**
  20868. * The dirty attribute flag value
  20869. */
  20870. static readonly AttributesDirtyFlag: number;
  20871. /**
  20872. * The dirty misc flag value
  20873. */
  20874. static readonly MiscDirtyFlag: number;
  20875. /**
  20876. * The all dirty flag value
  20877. */
  20878. static readonly AllDirtyFlag: number;
  20879. /**
  20880. * The ID of the material
  20881. */
  20882. id: string;
  20883. /**
  20884. * Gets or sets the unique id of the material
  20885. */
  20886. uniqueId: number;
  20887. /**
  20888. * The name of the material
  20889. */
  20890. name: string;
  20891. /**
  20892. * Gets or sets user defined metadata
  20893. */
  20894. metadata: any;
  20895. /**
  20896. * For internal use only. Please do not use.
  20897. */
  20898. reservedDataStore: any;
  20899. /**
  20900. * Specifies if the ready state should be checked on each call
  20901. */
  20902. checkReadyOnEveryCall: boolean;
  20903. /**
  20904. * Specifies if the ready state should be checked once
  20905. */
  20906. checkReadyOnlyOnce: boolean;
  20907. /**
  20908. * The state of the material
  20909. */
  20910. state: string;
  20911. /**
  20912. * The alpha value of the material
  20913. */
  20914. protected _alpha: number;
  20915. /**
  20916. * List of inspectable custom properties (used by the Inspector)
  20917. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20918. */
  20919. inspectableCustomProperties: IInspectable[];
  20920. /**
  20921. * Sets the alpha value of the material
  20922. */
  20923. /**
  20924. * Gets the alpha value of the material
  20925. */
  20926. alpha: number;
  20927. /**
  20928. * Specifies if back face culling is enabled
  20929. */
  20930. protected _backFaceCulling: boolean;
  20931. /**
  20932. * Sets the back-face culling state
  20933. */
  20934. /**
  20935. * Gets the back-face culling state
  20936. */
  20937. backFaceCulling: boolean;
  20938. /**
  20939. * Stores the value for side orientation
  20940. */
  20941. sideOrientation: number;
  20942. /**
  20943. * Callback triggered when the material is compiled
  20944. */
  20945. onCompiled: Nullable<(effect: Effect) => void>;
  20946. /**
  20947. * Callback triggered when an error occurs
  20948. */
  20949. onError: Nullable<(effect: Effect, errors: string) => void>;
  20950. /**
  20951. * Callback triggered to get the render target textures
  20952. */
  20953. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20954. /**
  20955. * Gets a boolean indicating that current material needs to register RTT
  20956. */
  20957. readonly hasRenderTargetTextures: boolean;
  20958. /**
  20959. * Specifies if the material should be serialized
  20960. */
  20961. doNotSerialize: boolean;
  20962. /**
  20963. * @hidden
  20964. */
  20965. _storeEffectOnSubMeshes: boolean;
  20966. /**
  20967. * Stores the animations for the material
  20968. */
  20969. animations: Nullable<Array<Animation>>;
  20970. /**
  20971. * An event triggered when the material is disposed
  20972. */
  20973. onDisposeObservable: Observable<Material>;
  20974. /**
  20975. * An observer which watches for dispose events
  20976. */
  20977. private _onDisposeObserver;
  20978. private _onUnBindObservable;
  20979. /**
  20980. * Called during a dispose event
  20981. */
  20982. onDispose: () => void;
  20983. private _onBindObservable;
  20984. /**
  20985. * An event triggered when the material is bound
  20986. */
  20987. readonly onBindObservable: Observable<AbstractMesh>;
  20988. /**
  20989. * An observer which watches for bind events
  20990. */
  20991. private _onBindObserver;
  20992. /**
  20993. * Called during a bind event
  20994. */
  20995. onBind: (Mesh: AbstractMesh) => void;
  20996. /**
  20997. * An event triggered when the material is unbound
  20998. */
  20999. readonly onUnBindObservable: Observable<Material>;
  21000. /**
  21001. * Stores the value of the alpha mode
  21002. */
  21003. private _alphaMode;
  21004. /**
  21005. * Sets the value of the alpha mode.
  21006. *
  21007. * | Value | Type | Description |
  21008. * | --- | --- | --- |
  21009. * | 0 | ALPHA_DISABLE | |
  21010. * | 1 | ALPHA_ADD | |
  21011. * | 2 | ALPHA_COMBINE | |
  21012. * | 3 | ALPHA_SUBTRACT | |
  21013. * | 4 | ALPHA_MULTIPLY | |
  21014. * | 5 | ALPHA_MAXIMIZED | |
  21015. * | 6 | ALPHA_ONEONE | |
  21016. * | 7 | ALPHA_PREMULTIPLIED | |
  21017. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21018. * | 9 | ALPHA_INTERPOLATE | |
  21019. * | 10 | ALPHA_SCREENMODE | |
  21020. *
  21021. */
  21022. /**
  21023. * Gets the value of the alpha mode
  21024. */
  21025. alphaMode: number;
  21026. /**
  21027. * Stores the state of the need depth pre-pass value
  21028. */
  21029. private _needDepthPrePass;
  21030. /**
  21031. * Sets the need depth pre-pass value
  21032. */
  21033. /**
  21034. * Gets the depth pre-pass value
  21035. */
  21036. needDepthPrePass: boolean;
  21037. /**
  21038. * Specifies if depth writing should be disabled
  21039. */
  21040. disableDepthWrite: boolean;
  21041. /**
  21042. * Specifies if depth writing should be forced
  21043. */
  21044. forceDepthWrite: boolean;
  21045. /**
  21046. * Specifies if there should be a separate pass for culling
  21047. */
  21048. separateCullingPass: boolean;
  21049. /**
  21050. * Stores the state specifing if fog should be enabled
  21051. */
  21052. private _fogEnabled;
  21053. /**
  21054. * Sets the state for enabling fog
  21055. */
  21056. /**
  21057. * Gets the value of the fog enabled state
  21058. */
  21059. fogEnabled: boolean;
  21060. /**
  21061. * Stores the size of points
  21062. */
  21063. pointSize: number;
  21064. /**
  21065. * Stores the z offset value
  21066. */
  21067. zOffset: number;
  21068. /**
  21069. * Gets a value specifying if wireframe mode is enabled
  21070. */
  21071. /**
  21072. * Sets the state of wireframe mode
  21073. */
  21074. wireframe: boolean;
  21075. /**
  21076. * Gets the value specifying if point clouds are enabled
  21077. */
  21078. /**
  21079. * Sets the state of point cloud mode
  21080. */
  21081. pointsCloud: boolean;
  21082. /**
  21083. * Gets the material fill mode
  21084. */
  21085. /**
  21086. * Sets the material fill mode
  21087. */
  21088. fillMode: number;
  21089. /**
  21090. * @hidden
  21091. * Stores the effects for the material
  21092. */
  21093. _effect: Nullable<Effect>;
  21094. /**
  21095. * @hidden
  21096. * Specifies if the material was previously ready
  21097. */
  21098. _wasPreviouslyReady: boolean;
  21099. /**
  21100. * Specifies if uniform buffers should be used
  21101. */
  21102. private _useUBO;
  21103. /**
  21104. * Stores a reference to the scene
  21105. */
  21106. private _scene;
  21107. /**
  21108. * Stores the fill mode state
  21109. */
  21110. private _fillMode;
  21111. /**
  21112. * Specifies if the depth write state should be cached
  21113. */
  21114. private _cachedDepthWriteState;
  21115. /**
  21116. * Stores the uniform buffer
  21117. */
  21118. protected _uniformBuffer: UniformBuffer;
  21119. /** @hidden */
  21120. _indexInSceneMaterialArray: number;
  21121. /** @hidden */
  21122. meshMap: Nullable<{
  21123. [id: string]: AbstractMesh | undefined;
  21124. }>;
  21125. /**
  21126. * Creates a material instance
  21127. * @param name defines the name of the material
  21128. * @param scene defines the scene to reference
  21129. * @param doNotAdd specifies if the material should be added to the scene
  21130. */
  21131. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21132. /**
  21133. * Returns a string representation of the current material
  21134. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21135. * @returns a string with material information
  21136. */
  21137. toString(fullDetails?: boolean): string;
  21138. /**
  21139. * Gets the class name of the material
  21140. * @returns a string with the class name of the material
  21141. */
  21142. getClassName(): string;
  21143. /**
  21144. * Specifies if updates for the material been locked
  21145. */
  21146. readonly isFrozen: boolean;
  21147. /**
  21148. * Locks updates for the material
  21149. */
  21150. freeze(): void;
  21151. /**
  21152. * Unlocks updates for the material
  21153. */
  21154. unfreeze(): void;
  21155. /**
  21156. * Specifies if the material is ready to be used
  21157. * @param mesh defines the mesh to check
  21158. * @param useInstances specifies if instances should be used
  21159. * @returns a boolean indicating if the material is ready to be used
  21160. */
  21161. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21162. /**
  21163. * Specifies that the submesh is ready to be used
  21164. * @param mesh defines the mesh to check
  21165. * @param subMesh defines which submesh to check
  21166. * @param useInstances specifies that instances should be used
  21167. * @returns a boolean indicating that the submesh is ready or not
  21168. */
  21169. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21170. /**
  21171. * Returns the material effect
  21172. * @returns the effect associated with the material
  21173. */
  21174. getEffect(): Nullable<Effect>;
  21175. /**
  21176. * Returns the current scene
  21177. * @returns a Scene
  21178. */
  21179. getScene(): Scene;
  21180. /**
  21181. * Specifies if the material will require alpha blending
  21182. * @returns a boolean specifying if alpha blending is needed
  21183. */
  21184. needAlphaBlending(): boolean;
  21185. /**
  21186. * Specifies if the mesh will require alpha blending
  21187. * @param mesh defines the mesh to check
  21188. * @returns a boolean specifying if alpha blending is needed for the mesh
  21189. */
  21190. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21191. /**
  21192. * Specifies if this material should be rendered in alpha test mode
  21193. * @returns a boolean specifying if an alpha test is needed.
  21194. */
  21195. needAlphaTesting(): boolean;
  21196. /**
  21197. * Gets the texture used for the alpha test
  21198. * @returns the texture to use for alpha testing
  21199. */
  21200. getAlphaTestTexture(): Nullable<BaseTexture>;
  21201. /**
  21202. * Marks the material to indicate that it needs to be re-calculated
  21203. */
  21204. markDirty(): void;
  21205. /** @hidden */
  21206. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21207. /**
  21208. * Binds the material to the mesh
  21209. * @param world defines the world transformation matrix
  21210. * @param mesh defines the mesh to bind the material to
  21211. */
  21212. bind(world: Matrix, mesh?: Mesh): void;
  21213. /**
  21214. * Binds the submesh to the material
  21215. * @param world defines the world transformation matrix
  21216. * @param mesh defines the mesh containing the submesh
  21217. * @param subMesh defines the submesh to bind the material to
  21218. */
  21219. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21220. /**
  21221. * Binds the world matrix to the material
  21222. * @param world defines the world transformation matrix
  21223. */
  21224. bindOnlyWorldMatrix(world: Matrix): void;
  21225. /**
  21226. * Binds the scene's uniform buffer to the effect.
  21227. * @param effect defines the effect to bind to the scene uniform buffer
  21228. * @param sceneUbo defines the uniform buffer storing scene data
  21229. */
  21230. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21231. /**
  21232. * Binds the view matrix to the effect
  21233. * @param effect defines the effect to bind the view matrix to
  21234. */
  21235. bindView(effect: Effect): void;
  21236. /**
  21237. * Binds the view projection matrix to the effect
  21238. * @param effect defines the effect to bind the view projection matrix to
  21239. */
  21240. bindViewProjection(effect: Effect): void;
  21241. /**
  21242. * Specifies if material alpha testing should be turned on for the mesh
  21243. * @param mesh defines the mesh to check
  21244. */
  21245. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21246. /**
  21247. * Processes to execute after binding the material to a mesh
  21248. * @param mesh defines the rendered mesh
  21249. */
  21250. protected _afterBind(mesh?: Mesh): void;
  21251. /**
  21252. * Unbinds the material from the mesh
  21253. */
  21254. unbind(): void;
  21255. /**
  21256. * Gets the active textures from the material
  21257. * @returns an array of textures
  21258. */
  21259. getActiveTextures(): BaseTexture[];
  21260. /**
  21261. * Specifies if the material uses a texture
  21262. * @param texture defines the texture to check against the material
  21263. * @returns a boolean specifying if the material uses the texture
  21264. */
  21265. hasTexture(texture: BaseTexture): boolean;
  21266. /**
  21267. * Makes a duplicate of the material, and gives it a new name
  21268. * @param name defines the new name for the duplicated material
  21269. * @returns the cloned material
  21270. */
  21271. clone(name: string): Nullable<Material>;
  21272. /**
  21273. * Gets the meshes bound to the material
  21274. * @returns an array of meshes bound to the material
  21275. */
  21276. getBindedMeshes(): AbstractMesh[];
  21277. /**
  21278. * Force shader compilation
  21279. * @param mesh defines the mesh associated with this material
  21280. * @param onCompiled defines a function to execute once the material is compiled
  21281. * @param options defines the options to configure the compilation
  21282. */
  21283. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21284. clipPlane: boolean;
  21285. }>): void;
  21286. /**
  21287. * Force shader compilation
  21288. * @param mesh defines the mesh that will use this material
  21289. * @param options defines additional options for compiling the shaders
  21290. * @returns a promise that resolves when the compilation completes
  21291. */
  21292. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21293. clipPlane: boolean;
  21294. }>): Promise<void>;
  21295. private static readonly _AllDirtyCallBack;
  21296. private static readonly _ImageProcessingDirtyCallBack;
  21297. private static readonly _TextureDirtyCallBack;
  21298. private static readonly _FresnelDirtyCallBack;
  21299. private static readonly _MiscDirtyCallBack;
  21300. private static readonly _LightsDirtyCallBack;
  21301. private static readonly _AttributeDirtyCallBack;
  21302. private static _FresnelAndMiscDirtyCallBack;
  21303. private static _TextureAndMiscDirtyCallBack;
  21304. private static readonly _DirtyCallbackArray;
  21305. private static readonly _RunDirtyCallBacks;
  21306. /**
  21307. * Marks a define in the material to indicate that it needs to be re-computed
  21308. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21309. */
  21310. markAsDirty(flag: number): void;
  21311. /**
  21312. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21313. * @param func defines a function which checks material defines against the submeshes
  21314. */
  21315. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21316. /**
  21317. * Indicates that we need to re-calculated for all submeshes
  21318. */
  21319. protected _markAllSubMeshesAsAllDirty(): void;
  21320. /**
  21321. * Indicates that image processing needs to be re-calculated for all submeshes
  21322. */
  21323. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21324. /**
  21325. * Indicates that textures need to be re-calculated for all submeshes
  21326. */
  21327. protected _markAllSubMeshesAsTexturesDirty(): void;
  21328. /**
  21329. * Indicates that fresnel needs to be re-calculated for all submeshes
  21330. */
  21331. protected _markAllSubMeshesAsFresnelDirty(): void;
  21332. /**
  21333. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21334. */
  21335. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21336. /**
  21337. * Indicates that lights need to be re-calculated for all submeshes
  21338. */
  21339. protected _markAllSubMeshesAsLightsDirty(): void;
  21340. /**
  21341. * Indicates that attributes need to be re-calculated for all submeshes
  21342. */
  21343. protected _markAllSubMeshesAsAttributesDirty(): void;
  21344. /**
  21345. * Indicates that misc needs to be re-calculated for all submeshes
  21346. */
  21347. protected _markAllSubMeshesAsMiscDirty(): void;
  21348. /**
  21349. * Indicates that textures and misc need to be re-calculated for all submeshes
  21350. */
  21351. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21352. /**
  21353. * Disposes the material
  21354. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21355. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21356. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21357. */
  21358. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21359. /** @hidden */
  21360. private releaseVertexArrayObject;
  21361. /**
  21362. * Serializes this material
  21363. * @returns the serialized material object
  21364. */
  21365. serialize(): any;
  21366. /**
  21367. * Creates a material from parsed material data
  21368. * @param parsedMaterial defines parsed material data
  21369. * @param scene defines the hosting scene
  21370. * @param rootUrl defines the root URL to use to load textures
  21371. * @returns a new material
  21372. */
  21373. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21374. }
  21375. }
  21376. declare module "babylonjs/Materials/multiMaterial" {
  21377. import { Nullable } from "babylonjs/types";
  21378. import { Scene } from "babylonjs/scene";
  21379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21380. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21382. import { Material } from "babylonjs/Materials/material";
  21383. /**
  21384. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21385. * separate meshes. This can be use to improve performances.
  21386. * @see http://doc.babylonjs.com/how_to/multi_materials
  21387. */
  21388. export class MultiMaterial extends Material {
  21389. private _subMaterials;
  21390. /**
  21391. * Gets or Sets the list of Materials used within the multi material.
  21392. * They need to be ordered according to the submeshes order in the associated mesh
  21393. */
  21394. subMaterials: Nullable<Material>[];
  21395. /**
  21396. * Function used to align with Node.getChildren()
  21397. * @returns the list of Materials used within the multi material
  21398. */
  21399. getChildren(): Nullable<Material>[];
  21400. /**
  21401. * Instantiates a new Multi Material
  21402. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21403. * separate meshes. This can be use to improve performances.
  21404. * @see http://doc.babylonjs.com/how_to/multi_materials
  21405. * @param name Define the name in the scene
  21406. * @param scene Define the scene the material belongs to
  21407. */
  21408. constructor(name: string, scene: Scene);
  21409. private _hookArray;
  21410. /**
  21411. * Get one of the submaterial by its index in the submaterials array
  21412. * @param index The index to look the sub material at
  21413. * @returns The Material if the index has been defined
  21414. */
  21415. getSubMaterial(index: number): Nullable<Material>;
  21416. /**
  21417. * Get the list of active textures for the whole sub materials list.
  21418. * @returns All the textures that will be used during the rendering
  21419. */
  21420. getActiveTextures(): BaseTexture[];
  21421. /**
  21422. * Gets the current class name of the material e.g. "MultiMaterial"
  21423. * Mainly use in serialization.
  21424. * @returns the class name
  21425. */
  21426. getClassName(): string;
  21427. /**
  21428. * Checks if the material is ready to render the requested sub mesh
  21429. * @param mesh Define the mesh the submesh belongs to
  21430. * @param subMesh Define the sub mesh to look readyness for
  21431. * @param useInstances Define whether or not the material is used with instances
  21432. * @returns true if ready, otherwise false
  21433. */
  21434. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21435. /**
  21436. * Clones the current material and its related sub materials
  21437. * @param name Define the name of the newly cloned material
  21438. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21439. * @returns the cloned material
  21440. */
  21441. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21442. /**
  21443. * Serializes the materials into a JSON representation.
  21444. * @returns the JSON representation
  21445. */
  21446. serialize(): any;
  21447. /**
  21448. * Dispose the material and release its associated resources
  21449. * @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)
  21450. * @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)
  21451. * @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)
  21452. */
  21453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21454. /**
  21455. * Creates a MultiMaterial from parsed MultiMaterial data.
  21456. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21457. * @param scene defines the hosting scene
  21458. * @returns a new MultiMaterial
  21459. */
  21460. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21461. }
  21462. }
  21463. declare module "babylonjs/Meshes/subMesh" {
  21464. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21465. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21466. import { Engine } from "babylonjs/Engines/engine";
  21467. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21468. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21469. import { Effect } from "babylonjs/Materials/effect";
  21470. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21471. import { Plane } from "babylonjs/Maths/math.plane";
  21472. import { Collider } from "babylonjs/Collisions/collider";
  21473. import { Material } from "babylonjs/Materials/material";
  21474. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21476. import { Mesh } from "babylonjs/Meshes/mesh";
  21477. import { Ray } from "babylonjs/Culling/ray";
  21478. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21479. /**
  21480. * Base class for submeshes
  21481. */
  21482. export class BaseSubMesh {
  21483. /** @hidden */
  21484. _materialDefines: Nullable<MaterialDefines>;
  21485. /** @hidden */
  21486. _materialEffect: Nullable<Effect>;
  21487. /**
  21488. * Gets associated effect
  21489. */
  21490. readonly effect: Nullable<Effect>;
  21491. /**
  21492. * Sets associated effect (effect used to render this submesh)
  21493. * @param effect defines the effect to associate with
  21494. * @param defines defines the set of defines used to compile this effect
  21495. */
  21496. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21497. }
  21498. /**
  21499. * Defines a subdivision inside a mesh
  21500. */
  21501. export class SubMesh extends BaseSubMesh implements ICullable {
  21502. /** the material index to use */
  21503. materialIndex: number;
  21504. /** vertex index start */
  21505. verticesStart: number;
  21506. /** vertices count */
  21507. verticesCount: number;
  21508. /** index start */
  21509. indexStart: number;
  21510. /** indices count */
  21511. indexCount: number;
  21512. /** @hidden */
  21513. _linesIndexCount: number;
  21514. private _mesh;
  21515. private _renderingMesh;
  21516. private _boundingInfo;
  21517. private _linesIndexBuffer;
  21518. /** @hidden */
  21519. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21520. /** @hidden */
  21521. _trianglePlanes: Plane[];
  21522. /** @hidden */
  21523. _lastColliderTransformMatrix: Nullable<Matrix>;
  21524. /** @hidden */
  21525. _renderId: number;
  21526. /** @hidden */
  21527. _alphaIndex: number;
  21528. /** @hidden */
  21529. _distanceToCamera: number;
  21530. /** @hidden */
  21531. _id: number;
  21532. private _currentMaterial;
  21533. /**
  21534. * Add a new submesh to a mesh
  21535. * @param materialIndex defines the material index to use
  21536. * @param verticesStart defines vertex index start
  21537. * @param verticesCount defines vertices count
  21538. * @param indexStart defines index start
  21539. * @param indexCount defines indices count
  21540. * @param mesh defines the parent mesh
  21541. * @param renderingMesh defines an optional rendering mesh
  21542. * @param createBoundingBox defines if bounding box should be created for this submesh
  21543. * @returns the new submesh
  21544. */
  21545. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21546. /**
  21547. * Creates a new submesh
  21548. * @param materialIndex defines the material index to use
  21549. * @param verticesStart defines vertex index start
  21550. * @param verticesCount defines vertices count
  21551. * @param indexStart defines index start
  21552. * @param indexCount defines indices count
  21553. * @param mesh defines the parent mesh
  21554. * @param renderingMesh defines an optional rendering mesh
  21555. * @param createBoundingBox defines if bounding box should be created for this submesh
  21556. */
  21557. constructor(
  21558. /** the material index to use */
  21559. materialIndex: number,
  21560. /** vertex index start */
  21561. verticesStart: number,
  21562. /** vertices count */
  21563. verticesCount: number,
  21564. /** index start */
  21565. indexStart: number,
  21566. /** indices count */
  21567. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21568. /**
  21569. * Returns true if this submesh covers the entire parent mesh
  21570. * @ignorenaming
  21571. */
  21572. readonly IsGlobal: boolean;
  21573. /**
  21574. * Returns the submesh BoudingInfo object
  21575. * @returns current bounding info (or mesh's one if the submesh is global)
  21576. */
  21577. getBoundingInfo(): BoundingInfo;
  21578. /**
  21579. * Sets the submesh BoundingInfo
  21580. * @param boundingInfo defines the new bounding info to use
  21581. * @returns the SubMesh
  21582. */
  21583. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21584. /**
  21585. * Returns the mesh of the current submesh
  21586. * @return the parent mesh
  21587. */
  21588. getMesh(): AbstractMesh;
  21589. /**
  21590. * Returns the rendering mesh of the submesh
  21591. * @returns the rendering mesh (could be different from parent mesh)
  21592. */
  21593. getRenderingMesh(): Mesh;
  21594. /**
  21595. * Returns the submesh material
  21596. * @returns null or the current material
  21597. */
  21598. getMaterial(): Nullable<Material>;
  21599. /**
  21600. * Sets a new updated BoundingInfo object to the submesh
  21601. * @param data defines an optional position array to use to determine the bounding info
  21602. * @returns the SubMesh
  21603. */
  21604. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21605. /** @hidden */
  21606. _checkCollision(collider: Collider): boolean;
  21607. /**
  21608. * Updates the submesh BoundingInfo
  21609. * @param world defines the world matrix to use to update the bounding info
  21610. * @returns the submesh
  21611. */
  21612. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21613. /**
  21614. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21615. * @param frustumPlanes defines the frustum planes
  21616. * @returns true if the submesh is intersecting with the frustum
  21617. */
  21618. isInFrustum(frustumPlanes: Plane[]): boolean;
  21619. /**
  21620. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21621. * @param frustumPlanes defines the frustum planes
  21622. * @returns true if the submesh is inside the frustum
  21623. */
  21624. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21625. /**
  21626. * Renders the submesh
  21627. * @param enableAlphaMode defines if alpha needs to be used
  21628. * @returns the submesh
  21629. */
  21630. render(enableAlphaMode: boolean): SubMesh;
  21631. /**
  21632. * @hidden
  21633. */
  21634. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21635. /**
  21636. * Checks if the submesh intersects with a ray
  21637. * @param ray defines the ray to test
  21638. * @returns true is the passed ray intersects the submesh bounding box
  21639. */
  21640. canIntersects(ray: Ray): boolean;
  21641. /**
  21642. * Intersects current submesh with a ray
  21643. * @param ray defines the ray to test
  21644. * @param positions defines mesh's positions array
  21645. * @param indices defines mesh's indices array
  21646. * @param fastCheck defines if only bounding info should be used
  21647. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21648. * @returns intersection info or null if no intersection
  21649. */
  21650. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21651. /** @hidden */
  21652. private _intersectLines;
  21653. /** @hidden */
  21654. private _intersectUnIndexedLines;
  21655. /** @hidden */
  21656. private _intersectTriangles;
  21657. /** @hidden */
  21658. private _intersectUnIndexedTriangles;
  21659. /** @hidden */
  21660. _rebuild(): void;
  21661. /**
  21662. * Creates a new submesh from the passed mesh
  21663. * @param newMesh defines the new hosting mesh
  21664. * @param newRenderingMesh defines an optional rendering mesh
  21665. * @returns the new submesh
  21666. */
  21667. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21668. /**
  21669. * Release associated resources
  21670. */
  21671. dispose(): void;
  21672. /**
  21673. * Gets the class name
  21674. * @returns the string "SubMesh".
  21675. */
  21676. getClassName(): string;
  21677. /**
  21678. * Creates a new submesh from indices data
  21679. * @param materialIndex the index of the main mesh material
  21680. * @param startIndex the index where to start the copy in the mesh indices array
  21681. * @param indexCount the number of indices to copy then from the startIndex
  21682. * @param mesh the main mesh to create the submesh from
  21683. * @param renderingMesh the optional rendering mesh
  21684. * @returns a new submesh
  21685. */
  21686. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21687. }
  21688. }
  21689. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21690. /**
  21691. * Class used to represent data loading progression
  21692. */
  21693. export class SceneLoaderFlags {
  21694. private static _ForceFullSceneLoadingForIncremental;
  21695. private static _ShowLoadingScreen;
  21696. private static _CleanBoneMatrixWeights;
  21697. private static _loggingLevel;
  21698. /**
  21699. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21700. */
  21701. static ForceFullSceneLoadingForIncremental: boolean;
  21702. /**
  21703. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21704. */
  21705. static ShowLoadingScreen: boolean;
  21706. /**
  21707. * Defines the current logging level (while loading the scene)
  21708. * @ignorenaming
  21709. */
  21710. static loggingLevel: number;
  21711. /**
  21712. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21713. */
  21714. static CleanBoneMatrixWeights: boolean;
  21715. }
  21716. }
  21717. declare module "babylonjs/Meshes/geometry" {
  21718. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21719. import { Scene } from "babylonjs/scene";
  21720. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21721. import { Engine } from "babylonjs/Engines/engine";
  21722. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21723. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21724. import { Effect } from "babylonjs/Materials/effect";
  21725. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21726. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21727. import { Mesh } from "babylonjs/Meshes/mesh";
  21728. /**
  21729. * Class used to store geometry data (vertex buffers + index buffer)
  21730. */
  21731. export class Geometry implements IGetSetVerticesData {
  21732. /**
  21733. * Gets or sets the ID of the geometry
  21734. */
  21735. id: string;
  21736. /**
  21737. * Gets or sets the unique ID of the geometry
  21738. */
  21739. uniqueId: number;
  21740. /**
  21741. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21742. */
  21743. delayLoadState: number;
  21744. /**
  21745. * Gets the file containing the data to load when running in delay load state
  21746. */
  21747. delayLoadingFile: Nullable<string>;
  21748. /**
  21749. * Callback called when the geometry is updated
  21750. */
  21751. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21752. private _scene;
  21753. private _engine;
  21754. private _meshes;
  21755. private _totalVertices;
  21756. /** @hidden */
  21757. _indices: IndicesArray;
  21758. /** @hidden */
  21759. _vertexBuffers: {
  21760. [key: string]: VertexBuffer;
  21761. };
  21762. private _isDisposed;
  21763. private _extend;
  21764. private _boundingBias;
  21765. /** @hidden */
  21766. _delayInfo: Array<string>;
  21767. private _indexBuffer;
  21768. private _indexBufferIsUpdatable;
  21769. /** @hidden */
  21770. _boundingInfo: Nullable<BoundingInfo>;
  21771. /** @hidden */
  21772. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21773. /** @hidden */
  21774. _softwareSkinningFrameId: number;
  21775. private _vertexArrayObjects;
  21776. private _updatable;
  21777. /** @hidden */
  21778. _positions: Nullable<Vector3[]>;
  21779. /**
  21780. * 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
  21781. */
  21782. /**
  21783. * 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
  21784. */
  21785. boundingBias: Vector2;
  21786. /**
  21787. * Static function used to attach a new empty geometry to a mesh
  21788. * @param mesh defines the mesh to attach the geometry to
  21789. * @returns the new Geometry
  21790. */
  21791. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21792. /**
  21793. * Creates a new geometry
  21794. * @param id defines the unique ID
  21795. * @param scene defines the hosting scene
  21796. * @param vertexData defines the VertexData used to get geometry data
  21797. * @param updatable defines if geometry must be updatable (false by default)
  21798. * @param mesh defines the mesh that will be associated with the geometry
  21799. */
  21800. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21801. /**
  21802. * Gets the current extend of the geometry
  21803. */
  21804. readonly extend: {
  21805. minimum: Vector3;
  21806. maximum: Vector3;
  21807. };
  21808. /**
  21809. * Gets the hosting scene
  21810. * @returns the hosting Scene
  21811. */
  21812. getScene(): Scene;
  21813. /**
  21814. * Gets the hosting engine
  21815. * @returns the hosting Engine
  21816. */
  21817. getEngine(): Engine;
  21818. /**
  21819. * Defines if the geometry is ready to use
  21820. * @returns true if the geometry is ready to be used
  21821. */
  21822. isReady(): boolean;
  21823. /**
  21824. * Gets a value indicating that the geometry should not be serialized
  21825. */
  21826. readonly doNotSerialize: boolean;
  21827. /** @hidden */
  21828. _rebuild(): void;
  21829. /**
  21830. * Affects all geometry data in one call
  21831. * @param vertexData defines the geometry data
  21832. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21833. */
  21834. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21835. /**
  21836. * Set specific vertex data
  21837. * @param kind defines the data kind (Position, normal, etc...)
  21838. * @param data defines the vertex data to use
  21839. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21840. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21841. */
  21842. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21843. /**
  21844. * Removes a specific vertex data
  21845. * @param kind defines the data kind (Position, normal, etc...)
  21846. */
  21847. removeVerticesData(kind: string): void;
  21848. /**
  21849. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21850. * @param buffer defines the vertex buffer to use
  21851. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21852. */
  21853. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21854. /**
  21855. * Update a specific vertex buffer
  21856. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21857. * It will do nothing if the buffer is not updatable
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param data defines the data to use
  21860. * @param offset defines the offset in the target buffer where to store the data
  21861. * @param useBytes set to true if the offset is in bytes
  21862. */
  21863. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21864. /**
  21865. * Update a specific vertex buffer
  21866. * This function will create a new buffer if the current one is not updatable
  21867. * @param kind defines the data kind (Position, normal, etc...)
  21868. * @param data defines the data to use
  21869. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21870. */
  21871. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21872. private _updateBoundingInfo;
  21873. /** @hidden */
  21874. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21875. /**
  21876. * Gets total number of vertices
  21877. * @returns the total number of vertices
  21878. */
  21879. getTotalVertices(): number;
  21880. /**
  21881. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21882. * @param kind defines the data kind (Position, normal, etc...)
  21883. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21885. * @returns a float array containing vertex data
  21886. */
  21887. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21888. /**
  21889. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21890. * @param kind defines the data kind (Position, normal, etc...)
  21891. * @returns true if the vertex buffer with the specified kind is updatable
  21892. */
  21893. isVertexBufferUpdatable(kind: string): boolean;
  21894. /**
  21895. * Gets a specific vertex buffer
  21896. * @param kind defines the data kind (Position, normal, etc...)
  21897. * @returns a VertexBuffer
  21898. */
  21899. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21900. /**
  21901. * Returns all vertex buffers
  21902. * @return an object holding all vertex buffers indexed by kind
  21903. */
  21904. getVertexBuffers(): Nullable<{
  21905. [key: string]: VertexBuffer;
  21906. }>;
  21907. /**
  21908. * Gets a boolean indicating if specific vertex buffer is present
  21909. * @param kind defines the data kind (Position, normal, etc...)
  21910. * @returns true if data is present
  21911. */
  21912. isVerticesDataPresent(kind: string): boolean;
  21913. /**
  21914. * Gets a list of all attached data kinds (Position, normal, etc...)
  21915. * @returns a list of string containing all kinds
  21916. */
  21917. getVerticesDataKinds(): string[];
  21918. /**
  21919. * Update index buffer
  21920. * @param indices defines the indices to store in the index buffer
  21921. * @param offset defines the offset in the target buffer where to store the data
  21922. * @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)
  21923. */
  21924. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21925. /**
  21926. * Creates a new index buffer
  21927. * @param indices defines the indices to store in the index buffer
  21928. * @param totalVertices defines the total number of vertices (could be null)
  21929. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21930. */
  21931. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21932. /**
  21933. * Return the total number of indices
  21934. * @returns the total number of indices
  21935. */
  21936. getTotalIndices(): number;
  21937. /**
  21938. * Gets the index buffer array
  21939. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21940. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21941. * @returns the index buffer array
  21942. */
  21943. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21944. /**
  21945. * Gets the index buffer
  21946. * @return the index buffer
  21947. */
  21948. getIndexBuffer(): Nullable<DataBuffer>;
  21949. /** @hidden */
  21950. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21951. /**
  21952. * Release the associated resources for a specific mesh
  21953. * @param mesh defines the source mesh
  21954. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21955. */
  21956. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21957. /**
  21958. * Apply current geometry to a given mesh
  21959. * @param mesh defines the mesh to apply geometry to
  21960. */
  21961. applyToMesh(mesh: Mesh): void;
  21962. private _updateExtend;
  21963. private _applyToMesh;
  21964. private notifyUpdate;
  21965. /**
  21966. * Load the geometry if it was flagged as delay loaded
  21967. * @param scene defines the hosting scene
  21968. * @param onLoaded defines a callback called when the geometry is loaded
  21969. */
  21970. load(scene: Scene, onLoaded?: () => void): void;
  21971. private _queueLoad;
  21972. /**
  21973. * Invert the geometry to move from a right handed system to a left handed one.
  21974. */
  21975. toLeftHanded(): void;
  21976. /** @hidden */
  21977. _resetPointsArrayCache(): void;
  21978. /** @hidden */
  21979. _generatePointsArray(): boolean;
  21980. /**
  21981. * Gets a value indicating if the geometry is disposed
  21982. * @returns true if the geometry was disposed
  21983. */
  21984. isDisposed(): boolean;
  21985. private _disposeVertexArrayObjects;
  21986. /**
  21987. * Free all associated resources
  21988. */
  21989. dispose(): void;
  21990. /**
  21991. * Clone the current geometry into a new geometry
  21992. * @param id defines the unique ID of the new geometry
  21993. * @returns a new geometry object
  21994. */
  21995. copy(id: string): Geometry;
  21996. /**
  21997. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21998. * @return a JSON representation of the current geometry data (without the vertices data)
  21999. */
  22000. serialize(): any;
  22001. private toNumberArray;
  22002. /**
  22003. * Serialize all vertices data into a JSON oject
  22004. * @returns a JSON representation of the current geometry data
  22005. */
  22006. serializeVerticeData(): any;
  22007. /**
  22008. * Extracts a clone of a mesh geometry
  22009. * @param mesh defines the source mesh
  22010. * @param id defines the unique ID of the new geometry object
  22011. * @returns the new geometry object
  22012. */
  22013. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22014. /**
  22015. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22016. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22017. * Be aware Math.random() could cause collisions, but:
  22018. * "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"
  22019. * @returns a string containing a new GUID
  22020. */
  22021. static RandomId(): string;
  22022. /** @hidden */
  22023. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22024. private static _CleanMatricesWeights;
  22025. /**
  22026. * Create a new geometry from persisted data (Using .babylon file format)
  22027. * @param parsedVertexData defines the persisted data
  22028. * @param scene defines the hosting scene
  22029. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22030. * @returns the new geometry object
  22031. */
  22032. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22033. }
  22034. }
  22035. declare module "babylonjs/Meshes/mesh.vertexData" {
  22036. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22037. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22038. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22039. import { Geometry } from "babylonjs/Meshes/geometry";
  22040. import { Mesh } from "babylonjs/Meshes/mesh";
  22041. /**
  22042. * Define an interface for all classes that will get and set the data on vertices
  22043. */
  22044. export interface IGetSetVerticesData {
  22045. /**
  22046. * Gets a boolean indicating if specific vertex data is present
  22047. * @param kind defines the vertex data kind to use
  22048. * @returns true is data kind is present
  22049. */
  22050. isVerticesDataPresent(kind: string): boolean;
  22051. /**
  22052. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22053. * @param kind defines the data kind (Position, normal, etc...)
  22054. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22055. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22056. * @returns a float array containing vertex data
  22057. */
  22058. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22059. /**
  22060. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22061. * @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.
  22062. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22063. * @returns the indices array or an empty array if the mesh has no geometry
  22064. */
  22065. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22066. /**
  22067. * Set specific vertex data
  22068. * @param kind defines the data kind (Position, normal, etc...)
  22069. * @param data defines the vertex data to use
  22070. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22071. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22072. */
  22073. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22074. /**
  22075. * Update a specific associated vertex buffer
  22076. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22077. * - VertexBuffer.PositionKind
  22078. * - VertexBuffer.UVKind
  22079. * - VertexBuffer.UV2Kind
  22080. * - VertexBuffer.UV3Kind
  22081. * - VertexBuffer.UV4Kind
  22082. * - VertexBuffer.UV5Kind
  22083. * - VertexBuffer.UV6Kind
  22084. * - VertexBuffer.ColorKind
  22085. * - VertexBuffer.MatricesIndicesKind
  22086. * - VertexBuffer.MatricesIndicesExtraKind
  22087. * - VertexBuffer.MatricesWeightsKind
  22088. * - VertexBuffer.MatricesWeightsExtraKind
  22089. * @param data defines the data source
  22090. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22091. * @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)
  22092. */
  22093. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22094. /**
  22095. * Creates a new index buffer
  22096. * @param indices defines the indices to store in the index buffer
  22097. * @param totalVertices defines the total number of vertices (could be null)
  22098. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22099. */
  22100. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22101. }
  22102. /**
  22103. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22104. */
  22105. export class VertexData {
  22106. /**
  22107. * Mesh side orientation : usually the external or front surface
  22108. */
  22109. static readonly FRONTSIDE: number;
  22110. /**
  22111. * Mesh side orientation : usually the internal or back surface
  22112. */
  22113. static readonly BACKSIDE: number;
  22114. /**
  22115. * Mesh side orientation : both internal and external or front and back surfaces
  22116. */
  22117. static readonly DOUBLESIDE: number;
  22118. /**
  22119. * Mesh side orientation : by default, `FRONTSIDE`
  22120. */
  22121. static readonly DEFAULTSIDE: number;
  22122. /**
  22123. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22124. */
  22125. positions: Nullable<FloatArray>;
  22126. /**
  22127. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22128. */
  22129. normals: Nullable<FloatArray>;
  22130. /**
  22131. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22132. */
  22133. tangents: Nullable<FloatArray>;
  22134. /**
  22135. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22136. */
  22137. uvs: Nullable<FloatArray>;
  22138. /**
  22139. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22140. */
  22141. uvs2: Nullable<FloatArray>;
  22142. /**
  22143. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22144. */
  22145. uvs3: Nullable<FloatArray>;
  22146. /**
  22147. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22148. */
  22149. uvs4: Nullable<FloatArray>;
  22150. /**
  22151. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22152. */
  22153. uvs5: Nullable<FloatArray>;
  22154. /**
  22155. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22156. */
  22157. uvs6: Nullable<FloatArray>;
  22158. /**
  22159. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22160. */
  22161. colors: Nullable<FloatArray>;
  22162. /**
  22163. * 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).
  22164. */
  22165. matricesIndices: Nullable<FloatArray>;
  22166. /**
  22167. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22168. */
  22169. matricesWeights: Nullable<FloatArray>;
  22170. /**
  22171. * An array extending the number of possible indices
  22172. */
  22173. matricesIndicesExtra: Nullable<FloatArray>;
  22174. /**
  22175. * An array extending the number of possible weights when the number of indices is extended
  22176. */
  22177. matricesWeightsExtra: Nullable<FloatArray>;
  22178. /**
  22179. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22180. */
  22181. indices: Nullable<IndicesArray>;
  22182. /**
  22183. * Uses the passed data array to set the set the values for the specified kind of data
  22184. * @param data a linear array of floating numbers
  22185. * @param kind the type of data that is being set, eg positions, colors etc
  22186. */
  22187. set(data: FloatArray, kind: string): void;
  22188. /**
  22189. * Associates the vertexData to the passed Mesh.
  22190. * Sets it as updatable or not (default `false`)
  22191. * @param mesh the mesh the vertexData is applied to
  22192. * @param updatable when used and having the value true allows new data to update the vertexData
  22193. * @returns the VertexData
  22194. */
  22195. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22196. /**
  22197. * Associates the vertexData to the passed Geometry.
  22198. * Sets it as updatable or not (default `false`)
  22199. * @param geometry the geometry the vertexData is applied to
  22200. * @param updatable when used and having the value true allows new data to update the vertexData
  22201. * @returns VertexData
  22202. */
  22203. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22204. /**
  22205. * Updates the associated mesh
  22206. * @param mesh the mesh to be updated
  22207. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22208. * @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
  22209. * @returns VertexData
  22210. */
  22211. updateMesh(mesh: Mesh): VertexData;
  22212. /**
  22213. * Updates the associated geometry
  22214. * @param geometry the geometry to be updated
  22215. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22216. * @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
  22217. * @returns VertexData.
  22218. */
  22219. updateGeometry(geometry: Geometry): VertexData;
  22220. private _applyTo;
  22221. private _update;
  22222. /**
  22223. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22224. * @param matrix the transforming matrix
  22225. * @returns the VertexData
  22226. */
  22227. transform(matrix: Matrix): VertexData;
  22228. /**
  22229. * Merges the passed VertexData into the current one
  22230. * @param other the VertexData to be merged into the current one
  22231. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22232. * @returns the modified VertexData
  22233. */
  22234. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22235. private _mergeElement;
  22236. private _validate;
  22237. /**
  22238. * Serializes the VertexData
  22239. * @returns a serialized object
  22240. */
  22241. serialize(): any;
  22242. /**
  22243. * Extracts the vertexData from a mesh
  22244. * @param mesh the mesh from which to extract the VertexData
  22245. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22246. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22247. * @returns the object VertexData associated to the passed mesh
  22248. */
  22249. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22250. /**
  22251. * Extracts the vertexData from the geometry
  22252. * @param geometry the geometry from which to extract the VertexData
  22253. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22254. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22255. * @returns the object VertexData associated to the passed mesh
  22256. */
  22257. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22258. private static _ExtractFrom;
  22259. /**
  22260. * Creates the VertexData for a Ribbon
  22261. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22262. * * pathArray array of paths, each of which an array of successive Vector3
  22263. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22264. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22265. * * 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
  22266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22267. * * 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)
  22268. * * 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)
  22269. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22270. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22271. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22272. * @returns the VertexData of the ribbon
  22273. */
  22274. static CreateRibbon(options: {
  22275. pathArray: Vector3[][];
  22276. closeArray?: boolean;
  22277. closePath?: boolean;
  22278. offset?: number;
  22279. sideOrientation?: number;
  22280. frontUVs?: Vector4;
  22281. backUVs?: Vector4;
  22282. invertUV?: boolean;
  22283. uvs?: Vector2[];
  22284. colors?: Color4[];
  22285. }): VertexData;
  22286. /**
  22287. * Creates the VertexData for a box
  22288. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22289. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22290. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22291. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22292. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22293. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22294. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22296. * * 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)
  22297. * * 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)
  22298. * @returns the VertexData of the box
  22299. */
  22300. static CreateBox(options: {
  22301. size?: number;
  22302. width?: number;
  22303. height?: number;
  22304. depth?: number;
  22305. faceUV?: Vector4[];
  22306. faceColors?: Color4[];
  22307. sideOrientation?: number;
  22308. frontUVs?: Vector4;
  22309. backUVs?: Vector4;
  22310. }): VertexData;
  22311. /**
  22312. * Creates the VertexData for a tiled box
  22313. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22314. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22315. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22316. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22318. * @returns the VertexData of the box
  22319. */
  22320. static CreateTiledBox(options: {
  22321. pattern?: number;
  22322. width?: number;
  22323. height?: number;
  22324. depth?: number;
  22325. tileSize?: number;
  22326. tileWidth?: number;
  22327. tileHeight?: number;
  22328. alignHorizontal?: number;
  22329. alignVertical?: number;
  22330. faceUV?: Vector4[];
  22331. faceColors?: Color4[];
  22332. sideOrientation?: number;
  22333. }): VertexData;
  22334. /**
  22335. * Creates the VertexData for a tiled plane
  22336. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22337. * * pattern a limited pattern arrangement depending on the number
  22338. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22339. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22340. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22342. * * 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)
  22343. * * 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)
  22344. * @returns the VertexData of the tiled plane
  22345. */
  22346. static CreateTiledPlane(options: {
  22347. pattern?: number;
  22348. tileSize?: number;
  22349. tileWidth?: number;
  22350. tileHeight?: number;
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. alignHorizontal?: number;
  22355. alignVertical?: number;
  22356. sideOrientation?: number;
  22357. frontUVs?: Vector4;
  22358. backUVs?: Vector4;
  22359. }): VertexData;
  22360. /**
  22361. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22362. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22363. * * segments sets the number of horizontal strips optional, default 32
  22364. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22365. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22366. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22367. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22368. * * 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
  22369. * * 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
  22370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22371. * * 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)
  22372. * * 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)
  22373. * @returns the VertexData of the ellipsoid
  22374. */
  22375. static CreateSphere(options: {
  22376. segments?: number;
  22377. diameter?: number;
  22378. diameterX?: number;
  22379. diameterY?: number;
  22380. diameterZ?: number;
  22381. arc?: number;
  22382. slice?: number;
  22383. sideOrientation?: number;
  22384. frontUVs?: Vector4;
  22385. backUVs?: Vector4;
  22386. }): VertexData;
  22387. /**
  22388. * Creates the VertexData for a cylinder, cone or prism
  22389. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22390. * * height sets the height (y direction) of the cylinder, optional, default 2
  22391. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22392. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22393. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22394. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22395. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22396. * * 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
  22397. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22398. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22399. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22400. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22402. * * 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)
  22403. * * 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)
  22404. * @returns the VertexData of the cylinder, cone or prism
  22405. */
  22406. static CreateCylinder(options: {
  22407. height?: number;
  22408. diameterTop?: number;
  22409. diameterBottom?: number;
  22410. diameter?: number;
  22411. tessellation?: number;
  22412. subdivisions?: number;
  22413. arc?: number;
  22414. faceColors?: Color4[];
  22415. faceUV?: Vector4[];
  22416. hasRings?: boolean;
  22417. enclose?: boolean;
  22418. sideOrientation?: number;
  22419. frontUVs?: Vector4;
  22420. backUVs?: Vector4;
  22421. }): VertexData;
  22422. /**
  22423. * Creates the VertexData for a torus
  22424. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22425. * * diameter the diameter of the torus, optional default 1
  22426. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22427. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22428. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22429. * * 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)
  22430. * * 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)
  22431. * @returns the VertexData of the torus
  22432. */
  22433. static CreateTorus(options: {
  22434. diameter?: number;
  22435. thickness?: number;
  22436. tessellation?: number;
  22437. sideOrientation?: number;
  22438. frontUVs?: Vector4;
  22439. backUVs?: Vector4;
  22440. }): VertexData;
  22441. /**
  22442. * Creates the VertexData of the LineSystem
  22443. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22444. * - lines an array of lines, each line being an array of successive Vector3
  22445. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22446. * @returns the VertexData of the LineSystem
  22447. */
  22448. static CreateLineSystem(options: {
  22449. lines: Vector3[][];
  22450. colors?: Nullable<Color4[][]>;
  22451. }): VertexData;
  22452. /**
  22453. * Create the VertexData for a DashedLines
  22454. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22455. * - points an array successive Vector3
  22456. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22457. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22458. * - dashNb the intended total number of dashes, optional, default 200
  22459. * @returns the VertexData for the DashedLines
  22460. */
  22461. static CreateDashedLines(options: {
  22462. points: Vector3[];
  22463. dashSize?: number;
  22464. gapSize?: number;
  22465. dashNb?: number;
  22466. }): VertexData;
  22467. /**
  22468. * Creates the VertexData for a Ground
  22469. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22470. * - width the width (x direction) of the ground, optional, default 1
  22471. * - height the height (z direction) of the ground, optional, default 1
  22472. * - subdivisions the number of subdivisions per side, optional, default 1
  22473. * @returns the VertexData of the Ground
  22474. */
  22475. static CreateGround(options: {
  22476. width?: number;
  22477. height?: number;
  22478. subdivisions?: number;
  22479. subdivisionsX?: number;
  22480. subdivisionsY?: number;
  22481. }): VertexData;
  22482. /**
  22483. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22484. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22485. * * xmin the ground minimum X coordinate, optional, default -1
  22486. * * zmin the ground minimum Z coordinate, optional, default -1
  22487. * * xmax the ground maximum X coordinate, optional, default 1
  22488. * * zmax the ground maximum Z coordinate, optional, default 1
  22489. * * 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}
  22490. * * 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}
  22491. * @returns the VertexData of the TiledGround
  22492. */
  22493. static CreateTiledGround(options: {
  22494. xmin: number;
  22495. zmin: number;
  22496. xmax: number;
  22497. zmax: number;
  22498. subdivisions?: {
  22499. w: number;
  22500. h: number;
  22501. };
  22502. precision?: {
  22503. w: number;
  22504. h: number;
  22505. };
  22506. }): VertexData;
  22507. /**
  22508. * Creates the VertexData of the Ground designed from a heightmap
  22509. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22510. * * width the width (x direction) of the ground
  22511. * * height the height (z direction) of the ground
  22512. * * subdivisions the number of subdivisions per side
  22513. * * minHeight the minimum altitude on the ground, optional, default 0
  22514. * * maxHeight the maximum altitude on the ground, optional default 1
  22515. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22516. * * buffer the array holding the image color data
  22517. * * bufferWidth the width of image
  22518. * * bufferHeight the height of image
  22519. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22520. * @returns the VertexData of the Ground designed from a heightmap
  22521. */
  22522. static CreateGroundFromHeightMap(options: {
  22523. width: number;
  22524. height: number;
  22525. subdivisions: number;
  22526. minHeight: number;
  22527. maxHeight: number;
  22528. colorFilter: Color3;
  22529. buffer: Uint8Array;
  22530. bufferWidth: number;
  22531. bufferHeight: number;
  22532. alphaFilter: number;
  22533. }): VertexData;
  22534. /**
  22535. * Creates the VertexData for a Plane
  22536. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22537. * * size sets the width and height of the plane to the value of size, optional default 1
  22538. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22539. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22541. * * 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)
  22542. * * 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)
  22543. * @returns the VertexData of the box
  22544. */
  22545. static CreatePlane(options: {
  22546. size?: number;
  22547. width?: number;
  22548. height?: number;
  22549. sideOrientation?: number;
  22550. frontUVs?: Vector4;
  22551. backUVs?: Vector4;
  22552. }): VertexData;
  22553. /**
  22554. * Creates the VertexData of the Disc or regular Polygon
  22555. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22556. * * radius the radius of the disc, optional default 0.5
  22557. * * tessellation the number of polygon sides, optional, default 64
  22558. * * 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
  22559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22560. * * 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)
  22561. * * 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)
  22562. * @returns the VertexData of the box
  22563. */
  22564. static CreateDisc(options: {
  22565. radius?: number;
  22566. tessellation?: number;
  22567. arc?: number;
  22568. sideOrientation?: number;
  22569. frontUVs?: Vector4;
  22570. backUVs?: Vector4;
  22571. }): VertexData;
  22572. /**
  22573. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22574. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22575. * @param polygon a mesh built from polygonTriangulation.build()
  22576. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22577. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22578. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22579. * @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)
  22580. * @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)
  22581. * @returns the VertexData of the Polygon
  22582. */
  22583. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22584. /**
  22585. * Creates the VertexData of the IcoSphere
  22586. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22587. * * radius the radius of the IcoSphere, optional default 1
  22588. * * radiusX allows stretching in the x direction, optional, default radius
  22589. * * radiusY allows stretching in the y direction, optional, default radius
  22590. * * radiusZ allows stretching in the z direction, optional, default radius
  22591. * * flat when true creates a flat shaded mesh, optional, default true
  22592. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22593. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22594. * * 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)
  22595. * * 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)
  22596. * @returns the VertexData of the IcoSphere
  22597. */
  22598. static CreateIcoSphere(options: {
  22599. radius?: number;
  22600. radiusX?: number;
  22601. radiusY?: number;
  22602. radiusZ?: number;
  22603. flat?: boolean;
  22604. subdivisions?: number;
  22605. sideOrientation?: number;
  22606. frontUVs?: Vector4;
  22607. backUVs?: Vector4;
  22608. }): VertexData;
  22609. /**
  22610. * Creates the VertexData for a Polyhedron
  22611. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22612. * * type provided types are:
  22613. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22614. * * 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)
  22615. * * size the size of the IcoSphere, optional default 1
  22616. * * sizeX allows stretching in the x direction, optional, default size
  22617. * * sizeY allows stretching in the y direction, optional, default size
  22618. * * sizeZ allows stretching in the z direction, optional, default size
  22619. * * 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
  22620. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22621. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22622. * * flat when true creates a flat shaded mesh, optional, default true
  22623. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22624. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22625. * * 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)
  22626. * * 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)
  22627. * @returns the VertexData of the Polyhedron
  22628. */
  22629. static CreatePolyhedron(options: {
  22630. type?: number;
  22631. size?: number;
  22632. sizeX?: number;
  22633. sizeY?: number;
  22634. sizeZ?: number;
  22635. custom?: any;
  22636. faceUV?: Vector4[];
  22637. faceColors?: Color4[];
  22638. flat?: boolean;
  22639. sideOrientation?: number;
  22640. frontUVs?: Vector4;
  22641. backUVs?: Vector4;
  22642. }): VertexData;
  22643. /**
  22644. * Creates the VertexData for a TorusKnot
  22645. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22646. * * radius the radius of the torus knot, optional, default 2
  22647. * * tube the thickness of the tube, optional, default 0.5
  22648. * * radialSegments the number of sides on each tube segments, optional, default 32
  22649. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22650. * * p the number of windings around the z axis, optional, default 2
  22651. * * q the number of windings around the x axis, optional, default 3
  22652. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22653. * * 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)
  22654. * * 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)
  22655. * @returns the VertexData of the Torus Knot
  22656. */
  22657. static CreateTorusKnot(options: {
  22658. radius?: number;
  22659. tube?: number;
  22660. radialSegments?: number;
  22661. tubularSegments?: number;
  22662. p?: number;
  22663. q?: number;
  22664. sideOrientation?: number;
  22665. frontUVs?: Vector4;
  22666. backUVs?: Vector4;
  22667. }): VertexData;
  22668. /**
  22669. * Compute normals for given positions and indices
  22670. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22671. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22672. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22673. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22674. * * facetNormals : optional array of facet normals (vector3)
  22675. * * facetPositions : optional array of facet positions (vector3)
  22676. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22677. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22678. * * bInfo : optional bounding info, required for facetPartitioning computation
  22679. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22680. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22681. * * useRightHandedSystem: optional boolean to for right handed system computation
  22682. * * depthSort : optional boolean to enable the facet depth sort computation
  22683. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22684. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22685. */
  22686. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22687. facetNormals?: any;
  22688. facetPositions?: any;
  22689. facetPartitioning?: any;
  22690. ratio?: number;
  22691. bInfo?: any;
  22692. bbSize?: Vector3;
  22693. subDiv?: any;
  22694. useRightHandedSystem?: boolean;
  22695. depthSort?: boolean;
  22696. distanceTo?: Vector3;
  22697. depthSortedFacets?: any;
  22698. }): void;
  22699. /** @hidden */
  22700. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22701. /**
  22702. * Applies VertexData created from the imported parameters to the geometry
  22703. * @param parsedVertexData the parsed data from an imported file
  22704. * @param geometry the geometry to apply the VertexData to
  22705. */
  22706. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22707. }
  22708. }
  22709. declare module "babylonjs/Morph/morphTarget" {
  22710. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22711. import { Observable } from "babylonjs/Misc/observable";
  22712. import { Nullable, FloatArray } from "babylonjs/types";
  22713. import { Scene } from "babylonjs/scene";
  22714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22715. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22716. /**
  22717. * Defines a target to use with MorphTargetManager
  22718. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22719. */
  22720. export class MorphTarget implements IAnimatable {
  22721. /** defines the name of the target */
  22722. name: string;
  22723. /**
  22724. * Gets or sets the list of animations
  22725. */
  22726. animations: import("babylonjs/Animations/animation").Animation[];
  22727. private _scene;
  22728. private _positions;
  22729. private _normals;
  22730. private _tangents;
  22731. private _uvs;
  22732. private _influence;
  22733. /**
  22734. * Observable raised when the influence changes
  22735. */
  22736. onInfluenceChanged: Observable<boolean>;
  22737. /** @hidden */
  22738. _onDataLayoutChanged: Observable<void>;
  22739. /**
  22740. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22741. */
  22742. influence: number;
  22743. /**
  22744. * Gets or sets the id of the morph Target
  22745. */
  22746. id: string;
  22747. private _animationPropertiesOverride;
  22748. /**
  22749. * Gets or sets the animation properties override
  22750. */
  22751. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22752. /**
  22753. * Creates a new MorphTarget
  22754. * @param name defines the name of the target
  22755. * @param influence defines the influence to use
  22756. * @param scene defines the scene the morphtarget belongs to
  22757. */
  22758. constructor(
  22759. /** defines the name of the target */
  22760. name: string, influence?: number, scene?: Nullable<Scene>);
  22761. /**
  22762. * Gets a boolean defining if the target contains position data
  22763. */
  22764. readonly hasPositions: boolean;
  22765. /**
  22766. * Gets a boolean defining if the target contains normal data
  22767. */
  22768. readonly hasNormals: boolean;
  22769. /**
  22770. * Gets a boolean defining if the target contains tangent data
  22771. */
  22772. readonly hasTangents: boolean;
  22773. /**
  22774. * Gets a boolean defining if the target contains texture coordinates data
  22775. */
  22776. readonly hasUVs: boolean;
  22777. /**
  22778. * Affects position data to this target
  22779. * @param data defines the position data to use
  22780. */
  22781. setPositions(data: Nullable<FloatArray>): void;
  22782. /**
  22783. * Gets the position data stored in this target
  22784. * @returns a FloatArray containing the position data (or null if not present)
  22785. */
  22786. getPositions(): Nullable<FloatArray>;
  22787. /**
  22788. * Affects normal data to this target
  22789. * @param data defines the normal data to use
  22790. */
  22791. setNormals(data: Nullable<FloatArray>): void;
  22792. /**
  22793. * Gets the normal data stored in this target
  22794. * @returns a FloatArray containing the normal data (or null if not present)
  22795. */
  22796. getNormals(): Nullable<FloatArray>;
  22797. /**
  22798. * Affects tangent data to this target
  22799. * @param data defines the tangent data to use
  22800. */
  22801. setTangents(data: Nullable<FloatArray>): void;
  22802. /**
  22803. * Gets the tangent data stored in this target
  22804. * @returns a FloatArray containing the tangent data (or null if not present)
  22805. */
  22806. getTangents(): Nullable<FloatArray>;
  22807. /**
  22808. * Affects texture coordinates data to this target
  22809. * @param data defines the texture coordinates data to use
  22810. */
  22811. setUVs(data: Nullable<FloatArray>): void;
  22812. /**
  22813. * Gets the texture coordinates data stored in this target
  22814. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22815. */
  22816. getUVs(): Nullable<FloatArray>;
  22817. /**
  22818. * Serializes the current target into a Serialization object
  22819. * @returns the serialized object
  22820. */
  22821. serialize(): any;
  22822. /**
  22823. * Returns the string "MorphTarget"
  22824. * @returns "MorphTarget"
  22825. */
  22826. getClassName(): string;
  22827. /**
  22828. * Creates a new target from serialized data
  22829. * @param serializationObject defines the serialized data to use
  22830. * @returns a new MorphTarget
  22831. */
  22832. static Parse(serializationObject: any): MorphTarget;
  22833. /**
  22834. * Creates a MorphTarget from mesh data
  22835. * @param mesh defines the source mesh
  22836. * @param name defines the name to use for the new target
  22837. * @param influence defines the influence to attach to the target
  22838. * @returns a new MorphTarget
  22839. */
  22840. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22841. }
  22842. }
  22843. declare module "babylonjs/Morph/morphTargetManager" {
  22844. import { Nullable } from "babylonjs/types";
  22845. import { Scene } from "babylonjs/scene";
  22846. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22847. /**
  22848. * This class is used to deform meshes using morphing between different targets
  22849. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22850. */
  22851. export class MorphTargetManager {
  22852. private _targets;
  22853. private _targetInfluenceChangedObservers;
  22854. private _targetDataLayoutChangedObservers;
  22855. private _activeTargets;
  22856. private _scene;
  22857. private _influences;
  22858. private _supportsNormals;
  22859. private _supportsTangents;
  22860. private _supportsUVs;
  22861. private _vertexCount;
  22862. private _uniqueId;
  22863. private _tempInfluences;
  22864. /**
  22865. * Gets or sets a boolean indicating if normals must be morphed
  22866. */
  22867. enableNormalMorphing: boolean;
  22868. /**
  22869. * Gets or sets a boolean indicating if tangents must be morphed
  22870. */
  22871. enableTangentMorphing: boolean;
  22872. /**
  22873. * Gets or sets a boolean indicating if UV must be morphed
  22874. */
  22875. enableUVMorphing: boolean;
  22876. /**
  22877. * Creates a new MorphTargetManager
  22878. * @param scene defines the current scene
  22879. */
  22880. constructor(scene?: Nullable<Scene>);
  22881. /**
  22882. * Gets the unique ID of this manager
  22883. */
  22884. readonly uniqueId: number;
  22885. /**
  22886. * Gets the number of vertices handled by this manager
  22887. */
  22888. readonly vertexCount: number;
  22889. /**
  22890. * Gets a boolean indicating if this manager supports morphing of normals
  22891. */
  22892. readonly supportsNormals: boolean;
  22893. /**
  22894. * Gets a boolean indicating if this manager supports morphing of tangents
  22895. */
  22896. readonly supportsTangents: boolean;
  22897. /**
  22898. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22899. */
  22900. readonly supportsUVs: boolean;
  22901. /**
  22902. * Gets the number of targets stored in this manager
  22903. */
  22904. readonly numTargets: number;
  22905. /**
  22906. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22907. */
  22908. readonly numInfluencers: number;
  22909. /**
  22910. * Gets the list of influences (one per target)
  22911. */
  22912. readonly influences: Float32Array;
  22913. /**
  22914. * Gets the active target at specified index. An active target is a target with an influence > 0
  22915. * @param index defines the index to check
  22916. * @returns the requested target
  22917. */
  22918. getActiveTarget(index: number): MorphTarget;
  22919. /**
  22920. * Gets the target at specified index
  22921. * @param index defines the index to check
  22922. * @returns the requested target
  22923. */
  22924. getTarget(index: number): MorphTarget;
  22925. /**
  22926. * Add a new target to this manager
  22927. * @param target defines the target to add
  22928. */
  22929. addTarget(target: MorphTarget): void;
  22930. /**
  22931. * Removes a target from the manager
  22932. * @param target defines the target to remove
  22933. */
  22934. removeTarget(target: MorphTarget): void;
  22935. /**
  22936. * Serializes the current manager into a Serialization object
  22937. * @returns the serialized object
  22938. */
  22939. serialize(): any;
  22940. private _syncActiveTargets;
  22941. /**
  22942. * Syncrhonize the targets with all the meshes using this morph target manager
  22943. */
  22944. synchronize(): void;
  22945. /**
  22946. * Creates a new MorphTargetManager from serialized data
  22947. * @param serializationObject defines the serialized data
  22948. * @param scene defines the hosting scene
  22949. * @returns the new MorphTargetManager
  22950. */
  22951. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22952. }
  22953. }
  22954. declare module "babylonjs/Meshes/meshLODLevel" {
  22955. import { Mesh } from "babylonjs/Meshes/mesh";
  22956. import { Nullable } from "babylonjs/types";
  22957. /**
  22958. * Class used to represent a specific level of detail of a mesh
  22959. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22960. */
  22961. export class MeshLODLevel {
  22962. /** Defines the distance where this level should start being displayed */
  22963. distance: number;
  22964. /** Defines the mesh to use to render this level */
  22965. mesh: Nullable<Mesh>;
  22966. /**
  22967. * Creates a new LOD level
  22968. * @param distance defines the distance where this level should star being displayed
  22969. * @param mesh defines the mesh to use to render this level
  22970. */
  22971. constructor(
  22972. /** Defines the distance where this level should start being displayed */
  22973. distance: number,
  22974. /** Defines the mesh to use to render this level */
  22975. mesh: Nullable<Mesh>);
  22976. }
  22977. }
  22978. declare module "babylonjs/Meshes/groundMesh" {
  22979. import { Scene } from "babylonjs/scene";
  22980. import { Vector3 } from "babylonjs/Maths/math.vector";
  22981. import { Mesh } from "babylonjs/Meshes/mesh";
  22982. /**
  22983. * Mesh representing the gorund
  22984. */
  22985. export class GroundMesh extends Mesh {
  22986. /** If octree should be generated */
  22987. generateOctree: boolean;
  22988. private _heightQuads;
  22989. /** @hidden */
  22990. _subdivisionsX: number;
  22991. /** @hidden */
  22992. _subdivisionsY: number;
  22993. /** @hidden */
  22994. _width: number;
  22995. /** @hidden */
  22996. _height: number;
  22997. /** @hidden */
  22998. _minX: number;
  22999. /** @hidden */
  23000. _maxX: number;
  23001. /** @hidden */
  23002. _minZ: number;
  23003. /** @hidden */
  23004. _maxZ: number;
  23005. constructor(name: string, scene: Scene);
  23006. /**
  23007. * "GroundMesh"
  23008. * @returns "GroundMesh"
  23009. */
  23010. getClassName(): string;
  23011. /**
  23012. * The minimum of x and y subdivisions
  23013. */
  23014. readonly subdivisions: number;
  23015. /**
  23016. * X subdivisions
  23017. */
  23018. readonly subdivisionsX: number;
  23019. /**
  23020. * Y subdivisions
  23021. */
  23022. readonly subdivisionsY: number;
  23023. /**
  23024. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23025. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23026. * @param chunksCount the number of subdivisions for x and y
  23027. * @param octreeBlocksSize (Default: 32)
  23028. */
  23029. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23030. /**
  23031. * Returns a height (y) value in the Worl system :
  23032. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23033. * @param x x coordinate
  23034. * @param z z coordinate
  23035. * @returns the ground y position if (x, z) are outside the ground surface.
  23036. */
  23037. getHeightAtCoordinates(x: number, z: number): number;
  23038. /**
  23039. * Returns a normalized vector (Vector3) orthogonal to the ground
  23040. * at the ground coordinates (x, z) expressed in the World system.
  23041. * @param x x coordinate
  23042. * @param z z coordinate
  23043. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23044. */
  23045. getNormalAtCoordinates(x: number, z: number): Vector3;
  23046. /**
  23047. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23048. * at the ground coordinates (x, z) expressed in the World system.
  23049. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23050. * @param x x coordinate
  23051. * @param z z coordinate
  23052. * @param ref vector to store the result
  23053. * @returns the GroundMesh.
  23054. */
  23055. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23056. /**
  23057. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23058. * if the ground has been updated.
  23059. * This can be used in the render loop.
  23060. * @returns the GroundMesh.
  23061. */
  23062. updateCoordinateHeights(): GroundMesh;
  23063. private _getFacetAt;
  23064. private _initHeightQuads;
  23065. private _computeHeightQuads;
  23066. /**
  23067. * Serializes this ground mesh
  23068. * @param serializationObject object to write serialization to
  23069. */
  23070. serialize(serializationObject: any): void;
  23071. /**
  23072. * Parses a serialized ground mesh
  23073. * @param parsedMesh the serialized mesh
  23074. * @param scene the scene to create the ground mesh in
  23075. * @returns the created ground mesh
  23076. */
  23077. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23078. }
  23079. }
  23080. declare module "babylonjs/Physics/physicsJoint" {
  23081. import { Vector3 } from "babylonjs/Maths/math.vector";
  23082. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23083. /**
  23084. * Interface for Physics-Joint data
  23085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23086. */
  23087. export interface PhysicsJointData {
  23088. /**
  23089. * The main pivot of the joint
  23090. */
  23091. mainPivot?: Vector3;
  23092. /**
  23093. * The connected pivot of the joint
  23094. */
  23095. connectedPivot?: Vector3;
  23096. /**
  23097. * The main axis of the joint
  23098. */
  23099. mainAxis?: Vector3;
  23100. /**
  23101. * The connected axis of the joint
  23102. */
  23103. connectedAxis?: Vector3;
  23104. /**
  23105. * The collision of the joint
  23106. */
  23107. collision?: boolean;
  23108. /**
  23109. * Native Oimo/Cannon/Energy data
  23110. */
  23111. nativeParams?: any;
  23112. }
  23113. /**
  23114. * This is a holder class for the physics joint created by the physics plugin
  23115. * It holds a set of functions to control the underlying joint
  23116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23117. */
  23118. export class PhysicsJoint {
  23119. /**
  23120. * The type of the physics joint
  23121. */
  23122. type: number;
  23123. /**
  23124. * The data for the physics joint
  23125. */
  23126. jointData: PhysicsJointData;
  23127. private _physicsJoint;
  23128. protected _physicsPlugin: IPhysicsEnginePlugin;
  23129. /**
  23130. * Initializes the physics joint
  23131. * @param type The type of the physics joint
  23132. * @param jointData The data for the physics joint
  23133. */
  23134. constructor(
  23135. /**
  23136. * The type of the physics joint
  23137. */
  23138. type: number,
  23139. /**
  23140. * The data for the physics joint
  23141. */
  23142. jointData: PhysicsJointData);
  23143. /**
  23144. * Gets the physics joint
  23145. */
  23146. /**
  23147. * Sets the physics joint
  23148. */
  23149. physicsJoint: any;
  23150. /**
  23151. * Sets the physics plugin
  23152. */
  23153. physicsPlugin: IPhysicsEnginePlugin;
  23154. /**
  23155. * Execute a function that is physics-plugin specific.
  23156. * @param {Function} func the function that will be executed.
  23157. * It accepts two parameters: the physics world and the physics joint
  23158. */
  23159. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23160. /**
  23161. * Distance-Joint type
  23162. */
  23163. static DistanceJoint: number;
  23164. /**
  23165. * Hinge-Joint type
  23166. */
  23167. static HingeJoint: number;
  23168. /**
  23169. * Ball-and-Socket joint type
  23170. */
  23171. static BallAndSocketJoint: number;
  23172. /**
  23173. * Wheel-Joint type
  23174. */
  23175. static WheelJoint: number;
  23176. /**
  23177. * Slider-Joint type
  23178. */
  23179. static SliderJoint: number;
  23180. /**
  23181. * Prismatic-Joint type
  23182. */
  23183. static PrismaticJoint: number;
  23184. /**
  23185. * Universal-Joint type
  23186. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23187. */
  23188. static UniversalJoint: number;
  23189. /**
  23190. * Hinge-Joint 2 type
  23191. */
  23192. static Hinge2Joint: number;
  23193. /**
  23194. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23195. */
  23196. static PointToPointJoint: number;
  23197. /**
  23198. * Spring-Joint type
  23199. */
  23200. static SpringJoint: number;
  23201. /**
  23202. * Lock-Joint type
  23203. */
  23204. static LockJoint: number;
  23205. }
  23206. /**
  23207. * A class representing a physics distance joint
  23208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23209. */
  23210. export class DistanceJoint extends PhysicsJoint {
  23211. /**
  23212. *
  23213. * @param jointData The data for the Distance-Joint
  23214. */
  23215. constructor(jointData: DistanceJointData);
  23216. /**
  23217. * Update the predefined distance.
  23218. * @param maxDistance The maximum preferred distance
  23219. * @param minDistance The minimum preferred distance
  23220. */
  23221. updateDistance(maxDistance: number, minDistance?: number): void;
  23222. }
  23223. /**
  23224. * Represents a Motor-Enabled Joint
  23225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23226. */
  23227. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23228. /**
  23229. * Initializes the Motor-Enabled Joint
  23230. * @param type The type of the joint
  23231. * @param jointData The physica joint data for the joint
  23232. */
  23233. constructor(type: number, jointData: PhysicsJointData);
  23234. /**
  23235. * Set the motor values.
  23236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23237. * @param force the force to apply
  23238. * @param maxForce max force for this motor.
  23239. */
  23240. setMotor(force?: number, maxForce?: number): void;
  23241. /**
  23242. * Set the motor's limits.
  23243. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23244. * @param upperLimit The upper limit of the motor
  23245. * @param lowerLimit The lower limit of the motor
  23246. */
  23247. setLimit(upperLimit: number, lowerLimit?: number): void;
  23248. }
  23249. /**
  23250. * This class represents a single physics Hinge-Joint
  23251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23252. */
  23253. export class HingeJoint extends MotorEnabledJoint {
  23254. /**
  23255. * Initializes the Hinge-Joint
  23256. * @param jointData The joint data for the Hinge-Joint
  23257. */
  23258. constructor(jointData: PhysicsJointData);
  23259. /**
  23260. * Set the motor values.
  23261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23262. * @param {number} force the force to apply
  23263. * @param {number} maxForce max force for this motor.
  23264. */
  23265. setMotor(force?: number, maxForce?: number): void;
  23266. /**
  23267. * Set the motor's limits.
  23268. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23269. * @param upperLimit The upper limit of the motor
  23270. * @param lowerLimit The lower limit of the motor
  23271. */
  23272. setLimit(upperLimit: number, lowerLimit?: number): void;
  23273. }
  23274. /**
  23275. * This class represents a dual hinge physics joint (same as wheel joint)
  23276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23277. */
  23278. export class Hinge2Joint extends MotorEnabledJoint {
  23279. /**
  23280. * Initializes the Hinge2-Joint
  23281. * @param jointData The joint data for the Hinge2-Joint
  23282. */
  23283. constructor(jointData: PhysicsJointData);
  23284. /**
  23285. * Set the motor values.
  23286. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23287. * @param {number} targetSpeed the speed the motor is to reach
  23288. * @param {number} maxForce max force for this motor.
  23289. * @param {motorIndex} the motor's index, 0 or 1.
  23290. */
  23291. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23292. /**
  23293. * Set the motor limits.
  23294. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23295. * @param {number} upperLimit the upper limit
  23296. * @param {number} lowerLimit lower limit
  23297. * @param {motorIndex} the motor's index, 0 or 1.
  23298. */
  23299. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23300. }
  23301. /**
  23302. * Interface for a motor enabled joint
  23303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23304. */
  23305. export interface IMotorEnabledJoint {
  23306. /**
  23307. * Physics joint
  23308. */
  23309. physicsJoint: any;
  23310. /**
  23311. * Sets the motor of the motor-enabled joint
  23312. * @param force The force of the motor
  23313. * @param maxForce The maximum force of the motor
  23314. * @param motorIndex The index of the motor
  23315. */
  23316. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23317. /**
  23318. * Sets the limit of the motor
  23319. * @param upperLimit The upper limit of the motor
  23320. * @param lowerLimit The lower limit of the motor
  23321. * @param motorIndex The index of the motor
  23322. */
  23323. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23324. }
  23325. /**
  23326. * Joint data for a Distance-Joint
  23327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23328. */
  23329. export interface DistanceJointData extends PhysicsJointData {
  23330. /**
  23331. * Max distance the 2 joint objects can be apart
  23332. */
  23333. maxDistance: number;
  23334. }
  23335. /**
  23336. * Joint data from a spring joint
  23337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23338. */
  23339. export interface SpringJointData extends PhysicsJointData {
  23340. /**
  23341. * Length of the spring
  23342. */
  23343. length: number;
  23344. /**
  23345. * Stiffness of the spring
  23346. */
  23347. stiffness: number;
  23348. /**
  23349. * Damping of the spring
  23350. */
  23351. damping: number;
  23352. /** this callback will be called when applying the force to the impostors. */
  23353. forceApplicationCallback: () => void;
  23354. }
  23355. }
  23356. declare module "babylonjs/Physics/physicsRaycastResult" {
  23357. import { Vector3 } from "babylonjs/Maths/math.vector";
  23358. /**
  23359. * Holds the data for the raycast result
  23360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23361. */
  23362. export class PhysicsRaycastResult {
  23363. private _hasHit;
  23364. private _hitDistance;
  23365. private _hitNormalWorld;
  23366. private _hitPointWorld;
  23367. private _rayFromWorld;
  23368. private _rayToWorld;
  23369. /**
  23370. * Gets if there was a hit
  23371. */
  23372. readonly hasHit: boolean;
  23373. /**
  23374. * Gets the distance from the hit
  23375. */
  23376. readonly hitDistance: number;
  23377. /**
  23378. * Gets the hit normal/direction in the world
  23379. */
  23380. readonly hitNormalWorld: Vector3;
  23381. /**
  23382. * Gets the hit point in the world
  23383. */
  23384. readonly hitPointWorld: Vector3;
  23385. /**
  23386. * Gets the ray "start point" of the ray in the world
  23387. */
  23388. readonly rayFromWorld: Vector3;
  23389. /**
  23390. * Gets the ray "end point" of the ray in the world
  23391. */
  23392. readonly rayToWorld: Vector3;
  23393. /**
  23394. * Sets the hit data (normal & point in world space)
  23395. * @param hitNormalWorld defines the normal in world space
  23396. * @param hitPointWorld defines the point in world space
  23397. */
  23398. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23399. /**
  23400. * Sets the distance from the start point to the hit point
  23401. * @param distance
  23402. */
  23403. setHitDistance(distance: number): void;
  23404. /**
  23405. * Calculates the distance manually
  23406. */
  23407. calculateHitDistance(): void;
  23408. /**
  23409. * Resets all the values to default
  23410. * @param from The from point on world space
  23411. * @param to The to point on world space
  23412. */
  23413. reset(from?: Vector3, to?: Vector3): void;
  23414. }
  23415. /**
  23416. * Interface for the size containing width and height
  23417. */
  23418. interface IXYZ {
  23419. /**
  23420. * X
  23421. */
  23422. x: number;
  23423. /**
  23424. * Y
  23425. */
  23426. y: number;
  23427. /**
  23428. * Z
  23429. */
  23430. z: number;
  23431. }
  23432. }
  23433. declare module "babylonjs/Physics/IPhysicsEngine" {
  23434. import { Nullable } from "babylonjs/types";
  23435. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23437. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23438. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23439. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23440. /**
  23441. * Interface used to describe a physics joint
  23442. */
  23443. export interface PhysicsImpostorJoint {
  23444. /** Defines the main impostor to which the joint is linked */
  23445. mainImpostor: PhysicsImpostor;
  23446. /** Defines the impostor that is connected to the main impostor using this joint */
  23447. connectedImpostor: PhysicsImpostor;
  23448. /** Defines the joint itself */
  23449. joint: PhysicsJoint;
  23450. }
  23451. /** @hidden */
  23452. export interface IPhysicsEnginePlugin {
  23453. world: any;
  23454. name: string;
  23455. setGravity(gravity: Vector3): void;
  23456. setTimeStep(timeStep: number): void;
  23457. getTimeStep(): number;
  23458. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23459. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23460. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23461. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23462. removePhysicsBody(impostor: PhysicsImpostor): void;
  23463. generateJoint(joint: PhysicsImpostorJoint): void;
  23464. removeJoint(joint: PhysicsImpostorJoint): void;
  23465. isSupported(): boolean;
  23466. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23467. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23468. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23469. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23470. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23471. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23472. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23473. getBodyMass(impostor: PhysicsImpostor): number;
  23474. getBodyFriction(impostor: PhysicsImpostor): number;
  23475. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23476. getBodyRestitution(impostor: PhysicsImpostor): number;
  23477. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23478. getBodyPressure?(impostor: PhysicsImpostor): number;
  23479. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23480. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23481. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23482. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23483. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23484. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23485. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23486. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23487. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23488. sleepBody(impostor: PhysicsImpostor): void;
  23489. wakeUpBody(impostor: PhysicsImpostor): void;
  23490. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23491. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23492. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23493. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23494. getRadius(impostor: PhysicsImpostor): number;
  23495. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23496. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23497. dispose(): void;
  23498. }
  23499. /**
  23500. * Interface used to define a physics engine
  23501. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23502. */
  23503. export interface IPhysicsEngine {
  23504. /**
  23505. * Gets the gravity vector used by the simulation
  23506. */
  23507. gravity: Vector3;
  23508. /**
  23509. * Sets the gravity vector used by the simulation
  23510. * @param gravity defines the gravity vector to use
  23511. */
  23512. setGravity(gravity: Vector3): void;
  23513. /**
  23514. * Set the time step of the physics engine.
  23515. * Default is 1/60.
  23516. * To slow it down, enter 1/600 for example.
  23517. * To speed it up, 1/30
  23518. * @param newTimeStep the new timestep to apply to this world.
  23519. */
  23520. setTimeStep(newTimeStep: number): void;
  23521. /**
  23522. * Get the time step of the physics engine.
  23523. * @returns the current time step
  23524. */
  23525. getTimeStep(): number;
  23526. /**
  23527. * Release all resources
  23528. */
  23529. dispose(): void;
  23530. /**
  23531. * Gets the name of the current physics plugin
  23532. * @returns the name of the plugin
  23533. */
  23534. getPhysicsPluginName(): string;
  23535. /**
  23536. * Adding a new impostor for the impostor tracking.
  23537. * This will be done by the impostor itself.
  23538. * @param impostor the impostor to add
  23539. */
  23540. addImpostor(impostor: PhysicsImpostor): void;
  23541. /**
  23542. * Remove an impostor from the engine.
  23543. * This impostor and its mesh will not longer be updated by the physics engine.
  23544. * @param impostor the impostor to remove
  23545. */
  23546. removeImpostor(impostor: PhysicsImpostor): void;
  23547. /**
  23548. * Add a joint to the physics engine
  23549. * @param mainImpostor defines the main impostor to which the joint is added.
  23550. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23551. * @param joint defines the joint that will connect both impostors.
  23552. */
  23553. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23554. /**
  23555. * Removes a joint from the simulation
  23556. * @param mainImpostor defines the impostor used with the joint
  23557. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23558. * @param joint defines the joint to remove
  23559. */
  23560. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23561. /**
  23562. * Gets the current plugin used to run the simulation
  23563. * @returns current plugin
  23564. */
  23565. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23566. /**
  23567. * Gets the list of physic impostors
  23568. * @returns an array of PhysicsImpostor
  23569. */
  23570. getImpostors(): Array<PhysicsImpostor>;
  23571. /**
  23572. * Gets the impostor for a physics enabled object
  23573. * @param object defines the object impersonated by the impostor
  23574. * @returns the PhysicsImpostor or null if not found
  23575. */
  23576. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23577. /**
  23578. * Gets the impostor for a physics body object
  23579. * @param body defines physics body used by the impostor
  23580. * @returns the PhysicsImpostor or null if not found
  23581. */
  23582. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23583. /**
  23584. * Does a raycast in the physics world
  23585. * @param from when should the ray start?
  23586. * @param to when should the ray end?
  23587. * @returns PhysicsRaycastResult
  23588. */
  23589. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23590. /**
  23591. * Called by the scene. No need to call it.
  23592. * @param delta defines the timespam between frames
  23593. */
  23594. _step(delta: number): void;
  23595. }
  23596. }
  23597. declare module "babylonjs/Physics/physicsImpostor" {
  23598. import { Nullable, IndicesArray } from "babylonjs/types";
  23599. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23600. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23602. import { Scene } from "babylonjs/scene";
  23603. import { Bone } from "babylonjs/Bones/bone";
  23604. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23605. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23606. import { Space } from "babylonjs/Maths/math.axis";
  23607. /**
  23608. * The interface for the physics imposter parameters
  23609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23610. */
  23611. export interface PhysicsImpostorParameters {
  23612. /**
  23613. * The mass of the physics imposter
  23614. */
  23615. mass: number;
  23616. /**
  23617. * The friction of the physics imposter
  23618. */
  23619. friction?: number;
  23620. /**
  23621. * The coefficient of restitution of the physics imposter
  23622. */
  23623. restitution?: number;
  23624. /**
  23625. * The native options of the physics imposter
  23626. */
  23627. nativeOptions?: any;
  23628. /**
  23629. * Specifies if the parent should be ignored
  23630. */
  23631. ignoreParent?: boolean;
  23632. /**
  23633. * Specifies if bi-directional transformations should be disabled
  23634. */
  23635. disableBidirectionalTransformation?: boolean;
  23636. /**
  23637. * The pressure inside the physics imposter, soft object only
  23638. */
  23639. pressure?: number;
  23640. /**
  23641. * The stiffness the physics imposter, soft object only
  23642. */
  23643. stiffness?: number;
  23644. /**
  23645. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23646. */
  23647. velocityIterations?: number;
  23648. /**
  23649. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23650. */
  23651. positionIterations?: number;
  23652. /**
  23653. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23654. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23655. * Add to fix multiple points
  23656. */
  23657. fixedPoints?: number;
  23658. /**
  23659. * The collision margin around a soft object
  23660. */
  23661. margin?: number;
  23662. /**
  23663. * The collision margin around a soft object
  23664. */
  23665. damping?: number;
  23666. /**
  23667. * The path for a rope based on an extrusion
  23668. */
  23669. path?: any;
  23670. /**
  23671. * The shape of an extrusion used for a rope based on an extrusion
  23672. */
  23673. shape?: any;
  23674. }
  23675. /**
  23676. * Interface for a physics-enabled object
  23677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23678. */
  23679. export interface IPhysicsEnabledObject {
  23680. /**
  23681. * The position of the physics-enabled object
  23682. */
  23683. position: Vector3;
  23684. /**
  23685. * The rotation of the physics-enabled object
  23686. */
  23687. rotationQuaternion: Nullable<Quaternion>;
  23688. /**
  23689. * The scale of the physics-enabled object
  23690. */
  23691. scaling: Vector3;
  23692. /**
  23693. * The rotation of the physics-enabled object
  23694. */
  23695. rotation?: Vector3;
  23696. /**
  23697. * The parent of the physics-enabled object
  23698. */
  23699. parent?: any;
  23700. /**
  23701. * The bounding info of the physics-enabled object
  23702. * @returns The bounding info of the physics-enabled object
  23703. */
  23704. getBoundingInfo(): BoundingInfo;
  23705. /**
  23706. * Computes the world matrix
  23707. * @param force Specifies if the world matrix should be computed by force
  23708. * @returns A world matrix
  23709. */
  23710. computeWorldMatrix(force: boolean): Matrix;
  23711. /**
  23712. * Gets the world matrix
  23713. * @returns A world matrix
  23714. */
  23715. getWorldMatrix?(): Matrix;
  23716. /**
  23717. * Gets the child meshes
  23718. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23719. * @returns An array of abstract meshes
  23720. */
  23721. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23722. /**
  23723. * Gets the vertex data
  23724. * @param kind The type of vertex data
  23725. * @returns A nullable array of numbers, or a float32 array
  23726. */
  23727. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23728. /**
  23729. * Gets the indices from the mesh
  23730. * @returns A nullable array of index arrays
  23731. */
  23732. getIndices?(): Nullable<IndicesArray>;
  23733. /**
  23734. * Gets the scene from the mesh
  23735. * @returns the indices array or null
  23736. */
  23737. getScene?(): Scene;
  23738. /**
  23739. * Gets the absolute position from the mesh
  23740. * @returns the absolute position
  23741. */
  23742. getAbsolutePosition(): Vector3;
  23743. /**
  23744. * Gets the absolute pivot point from the mesh
  23745. * @returns the absolute pivot point
  23746. */
  23747. getAbsolutePivotPoint(): Vector3;
  23748. /**
  23749. * Rotates the mesh
  23750. * @param axis The axis of rotation
  23751. * @param amount The amount of rotation
  23752. * @param space The space of the rotation
  23753. * @returns The rotation transform node
  23754. */
  23755. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23756. /**
  23757. * Translates the mesh
  23758. * @param axis The axis of translation
  23759. * @param distance The distance of translation
  23760. * @param space The space of the translation
  23761. * @returns The transform node
  23762. */
  23763. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23764. /**
  23765. * Sets the absolute position of the mesh
  23766. * @param absolutePosition The absolute position of the mesh
  23767. * @returns The transform node
  23768. */
  23769. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23770. /**
  23771. * Gets the class name of the mesh
  23772. * @returns The class name
  23773. */
  23774. getClassName(): string;
  23775. }
  23776. /**
  23777. * Represents a physics imposter
  23778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23779. */
  23780. export class PhysicsImpostor {
  23781. /**
  23782. * The physics-enabled object used as the physics imposter
  23783. */
  23784. object: IPhysicsEnabledObject;
  23785. /**
  23786. * The type of the physics imposter
  23787. */
  23788. type: number;
  23789. private _options;
  23790. private _scene?;
  23791. /**
  23792. * The default object size of the imposter
  23793. */
  23794. static DEFAULT_OBJECT_SIZE: Vector3;
  23795. /**
  23796. * The identity quaternion of the imposter
  23797. */
  23798. static IDENTITY_QUATERNION: Quaternion;
  23799. /** @hidden */
  23800. _pluginData: any;
  23801. private _physicsEngine;
  23802. private _physicsBody;
  23803. private _bodyUpdateRequired;
  23804. private _onBeforePhysicsStepCallbacks;
  23805. private _onAfterPhysicsStepCallbacks;
  23806. /** @hidden */
  23807. _onPhysicsCollideCallbacks: Array<{
  23808. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23809. otherImpostors: Array<PhysicsImpostor>;
  23810. }>;
  23811. private _deltaPosition;
  23812. private _deltaRotation;
  23813. private _deltaRotationConjugated;
  23814. /** @hidden */
  23815. _isFromLine: boolean;
  23816. private _parent;
  23817. private _isDisposed;
  23818. private static _tmpVecs;
  23819. private static _tmpQuat;
  23820. /**
  23821. * Specifies if the physics imposter is disposed
  23822. */
  23823. readonly isDisposed: boolean;
  23824. /**
  23825. * Gets the mass of the physics imposter
  23826. */
  23827. mass: number;
  23828. /**
  23829. * Gets the coefficient of friction
  23830. */
  23831. /**
  23832. * Sets the coefficient of friction
  23833. */
  23834. friction: number;
  23835. /**
  23836. * Gets the coefficient of restitution
  23837. */
  23838. /**
  23839. * Sets the coefficient of restitution
  23840. */
  23841. restitution: number;
  23842. /**
  23843. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23844. */
  23845. /**
  23846. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23847. */
  23848. pressure: number;
  23849. /**
  23850. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23851. */
  23852. /**
  23853. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23854. */
  23855. stiffness: number;
  23856. /**
  23857. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23858. */
  23859. /**
  23860. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23861. */
  23862. velocityIterations: number;
  23863. /**
  23864. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23865. */
  23866. /**
  23867. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23868. */
  23869. positionIterations: number;
  23870. /**
  23871. * The unique id of the physics imposter
  23872. * set by the physics engine when adding this impostor to the array
  23873. */
  23874. uniqueId: number;
  23875. /**
  23876. * @hidden
  23877. */
  23878. soft: boolean;
  23879. /**
  23880. * @hidden
  23881. */
  23882. segments: number;
  23883. private _joints;
  23884. /**
  23885. * Initializes the physics imposter
  23886. * @param object The physics-enabled object used as the physics imposter
  23887. * @param type The type of the physics imposter
  23888. * @param _options The options for the physics imposter
  23889. * @param _scene The Babylon scene
  23890. */
  23891. constructor(
  23892. /**
  23893. * The physics-enabled object used as the physics imposter
  23894. */
  23895. object: IPhysicsEnabledObject,
  23896. /**
  23897. * The type of the physics imposter
  23898. */
  23899. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23900. /**
  23901. * This function will completly initialize this impostor.
  23902. * It will create a new body - but only if this mesh has no parent.
  23903. * If it has, this impostor will not be used other than to define the impostor
  23904. * of the child mesh.
  23905. * @hidden
  23906. */
  23907. _init(): void;
  23908. private _getPhysicsParent;
  23909. /**
  23910. * Should a new body be generated.
  23911. * @returns boolean specifying if body initialization is required
  23912. */
  23913. isBodyInitRequired(): boolean;
  23914. /**
  23915. * Sets the updated scaling
  23916. * @param updated Specifies if the scaling is updated
  23917. */
  23918. setScalingUpdated(): void;
  23919. /**
  23920. * Force a regeneration of this or the parent's impostor's body.
  23921. * Use under cautious - This will remove all joints already implemented.
  23922. */
  23923. forceUpdate(): void;
  23924. /**
  23925. * Gets the body that holds this impostor. Either its own, or its parent.
  23926. */
  23927. /**
  23928. * Set the physics body. Used mainly by the physics engine/plugin
  23929. */
  23930. physicsBody: any;
  23931. /**
  23932. * Get the parent of the physics imposter
  23933. * @returns Physics imposter or null
  23934. */
  23935. /**
  23936. * Sets the parent of the physics imposter
  23937. */
  23938. parent: Nullable<PhysicsImpostor>;
  23939. /**
  23940. * Resets the update flags
  23941. */
  23942. resetUpdateFlags(): void;
  23943. /**
  23944. * Gets the object extend size
  23945. * @returns the object extend size
  23946. */
  23947. getObjectExtendSize(): Vector3;
  23948. /**
  23949. * Gets the object center
  23950. * @returns The object center
  23951. */
  23952. getObjectCenter(): Vector3;
  23953. /**
  23954. * Get a specific parametes from the options parameter
  23955. * @param paramName The object parameter name
  23956. * @returns The object parameter
  23957. */
  23958. getParam(paramName: string): any;
  23959. /**
  23960. * Sets a specific parameter in the options given to the physics plugin
  23961. * @param paramName The parameter name
  23962. * @param value The value of the parameter
  23963. */
  23964. setParam(paramName: string, value: number): void;
  23965. /**
  23966. * Specifically change the body's mass option. Won't recreate the physics body object
  23967. * @param mass The mass of the physics imposter
  23968. */
  23969. setMass(mass: number): void;
  23970. /**
  23971. * Gets the linear velocity
  23972. * @returns linear velocity or null
  23973. */
  23974. getLinearVelocity(): Nullable<Vector3>;
  23975. /**
  23976. * Sets the linear velocity
  23977. * @param velocity linear velocity or null
  23978. */
  23979. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23980. /**
  23981. * Gets the angular velocity
  23982. * @returns angular velocity or null
  23983. */
  23984. getAngularVelocity(): Nullable<Vector3>;
  23985. /**
  23986. * Sets the angular velocity
  23987. * @param velocity The velocity or null
  23988. */
  23989. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23990. /**
  23991. * Execute a function with the physics plugin native code
  23992. * Provide a function the will have two variables - the world object and the physics body object
  23993. * @param func The function to execute with the physics plugin native code
  23994. */
  23995. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23996. /**
  23997. * Register a function that will be executed before the physics world is stepping forward
  23998. * @param func The function to execute before the physics world is stepped forward
  23999. */
  24000. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24001. /**
  24002. * Unregister a function that will be executed before the physics world is stepping forward
  24003. * @param func The function to execute before the physics world is stepped forward
  24004. */
  24005. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24006. /**
  24007. * Register a function that will be executed after the physics step
  24008. * @param func The function to execute after physics step
  24009. */
  24010. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24011. /**
  24012. * Unregisters a function that will be executed after the physics step
  24013. * @param func The function to execute after physics step
  24014. */
  24015. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24016. /**
  24017. * register a function that will be executed when this impostor collides against a different body
  24018. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24019. * @param func Callback that is executed on collision
  24020. */
  24021. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24022. /**
  24023. * Unregisters the physics imposter on contact
  24024. * @param collideAgainst The physics object to collide against
  24025. * @param func Callback to execute on collision
  24026. */
  24027. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24028. private _tmpQuat;
  24029. private _tmpQuat2;
  24030. /**
  24031. * Get the parent rotation
  24032. * @returns The parent rotation
  24033. */
  24034. getParentsRotation(): Quaternion;
  24035. /**
  24036. * this function is executed by the physics engine.
  24037. */
  24038. beforeStep: () => void;
  24039. /**
  24040. * this function is executed by the physics engine
  24041. */
  24042. afterStep: () => void;
  24043. /**
  24044. * Legacy collision detection event support
  24045. */
  24046. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24047. /**
  24048. * event and body object due to cannon's event-based architecture.
  24049. */
  24050. onCollide: (e: {
  24051. body: any;
  24052. }) => void;
  24053. /**
  24054. * Apply a force
  24055. * @param force The force to apply
  24056. * @param contactPoint The contact point for the force
  24057. * @returns The physics imposter
  24058. */
  24059. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24060. /**
  24061. * Apply an impulse
  24062. * @param force The impulse force
  24063. * @param contactPoint The contact point for the impulse force
  24064. * @returns The physics imposter
  24065. */
  24066. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24067. /**
  24068. * A help function to create a joint
  24069. * @param otherImpostor A physics imposter used to create a joint
  24070. * @param jointType The type of joint
  24071. * @param jointData The data for the joint
  24072. * @returns The physics imposter
  24073. */
  24074. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24075. /**
  24076. * Add a joint to this impostor with a different impostor
  24077. * @param otherImpostor A physics imposter used to add a joint
  24078. * @param joint The joint to add
  24079. * @returns The physics imposter
  24080. */
  24081. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24082. /**
  24083. * Add an anchor to a cloth impostor
  24084. * @param otherImpostor rigid impostor to anchor to
  24085. * @param width ratio across width from 0 to 1
  24086. * @param height ratio up height from 0 to 1
  24087. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24088. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24089. * @returns impostor the soft imposter
  24090. */
  24091. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24092. /**
  24093. * Add a hook to a rope impostor
  24094. * @param otherImpostor rigid impostor to anchor to
  24095. * @param length ratio across rope from 0 to 1
  24096. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24097. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24098. * @returns impostor the rope imposter
  24099. */
  24100. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24101. /**
  24102. * Will keep this body still, in a sleep mode.
  24103. * @returns the physics imposter
  24104. */
  24105. sleep(): PhysicsImpostor;
  24106. /**
  24107. * Wake the body up.
  24108. * @returns The physics imposter
  24109. */
  24110. wakeUp(): PhysicsImpostor;
  24111. /**
  24112. * Clones the physics imposter
  24113. * @param newObject The physics imposter clones to this physics-enabled object
  24114. * @returns A nullable physics imposter
  24115. */
  24116. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24117. /**
  24118. * Disposes the physics imposter
  24119. */
  24120. dispose(): void;
  24121. /**
  24122. * Sets the delta position
  24123. * @param position The delta position amount
  24124. */
  24125. setDeltaPosition(position: Vector3): void;
  24126. /**
  24127. * Sets the delta rotation
  24128. * @param rotation The delta rotation amount
  24129. */
  24130. setDeltaRotation(rotation: Quaternion): void;
  24131. /**
  24132. * Gets the box size of the physics imposter and stores the result in the input parameter
  24133. * @param result Stores the box size
  24134. * @returns The physics imposter
  24135. */
  24136. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24137. /**
  24138. * Gets the radius of the physics imposter
  24139. * @returns Radius of the physics imposter
  24140. */
  24141. getRadius(): number;
  24142. /**
  24143. * Sync a bone with this impostor
  24144. * @param bone The bone to sync to the impostor.
  24145. * @param boneMesh The mesh that the bone is influencing.
  24146. * @param jointPivot The pivot of the joint / bone in local space.
  24147. * @param distToJoint Optional distance from the impostor to the joint.
  24148. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24149. */
  24150. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24151. /**
  24152. * Sync impostor to a bone
  24153. * @param bone The bone that the impostor will be synced to.
  24154. * @param boneMesh The mesh that the bone is influencing.
  24155. * @param jointPivot The pivot of the joint / bone in local space.
  24156. * @param distToJoint Optional distance from the impostor to the joint.
  24157. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24158. * @param boneAxis Optional vector3 axis the bone is aligned with
  24159. */
  24160. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24161. /**
  24162. * No-Imposter type
  24163. */
  24164. static NoImpostor: number;
  24165. /**
  24166. * Sphere-Imposter type
  24167. */
  24168. static SphereImpostor: number;
  24169. /**
  24170. * Box-Imposter type
  24171. */
  24172. static BoxImpostor: number;
  24173. /**
  24174. * Plane-Imposter type
  24175. */
  24176. static PlaneImpostor: number;
  24177. /**
  24178. * Mesh-imposter type
  24179. */
  24180. static MeshImpostor: number;
  24181. /**
  24182. * Capsule-Impostor type (Ammo.js plugin only)
  24183. */
  24184. static CapsuleImpostor: number;
  24185. /**
  24186. * Cylinder-Imposter type
  24187. */
  24188. static CylinderImpostor: number;
  24189. /**
  24190. * Particle-Imposter type
  24191. */
  24192. static ParticleImpostor: number;
  24193. /**
  24194. * Heightmap-Imposter type
  24195. */
  24196. static HeightmapImpostor: number;
  24197. /**
  24198. * ConvexHull-Impostor type (Ammo.js plugin only)
  24199. */
  24200. static ConvexHullImpostor: number;
  24201. /**
  24202. * Rope-Imposter type
  24203. */
  24204. static RopeImpostor: number;
  24205. /**
  24206. * Cloth-Imposter type
  24207. */
  24208. static ClothImpostor: number;
  24209. /**
  24210. * Softbody-Imposter type
  24211. */
  24212. static SoftbodyImpostor: number;
  24213. }
  24214. }
  24215. declare module "babylonjs/Meshes/mesh" {
  24216. import { Observable } from "babylonjs/Misc/observable";
  24217. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24218. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24219. import { Camera } from "babylonjs/Cameras/camera";
  24220. import { Scene } from "babylonjs/scene";
  24221. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24222. import { Color4 } from "babylonjs/Maths/math.color";
  24223. import { Engine } from "babylonjs/Engines/engine";
  24224. import { Node } from "babylonjs/node";
  24225. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24226. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24227. import { Buffer } from "babylonjs/Meshes/buffer";
  24228. import { Geometry } from "babylonjs/Meshes/geometry";
  24229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24231. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24232. import { Effect } from "babylonjs/Materials/effect";
  24233. import { Material } from "babylonjs/Materials/material";
  24234. import { Skeleton } from "babylonjs/Bones/skeleton";
  24235. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24236. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24237. import { Path3D } from "babylonjs/Maths/math.path";
  24238. import { Plane } from "babylonjs/Maths/math.plane";
  24239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24240. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24241. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24242. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24243. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24244. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24245. /**
  24246. * @hidden
  24247. **/
  24248. export class _CreationDataStorage {
  24249. closePath?: boolean;
  24250. closeArray?: boolean;
  24251. idx: number[];
  24252. dashSize: number;
  24253. gapSize: number;
  24254. path3D: Path3D;
  24255. pathArray: Vector3[][];
  24256. arc: number;
  24257. radius: number;
  24258. cap: number;
  24259. tessellation: number;
  24260. }
  24261. /**
  24262. * @hidden
  24263. **/
  24264. class _InstanceDataStorage {
  24265. visibleInstances: any;
  24266. batchCache: _InstancesBatch;
  24267. instancesBufferSize: number;
  24268. instancesBuffer: Nullable<Buffer>;
  24269. instancesData: Float32Array;
  24270. overridenInstanceCount: number;
  24271. isFrozen: boolean;
  24272. previousBatch: Nullable<_InstancesBatch>;
  24273. hardwareInstancedRendering: boolean;
  24274. sideOrientation: number;
  24275. }
  24276. /**
  24277. * @hidden
  24278. **/
  24279. export class _InstancesBatch {
  24280. mustReturn: boolean;
  24281. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24282. renderSelf: boolean[];
  24283. hardwareInstancedRendering: boolean[];
  24284. }
  24285. /**
  24286. * Class used to represent renderable models
  24287. */
  24288. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24289. /**
  24290. * Mesh side orientation : usually the external or front surface
  24291. */
  24292. static readonly FRONTSIDE: number;
  24293. /**
  24294. * Mesh side orientation : usually the internal or back surface
  24295. */
  24296. static readonly BACKSIDE: number;
  24297. /**
  24298. * Mesh side orientation : both internal and external or front and back surfaces
  24299. */
  24300. static readonly DOUBLESIDE: number;
  24301. /**
  24302. * Mesh side orientation : by default, `FRONTSIDE`
  24303. */
  24304. static readonly DEFAULTSIDE: number;
  24305. /**
  24306. * Mesh cap setting : no cap
  24307. */
  24308. static readonly NO_CAP: number;
  24309. /**
  24310. * Mesh cap setting : one cap at the beginning of the mesh
  24311. */
  24312. static readonly CAP_START: number;
  24313. /**
  24314. * Mesh cap setting : one cap at the end of the mesh
  24315. */
  24316. static readonly CAP_END: number;
  24317. /**
  24318. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24319. */
  24320. static readonly CAP_ALL: number;
  24321. /**
  24322. * Mesh pattern setting : no flip or rotate
  24323. */
  24324. static readonly NO_FLIP: number;
  24325. /**
  24326. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24327. */
  24328. static readonly FLIP_TILE: number;
  24329. /**
  24330. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24331. */
  24332. static readonly ROTATE_TILE: number;
  24333. /**
  24334. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24335. */
  24336. static readonly FLIP_ROW: number;
  24337. /**
  24338. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24339. */
  24340. static readonly ROTATE_ROW: number;
  24341. /**
  24342. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24343. */
  24344. static readonly FLIP_N_ROTATE_TILE: number;
  24345. /**
  24346. * Mesh pattern setting : rotate pattern and rotate
  24347. */
  24348. static readonly FLIP_N_ROTATE_ROW: number;
  24349. /**
  24350. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24351. */
  24352. static readonly CENTER: number;
  24353. /**
  24354. * Mesh tile positioning : part tiles on left
  24355. */
  24356. static readonly LEFT: number;
  24357. /**
  24358. * Mesh tile positioning : part tiles on right
  24359. */
  24360. static readonly RIGHT: number;
  24361. /**
  24362. * Mesh tile positioning : part tiles on top
  24363. */
  24364. static readonly TOP: number;
  24365. /**
  24366. * Mesh tile positioning : part tiles on bottom
  24367. */
  24368. static readonly BOTTOM: number;
  24369. /**
  24370. * Gets the default side orientation.
  24371. * @param orientation the orientation to value to attempt to get
  24372. * @returns the default orientation
  24373. * @hidden
  24374. */
  24375. static _GetDefaultSideOrientation(orientation?: number): number;
  24376. private _internalMeshDataInfo;
  24377. /**
  24378. * An event triggered before rendering the mesh
  24379. */
  24380. readonly onBeforeRenderObservable: Observable<Mesh>;
  24381. /**
  24382. * An event triggered before binding the mesh
  24383. */
  24384. readonly onBeforeBindObservable: Observable<Mesh>;
  24385. /**
  24386. * An event triggered after rendering the mesh
  24387. */
  24388. readonly onAfterRenderObservable: Observable<Mesh>;
  24389. /**
  24390. * An event triggered before drawing the mesh
  24391. */
  24392. readonly onBeforeDrawObservable: Observable<Mesh>;
  24393. private _onBeforeDrawObserver;
  24394. /**
  24395. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24396. */
  24397. onBeforeDraw: () => void;
  24398. readonly hasInstances: boolean;
  24399. /**
  24400. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24401. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24402. */
  24403. delayLoadState: number;
  24404. /**
  24405. * Gets the list of instances created from this mesh
  24406. * it is not supposed to be modified manually.
  24407. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24408. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24409. */
  24410. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24411. /**
  24412. * Gets the file containing delay loading data for this mesh
  24413. */
  24414. delayLoadingFile: string;
  24415. /** @hidden */
  24416. _binaryInfo: any;
  24417. /**
  24418. * User defined function used to change how LOD level selection is done
  24419. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24420. */
  24421. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24422. /**
  24423. * Gets or sets the morph target manager
  24424. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24425. */
  24426. morphTargetManager: Nullable<MorphTargetManager>;
  24427. /** @hidden */
  24428. _creationDataStorage: Nullable<_CreationDataStorage>;
  24429. /** @hidden */
  24430. _geometry: Nullable<Geometry>;
  24431. /** @hidden */
  24432. _delayInfo: Array<string>;
  24433. /** @hidden */
  24434. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24435. /** @hidden */
  24436. _instanceDataStorage: _InstanceDataStorage;
  24437. private _effectiveMaterial;
  24438. /** @hidden */
  24439. _shouldGenerateFlatShading: boolean;
  24440. /** @hidden */
  24441. _originalBuilderSideOrientation: number;
  24442. /**
  24443. * Use this property to change the original side orientation defined at construction time
  24444. */
  24445. overrideMaterialSideOrientation: Nullable<number>;
  24446. /**
  24447. * Gets the source mesh (the one used to clone this one from)
  24448. */
  24449. readonly source: Nullable<Mesh>;
  24450. /**
  24451. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24452. */
  24453. isUnIndexed: boolean;
  24454. /**
  24455. * @constructor
  24456. * @param name The value used by scene.getMeshByName() to do a lookup.
  24457. * @param scene The scene to add this mesh to.
  24458. * @param parent The parent of this mesh, if it has one
  24459. * @param source An optional Mesh from which geometry is shared, cloned.
  24460. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24461. * When false, achieved by calling a clone(), also passing False.
  24462. * This will make creation of children, recursive.
  24463. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24464. */
  24465. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24466. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24467. /**
  24468. * Gets the class name
  24469. * @returns the string "Mesh".
  24470. */
  24471. getClassName(): string;
  24472. /** @hidden */
  24473. readonly _isMesh: boolean;
  24474. /**
  24475. * Returns a description of this mesh
  24476. * @param fullDetails define if full details about this mesh must be used
  24477. * @returns a descriptive string representing this mesh
  24478. */
  24479. toString(fullDetails?: boolean): string;
  24480. /** @hidden */
  24481. _unBindEffect(): void;
  24482. /**
  24483. * Gets a boolean indicating if this mesh has LOD
  24484. */
  24485. readonly hasLODLevels: boolean;
  24486. /**
  24487. * Gets the list of MeshLODLevel associated with the current mesh
  24488. * @returns an array of MeshLODLevel
  24489. */
  24490. getLODLevels(): MeshLODLevel[];
  24491. private _sortLODLevels;
  24492. /**
  24493. * Add a mesh as LOD level triggered at the given distance.
  24494. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24495. * @param distance The distance from the center of the object to show this level
  24496. * @param mesh The mesh to be added as LOD level (can be null)
  24497. * @return This mesh (for chaining)
  24498. */
  24499. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24500. /**
  24501. * Returns the LOD level mesh at the passed distance or null if not found.
  24502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24503. * @param distance The distance from the center of the object to show this level
  24504. * @returns a Mesh or `null`
  24505. */
  24506. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24507. /**
  24508. * Remove a mesh from the LOD array
  24509. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24510. * @param mesh defines the mesh to be removed
  24511. * @return This mesh (for chaining)
  24512. */
  24513. removeLODLevel(mesh: Mesh): Mesh;
  24514. /**
  24515. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24516. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24517. * @param camera defines the camera to use to compute distance
  24518. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24519. * @return This mesh (for chaining)
  24520. */
  24521. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24522. /**
  24523. * Gets the mesh internal Geometry object
  24524. */
  24525. readonly geometry: Nullable<Geometry>;
  24526. /**
  24527. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24528. * @returns the total number of vertices
  24529. */
  24530. getTotalVertices(): number;
  24531. /**
  24532. * Returns the content of an associated vertex buffer
  24533. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24534. * - VertexBuffer.PositionKind
  24535. * - VertexBuffer.UVKind
  24536. * - VertexBuffer.UV2Kind
  24537. * - VertexBuffer.UV3Kind
  24538. * - VertexBuffer.UV4Kind
  24539. * - VertexBuffer.UV5Kind
  24540. * - VertexBuffer.UV6Kind
  24541. * - VertexBuffer.ColorKind
  24542. * - VertexBuffer.MatricesIndicesKind
  24543. * - VertexBuffer.MatricesIndicesExtraKind
  24544. * - VertexBuffer.MatricesWeightsKind
  24545. * - VertexBuffer.MatricesWeightsExtraKind
  24546. * @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
  24547. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24548. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24549. */
  24550. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24551. /**
  24552. * Returns the mesh VertexBuffer object from the requested `kind`
  24553. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24554. * - VertexBuffer.PositionKind
  24555. * - VertexBuffer.NormalKind
  24556. * - VertexBuffer.UVKind
  24557. * - VertexBuffer.UV2Kind
  24558. * - VertexBuffer.UV3Kind
  24559. * - VertexBuffer.UV4Kind
  24560. * - VertexBuffer.UV5Kind
  24561. * - VertexBuffer.UV6Kind
  24562. * - VertexBuffer.ColorKind
  24563. * - VertexBuffer.MatricesIndicesKind
  24564. * - VertexBuffer.MatricesIndicesExtraKind
  24565. * - VertexBuffer.MatricesWeightsKind
  24566. * - VertexBuffer.MatricesWeightsExtraKind
  24567. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24568. */
  24569. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24570. /**
  24571. * Tests if a specific vertex buffer is associated with this mesh
  24572. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24573. * - VertexBuffer.PositionKind
  24574. * - VertexBuffer.NormalKind
  24575. * - VertexBuffer.UVKind
  24576. * - VertexBuffer.UV2Kind
  24577. * - VertexBuffer.UV3Kind
  24578. * - VertexBuffer.UV4Kind
  24579. * - VertexBuffer.UV5Kind
  24580. * - VertexBuffer.UV6Kind
  24581. * - VertexBuffer.ColorKind
  24582. * - VertexBuffer.MatricesIndicesKind
  24583. * - VertexBuffer.MatricesIndicesExtraKind
  24584. * - VertexBuffer.MatricesWeightsKind
  24585. * - VertexBuffer.MatricesWeightsExtraKind
  24586. * @returns a boolean
  24587. */
  24588. isVerticesDataPresent(kind: string): boolean;
  24589. /**
  24590. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24591. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24592. * - VertexBuffer.PositionKind
  24593. * - VertexBuffer.UVKind
  24594. * - VertexBuffer.UV2Kind
  24595. * - VertexBuffer.UV3Kind
  24596. * - VertexBuffer.UV4Kind
  24597. * - VertexBuffer.UV5Kind
  24598. * - VertexBuffer.UV6Kind
  24599. * - VertexBuffer.ColorKind
  24600. * - VertexBuffer.MatricesIndicesKind
  24601. * - VertexBuffer.MatricesIndicesExtraKind
  24602. * - VertexBuffer.MatricesWeightsKind
  24603. * - VertexBuffer.MatricesWeightsExtraKind
  24604. * @returns a boolean
  24605. */
  24606. isVertexBufferUpdatable(kind: string): boolean;
  24607. /**
  24608. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24609. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24610. * - VertexBuffer.PositionKind
  24611. * - VertexBuffer.NormalKind
  24612. * - VertexBuffer.UVKind
  24613. * - VertexBuffer.UV2Kind
  24614. * - VertexBuffer.UV3Kind
  24615. * - VertexBuffer.UV4Kind
  24616. * - VertexBuffer.UV5Kind
  24617. * - VertexBuffer.UV6Kind
  24618. * - VertexBuffer.ColorKind
  24619. * - VertexBuffer.MatricesIndicesKind
  24620. * - VertexBuffer.MatricesIndicesExtraKind
  24621. * - VertexBuffer.MatricesWeightsKind
  24622. * - VertexBuffer.MatricesWeightsExtraKind
  24623. * @returns an array of strings
  24624. */
  24625. getVerticesDataKinds(): string[];
  24626. /**
  24627. * Returns a positive integer : the total number of indices in this mesh geometry.
  24628. * @returns the numner of indices or zero if the mesh has no geometry.
  24629. */
  24630. getTotalIndices(): number;
  24631. /**
  24632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24633. * @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.
  24634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24635. * @returns the indices array or an empty array if the mesh has no geometry
  24636. */
  24637. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24638. readonly isBlocked: boolean;
  24639. /**
  24640. * Determine if the current mesh is ready to be rendered
  24641. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24642. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24643. * @returns true if all associated assets are ready (material, textures, shaders)
  24644. */
  24645. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24646. /**
  24647. * 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.
  24648. */
  24649. readonly areNormalsFrozen: boolean;
  24650. /**
  24651. * 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.
  24652. * @returns the current mesh
  24653. */
  24654. freezeNormals(): Mesh;
  24655. /**
  24656. * 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
  24657. * @returns the current mesh
  24658. */
  24659. unfreezeNormals(): Mesh;
  24660. /**
  24661. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24662. */
  24663. overridenInstanceCount: number;
  24664. /** @hidden */
  24665. _preActivate(): Mesh;
  24666. /** @hidden */
  24667. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24668. /** @hidden */
  24669. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24670. /**
  24671. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24672. * This means the mesh underlying bounding box and sphere are recomputed.
  24673. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24674. * @returns the current mesh
  24675. */
  24676. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24677. /** @hidden */
  24678. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24679. /**
  24680. * This function will subdivide the mesh into multiple submeshes
  24681. * @param count defines the expected number of submeshes
  24682. */
  24683. subdivide(count: number): void;
  24684. /**
  24685. * Copy a FloatArray into a specific associated vertex buffer
  24686. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24687. * - VertexBuffer.PositionKind
  24688. * - VertexBuffer.UVKind
  24689. * - VertexBuffer.UV2Kind
  24690. * - VertexBuffer.UV3Kind
  24691. * - VertexBuffer.UV4Kind
  24692. * - VertexBuffer.UV5Kind
  24693. * - VertexBuffer.UV6Kind
  24694. * - VertexBuffer.ColorKind
  24695. * - VertexBuffer.MatricesIndicesKind
  24696. * - VertexBuffer.MatricesIndicesExtraKind
  24697. * - VertexBuffer.MatricesWeightsKind
  24698. * - VertexBuffer.MatricesWeightsExtraKind
  24699. * @param data defines the data source
  24700. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24701. * @param stride defines the data stride size (can be null)
  24702. * @returns the current mesh
  24703. */
  24704. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24705. /**
  24706. * Flags an associated vertex buffer as updatable
  24707. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24708. * - VertexBuffer.PositionKind
  24709. * - VertexBuffer.UVKind
  24710. * - VertexBuffer.UV2Kind
  24711. * - VertexBuffer.UV3Kind
  24712. * - VertexBuffer.UV4Kind
  24713. * - VertexBuffer.UV5Kind
  24714. * - VertexBuffer.UV6Kind
  24715. * - VertexBuffer.ColorKind
  24716. * - VertexBuffer.MatricesIndicesKind
  24717. * - VertexBuffer.MatricesIndicesExtraKind
  24718. * - VertexBuffer.MatricesWeightsKind
  24719. * - VertexBuffer.MatricesWeightsExtraKind
  24720. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24721. */
  24722. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24723. /**
  24724. * Sets the mesh global Vertex Buffer
  24725. * @param buffer defines the buffer to use
  24726. * @returns the current mesh
  24727. */
  24728. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24729. /**
  24730. * Update a specific associated vertex buffer
  24731. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24732. * - VertexBuffer.PositionKind
  24733. * - VertexBuffer.UVKind
  24734. * - VertexBuffer.UV2Kind
  24735. * - VertexBuffer.UV3Kind
  24736. * - VertexBuffer.UV4Kind
  24737. * - VertexBuffer.UV5Kind
  24738. * - VertexBuffer.UV6Kind
  24739. * - VertexBuffer.ColorKind
  24740. * - VertexBuffer.MatricesIndicesKind
  24741. * - VertexBuffer.MatricesIndicesExtraKind
  24742. * - VertexBuffer.MatricesWeightsKind
  24743. * - VertexBuffer.MatricesWeightsExtraKind
  24744. * @param data defines the data source
  24745. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24746. * @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)
  24747. * @returns the current mesh
  24748. */
  24749. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24750. /**
  24751. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24752. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24753. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24754. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24755. * @returns the current mesh
  24756. */
  24757. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24758. /**
  24759. * Creates a un-shared specific occurence of the geometry for the mesh.
  24760. * @returns the current mesh
  24761. */
  24762. makeGeometryUnique(): Mesh;
  24763. /**
  24764. * Set the index buffer of this mesh
  24765. * @param indices defines the source data
  24766. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24767. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24768. * @returns the current mesh
  24769. */
  24770. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24771. /**
  24772. * Update the current index buffer
  24773. * @param indices defines the source data
  24774. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24775. * @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)
  24776. * @returns the current mesh
  24777. */
  24778. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24779. /**
  24780. * Invert the geometry to move from a right handed system to a left handed one.
  24781. * @returns the current mesh
  24782. */
  24783. toLeftHanded(): Mesh;
  24784. /** @hidden */
  24785. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24786. /** @hidden */
  24787. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24788. /**
  24789. * Registers for this mesh a javascript function called just before the rendering process
  24790. * @param func defines the function to call before rendering this mesh
  24791. * @returns the current mesh
  24792. */
  24793. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24794. /**
  24795. * Disposes a previously registered javascript function called before the rendering
  24796. * @param func defines the function to remove
  24797. * @returns the current mesh
  24798. */
  24799. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24800. /**
  24801. * Registers for this mesh a javascript function called just after the rendering is complete
  24802. * @param func defines the function to call after rendering this mesh
  24803. * @returns the current mesh
  24804. */
  24805. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24806. /**
  24807. * Disposes a previously registered javascript function called after the rendering.
  24808. * @param func defines the function to remove
  24809. * @returns the current mesh
  24810. */
  24811. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24812. /** @hidden */
  24813. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24814. /** @hidden */
  24815. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24816. /** @hidden */
  24817. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24818. /** @hidden */
  24819. _rebuild(): void;
  24820. /** @hidden */
  24821. _freeze(): void;
  24822. /** @hidden */
  24823. _unFreeze(): void;
  24824. /**
  24825. * 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
  24826. * @param subMesh defines the subMesh to render
  24827. * @param enableAlphaMode defines if alpha mode can be changed
  24828. * @returns the current mesh
  24829. */
  24830. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24831. private _onBeforeDraw;
  24832. /**
  24833. * Renormalize the mesh and patch it up if there are no weights
  24834. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24835. * However in the case of zero weights then we set just a single influence to 1.
  24836. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24837. */
  24838. cleanMatrixWeights(): void;
  24839. private normalizeSkinFourWeights;
  24840. private normalizeSkinWeightsAndExtra;
  24841. /**
  24842. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24843. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24844. * the user know there was an issue with importing the mesh
  24845. * @returns a validation object with skinned, valid and report string
  24846. */
  24847. validateSkinning(): {
  24848. skinned: boolean;
  24849. valid: boolean;
  24850. report: string;
  24851. };
  24852. /** @hidden */
  24853. _checkDelayState(): Mesh;
  24854. private _queueLoad;
  24855. /**
  24856. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24857. * A mesh is in the frustum if its bounding box intersects the frustum
  24858. * @param frustumPlanes defines the frustum to test
  24859. * @returns true if the mesh is in the frustum planes
  24860. */
  24861. isInFrustum(frustumPlanes: Plane[]): boolean;
  24862. /**
  24863. * Sets the mesh material by the material or multiMaterial `id` property
  24864. * @param id is a string identifying the material or the multiMaterial
  24865. * @returns the current mesh
  24866. */
  24867. setMaterialByID(id: string): Mesh;
  24868. /**
  24869. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24870. * @returns an array of IAnimatable
  24871. */
  24872. getAnimatables(): IAnimatable[];
  24873. /**
  24874. * Modifies the mesh geometry according to the passed transformation matrix.
  24875. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24876. * The mesh normals are modified using the same transformation.
  24877. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24878. * @param transform defines the transform matrix to use
  24879. * @see http://doc.babylonjs.com/resources/baking_transformations
  24880. * @returns the current mesh
  24881. */
  24882. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24883. /**
  24884. * Modifies the mesh geometry according to its own current World Matrix.
  24885. * The mesh World Matrix is then reset.
  24886. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24887. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24888. * @see http://doc.babylonjs.com/resources/baking_transformations
  24889. * @returns the current mesh
  24890. */
  24891. bakeCurrentTransformIntoVertices(): Mesh;
  24892. /** @hidden */
  24893. readonly _positions: Nullable<Vector3[]>;
  24894. /** @hidden */
  24895. _resetPointsArrayCache(): Mesh;
  24896. /** @hidden */
  24897. _generatePointsArray(): boolean;
  24898. /**
  24899. * Returns a new Mesh object generated from the current mesh properties.
  24900. * This method must not get confused with createInstance()
  24901. * @param name is a string, the name given to the new mesh
  24902. * @param newParent can be any Node object (default `null`)
  24903. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24904. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24905. * @returns a new mesh
  24906. */
  24907. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24908. /**
  24909. * Releases resources associated with this mesh.
  24910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24912. */
  24913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24914. /**
  24915. * Modifies the mesh geometry according to a displacement map.
  24916. * 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.
  24917. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24918. * @param url is a string, the URL from the image file is to be downloaded.
  24919. * @param minHeight is the lower limit of the displacement.
  24920. * @param maxHeight is the upper limit of the displacement.
  24921. * @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.
  24922. * @param uvOffset is an optional vector2 used to offset UV.
  24923. * @param uvScale is an optional vector2 used to scale UV.
  24924. * @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.
  24925. * @returns the Mesh.
  24926. */
  24927. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24928. /**
  24929. * Modifies the mesh geometry according to a displacementMap buffer.
  24930. * 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.
  24931. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24932. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24933. * @param heightMapWidth is the width of the buffer image.
  24934. * @param heightMapHeight is the height of the buffer image.
  24935. * @param minHeight is the lower limit of the displacement.
  24936. * @param maxHeight is the upper limit of the displacement.
  24937. * @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.
  24938. * @param uvOffset is an optional vector2 used to offset UV.
  24939. * @param uvScale is an optional vector2 used to scale UV.
  24940. * @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.
  24941. * @returns the Mesh.
  24942. */
  24943. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24944. /**
  24945. * Modify the mesh to get a flat shading rendering.
  24946. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24947. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24948. * @returns current mesh
  24949. */
  24950. convertToFlatShadedMesh(): Mesh;
  24951. /**
  24952. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24953. * In other words, more vertices, no more indices and a single bigger VBO.
  24954. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24955. * @returns current mesh
  24956. */
  24957. convertToUnIndexedMesh(): Mesh;
  24958. /**
  24959. * Inverses facet orientations.
  24960. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24961. * @param flipNormals will also inverts the normals
  24962. * @returns current mesh
  24963. */
  24964. flipFaces(flipNormals?: boolean): Mesh;
  24965. /**
  24966. * Increase the number of facets and hence vertices in a mesh
  24967. * Vertex normals are interpolated from existing vertex normals
  24968. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24969. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24970. */
  24971. increaseVertices(numberPerEdge: number): void;
  24972. /**
  24973. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24974. * This will undo any application of covertToFlatShadedMesh
  24975. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24976. */
  24977. forceSharedVertices(): void;
  24978. /** @hidden */
  24979. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24980. /** @hidden */
  24981. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24982. /**
  24983. * Creates a new InstancedMesh object from the mesh model.
  24984. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24985. * @param name defines the name of the new instance
  24986. * @returns a new InstancedMesh
  24987. */
  24988. createInstance(name: string): InstancedMesh;
  24989. /**
  24990. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24991. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24992. * @returns the current mesh
  24993. */
  24994. synchronizeInstances(): Mesh;
  24995. /**
  24996. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24997. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24998. * This should be used together with the simplification to avoid disappearing triangles.
  24999. * @param successCallback an optional success callback to be called after the optimization finished.
  25000. * @returns the current mesh
  25001. */
  25002. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25003. /**
  25004. * Serialize current mesh
  25005. * @param serializationObject defines the object which will receive the serialization data
  25006. */
  25007. serialize(serializationObject: any): void;
  25008. /** @hidden */
  25009. _syncGeometryWithMorphTargetManager(): void;
  25010. /** @hidden */
  25011. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25012. /**
  25013. * Returns a new Mesh object parsed from the source provided.
  25014. * @param parsedMesh is the source
  25015. * @param scene defines the hosting scene
  25016. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25017. * @returns a new Mesh
  25018. */
  25019. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25020. /**
  25021. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25022. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25023. * @param name defines the name of the mesh to create
  25024. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25025. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25026. * @param closePath creates a seam between the first and the last points of each path of the path array
  25027. * @param offset is taken in account only if the `pathArray` is containing a single path
  25028. * @param scene defines the hosting scene
  25029. * @param updatable defines if the mesh must be flagged as updatable
  25030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25031. * @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)
  25032. * @returns a new Mesh
  25033. */
  25034. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25035. /**
  25036. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25037. * @param name defines the name of the mesh to create
  25038. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25039. * @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
  25040. * @param scene defines the hosting scene
  25041. * @param updatable defines if the mesh must be flagged as updatable
  25042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25043. * @returns a new Mesh
  25044. */
  25045. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25046. /**
  25047. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25048. * @param name defines the name of the mesh to create
  25049. * @param size sets the size (float) of each box side (default 1)
  25050. * @param scene defines the hosting scene
  25051. * @param updatable defines if the mesh must be flagged as updatable
  25052. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25053. * @returns a new Mesh
  25054. */
  25055. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25056. /**
  25057. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25058. * @param name defines the name of the mesh to create
  25059. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25060. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25061. * @param scene defines the hosting scene
  25062. * @param updatable defines if the mesh must be flagged as updatable
  25063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25067. /**
  25068. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25069. * @param name defines the name of the mesh to create
  25070. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25071. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25072. * @param scene defines the hosting scene
  25073. * @returns a new Mesh
  25074. */
  25075. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25076. /**
  25077. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25078. * @param name defines the name of the mesh to create
  25079. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25080. * @param diameterTop set the top cap diameter (floats, default 1)
  25081. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25082. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25083. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25087. * @returns a new Mesh
  25088. */
  25089. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25090. /**
  25091. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25092. * @param name defines the name of the mesh to create
  25093. * @param diameter sets the diameter size (float) of the torus (default 1)
  25094. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25095. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25096. * @param scene defines the hosting scene
  25097. * @param updatable defines if the mesh must be flagged as updatable
  25098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25099. * @returns a new Mesh
  25100. */
  25101. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25102. /**
  25103. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25104. * @param name defines the name of the mesh to create
  25105. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25106. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25107. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25108. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25109. * @param p the number of windings on X axis (positive integers, default 2)
  25110. * @param q the number of windings on Y axis (positive integers, default 3)
  25111. * @param scene defines the hosting scene
  25112. * @param updatable defines if the mesh must be flagged as updatable
  25113. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25114. * @returns a new Mesh
  25115. */
  25116. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25117. /**
  25118. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25119. * @param name defines the name of the mesh to create
  25120. * @param points is an array successive Vector3
  25121. * @param scene defines the hosting scene
  25122. * @param updatable defines if the mesh must be flagged as updatable
  25123. * @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).
  25124. * @returns a new Mesh
  25125. */
  25126. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25127. /**
  25128. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25129. * @param name defines the name of the mesh to create
  25130. * @param points is an array successive Vector3
  25131. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25132. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25133. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25134. * @param scene defines the hosting scene
  25135. * @param updatable defines if the mesh must be flagged as updatable
  25136. * @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)
  25137. * @returns a new Mesh
  25138. */
  25139. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25140. /**
  25141. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25142. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25143. * 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.
  25144. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25145. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25146. * Remember you can only change the shape positions, not their number when updating a polygon.
  25147. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25148. * @param name defines the name of the mesh to create
  25149. * @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
  25150. * @param scene defines the hosting scene
  25151. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25152. * @param updatable defines if the mesh must be flagged as updatable
  25153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25154. * @param earcutInjection can be used to inject your own earcut reference
  25155. * @returns a new Mesh
  25156. */
  25157. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25158. /**
  25159. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25160. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25161. * @param name defines the name of the mesh to create
  25162. * @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
  25163. * @param depth defines the height of extrusion
  25164. * @param scene defines the hosting scene
  25165. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25166. * @param updatable defines if the mesh must be flagged as updatable
  25167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25168. * @param earcutInjection can be used to inject your own earcut reference
  25169. * @returns a new Mesh
  25170. */
  25171. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25172. /**
  25173. * Creates an extruded shape mesh.
  25174. * 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
  25175. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25176. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25177. * @param name defines the name of the mesh to create
  25178. * @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
  25179. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25180. * @param scale is the value to scale the shape
  25181. * @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
  25182. * @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
  25183. * @param scene defines the hosting scene
  25184. * @param updatable defines if the mesh must be flagged as updatable
  25185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25186. * @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)
  25187. * @returns a new Mesh
  25188. */
  25189. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25190. /**
  25191. * Creates an custom extruded shape mesh.
  25192. * The custom extrusion is a parametric shape.
  25193. * It has no predefined shape. Its final shape will depend on the input parameters.
  25194. * Please consider using the same method from the MeshBuilder class instead
  25195. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25196. * @param name defines the name of the mesh to create
  25197. * @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
  25198. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25199. * @param scaleFunction is a custom Javascript function called on each path point
  25200. * @param rotationFunction is a custom Javascript function called on each path point
  25201. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25202. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25203. * @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
  25204. * @param scene defines the hosting scene
  25205. * @param updatable defines if the mesh must be flagged as updatable
  25206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25207. * @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)
  25208. * @returns a new Mesh
  25209. */
  25210. 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;
  25211. /**
  25212. * Creates lathe mesh.
  25213. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25214. * Please consider using the same method from the MeshBuilder class instead
  25215. * @param name defines the name of the mesh to create
  25216. * @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
  25217. * @param radius is the radius value of the lathe
  25218. * @param tessellation is the side number of the lathe.
  25219. * @param scene defines the hosting scene
  25220. * @param updatable defines if the mesh must be flagged as updatable
  25221. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25222. * @returns a new Mesh
  25223. */
  25224. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25225. /**
  25226. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25227. * @param name defines the name of the mesh to create
  25228. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25229. * @param scene defines the hosting scene
  25230. * @param updatable defines if the mesh must be flagged as updatable
  25231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25232. * @returns a new Mesh
  25233. */
  25234. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25235. /**
  25236. * Creates a ground mesh.
  25237. * Please consider using the same method from the MeshBuilder class instead
  25238. * @param name defines the name of the mesh to create
  25239. * @param width set the width of the ground
  25240. * @param height set the height of the ground
  25241. * @param subdivisions sets the number of subdivisions per side
  25242. * @param scene defines the hosting scene
  25243. * @param updatable defines if the mesh must be flagged as updatable
  25244. * @returns a new Mesh
  25245. */
  25246. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25247. /**
  25248. * Creates a tiled ground mesh.
  25249. * Please consider using the same method from the MeshBuilder class instead
  25250. * @param name defines the name of the mesh to create
  25251. * @param xmin set the ground minimum X coordinate
  25252. * @param zmin set the ground minimum Y coordinate
  25253. * @param xmax set the ground maximum X coordinate
  25254. * @param zmax set the ground maximum Z coordinate
  25255. * @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
  25256. * @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
  25257. * @param scene defines the hosting scene
  25258. * @param updatable defines if the mesh must be flagged as updatable
  25259. * @returns a new Mesh
  25260. */
  25261. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25262. w: number;
  25263. h: number;
  25264. }, precision: {
  25265. w: number;
  25266. h: number;
  25267. }, scene: Scene, updatable?: boolean): Mesh;
  25268. /**
  25269. * Creates a ground mesh from a height map.
  25270. * Please consider using the same method from the MeshBuilder class instead
  25271. * @see http://doc.babylonjs.com/babylon101/height_map
  25272. * @param name defines the name of the mesh to create
  25273. * @param url sets the URL of the height map image resource
  25274. * @param width set the ground width size
  25275. * @param height set the ground height size
  25276. * @param subdivisions sets the number of subdivision per side
  25277. * @param minHeight is the minimum altitude on the ground
  25278. * @param maxHeight is the maximum altitude on the ground
  25279. * @param scene defines the hosting scene
  25280. * @param updatable defines if the mesh must be flagged as updatable
  25281. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25282. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25283. * @returns a new Mesh
  25284. */
  25285. 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;
  25286. /**
  25287. * Creates a tube mesh.
  25288. * The tube is a parametric shape.
  25289. * It has no predefined shape. Its final shape will depend on the input parameters.
  25290. * Please consider using the same method from the MeshBuilder class instead
  25291. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25292. * @param name defines the name of the mesh to create
  25293. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25294. * @param radius sets the tube radius size
  25295. * @param tessellation is the number of sides on the tubular surface
  25296. * @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
  25297. * @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
  25298. * @param scene defines the hosting scene
  25299. * @param updatable defines if the mesh must be flagged as updatable
  25300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25301. * @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)
  25302. * @returns a new Mesh
  25303. */
  25304. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25305. (i: number, distance: number): number;
  25306. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25307. /**
  25308. * Creates a polyhedron mesh.
  25309. * Please consider using the same method from the MeshBuilder class instead.
  25310. * * 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
  25311. * * The parameter `size` (positive float, default 1) sets the polygon size
  25312. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25313. * * 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`
  25314. * * 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
  25315. * * 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)`)
  25316. * * 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
  25317. * * 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
  25318. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25319. * * If you create a double-sided mesh, you can choose what parts of 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
  25320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25321. * @param name defines the name of the mesh to create
  25322. * @param options defines the options used to create the mesh
  25323. * @param scene defines the hosting scene
  25324. * @returns a new Mesh
  25325. */
  25326. static CreatePolyhedron(name: string, options: {
  25327. type?: number;
  25328. size?: number;
  25329. sizeX?: number;
  25330. sizeY?: number;
  25331. sizeZ?: number;
  25332. custom?: any;
  25333. faceUV?: Vector4[];
  25334. faceColors?: Color4[];
  25335. updatable?: boolean;
  25336. sideOrientation?: number;
  25337. }, scene: Scene): Mesh;
  25338. /**
  25339. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25340. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25341. * * 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`)
  25342. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25343. * * 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
  25344. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25345. * * If you create a double-sided mesh, you can choose what parts of 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
  25346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25347. * @param name defines the name of the mesh
  25348. * @param options defines the options used to create the mesh
  25349. * @param scene defines the hosting scene
  25350. * @returns a new Mesh
  25351. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25352. */
  25353. static CreateIcoSphere(name: string, options: {
  25354. radius?: number;
  25355. flat?: boolean;
  25356. subdivisions?: number;
  25357. sideOrientation?: number;
  25358. updatable?: boolean;
  25359. }, scene: Scene): Mesh;
  25360. /**
  25361. * Creates a decal mesh.
  25362. * Please consider using the same method from the MeshBuilder class instead.
  25363. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25364. * @param name defines the name of the mesh
  25365. * @param sourceMesh defines the mesh receiving the decal
  25366. * @param position sets the position of the decal in world coordinates
  25367. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25368. * @param size sets the decal scaling
  25369. * @param angle sets the angle to rotate the decal
  25370. * @returns a new Mesh
  25371. */
  25372. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25373. /**
  25374. * Prepare internal position array for software CPU skinning
  25375. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25376. */
  25377. setPositionsForCPUSkinning(): Float32Array;
  25378. /**
  25379. * Prepare internal normal array for software CPU skinning
  25380. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25381. */
  25382. setNormalsForCPUSkinning(): Float32Array;
  25383. /**
  25384. * Updates the vertex buffer by applying transformation from the bones
  25385. * @param skeleton defines the skeleton to apply to current mesh
  25386. * @returns the current mesh
  25387. */
  25388. applySkeleton(skeleton: Skeleton): Mesh;
  25389. /**
  25390. * 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
  25391. * @param meshes defines the list of meshes to scan
  25392. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25393. */
  25394. static MinMax(meshes: AbstractMesh[]): {
  25395. min: Vector3;
  25396. max: Vector3;
  25397. };
  25398. /**
  25399. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25400. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25401. * @returns a vector3
  25402. */
  25403. static Center(meshesOrMinMaxVector: {
  25404. min: Vector3;
  25405. max: Vector3;
  25406. } | AbstractMesh[]): Vector3;
  25407. /**
  25408. * Merge the array of meshes into a single mesh for performance reasons.
  25409. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25410. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25411. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25412. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25413. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25414. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25415. * @returns a new mesh
  25416. */
  25417. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25418. /** @hidden */
  25419. addInstance(instance: InstancedMesh): void;
  25420. /** @hidden */
  25421. removeInstance(instance: InstancedMesh): void;
  25422. }
  25423. }
  25424. declare module "babylonjs/Cameras/camera" {
  25425. import { SmartArray } from "babylonjs/Misc/smartArray";
  25426. import { Observable } from "babylonjs/Misc/observable";
  25427. import { Nullable } from "babylonjs/types";
  25428. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25429. import { Scene } from "babylonjs/scene";
  25430. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25431. import { Node } from "babylonjs/node";
  25432. import { Mesh } from "babylonjs/Meshes/mesh";
  25433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25434. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25435. import { Viewport } from "babylonjs/Maths/math.viewport";
  25436. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25438. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25439. import { Ray } from "babylonjs/Culling/ray";
  25440. /**
  25441. * This is the base class of all the camera used in the application.
  25442. * @see http://doc.babylonjs.com/features/cameras
  25443. */
  25444. export class Camera extends Node {
  25445. /** @hidden */
  25446. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25447. /**
  25448. * This is the default projection mode used by the cameras.
  25449. * It helps recreating a feeling of perspective and better appreciate depth.
  25450. * This is the best way to simulate real life cameras.
  25451. */
  25452. static readonly PERSPECTIVE_CAMERA: number;
  25453. /**
  25454. * This helps creating camera with an orthographic mode.
  25455. * 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.
  25456. */
  25457. static readonly ORTHOGRAPHIC_CAMERA: number;
  25458. /**
  25459. * This is the default FOV mode for perspective cameras.
  25460. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25461. */
  25462. static readonly FOVMODE_VERTICAL_FIXED: number;
  25463. /**
  25464. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25465. */
  25466. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25467. /**
  25468. * This specifies ther is no need for a camera rig.
  25469. * Basically only one eye is rendered corresponding to the camera.
  25470. */
  25471. static readonly RIG_MODE_NONE: number;
  25472. /**
  25473. * Simulates a camera Rig with one blue eye and one red eye.
  25474. * This can be use with 3d blue and red glasses.
  25475. */
  25476. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25477. /**
  25478. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25479. */
  25480. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25481. /**
  25482. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25483. */
  25484. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25485. /**
  25486. * Defines that both eyes of the camera will be rendered over under each other.
  25487. */
  25488. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25489. /**
  25490. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25491. */
  25492. static readonly RIG_MODE_VR: number;
  25493. /**
  25494. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25495. */
  25496. static readonly RIG_MODE_WEBVR: number;
  25497. /**
  25498. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25499. */
  25500. static readonly RIG_MODE_CUSTOM: number;
  25501. /**
  25502. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25503. */
  25504. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25505. /**
  25506. * Define the input manager associated with the camera.
  25507. */
  25508. inputs: CameraInputsManager<Camera>;
  25509. /** @hidden */
  25510. _position: Vector3;
  25511. /**
  25512. * Define the current local position of the camera in the scene
  25513. */
  25514. position: Vector3;
  25515. /**
  25516. * The vector the camera should consider as up.
  25517. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25518. */
  25519. upVector: Vector3;
  25520. /**
  25521. * Define the current limit on the left side for an orthographic camera
  25522. * In scene unit
  25523. */
  25524. orthoLeft: Nullable<number>;
  25525. /**
  25526. * Define the current limit on the right side for an orthographic camera
  25527. * In scene unit
  25528. */
  25529. orthoRight: Nullable<number>;
  25530. /**
  25531. * Define the current limit on the bottom side for an orthographic camera
  25532. * In scene unit
  25533. */
  25534. orthoBottom: Nullable<number>;
  25535. /**
  25536. * Define the current limit on the top side for an orthographic camera
  25537. * In scene unit
  25538. */
  25539. orthoTop: Nullable<number>;
  25540. /**
  25541. * Field Of View is set in Radians. (default is 0.8)
  25542. */
  25543. fov: number;
  25544. /**
  25545. * Define the minimum distance the camera can see from.
  25546. * This is important to note that the depth buffer are not infinite and the closer it starts
  25547. * the more your scene might encounter depth fighting issue.
  25548. */
  25549. minZ: number;
  25550. /**
  25551. * Define the maximum distance the camera can see to.
  25552. * This is important to note that the depth buffer are not infinite and the further it end
  25553. * the more your scene might encounter depth fighting issue.
  25554. */
  25555. maxZ: number;
  25556. /**
  25557. * Define the default inertia of the camera.
  25558. * This helps giving a smooth feeling to the camera movement.
  25559. */
  25560. inertia: number;
  25561. /**
  25562. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25563. */
  25564. mode: number;
  25565. /**
  25566. * Define wether the camera is intermediate.
  25567. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25568. */
  25569. isIntermediate: boolean;
  25570. /**
  25571. * Define the viewport of the camera.
  25572. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25573. */
  25574. viewport: Viewport;
  25575. /**
  25576. * Restricts the camera to viewing objects with the same layerMask.
  25577. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25578. */
  25579. layerMask: number;
  25580. /**
  25581. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25582. */
  25583. fovMode: number;
  25584. /**
  25585. * Rig mode of the camera.
  25586. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25587. * This is normally controlled byt the camera themselves as internal use.
  25588. */
  25589. cameraRigMode: number;
  25590. /**
  25591. * Defines the distance between both "eyes" in case of a RIG
  25592. */
  25593. interaxialDistance: number;
  25594. /**
  25595. * Defines if stereoscopic rendering is done side by side or over under.
  25596. */
  25597. isStereoscopicSideBySide: boolean;
  25598. /**
  25599. * 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
  25600. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25601. * else in the scene. (Eg. security camera)
  25602. *
  25603. * 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)
  25604. */
  25605. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25606. /**
  25607. * When set, the camera will render to this render target instead of the default canvas
  25608. *
  25609. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25610. */
  25611. outputRenderTarget: Nullable<RenderTargetTexture>;
  25612. /**
  25613. * Observable triggered when the camera view matrix has changed.
  25614. */
  25615. onViewMatrixChangedObservable: Observable<Camera>;
  25616. /**
  25617. * Observable triggered when the camera Projection matrix has changed.
  25618. */
  25619. onProjectionMatrixChangedObservable: Observable<Camera>;
  25620. /**
  25621. * Observable triggered when the inputs have been processed.
  25622. */
  25623. onAfterCheckInputsObservable: Observable<Camera>;
  25624. /**
  25625. * Observable triggered when reset has been called and applied to the camera.
  25626. */
  25627. onRestoreStateObservable: Observable<Camera>;
  25628. /** @hidden */
  25629. _cameraRigParams: any;
  25630. /** @hidden */
  25631. _rigCameras: Camera[];
  25632. /** @hidden */
  25633. _rigPostProcess: Nullable<PostProcess>;
  25634. protected _webvrViewMatrix: Matrix;
  25635. /** @hidden */
  25636. _skipRendering: boolean;
  25637. /** @hidden */
  25638. _projectionMatrix: Matrix;
  25639. /** @hidden */
  25640. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25641. /** @hidden */
  25642. _activeMeshes: SmartArray<AbstractMesh>;
  25643. protected _globalPosition: Vector3;
  25644. /** @hidden */
  25645. _computedViewMatrix: Matrix;
  25646. private _doNotComputeProjectionMatrix;
  25647. private _transformMatrix;
  25648. private _frustumPlanes;
  25649. private _refreshFrustumPlanes;
  25650. private _storedFov;
  25651. private _stateStored;
  25652. /**
  25653. * Instantiates a new camera object.
  25654. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25655. * @see http://doc.babylonjs.com/features/cameras
  25656. * @param name Defines the name of the camera in the scene
  25657. * @param position Defines the position of the camera
  25658. * @param scene Defines the scene the camera belongs too
  25659. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25660. */
  25661. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25662. /**
  25663. * Store current camera state (fov, position, etc..)
  25664. * @returns the camera
  25665. */
  25666. storeState(): Camera;
  25667. /**
  25668. * Restores the camera state values if it has been stored. You must call storeState() first
  25669. */
  25670. protected _restoreStateValues(): boolean;
  25671. /**
  25672. * Restored camera state. You must call storeState() first.
  25673. * @returns true if restored and false otherwise
  25674. */
  25675. restoreState(): boolean;
  25676. /**
  25677. * Gets the class name of the camera.
  25678. * @returns the class name
  25679. */
  25680. getClassName(): string;
  25681. /** @hidden */
  25682. readonly _isCamera: boolean;
  25683. /**
  25684. * Gets a string representation of the camera useful for debug purpose.
  25685. * @param fullDetails Defines that a more verboe level of logging is required
  25686. * @returns the string representation
  25687. */
  25688. toString(fullDetails?: boolean): string;
  25689. /**
  25690. * Gets the current world space position of the camera.
  25691. */
  25692. readonly globalPosition: Vector3;
  25693. /**
  25694. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25695. * @returns the active meshe list
  25696. */
  25697. getActiveMeshes(): SmartArray<AbstractMesh>;
  25698. /**
  25699. * Check wether a mesh is part of the current active mesh list of the camera
  25700. * @param mesh Defines the mesh to check
  25701. * @returns true if active, false otherwise
  25702. */
  25703. isActiveMesh(mesh: Mesh): boolean;
  25704. /**
  25705. * Is this camera ready to be used/rendered
  25706. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25707. * @return true if the camera is ready
  25708. */
  25709. isReady(completeCheck?: boolean): boolean;
  25710. /** @hidden */
  25711. _initCache(): void;
  25712. /** @hidden */
  25713. _updateCache(ignoreParentClass?: boolean): void;
  25714. /** @hidden */
  25715. _isSynchronized(): boolean;
  25716. /** @hidden */
  25717. _isSynchronizedViewMatrix(): boolean;
  25718. /** @hidden */
  25719. _isSynchronizedProjectionMatrix(): boolean;
  25720. /**
  25721. * Attach the input controls to a specific dom element to get the input from.
  25722. * @param element Defines the element the controls should be listened from
  25723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25724. */
  25725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25726. /**
  25727. * Detach the current controls from the specified dom element.
  25728. * @param element Defines the element to stop listening the inputs from
  25729. */
  25730. detachControl(element: HTMLElement): void;
  25731. /**
  25732. * Update the camera state according to the different inputs gathered during the frame.
  25733. */
  25734. update(): void;
  25735. /** @hidden */
  25736. _checkInputs(): void;
  25737. /** @hidden */
  25738. readonly rigCameras: Camera[];
  25739. /**
  25740. * Gets the post process used by the rig cameras
  25741. */
  25742. readonly rigPostProcess: Nullable<PostProcess>;
  25743. /**
  25744. * Internal, gets the first post proces.
  25745. * @returns the first post process to be run on this camera.
  25746. */
  25747. _getFirstPostProcess(): Nullable<PostProcess>;
  25748. private _cascadePostProcessesToRigCams;
  25749. /**
  25750. * Attach a post process to the camera.
  25751. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25752. * @param postProcess The post process to attach to the camera
  25753. * @param insertAt The position of the post process in case several of them are in use in the scene
  25754. * @returns the position the post process has been inserted at
  25755. */
  25756. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25757. /**
  25758. * Detach a post process to the camera.
  25759. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25760. * @param postProcess The post process to detach from the camera
  25761. */
  25762. detachPostProcess(postProcess: PostProcess): void;
  25763. /**
  25764. * Gets the current world matrix of the camera
  25765. */
  25766. getWorldMatrix(): Matrix;
  25767. /** @hidden */
  25768. _getViewMatrix(): Matrix;
  25769. /**
  25770. * Gets the current view matrix of the camera.
  25771. * @param force forces the camera to recompute the matrix without looking at the cached state
  25772. * @returns the view matrix
  25773. */
  25774. getViewMatrix(force?: boolean): Matrix;
  25775. /**
  25776. * Freeze the projection matrix.
  25777. * It will prevent the cache check of the camera projection compute and can speed up perf
  25778. * if no parameter of the camera are meant to change
  25779. * @param projection Defines manually a projection if necessary
  25780. */
  25781. freezeProjectionMatrix(projection?: Matrix): void;
  25782. /**
  25783. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25784. */
  25785. unfreezeProjectionMatrix(): void;
  25786. /**
  25787. * Gets the current projection matrix of the camera.
  25788. * @param force forces the camera to recompute the matrix without looking at the cached state
  25789. * @returns the projection matrix
  25790. */
  25791. getProjectionMatrix(force?: boolean): Matrix;
  25792. /**
  25793. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25794. * @returns a Matrix
  25795. */
  25796. getTransformationMatrix(): Matrix;
  25797. private _updateFrustumPlanes;
  25798. /**
  25799. * Checks if a cullable object (mesh...) is in the camera frustum
  25800. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25801. * @param target The object to check
  25802. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25803. * @returns true if the object is in frustum otherwise false
  25804. */
  25805. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25806. /**
  25807. * Checks if a cullable object (mesh...) is in the camera frustum
  25808. * Unlike isInFrustum this cheks the full bounding box
  25809. * @param target The object to check
  25810. * @returns true if the object is in frustum otherwise false
  25811. */
  25812. isCompletelyInFrustum(target: ICullable): boolean;
  25813. /**
  25814. * Gets a ray in the forward direction from the camera.
  25815. * @param length Defines the length of the ray to create
  25816. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25817. * @param origin Defines the start point of the ray which defaults to the camera position
  25818. * @returns the forward ray
  25819. */
  25820. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25821. /**
  25822. * Releases resources associated with this node.
  25823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25825. */
  25826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25827. /** @hidden */
  25828. _isLeftCamera: boolean;
  25829. /**
  25830. * Gets the left camera of a rig setup in case of Rigged Camera
  25831. */
  25832. readonly isLeftCamera: boolean;
  25833. /** @hidden */
  25834. _isRightCamera: boolean;
  25835. /**
  25836. * Gets the right camera of a rig setup in case of Rigged Camera
  25837. */
  25838. readonly isRightCamera: boolean;
  25839. /**
  25840. * Gets the left camera of a rig setup in case of Rigged Camera
  25841. */
  25842. readonly leftCamera: Nullable<FreeCamera>;
  25843. /**
  25844. * Gets the right camera of a rig setup in case of Rigged Camera
  25845. */
  25846. readonly rightCamera: Nullable<FreeCamera>;
  25847. /**
  25848. * Gets the left camera target of a rig setup in case of Rigged Camera
  25849. * @returns the target position
  25850. */
  25851. getLeftTarget(): Nullable<Vector3>;
  25852. /**
  25853. * Gets the right camera target of a rig setup in case of Rigged Camera
  25854. * @returns the target position
  25855. */
  25856. getRightTarget(): Nullable<Vector3>;
  25857. /**
  25858. * @hidden
  25859. */
  25860. setCameraRigMode(mode: number, rigParams: any): void;
  25861. /** @hidden */
  25862. static _setStereoscopicRigMode(camera: Camera): void;
  25863. /** @hidden */
  25864. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25865. /** @hidden */
  25866. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25867. /** @hidden */
  25868. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25869. /** @hidden */
  25870. _getVRProjectionMatrix(): Matrix;
  25871. protected _updateCameraRotationMatrix(): void;
  25872. protected _updateWebVRCameraRotationMatrix(): void;
  25873. /**
  25874. * This function MUST be overwritten by the different WebVR cameras available.
  25875. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25876. * @hidden
  25877. */
  25878. _getWebVRProjectionMatrix(): Matrix;
  25879. /**
  25880. * This function MUST be overwritten by the different WebVR cameras available.
  25881. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25882. * @hidden
  25883. */
  25884. _getWebVRViewMatrix(): Matrix;
  25885. /** @hidden */
  25886. setCameraRigParameter(name: string, value: any): void;
  25887. /**
  25888. * needs to be overridden by children so sub has required properties to be copied
  25889. * @hidden
  25890. */
  25891. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25892. /**
  25893. * May need to be overridden by children
  25894. * @hidden
  25895. */
  25896. _updateRigCameras(): void;
  25897. /** @hidden */
  25898. _setupInputs(): void;
  25899. /**
  25900. * Serialiaze the camera setup to a json represention
  25901. * @returns the JSON representation
  25902. */
  25903. serialize(): any;
  25904. /**
  25905. * Clones the current camera.
  25906. * @param name The cloned camera name
  25907. * @returns the cloned camera
  25908. */
  25909. clone(name: string): Camera;
  25910. /**
  25911. * Gets the direction of the camera relative to a given local axis.
  25912. * @param localAxis Defines the reference axis to provide a relative direction.
  25913. * @return the direction
  25914. */
  25915. getDirection(localAxis: Vector3): Vector3;
  25916. /**
  25917. * Returns the current camera absolute rotation
  25918. */
  25919. readonly absoluteRotation: Quaternion;
  25920. /**
  25921. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25922. * @param localAxis Defines the reference axis to provide a relative direction.
  25923. * @param result Defines the vector to store the result in
  25924. */
  25925. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25926. /**
  25927. * Gets a camera constructor for a given camera type
  25928. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25929. * @param name The name of the camera the result will be able to instantiate
  25930. * @param scene The scene the result will construct the camera in
  25931. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25932. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25933. * @returns a factory method to construc the camera
  25934. */
  25935. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25936. /**
  25937. * Compute the world matrix of the camera.
  25938. * @returns the camera workd matrix
  25939. */
  25940. computeWorldMatrix(): Matrix;
  25941. /**
  25942. * Parse a JSON and creates the camera from the parsed information
  25943. * @param parsedCamera The JSON to parse
  25944. * @param scene The scene to instantiate the camera in
  25945. * @returns the newly constructed camera
  25946. */
  25947. static Parse(parsedCamera: any, scene: Scene): Camera;
  25948. }
  25949. }
  25950. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25951. import { Nullable } from "babylonjs/types";
  25952. import { Scene } from "babylonjs/scene";
  25953. import { Vector4 } from "babylonjs/Maths/math.vector";
  25954. import { Mesh } from "babylonjs/Meshes/mesh";
  25955. /**
  25956. * Class containing static functions to help procedurally build meshes
  25957. */
  25958. export class DiscBuilder {
  25959. /**
  25960. * Creates a plane polygonal mesh. By default, this is a disc
  25961. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25962. * * 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
  25963. * * 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
  25964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25967. * @param name defines the name of the mesh
  25968. * @param options defines the options used to create the mesh
  25969. * @param scene defines the hosting scene
  25970. * @returns the plane polygonal mesh
  25971. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25972. */
  25973. static CreateDisc(name: string, options: {
  25974. radius?: number;
  25975. tessellation?: number;
  25976. arc?: number;
  25977. updatable?: boolean;
  25978. sideOrientation?: number;
  25979. frontUVs?: Vector4;
  25980. backUVs?: Vector4;
  25981. }, scene?: Nullable<Scene>): Mesh;
  25982. }
  25983. }
  25984. declare module "babylonjs/Particles/solidParticleSystem" {
  25985. import { Vector3 } from "babylonjs/Maths/math.vector";
  25986. import { Mesh } from "babylonjs/Meshes/mesh";
  25987. import { Scene, IDisposable } from "babylonjs/scene";
  25988. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25989. /**
  25990. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25991. *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.
  25992. * The SPS is also a particle system. It provides some methods to manage the particles.
  25993. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25994. *
  25995. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25996. */
  25997. export class SolidParticleSystem implements IDisposable {
  25998. /**
  25999. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26000. * Example : var p = SPS.particles[i];
  26001. */
  26002. particles: SolidParticle[];
  26003. /**
  26004. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26005. */
  26006. nbParticles: number;
  26007. /**
  26008. * If the particles must ever face the camera (default false). Useful for planar particles.
  26009. */
  26010. billboard: boolean;
  26011. /**
  26012. * Recompute normals when adding a shape
  26013. */
  26014. recomputeNormals: boolean;
  26015. /**
  26016. * This a counter ofr your own usage. It's not set by any SPS functions.
  26017. */
  26018. counter: number;
  26019. /**
  26020. * The SPS name. This name is also given to the underlying mesh.
  26021. */
  26022. name: string;
  26023. /**
  26024. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26025. */
  26026. mesh: Mesh;
  26027. /**
  26028. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26029. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26030. */
  26031. vars: any;
  26032. /**
  26033. * This array is populated when the SPS is set as 'pickable'.
  26034. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26035. * Each element of this array is an object `{idx: int, faceId: int}`.
  26036. * `idx` is the picked particle index in the `SPS.particles` array
  26037. * `faceId` is the picked face index counted within this particle.
  26038. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26039. */
  26040. pickedParticles: {
  26041. idx: number;
  26042. faceId: number;
  26043. }[];
  26044. /**
  26045. * This array is populated when `enableDepthSort` is set to true.
  26046. * Each element of this array is an instance of the class DepthSortedParticle.
  26047. */
  26048. depthSortedParticles: DepthSortedParticle[];
  26049. /**
  26050. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26051. * @hidden
  26052. */
  26053. _bSphereOnly: boolean;
  26054. /**
  26055. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26056. * @hidden
  26057. */
  26058. _bSphereRadiusFactor: number;
  26059. private _scene;
  26060. private _positions;
  26061. private _indices;
  26062. private _normals;
  26063. private _colors;
  26064. private _uvs;
  26065. private _indices32;
  26066. private _positions32;
  26067. private _normals32;
  26068. private _fixedNormal32;
  26069. private _colors32;
  26070. private _uvs32;
  26071. private _index;
  26072. private _updatable;
  26073. private _pickable;
  26074. private _isVisibilityBoxLocked;
  26075. private _alwaysVisible;
  26076. private _depthSort;
  26077. private _shapeCounter;
  26078. private _copy;
  26079. private _color;
  26080. private _computeParticleColor;
  26081. private _computeParticleTexture;
  26082. private _computeParticleRotation;
  26083. private _computeParticleVertex;
  26084. private _computeBoundingBox;
  26085. private _depthSortParticles;
  26086. private _camera;
  26087. private _mustUnrotateFixedNormals;
  26088. private _particlesIntersect;
  26089. private _needs32Bits;
  26090. /**
  26091. * Creates a SPS (Solid Particle System) object.
  26092. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26093. * @param scene (Scene) is the scene in which the SPS is added.
  26094. * @param options defines the options of the sps e.g.
  26095. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26096. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26097. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26098. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26099. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26100. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26101. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26102. */
  26103. constructor(name: string, scene: Scene, options?: {
  26104. updatable?: boolean;
  26105. isPickable?: boolean;
  26106. enableDepthSort?: boolean;
  26107. particleIntersection?: boolean;
  26108. boundingSphereOnly?: boolean;
  26109. bSphereRadiusFactor?: number;
  26110. });
  26111. /**
  26112. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26113. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26114. * @returns the created mesh
  26115. */
  26116. buildMesh(): Mesh;
  26117. /**
  26118. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26119. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26120. * Thus the particles generated from `digest()` have their property `position` set yet.
  26121. * @param mesh ( Mesh ) is the mesh to be digested
  26122. * @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
  26123. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26124. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26125. * @returns the current SPS
  26126. */
  26127. digest(mesh: Mesh, options?: {
  26128. facetNb?: number;
  26129. number?: number;
  26130. delta?: number;
  26131. }): SolidParticleSystem;
  26132. private _unrotateFixedNormals;
  26133. private _resetCopy;
  26134. private _meshBuilder;
  26135. private _posToShape;
  26136. private _uvsToShapeUV;
  26137. private _addParticle;
  26138. /**
  26139. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26140. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26141. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26142. * @param nb (positive integer) the number of particles to be created from this model
  26143. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26144. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26145. * @returns the number of shapes in the system
  26146. */
  26147. addShape(mesh: Mesh, nb: number, options?: {
  26148. positionFunction?: any;
  26149. vertexFunction?: any;
  26150. }): number;
  26151. private _rebuildParticle;
  26152. /**
  26153. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26154. * @returns the SPS.
  26155. */
  26156. rebuildMesh(): SolidParticleSystem;
  26157. /**
  26158. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26159. * This method calls `updateParticle()` for each particle of the SPS.
  26160. * For an animated SPS, it is usually called within the render loop.
  26161. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26162. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26163. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26164. * @returns the SPS.
  26165. */
  26166. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26167. /**
  26168. * Disposes the SPS.
  26169. */
  26170. dispose(): void;
  26171. /**
  26172. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26173. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26174. * @returns the SPS.
  26175. */
  26176. refreshVisibleSize(): SolidParticleSystem;
  26177. /**
  26178. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26179. * @param size the size (float) of the visibility box
  26180. * note : this doesn't lock the SPS mesh bounding box.
  26181. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26182. */
  26183. setVisibilityBox(size: number): void;
  26184. /**
  26185. * Gets whether the SPS as always visible or not
  26186. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26187. */
  26188. /**
  26189. * Sets the SPS as always visible or not
  26190. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26191. */
  26192. isAlwaysVisible: boolean;
  26193. /**
  26194. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26196. */
  26197. /**
  26198. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26199. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26200. */
  26201. isVisibilityBoxLocked: boolean;
  26202. /**
  26203. * Tells to `setParticles()` to compute the particle rotations or not.
  26204. * Default value : true. The SPS is faster when it's set to false.
  26205. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26206. */
  26207. /**
  26208. * Gets if `setParticles()` computes the particle rotations or not.
  26209. * Default value : true. The SPS is faster when it's set to false.
  26210. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26211. */
  26212. computeParticleRotation: boolean;
  26213. /**
  26214. * Tells to `setParticles()` to compute the particle colors or not.
  26215. * Default value : true. The SPS is faster when it's set to false.
  26216. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26217. */
  26218. /**
  26219. * Gets if `setParticles()` computes the particle colors or not.
  26220. * Default value : true. The SPS is faster when it's set to false.
  26221. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26222. */
  26223. computeParticleColor: boolean;
  26224. /**
  26225. * Gets if `setParticles()` computes the particle textures or not.
  26226. * Default value : true. The SPS is faster when it's set to false.
  26227. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26228. */
  26229. computeParticleTexture: boolean;
  26230. /**
  26231. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26232. * Default value : false. The SPS is faster when it's set to false.
  26233. * Note : the particle custom vertex positions aren't stored values.
  26234. */
  26235. /**
  26236. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26237. * Default value : false. The SPS is faster when it's set to false.
  26238. * Note : the particle custom vertex positions aren't stored values.
  26239. */
  26240. computeParticleVertex: boolean;
  26241. /**
  26242. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26243. */
  26244. /**
  26245. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26246. */
  26247. computeBoundingBox: boolean;
  26248. /**
  26249. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26250. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26251. * Default : `true`
  26252. */
  26253. /**
  26254. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26255. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26256. * Default : `true`
  26257. */
  26258. depthSortParticles: boolean;
  26259. /**
  26260. * This function does nothing. It may be overwritten to set all the particle first values.
  26261. * The SPS doesn't call this function, you may have to call it by your own.
  26262. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26263. */
  26264. initParticles(): void;
  26265. /**
  26266. * This function does nothing. It may be overwritten to recycle a particle.
  26267. * The SPS doesn't call this function, you may have to call it by your own.
  26268. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26269. * @param particle The particle to recycle
  26270. * @returns the recycled particle
  26271. */
  26272. recycleParticle(particle: SolidParticle): SolidParticle;
  26273. /**
  26274. * Updates a particle : this function should be overwritten by the user.
  26275. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26276. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26277. * @example : just set a particle position or velocity and recycle conditions
  26278. * @param particle The particle to update
  26279. * @returns the updated particle
  26280. */
  26281. updateParticle(particle: SolidParticle): SolidParticle;
  26282. /**
  26283. * Updates a vertex of a particle : it can be overwritten by the user.
  26284. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26285. * @param particle the current particle
  26286. * @param vertex the current index of the current particle
  26287. * @param pt the index of the current vertex in the particle shape
  26288. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26289. * @example : just set a vertex particle position
  26290. * @returns the updated vertex
  26291. */
  26292. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26293. /**
  26294. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26295. * This does nothing and may be overwritten by the user.
  26296. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26297. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26298. * @param update the boolean update value actually passed to setParticles()
  26299. */
  26300. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26301. /**
  26302. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26303. * This will be passed three parameters.
  26304. * This does nothing and may be overwritten by the user.
  26305. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26306. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26307. * @param update the boolean update value actually passed to setParticles()
  26308. */
  26309. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26310. }
  26311. }
  26312. declare module "babylonjs/Particles/solidParticle" {
  26313. import { Nullable } from "babylonjs/types";
  26314. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26315. import { Color4 } from "babylonjs/Maths/math.color";
  26316. import { Mesh } from "babylonjs/Meshes/mesh";
  26317. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26318. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26319. import { Plane } from "babylonjs/Maths/math.plane";
  26320. /**
  26321. * Represents one particle of a solid particle system.
  26322. */
  26323. export class SolidParticle {
  26324. /**
  26325. * particle global index
  26326. */
  26327. idx: number;
  26328. /**
  26329. * The color of the particle
  26330. */
  26331. color: Nullable<Color4>;
  26332. /**
  26333. * The world space position of the particle.
  26334. */
  26335. position: Vector3;
  26336. /**
  26337. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26338. */
  26339. rotation: Vector3;
  26340. /**
  26341. * The world space rotation quaternion of the particle.
  26342. */
  26343. rotationQuaternion: Nullable<Quaternion>;
  26344. /**
  26345. * The scaling of the particle.
  26346. */
  26347. scaling: Vector3;
  26348. /**
  26349. * The uvs of the particle.
  26350. */
  26351. uvs: Vector4;
  26352. /**
  26353. * The current speed of the particle.
  26354. */
  26355. velocity: Vector3;
  26356. /**
  26357. * The pivot point in the particle local space.
  26358. */
  26359. pivot: Vector3;
  26360. /**
  26361. * Must the particle be translated from its pivot point in its local space ?
  26362. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26363. * Default : false
  26364. */
  26365. translateFromPivot: boolean;
  26366. /**
  26367. * Is the particle active or not ?
  26368. */
  26369. alive: boolean;
  26370. /**
  26371. * Is the particle visible or not ?
  26372. */
  26373. isVisible: boolean;
  26374. /**
  26375. * Index of this particle in the global "positions" array (Internal use)
  26376. * @hidden
  26377. */
  26378. _pos: number;
  26379. /**
  26380. * @hidden Index of this particle in the global "indices" array (Internal use)
  26381. */
  26382. _ind: number;
  26383. /**
  26384. * @hidden ModelShape of this particle (Internal use)
  26385. */
  26386. _model: ModelShape;
  26387. /**
  26388. * ModelShape id of this particle
  26389. */
  26390. shapeId: number;
  26391. /**
  26392. * Index of the particle in its shape id
  26393. */
  26394. idxInShape: number;
  26395. /**
  26396. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26397. */
  26398. _modelBoundingInfo: BoundingInfo;
  26399. /**
  26400. * @hidden Particle BoundingInfo object (Internal use)
  26401. */
  26402. _boundingInfo: BoundingInfo;
  26403. /**
  26404. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26405. */
  26406. _sps: SolidParticleSystem;
  26407. /**
  26408. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26409. */
  26410. _stillInvisible: boolean;
  26411. /**
  26412. * @hidden Last computed particle rotation matrix
  26413. */
  26414. _rotationMatrix: number[];
  26415. /**
  26416. * Parent particle Id, if any.
  26417. * Default null.
  26418. */
  26419. parentId: Nullable<number>;
  26420. /**
  26421. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  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. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26428. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26429. * */
  26430. cullingStrategy: number;
  26431. /**
  26432. * @hidden Internal global position in the SPS.
  26433. */
  26434. _globalPosition: Vector3;
  26435. /**
  26436. * Creates a Solid Particle object.
  26437. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26438. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26439. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26440. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26441. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26442. * @param shapeId (integer) is the model shape identifier in the SPS.
  26443. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26444. * @param sps defines the sps it is associated to
  26445. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26446. */
  26447. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26448. /**
  26449. * Legacy support, changed scale to scaling
  26450. */
  26451. /**
  26452. * Legacy support, changed scale to scaling
  26453. */
  26454. scale: Vector3;
  26455. /**
  26456. * Legacy support, changed quaternion to rotationQuaternion
  26457. */
  26458. /**
  26459. * Legacy support, changed quaternion to rotationQuaternion
  26460. */
  26461. quaternion: Nullable<Quaternion>;
  26462. /**
  26463. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26464. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26465. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26466. * @returns true if it intersects
  26467. */
  26468. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26469. /**
  26470. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26471. * A particle is in the frustum if its bounding box intersects the frustum
  26472. * @param frustumPlanes defines the frustum to test
  26473. * @returns true if the particle is in the frustum planes
  26474. */
  26475. isInFrustum(frustumPlanes: Plane[]): boolean;
  26476. /**
  26477. * get the rotation matrix of the particle
  26478. * @hidden
  26479. */
  26480. getRotationMatrix(m: Matrix): void;
  26481. }
  26482. /**
  26483. * Represents the shape of the model used by one particle of a solid particle system.
  26484. * SPS internal tool, don't use it manually.
  26485. */
  26486. export class ModelShape {
  26487. /**
  26488. * The shape id
  26489. * @hidden
  26490. */
  26491. shapeID: number;
  26492. /**
  26493. * flat array of model positions (internal use)
  26494. * @hidden
  26495. */
  26496. _shape: Vector3[];
  26497. /**
  26498. * flat array of model UVs (internal use)
  26499. * @hidden
  26500. */
  26501. _shapeUV: number[];
  26502. /**
  26503. * length of the shape in the model indices array (internal use)
  26504. * @hidden
  26505. */
  26506. _indicesLength: number;
  26507. /**
  26508. * Custom position function (internal use)
  26509. * @hidden
  26510. */
  26511. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26512. /**
  26513. * Custom vertex function (internal use)
  26514. * @hidden
  26515. */
  26516. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26517. /**
  26518. * 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.
  26519. * SPS internal tool, don't use it manually.
  26520. * @hidden
  26521. */
  26522. 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>);
  26523. }
  26524. /**
  26525. * Represents a Depth Sorted Particle in the solid particle system.
  26526. */
  26527. export class DepthSortedParticle {
  26528. /**
  26529. * Index of the particle in the "indices" array
  26530. */
  26531. ind: number;
  26532. /**
  26533. * Length of the particle shape in the "indices" array
  26534. */
  26535. indicesLength: number;
  26536. /**
  26537. * Squared distance from the particle to the camera
  26538. */
  26539. sqDistance: number;
  26540. }
  26541. }
  26542. declare module "babylonjs/Collisions/meshCollisionData" {
  26543. import { Collider } from "babylonjs/Collisions/collider";
  26544. import { Vector3 } from "babylonjs/Maths/math.vector";
  26545. import { Nullable } from "babylonjs/types";
  26546. import { Observer } from "babylonjs/Misc/observable";
  26547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26548. /**
  26549. * @hidden
  26550. */
  26551. export class _MeshCollisionData {
  26552. _checkCollisions: boolean;
  26553. _collisionMask: number;
  26554. _collisionGroup: number;
  26555. _collider: Nullable<Collider>;
  26556. _oldPositionForCollisions: Vector3;
  26557. _diffPositionForCollisions: Vector3;
  26558. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26559. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26560. }
  26561. }
  26562. declare module "babylonjs/Meshes/abstractMesh" {
  26563. import { Observable } from "babylonjs/Misc/observable";
  26564. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26565. import { Camera } from "babylonjs/Cameras/camera";
  26566. import { Scene, IDisposable } from "babylonjs/scene";
  26567. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26568. import { Node } from "babylonjs/node";
  26569. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26570. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26571. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26572. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26573. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26574. import { Material } from "babylonjs/Materials/material";
  26575. import { Light } from "babylonjs/Lights/light";
  26576. import { Skeleton } from "babylonjs/Bones/skeleton";
  26577. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26578. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26579. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26580. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26581. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26582. import { Plane } from "babylonjs/Maths/math.plane";
  26583. import { Ray } from "babylonjs/Culling/ray";
  26584. import { Collider } from "babylonjs/Collisions/collider";
  26585. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26586. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26587. /** @hidden */
  26588. class _FacetDataStorage {
  26589. facetPositions: Vector3[];
  26590. facetNormals: Vector3[];
  26591. facetPartitioning: number[][];
  26592. facetNb: number;
  26593. partitioningSubdivisions: number;
  26594. partitioningBBoxRatio: number;
  26595. facetDataEnabled: boolean;
  26596. facetParameters: any;
  26597. bbSize: Vector3;
  26598. subDiv: {
  26599. max: number;
  26600. X: number;
  26601. Y: number;
  26602. Z: number;
  26603. };
  26604. facetDepthSort: boolean;
  26605. facetDepthSortEnabled: boolean;
  26606. depthSortedIndices: IndicesArray;
  26607. depthSortedFacets: {
  26608. ind: number;
  26609. sqDistance: number;
  26610. }[];
  26611. facetDepthSortFunction: (f1: {
  26612. ind: number;
  26613. sqDistance: number;
  26614. }, f2: {
  26615. ind: number;
  26616. sqDistance: number;
  26617. }) => number;
  26618. facetDepthSortFrom: Vector3;
  26619. facetDepthSortOrigin: Vector3;
  26620. invertedMatrix: Matrix;
  26621. }
  26622. /**
  26623. * @hidden
  26624. **/
  26625. class _InternalAbstractMeshDataInfo {
  26626. _hasVertexAlpha: boolean;
  26627. _useVertexColors: boolean;
  26628. _numBoneInfluencers: number;
  26629. _applyFog: boolean;
  26630. _receiveShadows: boolean;
  26631. _facetData: _FacetDataStorage;
  26632. _visibility: number;
  26633. _skeleton: Nullable<Skeleton>;
  26634. _layerMask: number;
  26635. _computeBonesUsingShaders: boolean;
  26636. _isActive: boolean;
  26637. _onlyForInstances: boolean;
  26638. _isActiveIntermediate: boolean;
  26639. _onlyForInstancesIntermediate: boolean;
  26640. }
  26641. /**
  26642. * Class used to store all common mesh properties
  26643. */
  26644. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26645. /** No occlusion */
  26646. static OCCLUSION_TYPE_NONE: number;
  26647. /** Occlusion set to optimisitic */
  26648. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26649. /** Occlusion set to strict */
  26650. static OCCLUSION_TYPE_STRICT: number;
  26651. /** Use an accurante occlusion algorithm */
  26652. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26653. /** Use a conservative occlusion algorithm */
  26654. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26655. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26656. * Test order :
  26657. * Is the bounding sphere outside the frustum ?
  26658. * If not, are the bounding box vertices outside the frustum ?
  26659. * It not, then the cullable object is in the frustum.
  26660. */
  26661. static readonly CULLINGSTRATEGY_STANDARD: number;
  26662. /** Culling strategy : Bounding Sphere Only.
  26663. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26664. * It's also less accurate than the standard because some not visible objects can still be selected.
  26665. * Test : is the bounding sphere outside the frustum ?
  26666. * If not, then the cullable object is in the frustum.
  26667. */
  26668. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26669. /** Culling strategy : Optimistic Inclusion.
  26670. * This in an inclusion test first, then the standard exclusion test.
  26671. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26672. * 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.
  26673. * Anyway, it's as accurate as the standard strategy.
  26674. * Test :
  26675. * Is the cullable object bounding sphere center in the frustum ?
  26676. * If not, apply the default culling strategy.
  26677. */
  26678. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26679. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26680. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26681. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26682. * 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.
  26683. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26684. * Test :
  26685. * Is the cullable object bounding sphere center in the frustum ?
  26686. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26687. */
  26688. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26689. /**
  26690. * No billboard
  26691. */
  26692. static readonly BILLBOARDMODE_NONE: number;
  26693. /** Billboard on X axis */
  26694. static readonly BILLBOARDMODE_X: number;
  26695. /** Billboard on Y axis */
  26696. static readonly BILLBOARDMODE_Y: number;
  26697. /** Billboard on Z axis */
  26698. static readonly BILLBOARDMODE_Z: number;
  26699. /** Billboard on all axes */
  26700. static readonly BILLBOARDMODE_ALL: number;
  26701. /** Billboard on using position instead of orientation */
  26702. static readonly BILLBOARDMODE_USE_POSITION: number;
  26703. /** @hidden */
  26704. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26705. /**
  26706. * The culling strategy to use to check whether the mesh must be rendered or not.
  26707. * This value can be changed at any time and will be used on the next render mesh selection.
  26708. * The possible values are :
  26709. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26710. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26711. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26712. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26713. * Please read each static variable documentation to get details about the culling process.
  26714. * */
  26715. cullingStrategy: number;
  26716. /**
  26717. * Gets the number of facets in the mesh
  26718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26719. */
  26720. readonly facetNb: number;
  26721. /**
  26722. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26724. */
  26725. partitioningSubdivisions: number;
  26726. /**
  26727. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26728. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26730. */
  26731. partitioningBBoxRatio: number;
  26732. /**
  26733. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26734. * Works only for updatable meshes.
  26735. * Doesn't work with multi-materials
  26736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26737. */
  26738. mustDepthSortFacets: boolean;
  26739. /**
  26740. * The location (Vector3) where the facet depth sort must be computed from.
  26741. * By default, the active camera position.
  26742. * Used only when facet depth sort is enabled
  26743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26744. */
  26745. facetDepthSortFrom: Vector3;
  26746. /**
  26747. * gets a boolean indicating if facetData is enabled
  26748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26749. */
  26750. readonly isFacetDataEnabled: boolean;
  26751. /** @hidden */
  26752. _updateNonUniformScalingState(value: boolean): boolean;
  26753. /**
  26754. * An event triggered when this mesh collides with another one
  26755. */
  26756. onCollideObservable: Observable<AbstractMesh>;
  26757. /** Set a function to call when this mesh collides with another one */
  26758. onCollide: () => void;
  26759. /**
  26760. * An event triggered when the collision's position changes
  26761. */
  26762. onCollisionPositionChangeObservable: Observable<Vector3>;
  26763. /** Set a function to call when the collision's position changes */
  26764. onCollisionPositionChange: () => void;
  26765. /**
  26766. * An event triggered when material is changed
  26767. */
  26768. onMaterialChangedObservable: Observable<AbstractMesh>;
  26769. /**
  26770. * Gets or sets the orientation for POV movement & rotation
  26771. */
  26772. definedFacingForward: boolean;
  26773. /** @hidden */
  26774. _occlusionQuery: Nullable<WebGLQuery>;
  26775. /** @hidden */
  26776. _renderingGroup: Nullable<RenderingGroup>;
  26777. /**
  26778. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26779. */
  26780. /**
  26781. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26782. */
  26783. visibility: number;
  26784. /** Gets or sets the alpha index used to sort transparent meshes
  26785. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26786. */
  26787. alphaIndex: number;
  26788. /**
  26789. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26790. */
  26791. isVisible: boolean;
  26792. /**
  26793. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26794. */
  26795. isPickable: boolean;
  26796. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26797. showSubMeshesBoundingBox: boolean;
  26798. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26799. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26800. */
  26801. isBlocker: boolean;
  26802. /**
  26803. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26804. */
  26805. enablePointerMoveEvents: boolean;
  26806. /**
  26807. * Specifies the rendering group id for this mesh (0 by default)
  26808. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26809. */
  26810. renderingGroupId: number;
  26811. private _material;
  26812. /** Gets or sets current material */
  26813. material: Nullable<Material>;
  26814. /**
  26815. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26816. * @see http://doc.babylonjs.com/babylon101/shadows
  26817. */
  26818. receiveShadows: boolean;
  26819. /** Defines color to use when rendering outline */
  26820. outlineColor: Color3;
  26821. /** Define width to use when rendering outline */
  26822. outlineWidth: number;
  26823. /** Defines color to use when rendering overlay */
  26824. overlayColor: Color3;
  26825. /** Defines alpha to use when rendering overlay */
  26826. overlayAlpha: number;
  26827. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26828. hasVertexAlpha: boolean;
  26829. /** 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) */
  26830. useVertexColors: boolean;
  26831. /**
  26832. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26833. */
  26834. computeBonesUsingShaders: boolean;
  26835. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26836. numBoneInfluencers: number;
  26837. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26838. applyFog: boolean;
  26839. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26840. useOctreeForRenderingSelection: boolean;
  26841. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26842. useOctreeForPicking: boolean;
  26843. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26844. useOctreeForCollisions: boolean;
  26845. /**
  26846. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26847. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26848. */
  26849. layerMask: number;
  26850. /**
  26851. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26852. */
  26853. alwaysSelectAsActiveMesh: boolean;
  26854. /**
  26855. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26856. */
  26857. doNotSyncBoundingInfo: boolean;
  26858. /**
  26859. * Gets or sets the current action manager
  26860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26861. */
  26862. actionManager: Nullable<AbstractActionManager>;
  26863. private _meshCollisionData;
  26864. /**
  26865. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26867. */
  26868. ellipsoid: Vector3;
  26869. /**
  26870. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26872. */
  26873. ellipsoidOffset: Vector3;
  26874. /**
  26875. * Gets or sets a collision mask used to mask collisions (default is -1).
  26876. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26877. */
  26878. collisionMask: number;
  26879. /**
  26880. * Gets or sets the current collision group mask (-1 by default).
  26881. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26882. */
  26883. collisionGroup: number;
  26884. /**
  26885. * Defines edge width used when edgesRenderer is enabled
  26886. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26887. */
  26888. edgesWidth: number;
  26889. /**
  26890. * Defines edge color used when edgesRenderer is enabled
  26891. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26892. */
  26893. edgesColor: Color4;
  26894. /** @hidden */
  26895. _edgesRenderer: Nullable<IEdgesRenderer>;
  26896. /** @hidden */
  26897. _masterMesh: Nullable<AbstractMesh>;
  26898. /** @hidden */
  26899. _boundingInfo: Nullable<BoundingInfo>;
  26900. /** @hidden */
  26901. _renderId: number;
  26902. /**
  26903. * Gets or sets the list of subMeshes
  26904. * @see http://doc.babylonjs.com/how_to/multi_materials
  26905. */
  26906. subMeshes: SubMesh[];
  26907. /** @hidden */
  26908. _intersectionsInProgress: AbstractMesh[];
  26909. /** @hidden */
  26910. _unIndexed: boolean;
  26911. /** @hidden */
  26912. _lightSources: Light[];
  26913. /** Gets the list of lights affecting that mesh */
  26914. readonly lightSources: Light[];
  26915. /** @hidden */
  26916. readonly _positions: Nullable<Vector3[]>;
  26917. /** @hidden */
  26918. _waitingData: {
  26919. lods: Nullable<any>;
  26920. actions: Nullable<any>;
  26921. freezeWorldMatrix: Nullable<boolean>;
  26922. };
  26923. /** @hidden */
  26924. _bonesTransformMatrices: Nullable<Float32Array>;
  26925. /** @hidden */
  26926. _transformMatrixTexture: Nullable<RawTexture>;
  26927. /**
  26928. * Gets or sets a skeleton to apply skining transformations
  26929. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26930. */
  26931. skeleton: Nullable<Skeleton>;
  26932. /**
  26933. * An event triggered when the mesh is rebuilt.
  26934. */
  26935. onRebuildObservable: Observable<AbstractMesh>;
  26936. /**
  26937. * Creates a new AbstractMesh
  26938. * @param name defines the name of the mesh
  26939. * @param scene defines the hosting scene
  26940. */
  26941. constructor(name: string, scene?: Nullable<Scene>);
  26942. /**
  26943. * Returns the string "AbstractMesh"
  26944. * @returns "AbstractMesh"
  26945. */
  26946. getClassName(): string;
  26947. /**
  26948. * Gets a string representation of the current mesh
  26949. * @param fullDetails defines a boolean indicating if full details must be included
  26950. * @returns a string representation of the current mesh
  26951. */
  26952. toString(fullDetails?: boolean): string;
  26953. /**
  26954. * @hidden
  26955. */
  26956. protected _getEffectiveParent(): Nullable<Node>;
  26957. /** @hidden */
  26958. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26959. /** @hidden */
  26960. _rebuild(): void;
  26961. /** @hidden */
  26962. _resyncLightSources(): void;
  26963. /** @hidden */
  26964. _resyncLighSource(light: Light): void;
  26965. /** @hidden */
  26966. _unBindEffect(): void;
  26967. /** @hidden */
  26968. _removeLightSource(light: Light, dispose: boolean): void;
  26969. private _markSubMeshesAsDirty;
  26970. /** @hidden */
  26971. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26972. /** @hidden */
  26973. _markSubMeshesAsAttributesDirty(): void;
  26974. /** @hidden */
  26975. _markSubMeshesAsMiscDirty(): void;
  26976. /**
  26977. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26978. */
  26979. scaling: Vector3;
  26980. /**
  26981. * Returns true if the mesh is blocked. Implemented by child classes
  26982. */
  26983. readonly isBlocked: boolean;
  26984. /**
  26985. * Returns the mesh itself by default. Implemented by child classes
  26986. * @param camera defines the camera to use to pick the right LOD level
  26987. * @returns the currentAbstractMesh
  26988. */
  26989. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26990. /**
  26991. * Returns 0 by default. Implemented by child classes
  26992. * @returns an integer
  26993. */
  26994. getTotalVertices(): number;
  26995. /**
  26996. * Returns a positive integer : the total number of indices in this mesh geometry.
  26997. * @returns the numner of indices or zero if the mesh has no geometry.
  26998. */
  26999. getTotalIndices(): number;
  27000. /**
  27001. * Returns null by default. Implemented by child classes
  27002. * @returns null
  27003. */
  27004. getIndices(): Nullable<IndicesArray>;
  27005. /**
  27006. * Returns the array of the requested vertex data kind. Implemented by child classes
  27007. * @param kind defines the vertex data kind to use
  27008. * @returns null
  27009. */
  27010. getVerticesData(kind: string): Nullable<FloatArray>;
  27011. /**
  27012. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27013. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27014. * Note that a new underlying VertexBuffer object is created each call.
  27015. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27016. * @param kind defines vertex data kind:
  27017. * * VertexBuffer.PositionKind
  27018. * * VertexBuffer.UVKind
  27019. * * VertexBuffer.UV2Kind
  27020. * * VertexBuffer.UV3Kind
  27021. * * VertexBuffer.UV4Kind
  27022. * * VertexBuffer.UV5Kind
  27023. * * VertexBuffer.UV6Kind
  27024. * * VertexBuffer.ColorKind
  27025. * * VertexBuffer.MatricesIndicesKind
  27026. * * VertexBuffer.MatricesIndicesExtraKind
  27027. * * VertexBuffer.MatricesWeightsKind
  27028. * * VertexBuffer.MatricesWeightsExtraKind
  27029. * @param data defines the data source
  27030. * @param updatable defines if the data must be flagged as updatable (or static)
  27031. * @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
  27032. * @returns the current mesh
  27033. */
  27034. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27035. /**
  27036. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27037. * If the mesh has no geometry, it is simply returned as it is.
  27038. * @param kind defines vertex data kind:
  27039. * * VertexBuffer.PositionKind
  27040. * * VertexBuffer.UVKind
  27041. * * VertexBuffer.UV2Kind
  27042. * * VertexBuffer.UV3Kind
  27043. * * VertexBuffer.UV4Kind
  27044. * * VertexBuffer.UV5Kind
  27045. * * VertexBuffer.UV6Kind
  27046. * * VertexBuffer.ColorKind
  27047. * * VertexBuffer.MatricesIndicesKind
  27048. * * VertexBuffer.MatricesIndicesExtraKind
  27049. * * VertexBuffer.MatricesWeightsKind
  27050. * * VertexBuffer.MatricesWeightsExtraKind
  27051. * @param data defines the data source
  27052. * @param 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
  27053. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27054. * @returns the current mesh
  27055. */
  27056. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27057. /**
  27058. * Sets the mesh indices,
  27059. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27060. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27061. * @param totalVertices Defines the total number of vertices
  27062. * @returns the current mesh
  27063. */
  27064. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27065. /**
  27066. * Gets a boolean indicating if specific vertex data is present
  27067. * @param kind defines the vertex data kind to use
  27068. * @returns true is data kind is present
  27069. */
  27070. isVerticesDataPresent(kind: string): boolean;
  27071. /**
  27072. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27073. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27074. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27075. * @returns a BoundingInfo
  27076. */
  27077. getBoundingInfo(): BoundingInfo;
  27078. /**
  27079. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27080. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27081. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27082. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27083. * @returns the current mesh
  27084. */
  27085. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27086. /**
  27087. * Overwrite the current bounding info
  27088. * @param boundingInfo defines the new bounding info
  27089. * @returns the current mesh
  27090. */
  27091. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27092. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27093. readonly useBones: boolean;
  27094. /** @hidden */
  27095. _preActivate(): void;
  27096. /** @hidden */
  27097. _preActivateForIntermediateRendering(renderId: number): void;
  27098. /** @hidden */
  27099. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27100. /** @hidden */
  27101. _postActivate(): void;
  27102. /** @hidden */
  27103. _freeze(): void;
  27104. /** @hidden */
  27105. _unFreeze(): void;
  27106. /**
  27107. * Gets the current world matrix
  27108. * @returns a Matrix
  27109. */
  27110. getWorldMatrix(): Matrix;
  27111. /** @hidden */
  27112. _getWorldMatrixDeterminant(): number;
  27113. /**
  27114. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27115. */
  27116. readonly isAnInstance: boolean;
  27117. /**
  27118. * Gets a boolean indicating if this mesh has instances
  27119. */
  27120. readonly hasInstances: boolean;
  27121. /**
  27122. * Perform relative position change from the point of view of behind the front of the mesh.
  27123. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27124. * Supports definition of mesh facing forward or backward
  27125. * @param amountRight defines the distance on the right axis
  27126. * @param amountUp defines the distance on the up axis
  27127. * @param amountForward defines the distance on the forward axis
  27128. * @returns the current mesh
  27129. */
  27130. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27131. /**
  27132. * Calculate relative position change from the point of view of behind the front of the mesh.
  27133. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27134. * Supports definition of mesh facing forward or backward
  27135. * @param amountRight defines the distance on the right axis
  27136. * @param amountUp defines the distance on the up axis
  27137. * @param amountForward defines the distance on the forward axis
  27138. * @returns the new displacement vector
  27139. */
  27140. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27141. /**
  27142. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27143. * Supports definition of mesh facing forward or backward
  27144. * @param flipBack defines the flip
  27145. * @param twirlClockwise defines the twirl
  27146. * @param tiltRight defines the tilt
  27147. * @returns the current mesh
  27148. */
  27149. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27150. /**
  27151. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27152. * Supports definition of mesh facing forward or backward.
  27153. * @param flipBack defines the flip
  27154. * @param twirlClockwise defines the twirl
  27155. * @param tiltRight defines the tilt
  27156. * @returns the new rotation vector
  27157. */
  27158. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27159. /**
  27160. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27161. * This means the mesh underlying bounding box and sphere are recomputed.
  27162. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27163. * @returns the current mesh
  27164. */
  27165. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27166. /** @hidden */
  27167. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27168. /** @hidden */
  27169. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27170. /** @hidden */
  27171. _updateBoundingInfo(): AbstractMesh;
  27172. /** @hidden */
  27173. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27174. /** @hidden */
  27175. protected _afterComputeWorldMatrix(): void;
  27176. /** @hidden */
  27177. readonly _effectiveMesh: AbstractMesh;
  27178. /**
  27179. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27180. * A mesh is in the frustum if its bounding box intersects the frustum
  27181. * @param frustumPlanes defines the frustum to test
  27182. * @returns true if the mesh is in the frustum planes
  27183. */
  27184. isInFrustum(frustumPlanes: Plane[]): boolean;
  27185. /**
  27186. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27187. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27188. * @param frustumPlanes defines the frustum to test
  27189. * @returns true if the mesh is completely in the frustum planes
  27190. */
  27191. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27192. /**
  27193. * True if the mesh intersects another mesh or a SolidParticle object
  27194. * @param mesh defines a target mesh or SolidParticle to test
  27195. * @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)
  27196. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27197. * @returns true if there is an intersection
  27198. */
  27199. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27200. /**
  27201. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27202. * @param point defines the point to test
  27203. * @returns true if there is an intersection
  27204. */
  27205. intersectsPoint(point: Vector3): boolean;
  27206. /**
  27207. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27209. */
  27210. checkCollisions: boolean;
  27211. /**
  27212. * Gets Collider object used to compute collisions (not physics)
  27213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27214. */
  27215. readonly collider: Nullable<Collider>;
  27216. /**
  27217. * Move the mesh using collision engine
  27218. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27219. * @param displacement defines the requested displacement vector
  27220. * @returns the current mesh
  27221. */
  27222. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27223. private _onCollisionPositionChange;
  27224. /** @hidden */
  27225. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27226. /** @hidden */
  27227. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27228. /** @hidden */
  27229. _checkCollision(collider: Collider): AbstractMesh;
  27230. /** @hidden */
  27231. _generatePointsArray(): boolean;
  27232. /**
  27233. * Checks if the passed Ray intersects with the mesh
  27234. * @param ray defines the ray to use
  27235. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27236. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27237. * @returns the picking info
  27238. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27239. */
  27240. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27241. /**
  27242. * Clones the current mesh
  27243. * @param name defines the mesh name
  27244. * @param newParent defines the new mesh parent
  27245. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27246. * @returns the new mesh
  27247. */
  27248. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27249. /**
  27250. * Disposes all the submeshes of the current meshnp
  27251. * @returns the current mesh
  27252. */
  27253. releaseSubMeshes(): AbstractMesh;
  27254. /**
  27255. * Releases resources associated with this abstract mesh.
  27256. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27257. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27258. */
  27259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27260. /**
  27261. * Adds the passed mesh as a child to the current mesh
  27262. * @param mesh defines the child mesh
  27263. * @returns the current mesh
  27264. */
  27265. addChild(mesh: AbstractMesh): AbstractMesh;
  27266. /**
  27267. * Removes the passed mesh from the current mesh children list
  27268. * @param mesh defines the child mesh
  27269. * @returns the current mesh
  27270. */
  27271. removeChild(mesh: AbstractMesh): AbstractMesh;
  27272. /** @hidden */
  27273. private _initFacetData;
  27274. /**
  27275. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27276. * This method can be called within the render loop.
  27277. * 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
  27278. * @returns the current mesh
  27279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27280. */
  27281. updateFacetData(): AbstractMesh;
  27282. /**
  27283. * Returns the facetLocalNormals array.
  27284. * The normals are expressed in the mesh local spac
  27285. * @returns an array of Vector3
  27286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27287. */
  27288. getFacetLocalNormals(): Vector3[];
  27289. /**
  27290. * Returns the facetLocalPositions array.
  27291. * The facet positions are expressed in the mesh local space
  27292. * @returns an array of Vector3
  27293. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27294. */
  27295. getFacetLocalPositions(): Vector3[];
  27296. /**
  27297. * Returns the facetLocalPartioning array
  27298. * @returns an array of array of numbers
  27299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27300. */
  27301. getFacetLocalPartitioning(): number[][];
  27302. /**
  27303. * Returns the i-th facet position in the world system.
  27304. * This method allocates a new Vector3 per call
  27305. * @param i defines the facet index
  27306. * @returns a new Vector3
  27307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27308. */
  27309. getFacetPosition(i: number): Vector3;
  27310. /**
  27311. * Sets the reference Vector3 with the i-th facet position in the world system
  27312. * @param i defines the facet index
  27313. * @param ref defines the target vector
  27314. * @returns the current mesh
  27315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27316. */
  27317. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27318. /**
  27319. * Returns the i-th facet normal in the world system.
  27320. * This method allocates a new Vector3 per call
  27321. * @param i defines the facet index
  27322. * @returns a new Vector3
  27323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27324. */
  27325. getFacetNormal(i: number): Vector3;
  27326. /**
  27327. * Sets the reference Vector3 with the i-th facet normal in the world system
  27328. * @param i defines the facet index
  27329. * @param ref defines the target vector
  27330. * @returns the current mesh
  27331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27332. */
  27333. getFacetNormalToRef(i: number, ref: Vector3): this;
  27334. /**
  27335. * 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)
  27336. * @param x defines x coordinate
  27337. * @param y defines y coordinate
  27338. * @param z defines z coordinate
  27339. * @returns the array of facet indexes
  27340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27341. */
  27342. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27343. /**
  27344. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27345. * @param projected sets as the (x,y,z) world projection on the facet
  27346. * @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
  27347. * @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
  27348. * @param x defines x coordinate
  27349. * @param y defines y coordinate
  27350. * @param z defines z coordinate
  27351. * @returns the face index if found (or null instead)
  27352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27353. */
  27354. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27355. /**
  27356. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27357. * @param projected sets as the (x,y,z) local projection on the facet
  27358. * @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
  27359. * @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
  27360. * @param x defines x coordinate
  27361. * @param y defines y coordinate
  27362. * @param z defines z coordinate
  27363. * @returns the face index if found (or null instead)
  27364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27365. */
  27366. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27367. /**
  27368. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27369. * @returns the parameters
  27370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27371. */
  27372. getFacetDataParameters(): any;
  27373. /**
  27374. * Disables the feature FacetData and frees the related memory
  27375. * @returns the current mesh
  27376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27377. */
  27378. disableFacetData(): AbstractMesh;
  27379. /**
  27380. * Updates the AbstractMesh indices array
  27381. * @param indices defines the data source
  27382. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27383. * @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)
  27384. * @returns the current mesh
  27385. */
  27386. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27387. /**
  27388. * Creates new normals data for the mesh
  27389. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27390. * @returns the current mesh
  27391. */
  27392. createNormals(updatable: boolean): AbstractMesh;
  27393. /**
  27394. * Align the mesh with a normal
  27395. * @param normal defines the normal to use
  27396. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27397. * @returns the current mesh
  27398. */
  27399. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27400. /** @hidden */
  27401. _checkOcclusionQuery(): boolean;
  27402. /**
  27403. * Disables the mesh edge rendering mode
  27404. * @returns the currentAbstractMesh
  27405. */
  27406. disableEdgesRendering(): AbstractMesh;
  27407. /**
  27408. * Enables the edge rendering mode on the mesh.
  27409. * This mode makes the mesh edges visible
  27410. * @param epsilon defines the maximal distance between two angles to detect a face
  27411. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27412. * @returns the currentAbstractMesh
  27413. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27414. */
  27415. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27416. }
  27417. }
  27418. declare module "babylonjs/Actions/actionEvent" {
  27419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27420. import { Nullable } from "babylonjs/types";
  27421. import { Sprite } from "babylonjs/Sprites/sprite";
  27422. import { Scene } from "babylonjs/scene";
  27423. import { Vector2 } from "babylonjs/Maths/math.vector";
  27424. /**
  27425. * Interface used to define ActionEvent
  27426. */
  27427. export interface IActionEvent {
  27428. /** The mesh or sprite that triggered the action */
  27429. source: any;
  27430. /** The X mouse cursor position at the time of the event */
  27431. pointerX: number;
  27432. /** The Y mouse cursor position at the time of the event */
  27433. pointerY: number;
  27434. /** The mesh that is currently pointed at (can be null) */
  27435. meshUnderPointer: Nullable<AbstractMesh>;
  27436. /** the original (browser) event that triggered the ActionEvent */
  27437. sourceEvent?: any;
  27438. /** additional data for the event */
  27439. additionalData?: any;
  27440. }
  27441. /**
  27442. * ActionEvent is the event being sent when an action is triggered.
  27443. */
  27444. export class ActionEvent implements IActionEvent {
  27445. /** The mesh or sprite that triggered the action */
  27446. source: any;
  27447. /** The X mouse cursor position at the time of the event */
  27448. pointerX: number;
  27449. /** The Y mouse cursor position at the time of the event */
  27450. pointerY: number;
  27451. /** The mesh that is currently pointed at (can be null) */
  27452. meshUnderPointer: Nullable<AbstractMesh>;
  27453. /** the original (browser) event that triggered the ActionEvent */
  27454. sourceEvent?: any;
  27455. /** additional data for the event */
  27456. additionalData?: any;
  27457. /**
  27458. * Creates a new ActionEvent
  27459. * @param source The mesh or sprite that triggered the action
  27460. * @param pointerX The X mouse cursor position at the time of the event
  27461. * @param pointerY The Y mouse cursor position at the time of the event
  27462. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27463. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27464. * @param additionalData additional data for the event
  27465. */
  27466. constructor(
  27467. /** The mesh or sprite that triggered the action */
  27468. source: any,
  27469. /** The X mouse cursor position at the time of the event */
  27470. pointerX: number,
  27471. /** The Y mouse cursor position at the time of the event */
  27472. pointerY: number,
  27473. /** The mesh that is currently pointed at (can be null) */
  27474. meshUnderPointer: Nullable<AbstractMesh>,
  27475. /** the original (browser) event that triggered the ActionEvent */
  27476. sourceEvent?: any,
  27477. /** additional data for the event */
  27478. additionalData?: any);
  27479. /**
  27480. * Helper function to auto-create an ActionEvent from a source mesh.
  27481. * @param source The source mesh that triggered the event
  27482. * @param evt The original (browser) event
  27483. * @param additionalData additional data for the event
  27484. * @returns the new ActionEvent
  27485. */
  27486. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27487. /**
  27488. * Helper function to auto-create an ActionEvent from a source sprite
  27489. * @param source The source sprite that triggered the event
  27490. * @param scene Scene associated with the sprite
  27491. * @param evt The original (browser) event
  27492. * @param additionalData additional data for the event
  27493. * @returns the new ActionEvent
  27494. */
  27495. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27496. /**
  27497. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27498. * @param scene the scene where the event occurred
  27499. * @param evt The original (browser) event
  27500. * @returns the new ActionEvent
  27501. */
  27502. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27503. /**
  27504. * Helper function to auto-create an ActionEvent from a primitive
  27505. * @param prim defines the target primitive
  27506. * @param pointerPos defines the pointer position
  27507. * @param evt The original (browser) event
  27508. * @param additionalData additional data for the event
  27509. * @returns the new ActionEvent
  27510. */
  27511. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27512. }
  27513. }
  27514. declare module "babylonjs/Actions/abstractActionManager" {
  27515. import { IDisposable } from "babylonjs/scene";
  27516. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27517. import { IAction } from "babylonjs/Actions/action";
  27518. import { Nullable } from "babylonjs/types";
  27519. /**
  27520. * Abstract class used to decouple action Manager from scene and meshes.
  27521. * Do not instantiate.
  27522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27523. */
  27524. export abstract class AbstractActionManager implements IDisposable {
  27525. /** Gets the list of active triggers */
  27526. static Triggers: {
  27527. [key: string]: number;
  27528. };
  27529. /** Gets the cursor to use when hovering items */
  27530. hoverCursor: string;
  27531. /** Gets the list of actions */
  27532. actions: IAction[];
  27533. /**
  27534. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27535. */
  27536. isRecursive: boolean;
  27537. /**
  27538. * Releases all associated resources
  27539. */
  27540. abstract dispose(): void;
  27541. /**
  27542. * Does this action manager has pointer triggers
  27543. */
  27544. abstract readonly hasPointerTriggers: boolean;
  27545. /**
  27546. * Does this action manager has pick triggers
  27547. */
  27548. abstract readonly hasPickTriggers: boolean;
  27549. /**
  27550. * Process a specific trigger
  27551. * @param trigger defines the trigger to process
  27552. * @param evt defines the event details to be processed
  27553. */
  27554. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27555. /**
  27556. * Does this action manager handles actions of any of the given triggers
  27557. * @param triggers defines the triggers to be tested
  27558. * @return a boolean indicating whether one (or more) of the triggers is handled
  27559. */
  27560. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27561. /**
  27562. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27563. * speed.
  27564. * @param triggerA defines the trigger to be tested
  27565. * @param triggerB defines the trigger to be tested
  27566. * @return a boolean indicating whether one (or more) of the triggers is handled
  27567. */
  27568. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27569. /**
  27570. * Does this action manager handles actions of a given trigger
  27571. * @param trigger defines the trigger to be tested
  27572. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27573. * @return whether the trigger is handled
  27574. */
  27575. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27576. /**
  27577. * Serialize this manager to a JSON object
  27578. * @param name defines the property name to store this manager
  27579. * @returns a JSON representation of this manager
  27580. */
  27581. abstract serialize(name: string): any;
  27582. /**
  27583. * Registers an action to this action manager
  27584. * @param action defines the action to be registered
  27585. * @return the action amended (prepared) after registration
  27586. */
  27587. abstract registerAction(action: IAction): Nullable<IAction>;
  27588. /**
  27589. * Unregisters an action to this action manager
  27590. * @param action defines the action to be unregistered
  27591. * @return a boolean indicating whether the action has been unregistered
  27592. */
  27593. abstract unregisterAction(action: IAction): Boolean;
  27594. /**
  27595. * Does exist one action manager with at least one trigger
  27596. **/
  27597. static readonly HasTriggers: boolean;
  27598. /**
  27599. * Does exist one action manager with at least one pick trigger
  27600. **/
  27601. static readonly HasPickTriggers: boolean;
  27602. /**
  27603. * Does exist one action manager that handles actions of a given trigger
  27604. * @param trigger defines the trigger to be tested
  27605. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27606. **/
  27607. static HasSpecificTrigger(trigger: number): boolean;
  27608. }
  27609. }
  27610. declare module "babylonjs/node" {
  27611. import { Scene } from "babylonjs/scene";
  27612. import { Nullable } from "babylonjs/types";
  27613. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27614. import { Engine } from "babylonjs/Engines/engine";
  27615. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27616. import { Observable } from "babylonjs/Misc/observable";
  27617. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27618. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27619. import { Animatable } from "babylonjs/Animations/animatable";
  27620. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27621. import { Animation } from "babylonjs/Animations/animation";
  27622. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27624. /**
  27625. * Defines how a node can be built from a string name.
  27626. */
  27627. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27628. /**
  27629. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27630. */
  27631. export class Node implements IBehaviorAware<Node> {
  27632. /** @hidden */
  27633. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27634. private static _NodeConstructors;
  27635. /**
  27636. * Add a new node constructor
  27637. * @param type defines the type name of the node to construct
  27638. * @param constructorFunc defines the constructor function
  27639. */
  27640. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27641. /**
  27642. * Returns a node constructor based on type name
  27643. * @param type defines the type name
  27644. * @param name defines the new node name
  27645. * @param scene defines the hosting scene
  27646. * @param options defines optional options to transmit to constructors
  27647. * @returns the new constructor or null
  27648. */
  27649. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27650. /**
  27651. * Gets or sets the name of the node
  27652. */
  27653. name: string;
  27654. /**
  27655. * Gets or sets the id of the node
  27656. */
  27657. id: string;
  27658. /**
  27659. * Gets or sets the unique id of the node
  27660. */
  27661. uniqueId: number;
  27662. /**
  27663. * Gets or sets a string used to store user defined state for the node
  27664. */
  27665. state: string;
  27666. /**
  27667. * Gets or sets an object used to store user defined information for the node
  27668. */
  27669. metadata: any;
  27670. /**
  27671. * For internal use only. Please do not use.
  27672. */
  27673. reservedDataStore: any;
  27674. /**
  27675. * List of inspectable custom properties (used by the Inspector)
  27676. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27677. */
  27678. inspectableCustomProperties: IInspectable[];
  27679. /**
  27680. * Gets or sets a boolean used to define if the node must be serialized
  27681. */
  27682. doNotSerialize: boolean;
  27683. /** @hidden */
  27684. _isDisposed: boolean;
  27685. /**
  27686. * Gets a list of Animations associated with the node
  27687. */
  27688. animations: import("babylonjs/Animations/animation").Animation[];
  27689. protected _ranges: {
  27690. [name: string]: Nullable<AnimationRange>;
  27691. };
  27692. /**
  27693. * Callback raised when the node is ready to be used
  27694. */
  27695. onReady: Nullable<(node: Node) => void>;
  27696. private _isEnabled;
  27697. private _isParentEnabled;
  27698. private _isReady;
  27699. /** @hidden */
  27700. _currentRenderId: number;
  27701. private _parentUpdateId;
  27702. /** @hidden */
  27703. _childUpdateId: number;
  27704. /** @hidden */
  27705. _waitingParentId: Nullable<string>;
  27706. /** @hidden */
  27707. _scene: Scene;
  27708. /** @hidden */
  27709. _cache: any;
  27710. private _parentNode;
  27711. private _children;
  27712. /** @hidden */
  27713. _worldMatrix: Matrix;
  27714. /** @hidden */
  27715. _worldMatrixDeterminant: number;
  27716. /** @hidden */
  27717. _worldMatrixDeterminantIsDirty: boolean;
  27718. /** @hidden */
  27719. private _sceneRootNodesIndex;
  27720. /**
  27721. * Gets a boolean indicating if the node has been disposed
  27722. * @returns true if the node was disposed
  27723. */
  27724. isDisposed(): boolean;
  27725. /**
  27726. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27727. * @see https://doc.babylonjs.com/how_to/parenting
  27728. */
  27729. parent: Nullable<Node>;
  27730. private addToSceneRootNodes;
  27731. private removeFromSceneRootNodes;
  27732. private _animationPropertiesOverride;
  27733. /**
  27734. * Gets or sets the animation properties override
  27735. */
  27736. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27737. /**
  27738. * Gets a string idenfifying the name of the class
  27739. * @returns "Node" string
  27740. */
  27741. getClassName(): string;
  27742. /** @hidden */
  27743. readonly _isNode: boolean;
  27744. /**
  27745. * An event triggered when the mesh is disposed
  27746. */
  27747. onDisposeObservable: Observable<Node>;
  27748. private _onDisposeObserver;
  27749. /**
  27750. * Sets a callback that will be raised when the node will be disposed
  27751. */
  27752. onDispose: () => void;
  27753. /**
  27754. * Creates a new Node
  27755. * @param name the name and id to be given to this node
  27756. * @param scene the scene this node will be added to
  27757. * @param addToRootNodes the node will be added to scene.rootNodes
  27758. */
  27759. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27760. /**
  27761. * Gets the scene of the node
  27762. * @returns a scene
  27763. */
  27764. getScene(): Scene;
  27765. /**
  27766. * Gets the engine of the node
  27767. * @returns a Engine
  27768. */
  27769. getEngine(): Engine;
  27770. private _behaviors;
  27771. /**
  27772. * Attach a behavior to the node
  27773. * @see http://doc.babylonjs.com/features/behaviour
  27774. * @param behavior defines the behavior to attach
  27775. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27776. * @returns the current Node
  27777. */
  27778. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27779. /**
  27780. * Remove an attached behavior
  27781. * @see http://doc.babylonjs.com/features/behaviour
  27782. * @param behavior defines the behavior to attach
  27783. * @returns the current Node
  27784. */
  27785. removeBehavior(behavior: Behavior<Node>): Node;
  27786. /**
  27787. * Gets the list of attached behaviors
  27788. * @see http://doc.babylonjs.com/features/behaviour
  27789. */
  27790. readonly behaviors: Behavior<Node>[];
  27791. /**
  27792. * Gets an attached behavior by name
  27793. * @param name defines the name of the behavior to look for
  27794. * @see http://doc.babylonjs.com/features/behaviour
  27795. * @returns null if behavior was not found else the requested behavior
  27796. */
  27797. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27798. /**
  27799. * Returns the latest update of the World matrix
  27800. * @returns a Matrix
  27801. */
  27802. getWorldMatrix(): Matrix;
  27803. /** @hidden */
  27804. _getWorldMatrixDeterminant(): number;
  27805. /**
  27806. * Returns directly the latest state of the mesh World matrix.
  27807. * A Matrix is returned.
  27808. */
  27809. readonly worldMatrixFromCache: Matrix;
  27810. /** @hidden */
  27811. _initCache(): void;
  27812. /** @hidden */
  27813. updateCache(force?: boolean): void;
  27814. /** @hidden */
  27815. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27816. /** @hidden */
  27817. _updateCache(ignoreParentClass?: boolean): void;
  27818. /** @hidden */
  27819. _isSynchronized(): boolean;
  27820. /** @hidden */
  27821. _markSyncedWithParent(): void;
  27822. /** @hidden */
  27823. isSynchronizedWithParent(): boolean;
  27824. /** @hidden */
  27825. isSynchronized(): boolean;
  27826. /**
  27827. * Is this node ready to be used/rendered
  27828. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27829. * @return true if the node is ready
  27830. */
  27831. isReady(completeCheck?: boolean): boolean;
  27832. /**
  27833. * Is this node enabled?
  27834. * 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
  27835. * @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
  27836. * @return whether this node (and its parent) is enabled
  27837. */
  27838. isEnabled(checkAncestors?: boolean): boolean;
  27839. /** @hidden */
  27840. protected _syncParentEnabledState(): void;
  27841. /**
  27842. * Set the enabled state of this node
  27843. * @param value defines the new enabled state
  27844. */
  27845. setEnabled(value: boolean): void;
  27846. /**
  27847. * Is this node a descendant of the given node?
  27848. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27849. * @param ancestor defines the parent node to inspect
  27850. * @returns a boolean indicating if this node is a descendant of the given node
  27851. */
  27852. isDescendantOf(ancestor: Node): boolean;
  27853. /** @hidden */
  27854. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27855. /**
  27856. * Will return all nodes that have this node as ascendant
  27857. * @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
  27858. * @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
  27859. * @return all children nodes of all types
  27860. */
  27861. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27862. /**
  27863. * Get all child-meshes of this node
  27864. * @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)
  27865. * @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
  27866. * @returns an array of AbstractMesh
  27867. */
  27868. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27869. /**
  27870. * Get all direct children of this node
  27871. * @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
  27872. * @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)
  27873. * @returns an array of Node
  27874. */
  27875. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27876. /** @hidden */
  27877. _setReady(state: boolean): void;
  27878. /**
  27879. * Get an animation by name
  27880. * @param name defines the name of the animation to look for
  27881. * @returns null if not found else the requested animation
  27882. */
  27883. getAnimationByName(name: string): Nullable<Animation>;
  27884. /**
  27885. * Creates an animation range for this node
  27886. * @param name defines the name of the range
  27887. * @param from defines the starting key
  27888. * @param to defines the end key
  27889. */
  27890. createAnimationRange(name: string, from: number, to: number): void;
  27891. /**
  27892. * Delete a specific animation range
  27893. * @param name defines the name of the range to delete
  27894. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27895. */
  27896. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27897. /**
  27898. * Get an animation range by name
  27899. * @param name defines the name of the animation range to look for
  27900. * @returns null if not found else the requested animation range
  27901. */
  27902. getAnimationRange(name: string): Nullable<AnimationRange>;
  27903. /**
  27904. * Gets the list of all animation ranges defined on this node
  27905. * @returns an array
  27906. */
  27907. getAnimationRanges(): Nullable<AnimationRange>[];
  27908. /**
  27909. * Will start the animation sequence
  27910. * @param name defines the range frames for animation sequence
  27911. * @param loop defines if the animation should loop (false by default)
  27912. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27913. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27914. * @returns the object created for this animation. If range does not exist, it will return null
  27915. */
  27916. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27917. /**
  27918. * Serialize animation ranges into a JSON compatible object
  27919. * @returns serialization object
  27920. */
  27921. serializeAnimationRanges(): any;
  27922. /**
  27923. * Computes the world matrix of the node
  27924. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27925. * @returns the world matrix
  27926. */
  27927. computeWorldMatrix(force?: boolean): Matrix;
  27928. /**
  27929. * Releases resources associated with this node.
  27930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27932. */
  27933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27934. /**
  27935. * Parse animation range data from a serialization object and store them into a given node
  27936. * @param node defines where to store the animation ranges
  27937. * @param parsedNode defines the serialization object to read data from
  27938. * @param scene defines the hosting scene
  27939. */
  27940. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27941. /**
  27942. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27943. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27944. * @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
  27945. * @returns the new bounding vectors
  27946. */
  27947. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27948. min: Vector3;
  27949. max: Vector3;
  27950. };
  27951. }
  27952. }
  27953. declare module "babylonjs/Animations/animation" {
  27954. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27955. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27956. import { Color3 } from "babylonjs/Maths/math.color";
  27957. import { Nullable } from "babylonjs/types";
  27958. import { Scene } from "babylonjs/scene";
  27959. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27960. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27961. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27962. import { Node } from "babylonjs/node";
  27963. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27964. import { Size } from "babylonjs/Maths/math.size";
  27965. import { Animatable } from "babylonjs/Animations/animatable";
  27966. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27967. /**
  27968. * @hidden
  27969. */
  27970. export class _IAnimationState {
  27971. key: number;
  27972. repeatCount: number;
  27973. workValue?: any;
  27974. loopMode?: number;
  27975. offsetValue?: any;
  27976. highLimitValue?: any;
  27977. }
  27978. /**
  27979. * Class used to store any kind of animation
  27980. */
  27981. export class Animation {
  27982. /**Name of the animation */
  27983. name: string;
  27984. /**Property to animate */
  27985. targetProperty: string;
  27986. /**The frames per second of the animation */
  27987. framePerSecond: number;
  27988. /**The data type of the animation */
  27989. dataType: number;
  27990. /**The loop mode of the animation */
  27991. loopMode?: number | undefined;
  27992. /**Specifies if blending should be enabled */
  27993. enableBlending?: boolean | undefined;
  27994. /**
  27995. * Use matrix interpolation instead of using direct key value when animating matrices
  27996. */
  27997. static AllowMatricesInterpolation: boolean;
  27998. /**
  27999. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28000. */
  28001. static AllowMatrixDecomposeForInterpolation: boolean;
  28002. /**
  28003. * Stores the key frames of the animation
  28004. */
  28005. private _keys;
  28006. /**
  28007. * Stores the easing function of the animation
  28008. */
  28009. private _easingFunction;
  28010. /**
  28011. * @hidden Internal use only
  28012. */
  28013. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28014. /**
  28015. * The set of event that will be linked to this animation
  28016. */
  28017. private _events;
  28018. /**
  28019. * Stores an array of target property paths
  28020. */
  28021. targetPropertyPath: string[];
  28022. /**
  28023. * Stores the blending speed of the animation
  28024. */
  28025. blendingSpeed: number;
  28026. /**
  28027. * Stores the animation ranges for the animation
  28028. */
  28029. private _ranges;
  28030. /**
  28031. * @hidden Internal use
  28032. */
  28033. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28034. /**
  28035. * Sets up an animation
  28036. * @param property The property to animate
  28037. * @param animationType The animation type to apply
  28038. * @param framePerSecond The frames per second of the animation
  28039. * @param easingFunction The easing function used in the animation
  28040. * @returns The created animation
  28041. */
  28042. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28043. /**
  28044. * Create and start an animation on a node
  28045. * @param name defines the name of the global animation that will be run on all nodes
  28046. * @param node defines the root node where the animation will take place
  28047. * @param targetProperty defines property to animate
  28048. * @param framePerSecond defines the number of frame per second yo use
  28049. * @param totalFrame defines the number of frames in total
  28050. * @param from defines the initial value
  28051. * @param to defines the final value
  28052. * @param loopMode defines which loop mode you want to use (off by default)
  28053. * @param easingFunction defines the easing function to use (linear by default)
  28054. * @param onAnimationEnd defines the callback to call when animation end
  28055. * @returns the animatable created for this animation
  28056. */
  28057. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28058. /**
  28059. * Create and start an animation on a node and its descendants
  28060. * @param name defines the name of the global animation that will be run on all nodes
  28061. * @param node defines the root node where the animation will take place
  28062. * @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
  28063. * @param targetProperty defines property to animate
  28064. * @param framePerSecond defines the number of frame per second to use
  28065. * @param totalFrame defines the number of frames in total
  28066. * @param from defines the initial value
  28067. * @param to defines the final value
  28068. * @param loopMode defines which loop mode you want to use (off by default)
  28069. * @param easingFunction defines the easing function to use (linear by default)
  28070. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28071. * @returns the list of animatables created for all nodes
  28072. * @example https://www.babylonjs-playground.com/#MH0VLI
  28073. */
  28074. 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[]>;
  28075. /**
  28076. * Creates a new animation, merges it with the existing animations and starts it
  28077. * @param name Name of the animation
  28078. * @param node Node which contains the scene that begins the animations
  28079. * @param targetProperty Specifies which property to animate
  28080. * @param framePerSecond The frames per second of the animation
  28081. * @param totalFrame The total number of frames
  28082. * @param from The frame at the beginning of the animation
  28083. * @param to The frame at the end of the animation
  28084. * @param loopMode Specifies the loop mode of the animation
  28085. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28086. * @param onAnimationEnd Callback to run once the animation is complete
  28087. * @returns Nullable animation
  28088. */
  28089. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28090. /**
  28091. * Transition property of an host to the target Value
  28092. * @param property The property to transition
  28093. * @param targetValue The target Value of the property
  28094. * @param host The object where the property to animate belongs
  28095. * @param scene Scene used to run the animation
  28096. * @param frameRate Framerate (in frame/s) to use
  28097. * @param transition The transition type we want to use
  28098. * @param duration The duration of the animation, in milliseconds
  28099. * @param onAnimationEnd Callback trigger at the end of the animation
  28100. * @returns Nullable animation
  28101. */
  28102. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28103. /**
  28104. * Return the array of runtime animations currently using this animation
  28105. */
  28106. readonly runtimeAnimations: RuntimeAnimation[];
  28107. /**
  28108. * Specifies if any of the runtime animations are currently running
  28109. */
  28110. readonly hasRunningRuntimeAnimations: boolean;
  28111. /**
  28112. * Initializes the animation
  28113. * @param name Name of the animation
  28114. * @param targetProperty Property to animate
  28115. * @param framePerSecond The frames per second of the animation
  28116. * @param dataType The data type of the animation
  28117. * @param loopMode The loop mode of the animation
  28118. * @param enableBlending Specifies if blending should be enabled
  28119. */
  28120. constructor(
  28121. /**Name of the animation */
  28122. name: string,
  28123. /**Property to animate */
  28124. targetProperty: string,
  28125. /**The frames per second of the animation */
  28126. framePerSecond: number,
  28127. /**The data type of the animation */
  28128. dataType: number,
  28129. /**The loop mode of the animation */
  28130. loopMode?: number | undefined,
  28131. /**Specifies if blending should be enabled */
  28132. enableBlending?: boolean | undefined);
  28133. /**
  28134. * Converts the animation to a string
  28135. * @param fullDetails support for multiple levels of logging within scene loading
  28136. * @returns String form of the animation
  28137. */
  28138. toString(fullDetails?: boolean): string;
  28139. /**
  28140. * Add an event to this animation
  28141. * @param event Event to add
  28142. */
  28143. addEvent(event: AnimationEvent): void;
  28144. /**
  28145. * Remove all events found at the given frame
  28146. * @param frame The frame to remove events from
  28147. */
  28148. removeEvents(frame: number): void;
  28149. /**
  28150. * Retrieves all the events from the animation
  28151. * @returns Events from the animation
  28152. */
  28153. getEvents(): AnimationEvent[];
  28154. /**
  28155. * Creates an animation range
  28156. * @param name Name of the animation range
  28157. * @param from Starting frame of the animation range
  28158. * @param to Ending frame of the animation
  28159. */
  28160. createRange(name: string, from: number, to: number): void;
  28161. /**
  28162. * Deletes an animation range by name
  28163. * @param name Name of the animation range to delete
  28164. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28165. */
  28166. deleteRange(name: string, deleteFrames?: boolean): void;
  28167. /**
  28168. * Gets the animation range by name, or null if not defined
  28169. * @param name Name of the animation range
  28170. * @returns Nullable animation range
  28171. */
  28172. getRange(name: string): Nullable<AnimationRange>;
  28173. /**
  28174. * Gets the key frames from the animation
  28175. * @returns The key frames of the animation
  28176. */
  28177. getKeys(): Array<IAnimationKey>;
  28178. /**
  28179. * Gets the highest frame rate of the animation
  28180. * @returns Highest frame rate of the animation
  28181. */
  28182. getHighestFrame(): number;
  28183. /**
  28184. * Gets the easing function of the animation
  28185. * @returns Easing function of the animation
  28186. */
  28187. getEasingFunction(): IEasingFunction;
  28188. /**
  28189. * Sets the easing function of the animation
  28190. * @param easingFunction A custom mathematical formula for animation
  28191. */
  28192. setEasingFunction(easingFunction: EasingFunction): void;
  28193. /**
  28194. * Interpolates a scalar linearly
  28195. * @param startValue Start value of the animation curve
  28196. * @param endValue End value of the animation curve
  28197. * @param gradient Scalar amount to interpolate
  28198. * @returns Interpolated scalar value
  28199. */
  28200. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28201. /**
  28202. * Interpolates a scalar cubically
  28203. * @param startValue Start value of the animation curve
  28204. * @param outTangent End tangent of the animation
  28205. * @param endValue End value of the animation curve
  28206. * @param inTangent Start tangent of the animation curve
  28207. * @param gradient Scalar amount to interpolate
  28208. * @returns Interpolated scalar value
  28209. */
  28210. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28211. /**
  28212. * Interpolates a quaternion using a spherical linear interpolation
  28213. * @param startValue Start value of the animation curve
  28214. * @param endValue End value of the animation curve
  28215. * @param gradient Scalar amount to interpolate
  28216. * @returns Interpolated quaternion value
  28217. */
  28218. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28219. /**
  28220. * Interpolates a quaternion cubically
  28221. * @param startValue Start value of the animation curve
  28222. * @param outTangent End tangent of the animation curve
  28223. * @param endValue End value of the animation curve
  28224. * @param inTangent Start tangent of the animation curve
  28225. * @param gradient Scalar amount to interpolate
  28226. * @returns Interpolated quaternion value
  28227. */
  28228. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28229. /**
  28230. * Interpolates a Vector3 linearl
  28231. * @param startValue Start value of the animation curve
  28232. * @param endValue End value of the animation curve
  28233. * @param gradient Scalar amount to interpolate
  28234. * @returns Interpolated scalar value
  28235. */
  28236. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28237. /**
  28238. * Interpolates a Vector3 cubically
  28239. * @param startValue Start value of the animation curve
  28240. * @param outTangent End tangent of the animation
  28241. * @param endValue End value of the animation curve
  28242. * @param inTangent Start tangent of the animation curve
  28243. * @param gradient Scalar amount to interpolate
  28244. * @returns InterpolatedVector3 value
  28245. */
  28246. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28247. /**
  28248. * Interpolates a Vector2 linearly
  28249. * @param startValue Start value of the animation curve
  28250. * @param endValue End value of the animation curve
  28251. * @param gradient Scalar amount to interpolate
  28252. * @returns Interpolated Vector2 value
  28253. */
  28254. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28255. /**
  28256. * Interpolates a Vector2 cubically
  28257. * @param startValue Start value of the animation curve
  28258. * @param outTangent End tangent of the animation
  28259. * @param endValue End value of the animation curve
  28260. * @param inTangent Start tangent of the animation curve
  28261. * @param gradient Scalar amount to interpolate
  28262. * @returns Interpolated Vector2 value
  28263. */
  28264. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28265. /**
  28266. * Interpolates a size linearly
  28267. * @param startValue Start value of the animation curve
  28268. * @param endValue End value of the animation curve
  28269. * @param gradient Scalar amount to interpolate
  28270. * @returns Interpolated Size value
  28271. */
  28272. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28273. /**
  28274. * Interpolates a Color3 linearly
  28275. * @param startValue Start value of the animation curve
  28276. * @param endValue End value of the animation curve
  28277. * @param gradient Scalar amount to interpolate
  28278. * @returns Interpolated Color3 value
  28279. */
  28280. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28281. /**
  28282. * @hidden Internal use only
  28283. */
  28284. _getKeyValue(value: any): any;
  28285. /**
  28286. * @hidden Internal use only
  28287. */
  28288. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28289. /**
  28290. * Defines the function to use to interpolate matrices
  28291. * @param startValue defines the start matrix
  28292. * @param endValue defines the end matrix
  28293. * @param gradient defines the gradient between both matrices
  28294. * @param result defines an optional target matrix where to store the interpolation
  28295. * @returns the interpolated matrix
  28296. */
  28297. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28298. /**
  28299. * Makes a copy of the animation
  28300. * @returns Cloned animation
  28301. */
  28302. clone(): Animation;
  28303. /**
  28304. * Sets the key frames of the animation
  28305. * @param values The animation key frames to set
  28306. */
  28307. setKeys(values: Array<IAnimationKey>): void;
  28308. /**
  28309. * Serializes the animation to an object
  28310. * @returns Serialized object
  28311. */
  28312. serialize(): any;
  28313. /**
  28314. * Float animation type
  28315. */
  28316. private static _ANIMATIONTYPE_FLOAT;
  28317. /**
  28318. * Vector3 animation type
  28319. */
  28320. private static _ANIMATIONTYPE_VECTOR3;
  28321. /**
  28322. * Quaternion animation type
  28323. */
  28324. private static _ANIMATIONTYPE_QUATERNION;
  28325. /**
  28326. * Matrix animation type
  28327. */
  28328. private static _ANIMATIONTYPE_MATRIX;
  28329. /**
  28330. * Color3 animation type
  28331. */
  28332. private static _ANIMATIONTYPE_COLOR3;
  28333. /**
  28334. * Vector2 animation type
  28335. */
  28336. private static _ANIMATIONTYPE_VECTOR2;
  28337. /**
  28338. * Size animation type
  28339. */
  28340. private static _ANIMATIONTYPE_SIZE;
  28341. /**
  28342. * Relative Loop Mode
  28343. */
  28344. private static _ANIMATIONLOOPMODE_RELATIVE;
  28345. /**
  28346. * Cycle Loop Mode
  28347. */
  28348. private static _ANIMATIONLOOPMODE_CYCLE;
  28349. /**
  28350. * Constant Loop Mode
  28351. */
  28352. private static _ANIMATIONLOOPMODE_CONSTANT;
  28353. /**
  28354. * Get the float animation type
  28355. */
  28356. static readonly ANIMATIONTYPE_FLOAT: number;
  28357. /**
  28358. * Get the Vector3 animation type
  28359. */
  28360. static readonly ANIMATIONTYPE_VECTOR3: number;
  28361. /**
  28362. * Get the Vector2 animation type
  28363. */
  28364. static readonly ANIMATIONTYPE_VECTOR2: number;
  28365. /**
  28366. * Get the Size animation type
  28367. */
  28368. static readonly ANIMATIONTYPE_SIZE: number;
  28369. /**
  28370. * Get the Quaternion animation type
  28371. */
  28372. static readonly ANIMATIONTYPE_QUATERNION: number;
  28373. /**
  28374. * Get the Matrix animation type
  28375. */
  28376. static readonly ANIMATIONTYPE_MATRIX: number;
  28377. /**
  28378. * Get the Color3 animation type
  28379. */
  28380. static readonly ANIMATIONTYPE_COLOR3: number;
  28381. /**
  28382. * Get the Relative Loop Mode
  28383. */
  28384. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28385. /**
  28386. * Get the Cycle Loop Mode
  28387. */
  28388. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28389. /**
  28390. * Get the Constant Loop Mode
  28391. */
  28392. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28393. /** @hidden */
  28394. static _UniversalLerp(left: any, right: any, amount: number): any;
  28395. /**
  28396. * Parses an animation object and creates an animation
  28397. * @param parsedAnimation Parsed animation object
  28398. * @returns Animation object
  28399. */
  28400. static Parse(parsedAnimation: any): Animation;
  28401. /**
  28402. * Appends the serialized animations from the source animations
  28403. * @param source Source containing the animations
  28404. * @param destination Target to store the animations
  28405. */
  28406. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28407. }
  28408. }
  28409. declare module "babylonjs/Animations/animatable.interface" {
  28410. import { Nullable } from "babylonjs/types";
  28411. import { Animation } from "babylonjs/Animations/animation";
  28412. /**
  28413. * Interface containing an array of animations
  28414. */
  28415. export interface IAnimatable {
  28416. /**
  28417. * Array of animations
  28418. */
  28419. animations: Nullable<Array<Animation>>;
  28420. }
  28421. }
  28422. declare module "babylonjs/Materials/fresnelParameters" {
  28423. import { Color3 } from "babylonjs/Maths/math.color";
  28424. /**
  28425. * This represents all the required information to add a fresnel effect on a material:
  28426. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28427. */
  28428. export class FresnelParameters {
  28429. private _isEnabled;
  28430. /**
  28431. * Define if the fresnel effect is enable or not.
  28432. */
  28433. isEnabled: boolean;
  28434. /**
  28435. * Define the color used on edges (grazing angle)
  28436. */
  28437. leftColor: Color3;
  28438. /**
  28439. * Define the color used on center
  28440. */
  28441. rightColor: Color3;
  28442. /**
  28443. * Define bias applied to computed fresnel term
  28444. */
  28445. bias: number;
  28446. /**
  28447. * Defined the power exponent applied to fresnel term
  28448. */
  28449. power: number;
  28450. /**
  28451. * Clones the current fresnel and its valuues
  28452. * @returns a clone fresnel configuration
  28453. */
  28454. clone(): FresnelParameters;
  28455. /**
  28456. * Serializes the current fresnel parameters to a JSON representation.
  28457. * @return the JSON serialization
  28458. */
  28459. serialize(): any;
  28460. /**
  28461. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28462. * @param parsedFresnelParameters Define the JSON representation
  28463. * @returns the parsed parameters
  28464. */
  28465. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28466. }
  28467. }
  28468. declare module "babylonjs/Misc/decorators" {
  28469. import { Nullable } from "babylonjs/types";
  28470. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28471. import { Scene } from "babylonjs/scene";
  28472. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28473. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28474. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28475. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28476. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28477. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28478. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28479. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28480. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28481. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28482. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28483. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28484. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28485. /**
  28486. * Decorator used to define property that can be serialized as reference to a camera
  28487. * @param sourceName defines the name of the property to decorate
  28488. */
  28489. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28490. /**
  28491. * Class used to help serialization objects
  28492. */
  28493. export class SerializationHelper {
  28494. /** @hidden */
  28495. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28496. /** @hidden */
  28497. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28498. /** @hidden */
  28499. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28500. /** @hidden */
  28501. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28502. /**
  28503. * Appends the serialized animations from the source animations
  28504. * @param source Source containing the animations
  28505. * @param destination Target to store the animations
  28506. */
  28507. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28508. /**
  28509. * Static function used to serialized a specific entity
  28510. * @param entity defines the entity to serialize
  28511. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28512. * @returns a JSON compatible object representing the serialization of the entity
  28513. */
  28514. static Serialize<T>(entity: T, serializationObject?: any): any;
  28515. /**
  28516. * Creates a new entity from a serialization data object
  28517. * @param creationFunction defines a function used to instanciated the new entity
  28518. * @param source defines the source serialization data
  28519. * @param scene defines the hosting scene
  28520. * @param rootUrl defines the root url for resources
  28521. * @returns a new entity
  28522. */
  28523. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28524. /**
  28525. * Clones an object
  28526. * @param creationFunction defines the function used to instanciate the new object
  28527. * @param source defines the source object
  28528. * @returns the cloned object
  28529. */
  28530. static Clone<T>(creationFunction: () => T, source: T): T;
  28531. /**
  28532. * Instanciates a new object based on a source one (some data will be shared between both object)
  28533. * @param creationFunction defines the function used to instanciate the new object
  28534. * @param source defines the source object
  28535. * @returns the new object
  28536. */
  28537. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28538. }
  28539. }
  28540. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28541. import { Nullable } from "babylonjs/types";
  28542. /**
  28543. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28544. */
  28545. export interface CubeMapInfo {
  28546. /**
  28547. * The pixel array for the front face.
  28548. * This is stored in format, left to right, up to down format.
  28549. */
  28550. front: Nullable<ArrayBufferView>;
  28551. /**
  28552. * The pixel array for the back face.
  28553. * This is stored in format, left to right, up to down format.
  28554. */
  28555. back: Nullable<ArrayBufferView>;
  28556. /**
  28557. * The pixel array for the left face.
  28558. * This is stored in format, left to right, up to down format.
  28559. */
  28560. left: Nullable<ArrayBufferView>;
  28561. /**
  28562. * The pixel array for the right face.
  28563. * This is stored in format, left to right, up to down format.
  28564. */
  28565. right: Nullable<ArrayBufferView>;
  28566. /**
  28567. * The pixel array for the up face.
  28568. * This is stored in format, left to right, up to down format.
  28569. */
  28570. up: Nullable<ArrayBufferView>;
  28571. /**
  28572. * The pixel array for the down face.
  28573. * This is stored in format, left to right, up to down format.
  28574. */
  28575. down: Nullable<ArrayBufferView>;
  28576. /**
  28577. * The size of the cubemap stored.
  28578. *
  28579. * Each faces will be size * size pixels.
  28580. */
  28581. size: number;
  28582. /**
  28583. * The format of the texture.
  28584. *
  28585. * RGBA, RGB.
  28586. */
  28587. format: number;
  28588. /**
  28589. * The type of the texture data.
  28590. *
  28591. * UNSIGNED_INT, FLOAT.
  28592. */
  28593. type: number;
  28594. /**
  28595. * Specifies whether the texture is in gamma space.
  28596. */
  28597. gammaSpace: boolean;
  28598. }
  28599. /**
  28600. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28601. */
  28602. export class PanoramaToCubeMapTools {
  28603. private static FACE_FRONT;
  28604. private static FACE_BACK;
  28605. private static FACE_RIGHT;
  28606. private static FACE_LEFT;
  28607. private static FACE_DOWN;
  28608. private static FACE_UP;
  28609. /**
  28610. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28611. *
  28612. * @param float32Array The source data.
  28613. * @param inputWidth The width of the input panorama.
  28614. * @param inputHeight The height of the input panorama.
  28615. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28616. * @return The cubemap data
  28617. */
  28618. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28619. private static CreateCubemapTexture;
  28620. private static CalcProjectionSpherical;
  28621. }
  28622. }
  28623. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28624. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28626. import { Nullable } from "babylonjs/types";
  28627. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28628. /**
  28629. * Helper class dealing with the extraction of spherical polynomial dataArray
  28630. * from a cube map.
  28631. */
  28632. export class CubeMapToSphericalPolynomialTools {
  28633. private static FileFaces;
  28634. /**
  28635. * Converts a texture to the according Spherical Polynomial data.
  28636. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28637. *
  28638. * @param texture The texture to extract the information from.
  28639. * @return The Spherical Polynomial data.
  28640. */
  28641. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28642. /**
  28643. * Converts a cubemap to the according Spherical Polynomial data.
  28644. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28645. *
  28646. * @param cubeInfo The Cube map to extract the information from.
  28647. * @return The Spherical Polynomial data.
  28648. */
  28649. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28650. }
  28651. }
  28652. declare module "babylonjs/Misc/guid" {
  28653. /**
  28654. * Class used to manipulate GUIDs
  28655. */
  28656. export class GUID {
  28657. /**
  28658. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28659. * Be aware Math.random() could cause collisions, but:
  28660. * "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"
  28661. * @returns a pseudo random id
  28662. */
  28663. static RandomId(): string;
  28664. }
  28665. }
  28666. declare module "babylonjs/Materials/Textures/baseTexture" {
  28667. import { Observable } from "babylonjs/Misc/observable";
  28668. import { Nullable } from "babylonjs/types";
  28669. import { Scene } from "babylonjs/scene";
  28670. import { Matrix } from "babylonjs/Maths/math.vector";
  28671. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28673. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28674. import { ISize } from "babylonjs/Maths/math.size";
  28675. /**
  28676. * Base class of all the textures in babylon.
  28677. * It groups all the common properties the materials, post process, lights... might need
  28678. * in order to make a correct use of the texture.
  28679. */
  28680. export class BaseTexture implements IAnimatable {
  28681. /**
  28682. * Default anisotropic filtering level for the application.
  28683. * It is set to 4 as a good tradeoff between perf and quality.
  28684. */
  28685. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28686. /**
  28687. * Gets or sets the unique id of the texture
  28688. */
  28689. uniqueId: number;
  28690. /**
  28691. * Define the name of the texture.
  28692. */
  28693. name: string;
  28694. /**
  28695. * Gets or sets an object used to store user defined information.
  28696. */
  28697. metadata: any;
  28698. /**
  28699. * For internal use only. Please do not use.
  28700. */
  28701. reservedDataStore: any;
  28702. private _hasAlpha;
  28703. /**
  28704. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28705. */
  28706. hasAlpha: boolean;
  28707. /**
  28708. * Defines if the alpha value should be determined via the rgb values.
  28709. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28710. */
  28711. getAlphaFromRGB: boolean;
  28712. /**
  28713. * Intensity or strength of the texture.
  28714. * It is commonly used by materials to fine tune the intensity of the texture
  28715. */
  28716. level: number;
  28717. /**
  28718. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28719. * This is part of the texture as textures usually maps to one uv set.
  28720. */
  28721. coordinatesIndex: number;
  28722. private _coordinatesMode;
  28723. /**
  28724. * How a texture is mapped.
  28725. *
  28726. * | Value | Type | Description |
  28727. * | ----- | ----------------------------------- | ----------- |
  28728. * | 0 | EXPLICIT_MODE | |
  28729. * | 1 | SPHERICAL_MODE | |
  28730. * | 2 | PLANAR_MODE | |
  28731. * | 3 | CUBIC_MODE | |
  28732. * | 4 | PROJECTION_MODE | |
  28733. * | 5 | SKYBOX_MODE | |
  28734. * | 6 | INVCUBIC_MODE | |
  28735. * | 7 | EQUIRECTANGULAR_MODE | |
  28736. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28737. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28738. */
  28739. coordinatesMode: number;
  28740. /**
  28741. * | Value | Type | Description |
  28742. * | ----- | ------------------ | ----------- |
  28743. * | 0 | CLAMP_ADDRESSMODE | |
  28744. * | 1 | WRAP_ADDRESSMODE | |
  28745. * | 2 | MIRROR_ADDRESSMODE | |
  28746. */
  28747. wrapU: number;
  28748. /**
  28749. * | Value | Type | Description |
  28750. * | ----- | ------------------ | ----------- |
  28751. * | 0 | CLAMP_ADDRESSMODE | |
  28752. * | 1 | WRAP_ADDRESSMODE | |
  28753. * | 2 | MIRROR_ADDRESSMODE | |
  28754. */
  28755. wrapV: number;
  28756. /**
  28757. * | Value | Type | Description |
  28758. * | ----- | ------------------ | ----------- |
  28759. * | 0 | CLAMP_ADDRESSMODE | |
  28760. * | 1 | WRAP_ADDRESSMODE | |
  28761. * | 2 | MIRROR_ADDRESSMODE | |
  28762. */
  28763. wrapR: number;
  28764. /**
  28765. * With compliant hardware and browser (supporting anisotropic filtering)
  28766. * this defines the level of anisotropic filtering in the texture.
  28767. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28768. */
  28769. anisotropicFilteringLevel: number;
  28770. /**
  28771. * Define if the texture is a cube texture or if false a 2d texture.
  28772. */
  28773. isCube: boolean;
  28774. /**
  28775. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28776. */
  28777. is3D: boolean;
  28778. /**
  28779. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28780. * HDR texture are usually stored in linear space.
  28781. * This only impacts the PBR and Background materials
  28782. */
  28783. gammaSpace: boolean;
  28784. /**
  28785. * Gets or sets whether or not the texture contains RGBD data.
  28786. */
  28787. isRGBD: boolean;
  28788. /**
  28789. * Is Z inverted in the texture (useful in a cube texture).
  28790. */
  28791. invertZ: boolean;
  28792. /**
  28793. * Are mip maps generated for this texture or not.
  28794. */
  28795. readonly noMipmap: boolean;
  28796. /**
  28797. * @hidden
  28798. */
  28799. lodLevelInAlpha: boolean;
  28800. /**
  28801. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28802. */
  28803. lodGenerationOffset: number;
  28804. /**
  28805. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28806. */
  28807. lodGenerationScale: number;
  28808. /**
  28809. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28810. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28811. * average roughness values.
  28812. */
  28813. linearSpecularLOD: boolean;
  28814. /**
  28815. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28816. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28817. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28818. */
  28819. irradianceTexture: Nullable<BaseTexture>;
  28820. /**
  28821. * Define if the texture is a render target.
  28822. */
  28823. isRenderTarget: boolean;
  28824. /**
  28825. * Define the unique id of the texture in the scene.
  28826. */
  28827. readonly uid: string;
  28828. /**
  28829. * Return a string representation of the texture.
  28830. * @returns the texture as a string
  28831. */
  28832. toString(): string;
  28833. /**
  28834. * Get the class name of the texture.
  28835. * @returns "BaseTexture"
  28836. */
  28837. getClassName(): string;
  28838. /**
  28839. * Define the list of animation attached to the texture.
  28840. */
  28841. animations: import("babylonjs/Animations/animation").Animation[];
  28842. /**
  28843. * An event triggered when the texture is disposed.
  28844. */
  28845. onDisposeObservable: Observable<BaseTexture>;
  28846. private _onDisposeObserver;
  28847. /**
  28848. * Callback triggered when the texture has been disposed.
  28849. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28850. */
  28851. onDispose: () => void;
  28852. /**
  28853. * Define the current state of the loading sequence when in delayed load mode.
  28854. */
  28855. delayLoadState: number;
  28856. private _scene;
  28857. /** @hidden */
  28858. _texture: Nullable<InternalTexture>;
  28859. private _uid;
  28860. /**
  28861. * Define if the texture is preventinga material to render or not.
  28862. * If not and the texture is not ready, the engine will use a default black texture instead.
  28863. */
  28864. readonly isBlocking: boolean;
  28865. /**
  28866. * Instantiates a new BaseTexture.
  28867. * Base class of all the textures in babylon.
  28868. * It groups all the common properties the materials, post process, lights... might need
  28869. * in order to make a correct use of the texture.
  28870. * @param scene Define the scene the texture blongs to
  28871. */
  28872. constructor(scene: Nullable<Scene>);
  28873. /**
  28874. * Get the scene the texture belongs to.
  28875. * @returns the scene or null if undefined
  28876. */
  28877. getScene(): Nullable<Scene>;
  28878. /**
  28879. * Get the texture transform matrix used to offset tile the texture for istance.
  28880. * @returns the transformation matrix
  28881. */
  28882. getTextureMatrix(): Matrix;
  28883. /**
  28884. * Get the texture reflection matrix used to rotate/transform the reflection.
  28885. * @returns the reflection matrix
  28886. */
  28887. getReflectionTextureMatrix(): Matrix;
  28888. /**
  28889. * Get the underlying lower level texture from Babylon.
  28890. * @returns the insternal texture
  28891. */
  28892. getInternalTexture(): Nullable<InternalTexture>;
  28893. /**
  28894. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28895. * @returns true if ready or not blocking
  28896. */
  28897. isReadyOrNotBlocking(): boolean;
  28898. /**
  28899. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28900. * @returns true if fully ready
  28901. */
  28902. isReady(): boolean;
  28903. private _cachedSize;
  28904. /**
  28905. * Get the size of the texture.
  28906. * @returns the texture size.
  28907. */
  28908. getSize(): ISize;
  28909. /**
  28910. * Get the base size of the texture.
  28911. * It can be different from the size if the texture has been resized for POT for instance
  28912. * @returns the base size
  28913. */
  28914. getBaseSize(): ISize;
  28915. /**
  28916. * Update the sampling mode of the texture.
  28917. * Default is Trilinear mode.
  28918. *
  28919. * | Value | Type | Description |
  28920. * | ----- | ------------------ | ----------- |
  28921. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28922. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28923. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28924. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28925. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28926. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28927. * | 7 | NEAREST_LINEAR | |
  28928. * | 8 | NEAREST_NEAREST | |
  28929. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28930. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28931. * | 11 | LINEAR_LINEAR | |
  28932. * | 12 | LINEAR_NEAREST | |
  28933. *
  28934. * > _mag_: magnification filter (close to the viewer)
  28935. * > _min_: minification filter (far from the viewer)
  28936. * > _mip_: filter used between mip map levels
  28937. *@param samplingMode Define the new sampling mode of the texture
  28938. */
  28939. updateSamplingMode(samplingMode: number): void;
  28940. /**
  28941. * Scales the texture if is `canRescale()`
  28942. * @param ratio the resize factor we want to use to rescale
  28943. */
  28944. scale(ratio: number): void;
  28945. /**
  28946. * Get if the texture can rescale.
  28947. */
  28948. readonly canRescale: boolean;
  28949. /** @hidden */
  28950. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28951. /** @hidden */
  28952. _rebuild(): void;
  28953. /**
  28954. * Triggers the load sequence in delayed load mode.
  28955. */
  28956. delayLoad(): void;
  28957. /**
  28958. * Clones the texture.
  28959. * @returns the cloned texture
  28960. */
  28961. clone(): Nullable<BaseTexture>;
  28962. /**
  28963. * Get the texture underlying type (INT, FLOAT...)
  28964. */
  28965. readonly textureType: number;
  28966. /**
  28967. * Get the texture underlying format (RGB, RGBA...)
  28968. */
  28969. readonly textureFormat: number;
  28970. /**
  28971. * Indicates that textures need to be re-calculated for all materials
  28972. */
  28973. protected _markAllSubMeshesAsTexturesDirty(): void;
  28974. /**
  28975. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28976. * This will returns an RGBA array buffer containing either in values (0-255) or
  28977. * float values (0-1) depending of the underlying buffer type.
  28978. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28979. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28980. * @param buffer defines a user defined buffer to fill with data (can be null)
  28981. * @returns The Array buffer containing the pixels data.
  28982. */
  28983. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28984. /**
  28985. * Release and destroy the underlying lower level texture aka internalTexture.
  28986. */
  28987. releaseInternalTexture(): void;
  28988. /**
  28989. * Get the polynomial representation of the texture data.
  28990. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28991. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28992. */
  28993. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28994. /** @hidden */
  28995. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28996. /** @hidden */
  28997. readonly _lodTextureMid: Nullable<BaseTexture>;
  28998. /** @hidden */
  28999. readonly _lodTextureLow: Nullable<BaseTexture>;
  29000. /**
  29001. * Dispose the texture and release its associated resources.
  29002. */
  29003. dispose(): void;
  29004. /**
  29005. * Serialize the texture into a JSON representation that can be parsed later on.
  29006. * @returns the JSON representation of the texture
  29007. */
  29008. serialize(): any;
  29009. /**
  29010. * Helper function to be called back once a list of texture contains only ready textures.
  29011. * @param textures Define the list of textures to wait for
  29012. * @param callback Define the callback triggered once the entire list will be ready
  29013. */
  29014. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29015. }
  29016. }
  29017. declare module "babylonjs/Materials/effect" {
  29018. import { Observable } from "babylonjs/Misc/observable";
  29019. import { Nullable } from "babylonjs/types";
  29020. import { IDisposable } from "babylonjs/scene";
  29021. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29022. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29023. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29024. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29025. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29026. import { Engine } from "babylonjs/Engines/engine";
  29027. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29029. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29030. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29031. /**
  29032. * Options to be used when creating an effect.
  29033. */
  29034. export class EffectCreationOptions {
  29035. /**
  29036. * Atrributes that will be used in the shader.
  29037. */
  29038. attributes: string[];
  29039. /**
  29040. * Uniform varible names that will be set in the shader.
  29041. */
  29042. uniformsNames: string[];
  29043. /**
  29044. * Uniform buffer varible names that will be set in the shader.
  29045. */
  29046. uniformBuffersNames: string[];
  29047. /**
  29048. * Sampler texture variable names that will be set in the shader.
  29049. */
  29050. samplers: string[];
  29051. /**
  29052. * Define statements that will be set in the shader.
  29053. */
  29054. defines: any;
  29055. /**
  29056. * Possible fallbacks for this effect to improve performance when needed.
  29057. */
  29058. fallbacks: Nullable<IEffectFallbacks>;
  29059. /**
  29060. * Callback that will be called when the shader is compiled.
  29061. */
  29062. onCompiled: Nullable<(effect: Effect) => void>;
  29063. /**
  29064. * Callback that will be called if an error occurs during shader compilation.
  29065. */
  29066. onError: Nullable<(effect: Effect, errors: string) => void>;
  29067. /**
  29068. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29069. */
  29070. indexParameters?: any;
  29071. /**
  29072. * Max number of lights that can be used in the shader.
  29073. */
  29074. maxSimultaneousLights?: number;
  29075. /**
  29076. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29077. */
  29078. transformFeedbackVaryings?: Nullable<string[]>;
  29079. }
  29080. /**
  29081. * Effect containing vertex and fragment shader that can be executed on an object.
  29082. */
  29083. export class Effect implements IDisposable {
  29084. /**
  29085. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29086. */
  29087. static ShadersRepository: string;
  29088. /**
  29089. * Name of the effect.
  29090. */
  29091. name: any;
  29092. /**
  29093. * String container all the define statements that should be set on the shader.
  29094. */
  29095. defines: string;
  29096. /**
  29097. * Callback that will be called when the shader is compiled.
  29098. */
  29099. onCompiled: Nullable<(effect: Effect) => void>;
  29100. /**
  29101. * Callback that will be called if an error occurs during shader compilation.
  29102. */
  29103. onError: Nullable<(effect: Effect, errors: string) => void>;
  29104. /**
  29105. * Callback that will be called when effect is bound.
  29106. */
  29107. onBind: Nullable<(effect: Effect) => void>;
  29108. /**
  29109. * Unique ID of the effect.
  29110. */
  29111. uniqueId: number;
  29112. /**
  29113. * Observable that will be called when the shader is compiled.
  29114. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29115. */
  29116. onCompileObservable: Observable<Effect>;
  29117. /**
  29118. * Observable that will be called if an error occurs during shader compilation.
  29119. */
  29120. onErrorObservable: Observable<Effect>;
  29121. /** @hidden */
  29122. _onBindObservable: Nullable<Observable<Effect>>;
  29123. /**
  29124. * Observable that will be called when effect is bound.
  29125. */
  29126. readonly onBindObservable: Observable<Effect>;
  29127. /** @hidden */
  29128. _bonesComputationForcedToCPU: boolean;
  29129. private static _uniqueIdSeed;
  29130. private _engine;
  29131. private _uniformBuffersNames;
  29132. private _uniformsNames;
  29133. private _samplerList;
  29134. private _samplers;
  29135. private _isReady;
  29136. private _compilationError;
  29137. private _attributesNames;
  29138. private _attributes;
  29139. private _uniforms;
  29140. /**
  29141. * Key for the effect.
  29142. * @hidden
  29143. */
  29144. _key: string;
  29145. private _indexParameters;
  29146. private _fallbacks;
  29147. private _vertexSourceCode;
  29148. private _fragmentSourceCode;
  29149. private _vertexSourceCodeOverride;
  29150. private _fragmentSourceCodeOverride;
  29151. private _transformFeedbackVaryings;
  29152. /**
  29153. * Compiled shader to webGL program.
  29154. * @hidden
  29155. */
  29156. _pipelineContext: Nullable<IPipelineContext>;
  29157. private _valueCache;
  29158. private static _baseCache;
  29159. /**
  29160. * Instantiates an effect.
  29161. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29162. * @param baseName Name of the effect.
  29163. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29164. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29165. * @param samplers List of sampler variables that will be passed to the shader.
  29166. * @param engine Engine to be used to render the effect
  29167. * @param defines Define statements to be added to the shader.
  29168. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29169. * @param onCompiled Callback that will be called when the shader is compiled.
  29170. * @param onError Callback that will be called if an error occurs during shader compilation.
  29171. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29172. */
  29173. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29174. private _useFinalCode;
  29175. /**
  29176. * Unique key for this effect
  29177. */
  29178. readonly key: string;
  29179. /**
  29180. * If the effect has been compiled and prepared.
  29181. * @returns if the effect is compiled and prepared.
  29182. */
  29183. isReady(): boolean;
  29184. private _isReadyInternal;
  29185. /**
  29186. * The engine the effect was initialized with.
  29187. * @returns the engine.
  29188. */
  29189. getEngine(): Engine;
  29190. /**
  29191. * The pipeline context for this effect
  29192. * @returns the associated pipeline context
  29193. */
  29194. getPipelineContext(): Nullable<IPipelineContext>;
  29195. /**
  29196. * The set of names of attribute variables for the shader.
  29197. * @returns An array of attribute names.
  29198. */
  29199. getAttributesNames(): string[];
  29200. /**
  29201. * Returns the attribute at the given index.
  29202. * @param index The index of the attribute.
  29203. * @returns The location of the attribute.
  29204. */
  29205. getAttributeLocation(index: number): number;
  29206. /**
  29207. * Returns the attribute based on the name of the variable.
  29208. * @param name of the attribute to look up.
  29209. * @returns the attribute location.
  29210. */
  29211. getAttributeLocationByName(name: string): number;
  29212. /**
  29213. * The number of attributes.
  29214. * @returns the numnber of attributes.
  29215. */
  29216. getAttributesCount(): number;
  29217. /**
  29218. * Gets the index of a uniform variable.
  29219. * @param uniformName of the uniform to look up.
  29220. * @returns the index.
  29221. */
  29222. getUniformIndex(uniformName: string): number;
  29223. /**
  29224. * Returns the attribute based on the name of the variable.
  29225. * @param uniformName of the uniform to look up.
  29226. * @returns the location of the uniform.
  29227. */
  29228. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29229. /**
  29230. * Returns an array of sampler variable names
  29231. * @returns The array of sampler variable neames.
  29232. */
  29233. getSamplers(): string[];
  29234. /**
  29235. * The error from the last compilation.
  29236. * @returns the error string.
  29237. */
  29238. getCompilationError(): string;
  29239. /**
  29240. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29241. * @param func The callback to be used.
  29242. */
  29243. executeWhenCompiled(func: (effect: Effect) => void): void;
  29244. private _checkIsReady;
  29245. /** @hidden */
  29246. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29247. /** @hidden */
  29248. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29249. /** @hidden */
  29250. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29251. /**
  29252. * Recompiles the webGL program
  29253. * @param vertexSourceCode The source code for the vertex shader.
  29254. * @param fragmentSourceCode The source code for the fragment shader.
  29255. * @param onCompiled Callback called when completed.
  29256. * @param onError Callback called on error.
  29257. * @hidden
  29258. */
  29259. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29260. /**
  29261. * Prepares the effect
  29262. * @hidden
  29263. */
  29264. _prepareEffect(): void;
  29265. private _processCompilationErrors;
  29266. /**
  29267. * Checks if the effect is supported. (Must be called after compilation)
  29268. */
  29269. readonly isSupported: boolean;
  29270. /**
  29271. * Binds a texture to the engine to be used as output of the shader.
  29272. * @param channel Name of the output variable.
  29273. * @param texture Texture to bind.
  29274. * @hidden
  29275. */
  29276. _bindTexture(channel: string, texture: InternalTexture): void;
  29277. /**
  29278. * Sets a texture on the engine to be used in the shader.
  29279. * @param channel Name of the sampler variable.
  29280. * @param texture Texture to set.
  29281. */
  29282. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29283. /**
  29284. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29285. * @param channel Name of the sampler variable.
  29286. * @param texture Texture to set.
  29287. */
  29288. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29289. /**
  29290. * Sets an array of textures on the engine to be used in the shader.
  29291. * @param channel Name of the variable.
  29292. * @param textures Textures to set.
  29293. */
  29294. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29295. /**
  29296. * 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)
  29297. * @param channel Name of the sampler variable.
  29298. * @param postProcess Post process to get the input texture from.
  29299. */
  29300. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29301. /**
  29302. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29303. * 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)
  29304. * @param channel Name of the sampler variable.
  29305. * @param postProcess Post process to get the output texture from.
  29306. */
  29307. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29308. /** @hidden */
  29309. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29310. /** @hidden */
  29311. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29312. /** @hidden */
  29313. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29314. /** @hidden */
  29315. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29316. /**
  29317. * Binds a buffer to a uniform.
  29318. * @param buffer Buffer to bind.
  29319. * @param name Name of the uniform variable to bind to.
  29320. */
  29321. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29322. /**
  29323. * Binds block to a uniform.
  29324. * @param blockName Name of the block to bind.
  29325. * @param index Index to bind.
  29326. */
  29327. bindUniformBlock(blockName: string, index: number): void;
  29328. /**
  29329. * Sets an interger value on a uniform variable.
  29330. * @param uniformName Name of the variable.
  29331. * @param value Value to be set.
  29332. * @returns this effect.
  29333. */
  29334. setInt(uniformName: string, value: number): Effect;
  29335. /**
  29336. * Sets an int array on a uniform variable.
  29337. * @param uniformName Name of the variable.
  29338. * @param array array to be set.
  29339. * @returns this effect.
  29340. */
  29341. setIntArray(uniformName: string, array: Int32Array): Effect;
  29342. /**
  29343. * 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)
  29344. * @param uniformName Name of the variable.
  29345. * @param array array to be set.
  29346. * @returns this effect.
  29347. */
  29348. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29349. /**
  29350. * 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)
  29351. * @param uniformName Name of the variable.
  29352. * @param array array to be set.
  29353. * @returns this effect.
  29354. */
  29355. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29356. /**
  29357. * 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)
  29358. * @param uniformName Name of the variable.
  29359. * @param array array to be set.
  29360. * @returns this effect.
  29361. */
  29362. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29363. /**
  29364. * Sets an float array on a uniform variable.
  29365. * @param uniformName Name of the variable.
  29366. * @param array array to be set.
  29367. * @returns this effect.
  29368. */
  29369. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29370. /**
  29371. * 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)
  29372. * @param uniformName Name of the variable.
  29373. * @param array array to be set.
  29374. * @returns this effect.
  29375. */
  29376. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29377. /**
  29378. * 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)
  29379. * @param uniformName Name of the variable.
  29380. * @param array array to be set.
  29381. * @returns this effect.
  29382. */
  29383. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29384. /**
  29385. * 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)
  29386. * @param uniformName Name of the variable.
  29387. * @param array array to be set.
  29388. * @returns this effect.
  29389. */
  29390. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29391. /**
  29392. * Sets an array on a uniform variable.
  29393. * @param uniformName Name of the variable.
  29394. * @param array array to be set.
  29395. * @returns this effect.
  29396. */
  29397. setArray(uniformName: string, array: number[]): Effect;
  29398. /**
  29399. * 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)
  29400. * @param uniformName Name of the variable.
  29401. * @param array array to be set.
  29402. * @returns this effect.
  29403. */
  29404. setArray2(uniformName: string, array: number[]): Effect;
  29405. /**
  29406. * 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)
  29407. * @param uniformName Name of the variable.
  29408. * @param array array to be set.
  29409. * @returns this effect.
  29410. */
  29411. setArray3(uniformName: string, array: number[]): Effect;
  29412. /**
  29413. * 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)
  29414. * @param uniformName Name of the variable.
  29415. * @param array array to be set.
  29416. * @returns this effect.
  29417. */
  29418. setArray4(uniformName: string, array: number[]): Effect;
  29419. /**
  29420. * Sets matrices on a uniform variable.
  29421. * @param uniformName Name of the variable.
  29422. * @param matrices matrices to be set.
  29423. * @returns this effect.
  29424. */
  29425. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29426. /**
  29427. * Sets matrix on a uniform variable.
  29428. * @param uniformName Name of the variable.
  29429. * @param matrix matrix to be set.
  29430. * @returns this effect.
  29431. */
  29432. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29433. /**
  29434. * 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)
  29435. * @param uniformName Name of the variable.
  29436. * @param matrix matrix to be set.
  29437. * @returns this effect.
  29438. */
  29439. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29440. /**
  29441. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29442. * @param uniformName Name of the variable.
  29443. * @param matrix matrix to be set.
  29444. * @returns this effect.
  29445. */
  29446. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29447. /**
  29448. * Sets a float on a uniform variable.
  29449. * @param uniformName Name of the variable.
  29450. * @param value value to be set.
  29451. * @returns this effect.
  29452. */
  29453. setFloat(uniformName: string, value: number): Effect;
  29454. /**
  29455. * Sets a boolean on a uniform variable.
  29456. * @param uniformName Name of the variable.
  29457. * @param bool value to be set.
  29458. * @returns this effect.
  29459. */
  29460. setBool(uniformName: string, bool: boolean): Effect;
  29461. /**
  29462. * Sets a Vector2 on a uniform variable.
  29463. * @param uniformName Name of the variable.
  29464. * @param vector2 vector2 to be set.
  29465. * @returns this effect.
  29466. */
  29467. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29468. /**
  29469. * Sets a float2 on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param x First float in float2.
  29472. * @param y Second float in float2.
  29473. * @returns this effect.
  29474. */
  29475. setFloat2(uniformName: string, x: number, y: number): Effect;
  29476. /**
  29477. * Sets a Vector3 on a uniform variable.
  29478. * @param uniformName Name of the variable.
  29479. * @param vector3 Value to be set.
  29480. * @returns this effect.
  29481. */
  29482. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29483. /**
  29484. * Sets a float3 on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param x First float in float3.
  29487. * @param y Second float in float3.
  29488. * @param z Third float in float3.
  29489. * @returns this effect.
  29490. */
  29491. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29492. /**
  29493. * Sets a Vector4 on a uniform variable.
  29494. * @param uniformName Name of the variable.
  29495. * @param vector4 Value to be set.
  29496. * @returns this effect.
  29497. */
  29498. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29499. /**
  29500. * Sets a float4 on a uniform variable.
  29501. * @param uniformName Name of the variable.
  29502. * @param x First float in float4.
  29503. * @param y Second float in float4.
  29504. * @param z Third float in float4.
  29505. * @param w Fourth float in float4.
  29506. * @returns this effect.
  29507. */
  29508. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29509. /**
  29510. * Sets a Color3 on a uniform variable.
  29511. * @param uniformName Name of the variable.
  29512. * @param color3 Value to be set.
  29513. * @returns this effect.
  29514. */
  29515. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29516. /**
  29517. * Sets a Color4 on a uniform variable.
  29518. * @param uniformName Name of the variable.
  29519. * @param color3 Value to be set.
  29520. * @param alpha Alpha value to be set.
  29521. * @returns this effect.
  29522. */
  29523. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29524. /**
  29525. * Sets a Color4 on a uniform variable
  29526. * @param uniformName defines the name of the variable
  29527. * @param color4 defines the value to be set
  29528. * @returns this effect.
  29529. */
  29530. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29531. /** Release all associated resources */
  29532. dispose(): void;
  29533. /**
  29534. * This function will add a new shader to the shader store
  29535. * @param name the name of the shader
  29536. * @param pixelShader optional pixel shader content
  29537. * @param vertexShader optional vertex shader content
  29538. */
  29539. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29540. /**
  29541. * Store of each shader (The can be looked up using effect.key)
  29542. */
  29543. static ShadersStore: {
  29544. [key: string]: string;
  29545. };
  29546. /**
  29547. * Store of each included file for a shader (The can be looked up using effect.key)
  29548. */
  29549. static IncludesShadersStore: {
  29550. [key: string]: string;
  29551. };
  29552. /**
  29553. * Resets the cache of effects.
  29554. */
  29555. static ResetCache(): void;
  29556. }
  29557. }
  29558. declare module "babylonjs/Engines/engineCapabilities" {
  29559. import { Nullable } from "babylonjs/types";
  29560. /**
  29561. * Class used to describe the capabilities of the engine relatively to the current browser
  29562. */
  29563. export class EngineCapabilities {
  29564. /** Maximum textures units per fragment shader */
  29565. maxTexturesImageUnits: number;
  29566. /** Maximum texture units per vertex shader */
  29567. maxVertexTextureImageUnits: number;
  29568. /** Maximum textures units in the entire pipeline */
  29569. maxCombinedTexturesImageUnits: number;
  29570. /** Maximum texture size */
  29571. maxTextureSize: number;
  29572. /** Maximum cube texture size */
  29573. maxCubemapTextureSize: number;
  29574. /** Maximum render texture size */
  29575. maxRenderTextureSize: number;
  29576. /** Maximum number of vertex attributes */
  29577. maxVertexAttribs: number;
  29578. /** Maximum number of varyings */
  29579. maxVaryingVectors: number;
  29580. /** Maximum number of uniforms per vertex shader */
  29581. maxVertexUniformVectors: number;
  29582. /** Maximum number of uniforms per fragment shader */
  29583. maxFragmentUniformVectors: number;
  29584. /** Defines if standard derivates (dx/dy) are supported */
  29585. standardDerivatives: boolean;
  29586. /** Defines if s3tc texture compression is supported */
  29587. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29588. /** Defines if pvrtc texture compression is supported */
  29589. pvrtc: any;
  29590. /** Defines if etc1 texture compression is supported */
  29591. etc1: any;
  29592. /** Defines if etc2 texture compression is supported */
  29593. etc2: any;
  29594. /** Defines if astc texture compression is supported */
  29595. astc: any;
  29596. /** Defines if float textures are supported */
  29597. textureFloat: boolean;
  29598. /** Defines if vertex array objects are supported */
  29599. vertexArrayObject: boolean;
  29600. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29601. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29602. /** Gets the maximum level of anisotropy supported */
  29603. maxAnisotropy: number;
  29604. /** Defines if instancing is supported */
  29605. instancedArrays: boolean;
  29606. /** Defines if 32 bits indices are supported */
  29607. uintIndices: boolean;
  29608. /** Defines if high precision shaders are supported */
  29609. highPrecisionShaderSupported: boolean;
  29610. /** Defines if depth reading in the fragment shader is supported */
  29611. fragmentDepthSupported: boolean;
  29612. /** Defines if float texture linear filtering is supported*/
  29613. textureFloatLinearFiltering: boolean;
  29614. /** Defines if rendering to float textures is supported */
  29615. textureFloatRender: boolean;
  29616. /** Defines if half float textures are supported*/
  29617. textureHalfFloat: boolean;
  29618. /** Defines if half float texture linear filtering is supported*/
  29619. textureHalfFloatLinearFiltering: boolean;
  29620. /** Defines if rendering to half float textures is supported */
  29621. textureHalfFloatRender: boolean;
  29622. /** Defines if textureLOD shader command is supported */
  29623. textureLOD: boolean;
  29624. /** Defines if draw buffers extension is supported */
  29625. drawBuffersExtension: boolean;
  29626. /** Defines if depth textures are supported */
  29627. depthTextureExtension: boolean;
  29628. /** Defines if float color buffer are supported */
  29629. colorBufferFloat: boolean;
  29630. /** Gets disjoint timer query extension (null if not supported) */
  29631. timerQuery: EXT_disjoint_timer_query;
  29632. /** Defines if timestamp can be used with timer query */
  29633. canUseTimestampForTimerQuery: boolean;
  29634. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29635. multiview: any;
  29636. /** Function used to let the system compiles shaders in background */
  29637. parallelShaderCompile: {
  29638. COMPLETION_STATUS_KHR: number;
  29639. };
  29640. /** Max number of texture samples for MSAA */
  29641. maxMSAASamples: number;
  29642. /** Defines if the blend min max extension is supported */
  29643. blendMinMax: boolean;
  29644. }
  29645. }
  29646. declare module "babylonjs/Misc/perfCounter" {
  29647. /**
  29648. * This class is used to track a performance counter which is number based.
  29649. * The user has access to many properties which give statistics of different nature.
  29650. *
  29651. * The implementer can track two kinds of Performance Counter: time and count.
  29652. * 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.
  29653. * 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.
  29654. */
  29655. export class PerfCounter {
  29656. /**
  29657. * Gets or sets a global boolean to turn on and off all the counters
  29658. */
  29659. static Enabled: boolean;
  29660. /**
  29661. * Returns the smallest value ever
  29662. */
  29663. readonly min: number;
  29664. /**
  29665. * Returns the biggest value ever
  29666. */
  29667. readonly max: number;
  29668. /**
  29669. * Returns the average value since the performance counter is running
  29670. */
  29671. readonly average: number;
  29672. /**
  29673. * Returns the average value of the last second the counter was monitored
  29674. */
  29675. readonly lastSecAverage: number;
  29676. /**
  29677. * Returns the current value
  29678. */
  29679. readonly current: number;
  29680. /**
  29681. * Gets the accumulated total
  29682. */
  29683. readonly total: number;
  29684. /**
  29685. * Gets the total value count
  29686. */
  29687. readonly count: number;
  29688. /**
  29689. * Creates a new counter
  29690. */
  29691. constructor();
  29692. /**
  29693. * Call this method to start monitoring a new frame.
  29694. * 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.
  29695. */
  29696. fetchNewFrame(): void;
  29697. /**
  29698. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29699. * @param newCount the count value to add to the monitored count
  29700. * @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.
  29701. */
  29702. addCount(newCount: number, fetchResult: boolean): void;
  29703. /**
  29704. * Start monitoring this performance counter
  29705. */
  29706. beginMonitoring(): void;
  29707. /**
  29708. * Compute the time lapsed since the previous beginMonitoring() call.
  29709. * @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
  29710. */
  29711. endMonitoring(newFrame?: boolean): void;
  29712. private _fetchResult;
  29713. private _startMonitoringTime;
  29714. private _min;
  29715. private _max;
  29716. private _average;
  29717. private _current;
  29718. private _totalValueCount;
  29719. private _totalAccumulated;
  29720. private _lastSecAverage;
  29721. private _lastSecAccumulated;
  29722. private _lastSecTime;
  29723. private _lastSecValueCount;
  29724. }
  29725. }
  29726. declare module "babylonjs/States/depthCullingState" {
  29727. import { Nullable } from "babylonjs/types";
  29728. /**
  29729. * @hidden
  29730. **/
  29731. export class DepthCullingState {
  29732. private _isDepthTestDirty;
  29733. private _isDepthMaskDirty;
  29734. private _isDepthFuncDirty;
  29735. private _isCullFaceDirty;
  29736. private _isCullDirty;
  29737. private _isZOffsetDirty;
  29738. private _isFrontFaceDirty;
  29739. private _depthTest;
  29740. private _depthMask;
  29741. private _depthFunc;
  29742. private _cull;
  29743. private _cullFace;
  29744. private _zOffset;
  29745. private _frontFace;
  29746. /**
  29747. * Initializes the state.
  29748. */
  29749. constructor();
  29750. readonly isDirty: boolean;
  29751. zOffset: number;
  29752. cullFace: Nullable<number>;
  29753. cull: Nullable<boolean>;
  29754. depthFunc: Nullable<number>;
  29755. depthMask: boolean;
  29756. depthTest: boolean;
  29757. frontFace: Nullable<number>;
  29758. reset(): void;
  29759. apply(gl: WebGLRenderingContext): void;
  29760. }
  29761. }
  29762. declare module "babylonjs/States/stencilState" {
  29763. /**
  29764. * @hidden
  29765. **/
  29766. export class StencilState {
  29767. /** 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 */
  29768. static readonly ALWAYS: number;
  29769. /** Passed to stencilOperation to specify that stencil value must be kept */
  29770. static readonly KEEP: number;
  29771. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29772. static readonly REPLACE: number;
  29773. private _isStencilTestDirty;
  29774. private _isStencilMaskDirty;
  29775. private _isStencilFuncDirty;
  29776. private _isStencilOpDirty;
  29777. private _stencilTest;
  29778. private _stencilMask;
  29779. private _stencilFunc;
  29780. private _stencilFuncRef;
  29781. private _stencilFuncMask;
  29782. private _stencilOpStencilFail;
  29783. private _stencilOpDepthFail;
  29784. private _stencilOpStencilDepthPass;
  29785. readonly isDirty: boolean;
  29786. stencilFunc: number;
  29787. stencilFuncRef: number;
  29788. stencilFuncMask: number;
  29789. stencilOpStencilFail: number;
  29790. stencilOpDepthFail: number;
  29791. stencilOpStencilDepthPass: number;
  29792. stencilMask: number;
  29793. stencilTest: boolean;
  29794. constructor();
  29795. reset(): void;
  29796. apply(gl: WebGLRenderingContext): void;
  29797. }
  29798. }
  29799. declare module "babylonjs/States/alphaCullingState" {
  29800. /**
  29801. * @hidden
  29802. **/
  29803. export class AlphaState {
  29804. private _isAlphaBlendDirty;
  29805. private _isBlendFunctionParametersDirty;
  29806. private _isBlendEquationParametersDirty;
  29807. private _isBlendConstantsDirty;
  29808. private _alphaBlend;
  29809. private _blendFunctionParameters;
  29810. private _blendEquationParameters;
  29811. private _blendConstants;
  29812. /**
  29813. * Initializes the state.
  29814. */
  29815. constructor();
  29816. readonly isDirty: boolean;
  29817. alphaBlend: boolean;
  29818. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29819. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29820. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29821. reset(): void;
  29822. apply(gl: WebGLRenderingContext): void;
  29823. }
  29824. }
  29825. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29826. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29827. /** @hidden */
  29828. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29829. attributeProcessor(attribute: string): string;
  29830. varyingProcessor(varying: string, isFragment: boolean): string;
  29831. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29832. }
  29833. }
  29834. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29835. /**
  29836. * Interface for attribute information associated with buffer instanciation
  29837. */
  29838. export class InstancingAttributeInfo {
  29839. /**
  29840. * Index/offset of the attribute in the vertex shader
  29841. */
  29842. index: number;
  29843. /**
  29844. * size of the attribute, 1, 2, 3 or 4
  29845. */
  29846. attributeSize: number;
  29847. /**
  29848. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29849. * default is FLOAT
  29850. */
  29851. attribyteType: number;
  29852. /**
  29853. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29854. */
  29855. normalized: boolean;
  29856. /**
  29857. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29858. */
  29859. offset: number;
  29860. /**
  29861. * Name of the GLSL attribute, for debugging purpose only
  29862. */
  29863. attributeName: string;
  29864. }
  29865. }
  29866. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29868. import { Nullable } from "babylonjs/types";
  29869. module "babylonjs/Engines/thinEngine" {
  29870. interface ThinEngine {
  29871. /**
  29872. * Update a video texture
  29873. * @param texture defines the texture to update
  29874. * @param video defines the video element to use
  29875. * @param invertY defines if data must be stored with Y axis inverted
  29876. */
  29877. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29878. }
  29879. }
  29880. }
  29881. declare module "babylonjs/Materials/Textures/videoTexture" {
  29882. import { Observable } from "babylonjs/Misc/observable";
  29883. import { Nullable } from "babylonjs/types";
  29884. import { Scene } from "babylonjs/scene";
  29885. import { Texture } from "babylonjs/Materials/Textures/texture";
  29886. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29887. /**
  29888. * Settings for finer control over video usage
  29889. */
  29890. export interface VideoTextureSettings {
  29891. /**
  29892. * Applies `autoplay` to video, if specified
  29893. */
  29894. autoPlay?: boolean;
  29895. /**
  29896. * Applies `loop` to video, if specified
  29897. */
  29898. loop?: boolean;
  29899. /**
  29900. * Automatically updates internal texture from video at every frame in the render loop
  29901. */
  29902. autoUpdateTexture: boolean;
  29903. /**
  29904. * Image src displayed during the video loading or until the user interacts with the video.
  29905. */
  29906. poster?: string;
  29907. }
  29908. /**
  29909. * If you want to display a video in your scene, this is the special texture for that.
  29910. * This special texture works similar to other textures, with the exception of a few parameters.
  29911. * @see https://doc.babylonjs.com/how_to/video_texture
  29912. */
  29913. export class VideoTexture extends Texture {
  29914. /**
  29915. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29916. */
  29917. readonly autoUpdateTexture: boolean;
  29918. /**
  29919. * The video instance used by the texture internally
  29920. */
  29921. readonly video: HTMLVideoElement;
  29922. private _onUserActionRequestedObservable;
  29923. /**
  29924. * Event triggerd when a dom action is required by the user to play the video.
  29925. * This happens due to recent changes in browser policies preventing video to auto start.
  29926. */
  29927. readonly onUserActionRequestedObservable: Observable<Texture>;
  29928. private _generateMipMaps;
  29929. private _engine;
  29930. private _stillImageCaptured;
  29931. private _displayingPosterTexture;
  29932. private _settings;
  29933. private _createInternalTextureOnEvent;
  29934. private _frameId;
  29935. /**
  29936. * Creates a video texture.
  29937. * If you want to display a video in your scene, this is the special texture for that.
  29938. * This special texture works similar to other textures, with the exception of a few parameters.
  29939. * @see https://doc.babylonjs.com/how_to/video_texture
  29940. * @param name optional name, will detect from video source, if not defined
  29941. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29942. * @param scene is obviously the current scene.
  29943. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29944. * @param invertY is false by default but can be used to invert video on Y axis
  29945. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29946. * @param settings allows finer control over video usage
  29947. */
  29948. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29949. private _getName;
  29950. private _getVideo;
  29951. private _createInternalTexture;
  29952. private reset;
  29953. /**
  29954. * @hidden Internal method to initiate `update`.
  29955. */
  29956. _rebuild(): void;
  29957. /**
  29958. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29959. */
  29960. update(): void;
  29961. /**
  29962. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29963. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29964. */
  29965. updateTexture(isVisible: boolean): void;
  29966. protected _updateInternalTexture: () => void;
  29967. /**
  29968. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29969. * @param url New url.
  29970. */
  29971. updateURL(url: string): void;
  29972. /**
  29973. * Dispose the texture and release its associated resources.
  29974. */
  29975. dispose(): void;
  29976. /**
  29977. * Creates a video texture straight from a stream.
  29978. * @param scene Define the scene the texture should be created in
  29979. * @param stream Define the stream the texture should be created from
  29980. * @returns The created video texture as a promise
  29981. */
  29982. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29983. /**
  29984. * Creates a video texture straight from your WebCam video feed.
  29985. * @param scene Define the scene the texture should be created in
  29986. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29987. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29988. * @returns The created video texture as a promise
  29989. */
  29990. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29991. minWidth: number;
  29992. maxWidth: number;
  29993. minHeight: number;
  29994. maxHeight: number;
  29995. deviceId: string;
  29996. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29997. /**
  29998. * Creates a video texture straight from your WebCam video feed.
  29999. * @param scene Define the scene the texture should be created in
  30000. * @param onReady Define a callback to triggered once the texture will be ready
  30001. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30002. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30003. */
  30004. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30005. minWidth: number;
  30006. maxWidth: number;
  30007. minHeight: number;
  30008. maxHeight: number;
  30009. deviceId: string;
  30010. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30011. }
  30012. }
  30013. declare module "babylonjs/Engines/thinEngine" {
  30014. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30015. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  30016. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30017. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30018. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30019. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30020. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30021. import { Observable } from "babylonjs/Misc/observable";
  30022. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30023. import { StencilState } from "babylonjs/States/stencilState";
  30024. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30026. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30027. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30028. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30029. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30030. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30031. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30032. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30033. import { WebRequest } from "babylonjs/Misc/webRequest";
  30034. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  30035. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30036. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30037. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30038. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30039. /**
  30040. * Defines the interface used by objects working like Scene
  30041. * @hidden
  30042. */
  30043. interface ISceneLike {
  30044. _addPendingData(data: any): void;
  30045. _removePendingData(data: any): void;
  30046. offlineProvider: IOfflineProvider;
  30047. }
  30048. /** Interface defining initialization parameters for Engine class */
  30049. export interface EngineOptions extends WebGLContextAttributes {
  30050. /**
  30051. * Defines if the engine should no exceed a specified device ratio
  30052. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30053. */
  30054. limitDeviceRatio?: number;
  30055. /**
  30056. * Defines if webvr should be enabled automatically
  30057. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30058. */
  30059. autoEnableWebVR?: boolean;
  30060. /**
  30061. * Defines if webgl2 should be turned off even if supported
  30062. * @see http://doc.babylonjs.com/features/webgl2
  30063. */
  30064. disableWebGL2Support?: boolean;
  30065. /**
  30066. * Defines if webaudio should be initialized as well
  30067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30068. */
  30069. audioEngine?: boolean;
  30070. /**
  30071. * Defines if animations should run using a deterministic lock step
  30072. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30073. */
  30074. deterministicLockstep?: boolean;
  30075. /** Defines the maximum steps to use with deterministic lock step mode */
  30076. lockstepMaxSteps?: number;
  30077. /**
  30078. * Defines that engine should ignore context lost events
  30079. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30080. */
  30081. doNotHandleContextLost?: boolean;
  30082. /**
  30083. * Defines that engine should ignore modifying touch action attribute and style
  30084. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30085. */
  30086. doNotHandleTouchAction?: boolean;
  30087. /**
  30088. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30089. */
  30090. useHighPrecisionFloats?: boolean;
  30091. }
  30092. /**
  30093. * The base engine class (root of all engines)
  30094. */
  30095. export class ThinEngine {
  30096. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30097. static ExceptionList: ({
  30098. key: string;
  30099. capture: string;
  30100. captureConstraint: number;
  30101. targets: string[];
  30102. } | {
  30103. key: string;
  30104. capture: null;
  30105. captureConstraint: null;
  30106. targets: string[];
  30107. })[];
  30108. /** @hidden */
  30109. static _TextureLoaders: IInternalTextureLoader[];
  30110. /**
  30111. * Returns the current npm package of the sdk
  30112. */
  30113. static readonly NpmPackage: string;
  30114. /**
  30115. * Returns the current version of the framework
  30116. */
  30117. static readonly Version: string;
  30118. /**
  30119. * Returns a string describing the current engine
  30120. */
  30121. readonly description: string;
  30122. /**
  30123. * Gets or sets the epsilon value used by collision engine
  30124. */
  30125. static CollisionsEpsilon: number;
  30126. /**
  30127. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30128. */
  30129. static ShadersRepository: string;
  30130. /** @hidden */
  30131. _shaderProcessor: IShaderProcessor;
  30132. /**
  30133. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30134. */
  30135. forcePOTTextures: boolean;
  30136. /**
  30137. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30138. */
  30139. isFullscreen: boolean;
  30140. /**
  30141. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30142. */
  30143. cullBackFaces: boolean;
  30144. /**
  30145. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30146. */
  30147. renderEvenInBackground: boolean;
  30148. /**
  30149. * Gets or sets a boolean indicating that cache can be kept between frames
  30150. */
  30151. preventCacheWipeBetweenFrames: boolean;
  30152. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30153. validateShaderPrograms: boolean;
  30154. /**
  30155. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30156. */
  30157. disableUniformBuffers: boolean;
  30158. /** @hidden */
  30159. _uniformBuffers: UniformBuffer[];
  30160. /**
  30161. * Gets a boolean indicating that the engine supports uniform buffers
  30162. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30163. */
  30164. readonly supportsUniformBuffers: boolean;
  30165. /** @hidden */
  30166. _gl: WebGLRenderingContext;
  30167. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30168. protected _windowIsBackground: boolean;
  30169. protected _webGLVersion: number;
  30170. protected _highPrecisionShadersAllowed: boolean;
  30171. /** @hidden */
  30172. readonly _shouldUseHighPrecisionShader: boolean;
  30173. /**
  30174. * Gets a boolean indicating that only power of 2 textures are supported
  30175. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30176. */
  30177. readonly needPOTTextures: boolean;
  30178. /** @hidden */
  30179. _badOS: boolean;
  30180. /** @hidden */
  30181. _badDesktopOS: boolean;
  30182. private _hardwareScalingLevel;
  30183. /** @hidden */
  30184. _caps: EngineCapabilities;
  30185. private _isStencilEnable;
  30186. protected _colorWrite: boolean;
  30187. /** @hidden */
  30188. _drawCalls: PerfCounter;
  30189. private _glVersion;
  30190. private _glRenderer;
  30191. private _glVendor;
  30192. /** @hidden */
  30193. _videoTextureSupported: boolean;
  30194. protected _renderingQueueLaunched: boolean;
  30195. protected _activeRenderLoops: (() => void)[];
  30196. /**
  30197. * Observable signaled when a context lost event is raised
  30198. */
  30199. onContextLostObservable: Observable<ThinEngine>;
  30200. /**
  30201. * Observable signaled when a context restored event is raised
  30202. */
  30203. onContextRestoredObservable: Observable<ThinEngine>;
  30204. private _onContextLost;
  30205. private _onContextRestored;
  30206. protected _contextWasLost: boolean;
  30207. /** @hidden */
  30208. _doNotHandleContextLost: boolean;
  30209. /**
  30210. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30211. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30212. */
  30213. doNotHandleContextLost: boolean;
  30214. /**
  30215. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30216. */
  30217. disableVertexArrayObjects: boolean;
  30218. /** @hidden */
  30219. protected _depthCullingState: DepthCullingState;
  30220. /** @hidden */
  30221. protected _stencilState: StencilState;
  30222. /** @hidden */
  30223. protected _alphaState: AlphaState;
  30224. /** @hidden */
  30225. _internalTexturesCache: InternalTexture[];
  30226. /** @hidden */
  30227. protected _activeChannel: number;
  30228. private _currentTextureChannel;
  30229. /** @hidden */
  30230. protected _boundTexturesCache: {
  30231. [key: string]: Nullable<InternalTexture>;
  30232. };
  30233. /** @hidden */
  30234. protected _currentEffect: Nullable<Effect>;
  30235. /** @hidden */
  30236. protected _currentProgram: Nullable<WebGLProgram>;
  30237. private _compiledEffects;
  30238. private _vertexAttribArraysEnabled;
  30239. /** @hidden */
  30240. protected _cachedViewport: Nullable<IViewportLike>;
  30241. private _cachedVertexArrayObject;
  30242. /** @hidden */
  30243. protected _cachedVertexBuffers: any;
  30244. /** @hidden */
  30245. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30246. /** @hidden */
  30247. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30248. /** @hidden */
  30249. _currentRenderTarget: Nullable<InternalTexture>;
  30250. private _uintIndicesCurrentlySet;
  30251. private _currentBoundBuffer;
  30252. /** @hidden */
  30253. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30254. private _currentBufferPointers;
  30255. private _currentInstanceLocations;
  30256. private _currentInstanceBuffers;
  30257. private _textureUnits;
  30258. /** @hidden */
  30259. _workingCanvas: Nullable<HTMLCanvasElement>;
  30260. /** @hidden */
  30261. _workingContext: Nullable<CanvasRenderingContext2D>;
  30262. /** @hidden */
  30263. _bindedRenderFunction: any;
  30264. private _vaoRecordInProgress;
  30265. private _mustWipeVertexAttributes;
  30266. private _emptyTexture;
  30267. private _emptyCubeTexture;
  30268. private _emptyTexture3D;
  30269. /** @hidden */
  30270. _frameHandler: number;
  30271. private _nextFreeTextureSlots;
  30272. private _maxSimultaneousTextures;
  30273. private _activeRequests;
  30274. protected _texturesSupported: string[];
  30275. /** @hidden */
  30276. _textureFormatInUse: Nullable<string>;
  30277. protected readonly _supportsHardwareTextureRescaling: boolean;
  30278. /**
  30279. * Gets the list of texture formats supported
  30280. */
  30281. readonly texturesSupported: Array<string>;
  30282. /**
  30283. * Gets the list of texture formats in use
  30284. */
  30285. readonly textureFormatInUse: Nullable<string>;
  30286. /**
  30287. * Gets the current viewport
  30288. */
  30289. readonly currentViewport: Nullable<IViewportLike>;
  30290. /**
  30291. * Gets the default empty texture
  30292. */
  30293. readonly emptyTexture: InternalTexture;
  30294. /**
  30295. * Gets the default empty 3D texture
  30296. */
  30297. readonly emptyTexture3D: InternalTexture;
  30298. /**
  30299. * Gets the default empty cube texture
  30300. */
  30301. readonly emptyCubeTexture: InternalTexture;
  30302. /**
  30303. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30304. */
  30305. readonly premultipliedAlpha: boolean;
  30306. /**
  30307. * Creates a new engine
  30308. * @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
  30309. * @param antialias defines enable antialiasing (default: false)
  30310. * @param options defines further options to be sent to the getContext() function
  30311. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30312. */
  30313. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30314. private _rebuildInternalTextures;
  30315. private _rebuildEffects;
  30316. /**
  30317. * Gets a boolean indicating if all created effects are ready
  30318. * @returns true if all effects are ready
  30319. */
  30320. areAllEffectsReady(): boolean;
  30321. protected _rebuildBuffers(): void;
  30322. private _initGLContext;
  30323. /**
  30324. * Gets version of the current webGL context
  30325. */
  30326. readonly webGLVersion: number;
  30327. /**
  30328. * Gets a string idenfifying the name of the class
  30329. * @returns "Engine" string
  30330. */
  30331. getClassName(): string;
  30332. /**
  30333. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30334. */
  30335. readonly isStencilEnable: boolean;
  30336. /** @hidden */
  30337. _prepareWorkingCanvas(): void;
  30338. /**
  30339. * Reset the texture cache to empty state
  30340. */
  30341. resetTextureCache(): void;
  30342. /**
  30343. * Gets an object containing information about the current webGL context
  30344. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30345. */
  30346. getGlInfo(): {
  30347. vendor: string;
  30348. renderer: string;
  30349. version: string;
  30350. };
  30351. /**
  30352. * Defines the hardware scaling level.
  30353. * By default the hardware scaling level is computed from the window device ratio.
  30354. * 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.
  30355. * @param level defines the level to use
  30356. */
  30357. setHardwareScalingLevel(level: number): void;
  30358. /**
  30359. * Gets the current hardware scaling level.
  30360. * By default the hardware scaling level is computed from the window device ratio.
  30361. * 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.
  30362. * @returns a number indicating the current hardware scaling level
  30363. */
  30364. getHardwareScalingLevel(): number;
  30365. /**
  30366. * Gets the list of loaded textures
  30367. * @returns an array containing all loaded textures
  30368. */
  30369. getLoadedTexturesCache(): InternalTexture[];
  30370. /**
  30371. * Gets the object containing all engine capabilities
  30372. * @returns the EngineCapabilities object
  30373. */
  30374. getCaps(): EngineCapabilities;
  30375. /**
  30376. * stop executing a render loop function and remove it from the execution array
  30377. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30378. */
  30379. stopRenderLoop(renderFunction?: () => void): void;
  30380. /** @hidden */
  30381. _renderLoop(): void;
  30382. /**
  30383. * Gets the HTML canvas attached with the current webGL context
  30384. * @returns a HTML canvas
  30385. */
  30386. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30387. /**
  30388. * Gets host window
  30389. * @returns the host window object
  30390. */
  30391. getHostWindow(): Window;
  30392. /**
  30393. * Gets the current render width
  30394. * @param useScreen defines if screen size must be used (or the current render target if any)
  30395. * @returns a number defining the current render width
  30396. */
  30397. getRenderWidth(useScreen?: boolean): number;
  30398. /**
  30399. * Gets the current render height
  30400. * @param useScreen defines if screen size must be used (or the current render target if any)
  30401. * @returns a number defining the current render height
  30402. */
  30403. getRenderHeight(useScreen?: boolean): number;
  30404. /**
  30405. * Can be used to override the current requestAnimationFrame requester.
  30406. * @hidden
  30407. */
  30408. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30409. /**
  30410. * Register and execute a render loop. The engine can have more than one render function
  30411. * @param renderFunction defines the function to continuously execute
  30412. */
  30413. runRenderLoop(renderFunction: () => void): void;
  30414. /**
  30415. * Clear the current render buffer or the current render target (if any is set up)
  30416. * @param color defines the color to use
  30417. * @param backBuffer defines if the back buffer must be cleared
  30418. * @param depth defines if the depth buffer must be cleared
  30419. * @param stencil defines if the stencil buffer must be cleared
  30420. */
  30421. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30422. private _viewportCached;
  30423. /** @hidden */
  30424. _viewport(x: number, y: number, width: number, height: number): void;
  30425. /**
  30426. * Set the WebGL's viewport
  30427. * @param viewport defines the viewport element to be used
  30428. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30429. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30430. */
  30431. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30432. /**
  30433. * Begin a new frame
  30434. */
  30435. beginFrame(): void;
  30436. /**
  30437. * Enf the current frame
  30438. */
  30439. endFrame(): void;
  30440. /**
  30441. * Resize the view according to the canvas' size
  30442. */
  30443. resize(): void;
  30444. /**
  30445. * Force a specific size of the canvas
  30446. * @param width defines the new canvas' width
  30447. * @param height defines the new canvas' height
  30448. */
  30449. setSize(width: number, height: number): void;
  30450. /**
  30451. * Binds the frame buffer to the specified texture.
  30452. * @param texture The texture to render to or null for the default canvas
  30453. * @param faceIndex The face of the texture to render to in case of cube texture
  30454. * @param requiredWidth The width of the target to render to
  30455. * @param requiredHeight The height of the target to render to
  30456. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30457. * @param depthStencilTexture The depth stencil texture to use to render
  30458. * @param lodLevel defines le lod level to bind to the frame buffer
  30459. */
  30460. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30461. /** @hidden */
  30462. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30463. /**
  30464. * Unbind the current render target texture from the webGL context
  30465. * @param texture defines the render target texture to unbind
  30466. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30467. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30468. */
  30469. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30470. /**
  30471. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30472. */
  30473. flushFramebuffer(): void;
  30474. /**
  30475. * Unbind the current render target and bind the default framebuffer
  30476. */
  30477. restoreDefaultFramebuffer(): void;
  30478. private _resetVertexBufferBinding;
  30479. /**
  30480. * Creates a vertex buffer
  30481. * @param data the data for the vertex buffer
  30482. * @returns the new WebGL static buffer
  30483. */
  30484. createVertexBuffer(data: DataArray): DataBuffer;
  30485. private _createVertexBuffer;
  30486. /**
  30487. * Creates a dynamic vertex buffer
  30488. * @param data the data for the dynamic vertex buffer
  30489. * @returns the new WebGL dynamic buffer
  30490. */
  30491. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30492. /**
  30493. * Update a dynamic index buffer
  30494. * @param indexBuffer defines the target index buffer
  30495. * @param indices defines the data to update
  30496. * @param offset defines the offset in the target index buffer where update should start
  30497. */
  30498. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30499. /**
  30500. * Updates a dynamic vertex buffer.
  30501. * @param vertexBuffer the vertex buffer to update
  30502. * @param data the data used to update the vertex buffer
  30503. * @param byteOffset the byte offset of the data
  30504. * @param byteLength the byte length of the data
  30505. */
  30506. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30507. private _resetIndexBufferBinding;
  30508. /**
  30509. * Creates a new index buffer
  30510. * @param indices defines the content of the index buffer
  30511. * @param updatable defines if the index buffer must be updatable
  30512. * @returns a new webGL buffer
  30513. */
  30514. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30515. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30516. /**
  30517. * Bind a webGL buffer to the webGL context
  30518. * @param buffer defines the buffer to bind
  30519. */
  30520. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30521. private bindIndexBuffer;
  30522. private bindBuffer;
  30523. /**
  30524. * update the bound buffer with the given data
  30525. * @param data defines the data to update
  30526. */
  30527. updateArrayBuffer(data: Float32Array): void;
  30528. private _vertexAttribPointer;
  30529. private _bindIndexBufferWithCache;
  30530. private _bindVertexBuffersAttributes;
  30531. /**
  30532. * Records a vertex array object
  30533. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30534. * @param vertexBuffers defines the list of vertex buffers to store
  30535. * @param indexBuffer defines the index buffer to store
  30536. * @param effect defines the effect to store
  30537. * @returns the new vertex array object
  30538. */
  30539. recordVertexArrayObject(vertexBuffers: {
  30540. [key: string]: VertexBuffer;
  30541. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30542. /**
  30543. * Bind a specific vertex array object
  30544. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30545. * @param vertexArrayObject defines the vertex array object to bind
  30546. * @param indexBuffer defines the index buffer to bind
  30547. */
  30548. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30549. /**
  30550. * Bind webGl buffers directly to the webGL context
  30551. * @param vertexBuffer defines the vertex buffer to bind
  30552. * @param indexBuffer defines the index buffer to bind
  30553. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30554. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30555. * @param effect defines the effect associated with the vertex buffer
  30556. */
  30557. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30558. private _unbindVertexArrayObject;
  30559. /**
  30560. * Bind a list of vertex buffers to the webGL context
  30561. * @param vertexBuffers defines the list of vertex buffers to bind
  30562. * @param indexBuffer defines the index buffer to bind
  30563. * @param effect defines the effect associated with the vertex buffers
  30564. */
  30565. bindBuffers(vertexBuffers: {
  30566. [key: string]: Nullable<VertexBuffer>;
  30567. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30568. /**
  30569. * Unbind all instance attributes
  30570. */
  30571. unbindInstanceAttributes(): void;
  30572. /**
  30573. * Release and free the memory of a vertex array object
  30574. * @param vao defines the vertex array object to delete
  30575. */
  30576. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30577. /** @hidden */
  30578. _releaseBuffer(buffer: DataBuffer): boolean;
  30579. protected _deleteBuffer(buffer: DataBuffer): void;
  30580. /**
  30581. * Creates a webGL buffer to use with instanciation
  30582. * @param capacity defines the size of the buffer
  30583. * @returns the webGL buffer
  30584. */
  30585. createInstancesBuffer(capacity: number): DataBuffer;
  30586. /**
  30587. * Delete a webGL buffer used with instanciation
  30588. * @param buffer defines the webGL buffer to delete
  30589. */
  30590. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30591. /**
  30592. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30593. * @param instancesBuffer defines the webGL buffer to update and bind
  30594. * @param data defines the data to store in the buffer
  30595. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30596. */
  30597. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30598. /**
  30599. * Apply all cached states (depth, culling, stencil and alpha)
  30600. */
  30601. applyStates(): void;
  30602. /**
  30603. * Send a draw order
  30604. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30605. * @param indexStart defines the starting index
  30606. * @param indexCount defines the number of index to draw
  30607. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30608. */
  30609. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30610. /**
  30611. * Draw a list of points
  30612. * @param verticesStart defines the index of first vertex to draw
  30613. * @param verticesCount defines the count of vertices to draw
  30614. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30615. */
  30616. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30617. /**
  30618. * Draw a list of unindexed primitives
  30619. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30620. * @param verticesStart defines the index of first vertex to draw
  30621. * @param verticesCount defines the count of vertices to draw
  30622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30623. */
  30624. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30625. /**
  30626. * Draw a list of indexed primitives
  30627. * @param fillMode defines the primitive to use
  30628. * @param indexStart defines the starting index
  30629. * @param indexCount defines the number of index to draw
  30630. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30631. */
  30632. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30633. /**
  30634. * Draw a list of unindexed primitives
  30635. * @param fillMode defines the primitive to use
  30636. * @param verticesStart defines the index of first vertex to draw
  30637. * @param verticesCount defines the count of vertices to draw
  30638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30639. */
  30640. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30641. private _drawMode;
  30642. /** @hidden */
  30643. _releaseEffect(effect: Effect): void;
  30644. /** @hidden */
  30645. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30646. /**
  30647. * Create a new effect (used to store vertex/fragment shaders)
  30648. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30649. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30650. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30651. * @param samplers defines an array of string used to represent textures
  30652. * @param defines defines the string containing the defines to use to compile the shaders
  30653. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30654. * @param onCompiled defines a function to call when the effect creation is successful
  30655. * @param onError defines a function to call when the effect creation has failed
  30656. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30657. * @returns the new Effect
  30658. */
  30659. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30660. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30661. private _compileShader;
  30662. private _compileRawShader;
  30663. /**
  30664. * Directly creates a webGL program
  30665. * @param pipelineContext defines the pipeline context to attach to
  30666. * @param vertexCode defines the vertex shader code to use
  30667. * @param fragmentCode defines the fragment shader code to use
  30668. * @param context defines the webGL context to use (if not set, the current one will be used)
  30669. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30670. * @returns the new webGL program
  30671. */
  30672. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30673. /**
  30674. * Creates a webGL program
  30675. * @param pipelineContext defines the pipeline context to attach to
  30676. * @param vertexCode defines the vertex shader code to use
  30677. * @param fragmentCode defines the fragment shader code to use
  30678. * @param defines defines the string containing the defines to use to compile the shaders
  30679. * @param context defines the webGL context to use (if not set, the current one will be used)
  30680. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30681. * @returns the new webGL program
  30682. */
  30683. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30684. /**
  30685. * Creates a new pipeline context
  30686. * @returns the new pipeline
  30687. */
  30688. createPipelineContext(): IPipelineContext;
  30689. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30690. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30691. /** @hidden */
  30692. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30693. /** @hidden */
  30694. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30695. /** @hidden */
  30696. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30697. /**
  30698. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30699. * @param pipelineContext defines the pipeline context to use
  30700. * @param uniformsNames defines the list of uniform names
  30701. * @returns an array of webGL uniform locations
  30702. */
  30703. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30704. /**
  30705. * Gets the lsit of active attributes for a given webGL program
  30706. * @param pipelineContext defines the pipeline context to use
  30707. * @param attributesNames defines the list of attribute names to get
  30708. * @returns an array of indices indicating the offset of each attribute
  30709. */
  30710. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30711. /**
  30712. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30713. * @param effect defines the effect to activate
  30714. */
  30715. enableEffect(effect: Nullable<Effect>): void;
  30716. /**
  30717. * Set the value of an uniform to an array of int32
  30718. * @param uniform defines the webGL uniform location where to store the value
  30719. * @param array defines the array of int32 to store
  30720. */
  30721. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30722. /**
  30723. * Set the value of an uniform to an array of int32 (stored as vec2)
  30724. * @param uniform defines the webGL uniform location where to store the value
  30725. * @param array defines the array of int32 to store
  30726. */
  30727. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30728. /**
  30729. * Set the value of an uniform to an array of int32 (stored as vec3)
  30730. * @param uniform defines the webGL uniform location where to store the value
  30731. * @param array defines the array of int32 to store
  30732. */
  30733. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30734. /**
  30735. * Set the value of an uniform to an array of int32 (stored as vec4)
  30736. * @param uniform defines the webGL uniform location where to store the value
  30737. * @param array defines the array of int32 to store
  30738. */
  30739. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30740. /**
  30741. * Set the value of an uniform to an array of float32
  30742. * @param uniform defines the webGL uniform location where to store the value
  30743. * @param array defines the array of float32 to store
  30744. */
  30745. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30746. /**
  30747. * Set the value of an uniform to an array of float32 (stored as vec2)
  30748. * @param uniform defines the webGL uniform location where to store the value
  30749. * @param array defines the array of float32 to store
  30750. */
  30751. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30752. /**
  30753. * Set the value of an uniform to an array of float32 (stored as vec3)
  30754. * @param uniform defines the webGL uniform location where to store the value
  30755. * @param array defines the array of float32 to store
  30756. */
  30757. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30758. /**
  30759. * Set the value of an uniform to an array of float32 (stored as vec4)
  30760. * @param uniform defines the webGL uniform location where to store the value
  30761. * @param array defines the array of float32 to store
  30762. */
  30763. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30764. /**
  30765. * Set the value of an uniform to an array of number
  30766. * @param uniform defines the webGL uniform location where to store the value
  30767. * @param array defines the array of number to store
  30768. */
  30769. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30770. /**
  30771. * Set the value of an uniform to an array of number (stored as vec2)
  30772. * @param uniform defines the webGL uniform location where to store the value
  30773. * @param array defines the array of number to store
  30774. */
  30775. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30776. /**
  30777. * Set the value of an uniform to an array of number (stored as vec3)
  30778. * @param uniform defines the webGL uniform location where to store the value
  30779. * @param array defines the array of number to store
  30780. */
  30781. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30782. /**
  30783. * Set the value of an uniform to an array of number (stored as vec4)
  30784. * @param uniform defines the webGL uniform location where to store the value
  30785. * @param array defines the array of number to store
  30786. */
  30787. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30788. /**
  30789. * Set the value of an uniform to an array of float32 (stored as matrices)
  30790. * @param uniform defines the webGL uniform location where to store the value
  30791. * @param matrices defines the array of float32 to store
  30792. */
  30793. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30794. /**
  30795. * Set the value of an uniform to a matrix (3x3)
  30796. * @param uniform defines the webGL uniform location where to store the value
  30797. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30798. */
  30799. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30800. /**
  30801. * Set the value of an uniform to a matrix (2x2)
  30802. * @param uniform defines the webGL uniform location where to store the value
  30803. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30804. */
  30805. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30806. /**
  30807. * Set the value of an uniform to a number (int)
  30808. * @param uniform defines the webGL uniform location where to store the value
  30809. * @param value defines the int number to store
  30810. */
  30811. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30812. /**
  30813. * Set the value of an uniform to a number (float)
  30814. * @param uniform defines the webGL uniform location where to store the value
  30815. * @param value defines the float number to store
  30816. */
  30817. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30818. /**
  30819. * Set the value of an uniform to a vec2
  30820. * @param uniform defines the webGL uniform location where to store the value
  30821. * @param x defines the 1st component of the value
  30822. * @param y defines the 2nd component of the value
  30823. */
  30824. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30825. /**
  30826. * Set the value of an uniform to a vec3
  30827. * @param uniform defines the webGL uniform location where to store the value
  30828. * @param x defines the 1st component of the value
  30829. * @param y defines the 2nd component of the value
  30830. * @param z defines the 3rd component of the value
  30831. */
  30832. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30833. /**
  30834. * Set the value of an uniform to a boolean
  30835. * @param uniform defines the webGL uniform location where to store the value
  30836. * @param bool defines the boolean to store
  30837. */
  30838. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30839. /**
  30840. * Set the value of an uniform to a vec4
  30841. * @param uniform defines the webGL uniform location where to store the value
  30842. * @param x defines the 1st component of the value
  30843. * @param y defines the 2nd component of the value
  30844. * @param z defines the 3rd component of the value
  30845. * @param w defines the 4th component of the value
  30846. */
  30847. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30848. /**
  30849. * Sets a Color4 on a uniform variable
  30850. * @param uniform defines the uniform location
  30851. * @param color4 defines the value to be set
  30852. */
  30853. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30854. /**
  30855. * Gets the depth culling state manager
  30856. */
  30857. readonly depthCullingState: DepthCullingState;
  30858. /**
  30859. * Gets the alpha state manager
  30860. */
  30861. readonly alphaState: AlphaState;
  30862. /**
  30863. * Gets the stencil state manager
  30864. */
  30865. readonly stencilState: StencilState;
  30866. /**
  30867. * Clears the list of texture accessible through engine.
  30868. * This can help preventing texture load conflict due to name collision.
  30869. */
  30870. clearInternalTexturesCache(): void;
  30871. /**
  30872. * Force the entire cache to be cleared
  30873. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30874. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30875. */
  30876. wipeCaches(bruteForce?: boolean): void;
  30877. /** @hidden */
  30878. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30879. min: number;
  30880. mag: number;
  30881. };
  30882. /** @hidden */
  30883. _createTexture(): WebGLTexture;
  30884. /**
  30885. * Usually called from Texture.ts.
  30886. * Passed information to create a WebGLTexture
  30887. * @param urlArg defines a value which contains one of the following:
  30888. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30889. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30890. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30891. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30892. * @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)
  30893. * @param scene needed for loading to the correct scene
  30894. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30895. * @param onLoad optional callback to be called upon successful completion
  30896. * @param onError optional callback to be called upon failure
  30897. * @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
  30898. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30899. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30900. * @param forcedExtension defines the extension to use to pick the right loader
  30901. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30902. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30903. */
  30904. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30905. /**
  30906. * @hidden
  30907. */
  30908. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30909. /**
  30910. * Creates a raw texture
  30911. * @param data defines the data to store in the texture
  30912. * @param width defines the width of the texture
  30913. * @param height defines the height of the texture
  30914. * @param format defines the format of the data
  30915. * @param generateMipMaps defines if the engine should generate the mip levels
  30916. * @param invertY defines if data must be stored with Y axis inverted
  30917. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30918. * @param compression defines the compression used (null by default)
  30919. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30920. * @returns the raw texture inside an InternalTexture
  30921. */
  30922. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30923. /**
  30924. * Creates a new raw cube texture
  30925. * @param data defines the array of data to use to create each face
  30926. * @param size defines the size of the textures
  30927. * @param format defines the format of the data
  30928. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30929. * @param generateMipMaps defines if the engine should generate the mip levels
  30930. * @param invertY defines if data must be stored with Y axis inverted
  30931. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30932. * @param compression defines the compression used (null by default)
  30933. * @returns the cube texture as an InternalTexture
  30934. */
  30935. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30936. /**
  30937. * Creates a new raw 3D texture
  30938. * @param data defines the data used to create the texture
  30939. * @param width defines the width of the texture
  30940. * @param height defines the height of the texture
  30941. * @param depth defines the depth of the texture
  30942. * @param format defines the format of the texture
  30943. * @param generateMipMaps defines if the engine must generate mip levels
  30944. * @param invertY defines if data must be stored with Y axis inverted
  30945. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30946. * @param compression defines the compressed used (can be null)
  30947. * @param textureType defines the compressed used (can be null)
  30948. * @returns a new raw 3D texture (stored in an InternalTexture)
  30949. */
  30950. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30951. private _unpackFlipYCached;
  30952. /**
  30953. * In case you are sharing the context with other applications, it might
  30954. * be interested to not cache the unpack flip y state to ensure a consistent
  30955. * value would be set.
  30956. */
  30957. enableUnpackFlipYCached: boolean;
  30958. /** @hidden */
  30959. _unpackFlipY(value: boolean): void;
  30960. /** @hidden */
  30961. _getUnpackAlignement(): number;
  30962. /**
  30963. * Update the sampling mode of a given texture
  30964. * @param samplingMode defines the required sampling mode
  30965. * @param texture defines the texture to update
  30966. */
  30967. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30968. /**
  30969. * Updates a depth texture Comparison Mode and Function.
  30970. * If the comparison Function is equal to 0, the mode will be set to none.
  30971. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30972. * @param texture The texture to set the comparison function for
  30973. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30974. */
  30975. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30976. /** @hidden */
  30977. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30978. width: number;
  30979. height: number;
  30980. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30981. /**
  30982. * Creates a depth stencil texture.
  30983. * This is only available in WebGL 2 or with the depth texture extension available.
  30984. * @param size The size of face edge in the texture.
  30985. * @param options The options defining the texture.
  30986. * @returns The texture
  30987. */
  30988. createDepthStencilTexture(size: number | {
  30989. width: number;
  30990. height: number;
  30991. }, options: DepthTextureCreationOptions): InternalTexture;
  30992. /**
  30993. * Creates a depth stencil texture.
  30994. * This is only available in WebGL 2 or with the depth texture extension available.
  30995. * @param size The size of face edge in the texture.
  30996. * @param options The options defining the texture.
  30997. * @returns The texture
  30998. */
  30999. private _createDepthStencilTexture;
  31000. /**
  31001. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31002. * @param renderTarget The render target to set the frame buffer for
  31003. */
  31004. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31005. /** @hidden */
  31006. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31007. /** @hidden */
  31008. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31009. /** @hidden */
  31010. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31011. /** @hidden */
  31012. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31013. /** @hidden */
  31014. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31015. /**
  31016. * @hidden
  31017. */
  31018. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31019. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31020. private _prepareWebGLTexture;
  31021. /** @hidden */
  31022. _releaseFramebufferObjects(texture: InternalTexture): void;
  31023. /** @hidden */
  31024. _releaseTexture(texture: InternalTexture): void;
  31025. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31026. protected _setProgram(program: WebGLProgram): void;
  31027. protected _boundUniforms: {
  31028. [key: number]: WebGLUniformLocation;
  31029. };
  31030. /**
  31031. * Binds an effect to the webGL context
  31032. * @param effect defines the effect to bind
  31033. */
  31034. bindSamplers(effect: Effect): void;
  31035. private _activateCurrentTexture;
  31036. /** @hidden */
  31037. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31038. /** @hidden */
  31039. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31040. /**
  31041. * Unbind all textures from the webGL context
  31042. */
  31043. unbindAllTextures(): void;
  31044. /**
  31045. * Sets a texture to the according uniform.
  31046. * @param channel The texture channel
  31047. * @param uniform The uniform to set
  31048. * @param texture The texture to apply
  31049. */
  31050. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31051. private _bindSamplerUniformToChannel;
  31052. private _getTextureWrapMode;
  31053. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31054. /**
  31055. * Sets an array of texture to the webGL context
  31056. * @param channel defines the channel where the texture array must be set
  31057. * @param uniform defines the associated uniform location
  31058. * @param textures defines the array of textures to bind
  31059. */
  31060. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31061. /** @hidden */
  31062. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31063. private _setTextureParameterFloat;
  31064. private _setTextureParameterInteger;
  31065. /**
  31066. * Unbind all vertex attributes from the webGL context
  31067. */
  31068. unbindAllAttributes(): void;
  31069. /**
  31070. * 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
  31071. */
  31072. releaseEffects(): void;
  31073. /**
  31074. * Dispose and release all associated resources
  31075. */
  31076. dispose(): void;
  31077. /**
  31078. * Attach a new callback raised when context lost event is fired
  31079. * @param callback defines the callback to call
  31080. */
  31081. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31082. /**
  31083. * Attach a new callback raised when context restored event is fired
  31084. * @param callback defines the callback to call
  31085. */
  31086. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31087. /**
  31088. * Get the current error code of the webGL context
  31089. * @returns the error code
  31090. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31091. */
  31092. getError(): number;
  31093. private _canRenderToFloatFramebuffer;
  31094. private _canRenderToHalfFloatFramebuffer;
  31095. private _canRenderToFramebuffer;
  31096. /** @hidden */
  31097. _getWebGLTextureType(type: number): number;
  31098. /** @hidden */
  31099. _getInternalFormat(format: number): number;
  31100. /** @hidden */
  31101. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31102. /** @hidden */
  31103. _getRGBAMultiSampleBufferFormat(type: number): number;
  31104. /** @hidden */
  31105. _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;
  31106. /**
  31107. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31108. * @returns true if the engine can be created
  31109. * @ignorenaming
  31110. */
  31111. static isSupported(): boolean;
  31112. /**
  31113. * Find the next highest power of two.
  31114. * @param x Number to start search from.
  31115. * @return Next highest power of two.
  31116. */
  31117. static CeilingPOT(x: number): number;
  31118. /**
  31119. * Find the next lowest power of two.
  31120. * @param x Number to start search from.
  31121. * @return Next lowest power of two.
  31122. */
  31123. static FloorPOT(x: number): number;
  31124. /**
  31125. * Find the nearest power of two.
  31126. * @param x Number to start search from.
  31127. * @return Next nearest power of two.
  31128. */
  31129. static NearestPOT(x: number): number;
  31130. /**
  31131. * Get the closest exponent of two
  31132. * @param value defines the value to approximate
  31133. * @param max defines the maximum value to return
  31134. * @param mode defines how to define the closest value
  31135. * @returns closest exponent of two of the given value
  31136. */
  31137. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31138. /**
  31139. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31140. * @param func - the function to be called
  31141. * @param requester - the object that will request the next frame. Falls back to window.
  31142. * @returns frame number
  31143. */
  31144. static QueueNewFrame(func: () => void, requester?: any): number;
  31145. }
  31146. }
  31147. declare module "babylonjs/Materials/Textures/internalTexture" {
  31148. import { Observable } from "babylonjs/Misc/observable";
  31149. import { Nullable, int } from "babylonjs/types";
  31150. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31151. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31153. /**
  31154. * Class used to store data associated with WebGL texture data for the engine
  31155. * This class should not be used directly
  31156. */
  31157. export class InternalTexture {
  31158. /** @hidden */
  31159. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31160. /**
  31161. * The source of the texture data is unknown
  31162. */
  31163. static DATASOURCE_UNKNOWN: number;
  31164. /**
  31165. * Texture data comes from an URL
  31166. */
  31167. static DATASOURCE_URL: number;
  31168. /**
  31169. * Texture data is only used for temporary storage
  31170. */
  31171. static DATASOURCE_TEMP: number;
  31172. /**
  31173. * Texture data comes from raw data (ArrayBuffer)
  31174. */
  31175. static DATASOURCE_RAW: number;
  31176. /**
  31177. * Texture content is dynamic (video or dynamic texture)
  31178. */
  31179. static DATASOURCE_DYNAMIC: number;
  31180. /**
  31181. * Texture content is generated by rendering to it
  31182. */
  31183. static DATASOURCE_RENDERTARGET: number;
  31184. /**
  31185. * Texture content is part of a multi render target process
  31186. */
  31187. static DATASOURCE_MULTIRENDERTARGET: number;
  31188. /**
  31189. * Texture data comes from a cube data file
  31190. */
  31191. static DATASOURCE_CUBE: number;
  31192. /**
  31193. * Texture data comes from a raw cube data
  31194. */
  31195. static DATASOURCE_CUBERAW: number;
  31196. /**
  31197. * Texture data come from a prefiltered cube data file
  31198. */
  31199. static DATASOURCE_CUBEPREFILTERED: number;
  31200. /**
  31201. * Texture content is raw 3D data
  31202. */
  31203. static DATASOURCE_RAW3D: number;
  31204. /**
  31205. * Texture content is a depth texture
  31206. */
  31207. static DATASOURCE_DEPTHTEXTURE: number;
  31208. /**
  31209. * Texture data comes from a raw cube data encoded with RGBD
  31210. */
  31211. static DATASOURCE_CUBERAW_RGBD: number;
  31212. /**
  31213. * Defines if the texture is ready
  31214. */
  31215. isReady: boolean;
  31216. /**
  31217. * Defines if the texture is a cube texture
  31218. */
  31219. isCube: boolean;
  31220. /**
  31221. * Defines if the texture contains 3D data
  31222. */
  31223. is3D: boolean;
  31224. /**
  31225. * Defines if the texture contains multiview data
  31226. */
  31227. isMultiview: boolean;
  31228. /**
  31229. * Gets the URL used to load this texture
  31230. */
  31231. url: string;
  31232. /**
  31233. * Gets the sampling mode of the texture
  31234. */
  31235. samplingMode: number;
  31236. /**
  31237. * Gets a boolean indicating if the texture needs mipmaps generation
  31238. */
  31239. generateMipMaps: boolean;
  31240. /**
  31241. * Gets the number of samples used by the texture (WebGL2+ only)
  31242. */
  31243. samples: number;
  31244. /**
  31245. * Gets the type of the texture (int, float...)
  31246. */
  31247. type: number;
  31248. /**
  31249. * Gets the format of the texture (RGB, RGBA...)
  31250. */
  31251. format: number;
  31252. /**
  31253. * Observable called when the texture is loaded
  31254. */
  31255. onLoadedObservable: Observable<InternalTexture>;
  31256. /**
  31257. * Gets the width of the texture
  31258. */
  31259. width: number;
  31260. /**
  31261. * Gets the height of the texture
  31262. */
  31263. height: number;
  31264. /**
  31265. * Gets the depth of the texture
  31266. */
  31267. depth: number;
  31268. /**
  31269. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31270. */
  31271. baseWidth: number;
  31272. /**
  31273. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31274. */
  31275. baseHeight: number;
  31276. /**
  31277. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31278. */
  31279. baseDepth: number;
  31280. /**
  31281. * Gets a boolean indicating if the texture is inverted on Y axis
  31282. */
  31283. invertY: boolean;
  31284. /** @hidden */
  31285. _invertVScale: boolean;
  31286. /** @hidden */
  31287. _associatedChannel: number;
  31288. /** @hidden */
  31289. _dataSource: number;
  31290. /** @hidden */
  31291. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31292. /** @hidden */
  31293. _bufferView: Nullable<ArrayBufferView>;
  31294. /** @hidden */
  31295. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31296. /** @hidden */
  31297. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31298. /** @hidden */
  31299. _size: number;
  31300. /** @hidden */
  31301. _extension: string;
  31302. /** @hidden */
  31303. _files: Nullable<string[]>;
  31304. /** @hidden */
  31305. _workingCanvas: Nullable<HTMLCanvasElement>;
  31306. /** @hidden */
  31307. _workingContext: Nullable<CanvasRenderingContext2D>;
  31308. /** @hidden */
  31309. _framebuffer: Nullable<WebGLFramebuffer>;
  31310. /** @hidden */
  31311. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31312. /** @hidden */
  31313. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31314. /** @hidden */
  31315. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31316. /** @hidden */
  31317. _attachments: Nullable<number[]>;
  31318. /** @hidden */
  31319. _cachedCoordinatesMode: Nullable<number>;
  31320. /** @hidden */
  31321. _cachedWrapU: Nullable<number>;
  31322. /** @hidden */
  31323. _cachedWrapV: Nullable<number>;
  31324. /** @hidden */
  31325. _cachedWrapR: Nullable<number>;
  31326. /** @hidden */
  31327. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31328. /** @hidden */
  31329. _isDisabled: boolean;
  31330. /** @hidden */
  31331. _compression: Nullable<string>;
  31332. /** @hidden */
  31333. _generateStencilBuffer: boolean;
  31334. /** @hidden */
  31335. _generateDepthBuffer: boolean;
  31336. /** @hidden */
  31337. _comparisonFunction: number;
  31338. /** @hidden */
  31339. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31340. /** @hidden */
  31341. _lodGenerationScale: number;
  31342. /** @hidden */
  31343. _lodGenerationOffset: number;
  31344. /** @hidden */
  31345. _colorTextureArray: Nullable<WebGLTexture>;
  31346. /** @hidden */
  31347. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31348. /** @hidden */
  31349. _lodTextureHigh: Nullable<BaseTexture>;
  31350. /** @hidden */
  31351. _lodTextureMid: Nullable<BaseTexture>;
  31352. /** @hidden */
  31353. _lodTextureLow: Nullable<BaseTexture>;
  31354. /** @hidden */
  31355. _isRGBD: boolean;
  31356. /** @hidden */
  31357. _linearSpecularLOD: boolean;
  31358. /** @hidden */
  31359. _irradianceTexture: Nullable<BaseTexture>;
  31360. /** @hidden */
  31361. _webGLTexture: Nullable<WebGLTexture>;
  31362. /** @hidden */
  31363. _references: number;
  31364. private _engine;
  31365. /**
  31366. * Gets the Engine the texture belongs to.
  31367. * @returns The babylon engine
  31368. */
  31369. getEngine(): ThinEngine;
  31370. /**
  31371. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  31372. */
  31373. readonly dataSource: number;
  31374. /**
  31375. * Creates a new InternalTexture
  31376. * @param engine defines the engine to use
  31377. * @param dataSource defines the type of data that will be used
  31378. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31379. */
  31380. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  31381. /**
  31382. * Increments the number of references (ie. the number of Texture that point to it)
  31383. */
  31384. incrementReferences(): void;
  31385. /**
  31386. * Change the size of the texture (not the size of the content)
  31387. * @param width defines the new width
  31388. * @param height defines the new height
  31389. * @param depth defines the new depth (1 by default)
  31390. */
  31391. updateSize(width: int, height: int, depth?: int): void;
  31392. /** @hidden */
  31393. _rebuild(): void;
  31394. /** @hidden */
  31395. _swapAndDie(target: InternalTexture): void;
  31396. /**
  31397. * Dispose the current allocated resources
  31398. */
  31399. dispose(): void;
  31400. }
  31401. }
  31402. declare module "babylonjs/Audio/analyser" {
  31403. import { Scene } from "babylonjs/scene";
  31404. /**
  31405. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31407. */
  31408. export class Analyser {
  31409. /**
  31410. * Gets or sets the smoothing
  31411. * @ignorenaming
  31412. */
  31413. SMOOTHING: number;
  31414. /**
  31415. * Gets or sets the FFT table size
  31416. * @ignorenaming
  31417. */
  31418. FFT_SIZE: number;
  31419. /**
  31420. * Gets or sets the bar graph amplitude
  31421. * @ignorenaming
  31422. */
  31423. BARGRAPHAMPLITUDE: number;
  31424. /**
  31425. * Gets or sets the position of the debug canvas
  31426. * @ignorenaming
  31427. */
  31428. DEBUGCANVASPOS: {
  31429. x: number;
  31430. y: number;
  31431. };
  31432. /**
  31433. * Gets or sets the debug canvas size
  31434. * @ignorenaming
  31435. */
  31436. DEBUGCANVASSIZE: {
  31437. width: number;
  31438. height: number;
  31439. };
  31440. private _byteFreqs;
  31441. private _byteTime;
  31442. private _floatFreqs;
  31443. private _webAudioAnalyser;
  31444. private _debugCanvas;
  31445. private _debugCanvasContext;
  31446. private _scene;
  31447. private _registerFunc;
  31448. private _audioEngine;
  31449. /**
  31450. * Creates a new analyser
  31451. * @param scene defines hosting scene
  31452. */
  31453. constructor(scene: Scene);
  31454. /**
  31455. * Get the number of data values you will have to play with for the visualization
  31456. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31457. * @returns a number
  31458. */
  31459. getFrequencyBinCount(): number;
  31460. /**
  31461. * Gets the current frequency data as a byte array
  31462. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31463. * @returns a Uint8Array
  31464. */
  31465. getByteFrequencyData(): Uint8Array;
  31466. /**
  31467. * Gets the current waveform as a byte array
  31468. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31469. * @returns a Uint8Array
  31470. */
  31471. getByteTimeDomainData(): Uint8Array;
  31472. /**
  31473. * Gets the current frequency data as a float array
  31474. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31475. * @returns a Float32Array
  31476. */
  31477. getFloatFrequencyData(): Float32Array;
  31478. /**
  31479. * Renders the debug canvas
  31480. */
  31481. drawDebugCanvas(): void;
  31482. /**
  31483. * Stops rendering the debug canvas and removes it
  31484. */
  31485. stopDebugCanvas(): void;
  31486. /**
  31487. * Connects two audio nodes
  31488. * @param inputAudioNode defines first node to connect
  31489. * @param outputAudioNode defines second node to connect
  31490. */
  31491. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31492. /**
  31493. * Releases all associated resources
  31494. */
  31495. dispose(): void;
  31496. }
  31497. }
  31498. declare module "babylonjs/Audio/audioEngine" {
  31499. import { IDisposable } from "babylonjs/scene";
  31500. import { Analyser } from "babylonjs/Audio/analyser";
  31501. import { Nullable } from "babylonjs/types";
  31502. import { Observable } from "babylonjs/Misc/observable";
  31503. /**
  31504. * This represents an audio engine and it is responsible
  31505. * to play, synchronize and analyse sounds throughout the application.
  31506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31507. */
  31508. export interface IAudioEngine extends IDisposable {
  31509. /**
  31510. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31511. */
  31512. readonly canUseWebAudio: boolean;
  31513. /**
  31514. * Gets the current AudioContext if available.
  31515. */
  31516. readonly audioContext: Nullable<AudioContext>;
  31517. /**
  31518. * The master gain node defines the global audio volume of your audio engine.
  31519. */
  31520. readonly masterGain: GainNode;
  31521. /**
  31522. * Gets whether or not mp3 are supported by your browser.
  31523. */
  31524. readonly isMP3supported: boolean;
  31525. /**
  31526. * Gets whether or not ogg are supported by your browser.
  31527. */
  31528. readonly isOGGsupported: boolean;
  31529. /**
  31530. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31531. * @ignoreNaming
  31532. */
  31533. WarnedWebAudioUnsupported: boolean;
  31534. /**
  31535. * Defines if the audio engine relies on a custom unlocked button.
  31536. * In this case, the embedded button will not be displayed.
  31537. */
  31538. useCustomUnlockedButton: boolean;
  31539. /**
  31540. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31541. */
  31542. readonly unlocked: boolean;
  31543. /**
  31544. * Event raised when audio has been unlocked on the browser.
  31545. */
  31546. onAudioUnlockedObservable: Observable<AudioEngine>;
  31547. /**
  31548. * Event raised when audio has been locked on the browser.
  31549. */
  31550. onAudioLockedObservable: Observable<AudioEngine>;
  31551. /**
  31552. * Flags the audio engine in Locked state.
  31553. * This happens due to new browser policies preventing audio to autoplay.
  31554. */
  31555. lock(): void;
  31556. /**
  31557. * Unlocks the audio engine once a user action has been done on the dom.
  31558. * This is helpful to resume play once browser policies have been satisfied.
  31559. */
  31560. unlock(): void;
  31561. }
  31562. /**
  31563. * This represents the default audio engine used in babylon.
  31564. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31566. */
  31567. export class AudioEngine implements IAudioEngine {
  31568. private _audioContext;
  31569. private _audioContextInitialized;
  31570. private _muteButton;
  31571. private _hostElement;
  31572. /**
  31573. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31574. */
  31575. canUseWebAudio: boolean;
  31576. /**
  31577. * The master gain node defines the global audio volume of your audio engine.
  31578. */
  31579. masterGain: GainNode;
  31580. /**
  31581. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31582. * @ignoreNaming
  31583. */
  31584. WarnedWebAudioUnsupported: boolean;
  31585. /**
  31586. * Gets whether or not mp3 are supported by your browser.
  31587. */
  31588. isMP3supported: boolean;
  31589. /**
  31590. * Gets whether or not ogg are supported by your browser.
  31591. */
  31592. isOGGsupported: boolean;
  31593. /**
  31594. * Gets whether audio has been unlocked on the device.
  31595. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31596. * a user interaction has happened.
  31597. */
  31598. unlocked: boolean;
  31599. /**
  31600. * Defines if the audio engine relies on a custom unlocked button.
  31601. * In this case, the embedded button will not be displayed.
  31602. */
  31603. useCustomUnlockedButton: boolean;
  31604. /**
  31605. * Event raised when audio has been unlocked on the browser.
  31606. */
  31607. onAudioUnlockedObservable: Observable<AudioEngine>;
  31608. /**
  31609. * Event raised when audio has been locked on the browser.
  31610. */
  31611. onAudioLockedObservable: Observable<AudioEngine>;
  31612. /**
  31613. * Gets the current AudioContext if available.
  31614. */
  31615. readonly audioContext: Nullable<AudioContext>;
  31616. private _connectedAnalyser;
  31617. /**
  31618. * Instantiates a new audio engine.
  31619. *
  31620. * There should be only one per page as some browsers restrict the number
  31621. * of audio contexts you can create.
  31622. * @param hostElement defines the host element where to display the mute icon if necessary
  31623. */
  31624. constructor(hostElement?: Nullable<HTMLElement>);
  31625. /**
  31626. * Flags the audio engine in Locked state.
  31627. * This happens due to new browser policies preventing audio to autoplay.
  31628. */
  31629. lock(): void;
  31630. /**
  31631. * Unlocks the audio engine once a user action has been done on the dom.
  31632. * This is helpful to resume play once browser policies have been satisfied.
  31633. */
  31634. unlock(): void;
  31635. private _resumeAudioContext;
  31636. private _initializeAudioContext;
  31637. private _tryToRun;
  31638. private _triggerRunningState;
  31639. private _triggerSuspendedState;
  31640. private _displayMuteButton;
  31641. private _moveButtonToTopLeft;
  31642. private _onResize;
  31643. private _hideMuteButton;
  31644. /**
  31645. * Destroy and release the resources associated with the audio ccontext.
  31646. */
  31647. dispose(): void;
  31648. /**
  31649. * Gets the global volume sets on the master gain.
  31650. * @returns the global volume if set or -1 otherwise
  31651. */
  31652. getGlobalVolume(): number;
  31653. /**
  31654. * Sets the global volume of your experience (sets on the master gain).
  31655. * @param newVolume Defines the new global volume of the application
  31656. */
  31657. setGlobalVolume(newVolume: number): void;
  31658. /**
  31659. * Connect the audio engine to an audio analyser allowing some amazing
  31660. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31662. * @param analyser The analyser to connect to the engine
  31663. */
  31664. connectToAnalyser(analyser: Analyser): void;
  31665. }
  31666. }
  31667. declare module "babylonjs/Loading/loadingScreen" {
  31668. /**
  31669. * Interface used to present a loading screen while loading a scene
  31670. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31671. */
  31672. export interface ILoadingScreen {
  31673. /**
  31674. * Function called to display the loading screen
  31675. */
  31676. displayLoadingUI: () => void;
  31677. /**
  31678. * Function called to hide the loading screen
  31679. */
  31680. hideLoadingUI: () => void;
  31681. /**
  31682. * Gets or sets the color to use for the background
  31683. */
  31684. loadingUIBackgroundColor: string;
  31685. /**
  31686. * Gets or sets the text to display while loading
  31687. */
  31688. loadingUIText: string;
  31689. }
  31690. /**
  31691. * Class used for the default loading screen
  31692. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31693. */
  31694. export class DefaultLoadingScreen implements ILoadingScreen {
  31695. private _renderingCanvas;
  31696. private _loadingText;
  31697. private _loadingDivBackgroundColor;
  31698. private _loadingDiv;
  31699. private _loadingTextDiv;
  31700. /** Gets or sets the logo url to use for the default loading screen */
  31701. static DefaultLogoUrl: string;
  31702. /** Gets or sets the spinner url to use for the default loading screen */
  31703. static DefaultSpinnerUrl: string;
  31704. /**
  31705. * Creates a new default loading screen
  31706. * @param _renderingCanvas defines the canvas used to render the scene
  31707. * @param _loadingText defines the default text to display
  31708. * @param _loadingDivBackgroundColor defines the default background color
  31709. */
  31710. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31711. /**
  31712. * Function called to display the loading screen
  31713. */
  31714. displayLoadingUI(): void;
  31715. /**
  31716. * Function called to hide the loading screen
  31717. */
  31718. hideLoadingUI(): void;
  31719. /**
  31720. * Gets or sets the text to display while loading
  31721. */
  31722. loadingUIText: string;
  31723. /**
  31724. * Gets or sets the color to use for the background
  31725. */
  31726. loadingUIBackgroundColor: string;
  31727. private _resizeLoadingUI;
  31728. }
  31729. }
  31730. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31731. /**
  31732. * Interface for any object that can request an animation frame
  31733. */
  31734. export interface ICustomAnimationFrameRequester {
  31735. /**
  31736. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31737. */
  31738. renderFunction?: Function;
  31739. /**
  31740. * Called to request the next frame to render to
  31741. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31742. */
  31743. requestAnimationFrame: Function;
  31744. /**
  31745. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31746. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31747. */
  31748. requestID?: number;
  31749. }
  31750. }
  31751. declare module "babylonjs/Misc/performanceMonitor" {
  31752. /**
  31753. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31754. */
  31755. export class PerformanceMonitor {
  31756. private _enabled;
  31757. private _rollingFrameTime;
  31758. private _lastFrameTimeMs;
  31759. /**
  31760. * constructor
  31761. * @param frameSampleSize The number of samples required to saturate the sliding window
  31762. */
  31763. constructor(frameSampleSize?: number);
  31764. /**
  31765. * Samples current frame
  31766. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31767. */
  31768. sampleFrame(timeMs?: number): void;
  31769. /**
  31770. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31771. */
  31772. readonly averageFrameTime: number;
  31773. /**
  31774. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31775. */
  31776. readonly averageFrameTimeVariance: number;
  31777. /**
  31778. * Returns the frame time of the most recent frame
  31779. */
  31780. readonly instantaneousFrameTime: number;
  31781. /**
  31782. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31783. */
  31784. readonly averageFPS: number;
  31785. /**
  31786. * Returns the average framerate in frames per second using the most recent frame time
  31787. */
  31788. readonly instantaneousFPS: number;
  31789. /**
  31790. * Returns true if enough samples have been taken to completely fill the sliding window
  31791. */
  31792. readonly isSaturated: boolean;
  31793. /**
  31794. * Enables contributions to the sliding window sample set
  31795. */
  31796. enable(): void;
  31797. /**
  31798. * Disables contributions to the sliding window sample set
  31799. * Samples will not be interpolated over the disabled period
  31800. */
  31801. disable(): void;
  31802. /**
  31803. * Returns true if sampling is enabled
  31804. */
  31805. readonly isEnabled: boolean;
  31806. /**
  31807. * Resets performance monitor
  31808. */
  31809. reset(): void;
  31810. }
  31811. /**
  31812. * RollingAverage
  31813. *
  31814. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31815. */
  31816. export class RollingAverage {
  31817. /**
  31818. * Current average
  31819. */
  31820. average: number;
  31821. /**
  31822. * Current variance
  31823. */
  31824. variance: number;
  31825. protected _samples: Array<number>;
  31826. protected _sampleCount: number;
  31827. protected _pos: number;
  31828. protected _m2: number;
  31829. /**
  31830. * constructor
  31831. * @param length The number of samples required to saturate the sliding window
  31832. */
  31833. constructor(length: number);
  31834. /**
  31835. * Adds a sample to the sample set
  31836. * @param v The sample value
  31837. */
  31838. add(v: number): void;
  31839. /**
  31840. * Returns previously added values or null if outside of history or outside the sliding window domain
  31841. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31842. * @return Value previously recorded with add() or null if outside of range
  31843. */
  31844. history(i: number): number;
  31845. /**
  31846. * Returns true if enough samples have been taken to completely fill the sliding window
  31847. * @return true if sample-set saturated
  31848. */
  31849. isSaturated(): boolean;
  31850. /**
  31851. * Resets the rolling average (equivalent to 0 samples taken so far)
  31852. */
  31853. reset(): void;
  31854. /**
  31855. * Wraps a value around the sample range boundaries
  31856. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31857. * @return Wrapped position in sample range
  31858. */
  31859. protected _wrapPosition(i: number): number;
  31860. }
  31861. }
  31862. declare module "babylonjs/Engines/engine" {
  31863. import { Observable } from "babylonjs/Misc/observable";
  31864. import { Nullable } from "babylonjs/types";
  31865. import { Scene } from "babylonjs/scene";
  31866. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31867. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31868. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31869. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31870. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31871. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31872. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31873. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31874. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31875. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  31876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31877. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31878. import { Material } from "babylonjs/Materials/material";
  31879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31880. /**
  31881. * Defines the interface used by display changed events
  31882. */
  31883. export interface IDisplayChangedEventArgs {
  31884. /** Gets the vrDisplay object (if any) */
  31885. vrDisplay: Nullable<any>;
  31886. /** Gets a boolean indicating if webVR is supported */
  31887. vrSupported: boolean;
  31888. }
  31889. /**
  31890. * Defines the interface used by objects containing a viewport (like a camera)
  31891. */
  31892. interface IViewportOwnerLike {
  31893. /**
  31894. * Gets or sets the viewport
  31895. */
  31896. viewport: IViewportLike;
  31897. }
  31898. /**
  31899. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31900. */
  31901. export class Engine extends ThinEngine {
  31902. /** Defines that alpha blending is disabled */
  31903. static readonly ALPHA_DISABLE: number;
  31904. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31905. static readonly ALPHA_ADD: number;
  31906. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31907. static readonly ALPHA_COMBINE: number;
  31908. /** Defines that alpha blending to DEST - SRC * DEST */
  31909. static readonly ALPHA_SUBTRACT: number;
  31910. /** Defines that alpha blending to SRC * DEST */
  31911. static readonly ALPHA_MULTIPLY: number;
  31912. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31913. static readonly ALPHA_MAXIMIZED: number;
  31914. /** Defines that alpha blending to SRC + DEST */
  31915. static readonly ALPHA_ONEONE: number;
  31916. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31917. static readonly ALPHA_PREMULTIPLIED: number;
  31918. /**
  31919. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31920. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31921. */
  31922. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31923. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31924. static readonly ALPHA_INTERPOLATE: number;
  31925. /**
  31926. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31927. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31928. */
  31929. static readonly ALPHA_SCREENMODE: number;
  31930. /** Defines that the ressource is not delayed*/
  31931. static readonly DELAYLOADSTATE_NONE: number;
  31932. /** Defines that the ressource was successfully delay loaded */
  31933. static readonly DELAYLOADSTATE_LOADED: number;
  31934. /** Defines that the ressource is currently delay loading */
  31935. static readonly DELAYLOADSTATE_LOADING: number;
  31936. /** Defines that the ressource is delayed and has not started loading */
  31937. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31938. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31939. static readonly NEVER: number;
  31940. /** 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 */
  31941. static readonly ALWAYS: number;
  31942. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31943. static readonly LESS: number;
  31944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31945. static readonly EQUAL: number;
  31946. /** 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 */
  31947. static readonly LEQUAL: number;
  31948. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31949. static readonly GREATER: number;
  31950. /** 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 */
  31951. static readonly GEQUAL: number;
  31952. /** 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 */
  31953. static readonly NOTEQUAL: number;
  31954. /** Passed to stencilOperation to specify that stencil value must be kept */
  31955. static readonly KEEP: number;
  31956. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31957. static readonly REPLACE: number;
  31958. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31959. static readonly INCR: number;
  31960. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31961. static readonly DECR: number;
  31962. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31963. static readonly INVERT: number;
  31964. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31965. static readonly INCR_WRAP: number;
  31966. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31967. static readonly DECR_WRAP: number;
  31968. /** Texture is not repeating outside of 0..1 UVs */
  31969. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31970. /** Texture is repeating outside of 0..1 UVs */
  31971. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31972. /** Texture is repeating and mirrored */
  31973. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31974. /** ALPHA */
  31975. static readonly TEXTUREFORMAT_ALPHA: number;
  31976. /** LUMINANCE */
  31977. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31978. /** LUMINANCE_ALPHA */
  31979. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31980. /** RGB */
  31981. static readonly TEXTUREFORMAT_RGB: number;
  31982. /** RGBA */
  31983. static readonly TEXTUREFORMAT_RGBA: number;
  31984. /** RED */
  31985. static readonly TEXTUREFORMAT_RED: number;
  31986. /** RED (2nd reference) */
  31987. static readonly TEXTUREFORMAT_R: number;
  31988. /** RG */
  31989. static readonly TEXTUREFORMAT_RG: number;
  31990. /** RED_INTEGER */
  31991. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31992. /** RED_INTEGER (2nd reference) */
  31993. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31994. /** RG_INTEGER */
  31995. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31996. /** RGB_INTEGER */
  31997. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31998. /** RGBA_INTEGER */
  31999. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32000. /** UNSIGNED_BYTE */
  32001. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32002. /** UNSIGNED_BYTE (2nd reference) */
  32003. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32004. /** FLOAT */
  32005. static readonly TEXTURETYPE_FLOAT: number;
  32006. /** HALF_FLOAT */
  32007. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32008. /** BYTE */
  32009. static readonly TEXTURETYPE_BYTE: number;
  32010. /** SHORT */
  32011. static readonly TEXTURETYPE_SHORT: number;
  32012. /** UNSIGNED_SHORT */
  32013. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32014. /** INT */
  32015. static readonly TEXTURETYPE_INT: number;
  32016. /** UNSIGNED_INT */
  32017. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32018. /** UNSIGNED_SHORT_4_4_4_4 */
  32019. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32020. /** UNSIGNED_SHORT_5_5_5_1 */
  32021. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32022. /** UNSIGNED_SHORT_5_6_5 */
  32023. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32024. /** UNSIGNED_INT_2_10_10_10_REV */
  32025. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32026. /** UNSIGNED_INT_24_8 */
  32027. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32028. /** UNSIGNED_INT_10F_11F_11F_REV */
  32029. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32030. /** UNSIGNED_INT_5_9_9_9_REV */
  32031. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32032. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32033. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32034. /** nearest is mag = nearest and min = nearest and mip = linear */
  32035. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32036. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32037. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32038. /** Trilinear is mag = linear and min = linear and mip = linear */
  32039. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32040. /** nearest is mag = nearest and min = nearest and mip = linear */
  32041. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32042. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32043. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32044. /** Trilinear is mag = linear and min = linear and mip = linear */
  32045. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32046. /** mag = nearest and min = nearest and mip = nearest */
  32047. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32048. /** mag = nearest and min = linear and mip = nearest */
  32049. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32050. /** mag = nearest and min = linear and mip = linear */
  32051. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32052. /** mag = nearest and min = linear and mip = none */
  32053. static readonly TEXTURE_NEAREST_LINEAR: number;
  32054. /** mag = nearest and min = nearest and mip = none */
  32055. static readonly TEXTURE_NEAREST_NEAREST: number;
  32056. /** mag = linear and min = nearest and mip = nearest */
  32057. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32058. /** mag = linear and min = nearest and mip = linear */
  32059. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32060. /** mag = linear and min = linear and mip = none */
  32061. static readonly TEXTURE_LINEAR_LINEAR: number;
  32062. /** mag = linear and min = nearest and mip = none */
  32063. static readonly TEXTURE_LINEAR_NEAREST: number;
  32064. /** Explicit coordinates mode */
  32065. static readonly TEXTURE_EXPLICIT_MODE: number;
  32066. /** Spherical coordinates mode */
  32067. static readonly TEXTURE_SPHERICAL_MODE: number;
  32068. /** Planar coordinates mode */
  32069. static readonly TEXTURE_PLANAR_MODE: number;
  32070. /** Cubic coordinates mode */
  32071. static readonly TEXTURE_CUBIC_MODE: number;
  32072. /** Projection coordinates mode */
  32073. static readonly TEXTURE_PROJECTION_MODE: number;
  32074. /** Skybox coordinates mode */
  32075. static readonly TEXTURE_SKYBOX_MODE: number;
  32076. /** Inverse Cubic coordinates mode */
  32077. static readonly TEXTURE_INVCUBIC_MODE: number;
  32078. /** Equirectangular coordinates mode */
  32079. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32080. /** Equirectangular Fixed coordinates mode */
  32081. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32082. /** Equirectangular Fixed Mirrored coordinates mode */
  32083. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32084. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32085. static readonly SCALEMODE_FLOOR: number;
  32086. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32087. static readonly SCALEMODE_NEAREST: number;
  32088. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32089. static readonly SCALEMODE_CEILING: number;
  32090. /**
  32091. * Returns the current npm package of the sdk
  32092. */
  32093. static readonly NpmPackage: string;
  32094. /**
  32095. * Returns the current version of the framework
  32096. */
  32097. static readonly Version: string;
  32098. /** Gets the list of created engines */
  32099. static readonly Instances: Engine[];
  32100. /**
  32101. * Gets the latest created engine
  32102. */
  32103. static readonly LastCreatedEngine: Nullable<Engine>;
  32104. /**
  32105. * Gets the latest created scene
  32106. */
  32107. static readonly LastCreatedScene: Nullable<Scene>;
  32108. /**
  32109. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32110. * @param flag defines which part of the materials must be marked as dirty
  32111. * @param predicate defines a predicate used to filter which materials should be affected
  32112. */
  32113. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32114. /**
  32115. * Method called to create the default loading screen.
  32116. * This can be overriden in your own app.
  32117. * @param canvas The rendering canvas element
  32118. * @returns The loading screen
  32119. */
  32120. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32121. /**
  32122. * Method called to create the default rescale post process on each engine.
  32123. */
  32124. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32125. /**
  32126. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32127. **/
  32128. enableOfflineSupport: boolean;
  32129. /**
  32130. * 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)
  32131. **/
  32132. disableManifestCheck: boolean;
  32133. /**
  32134. * Gets the list of created scenes
  32135. */
  32136. scenes: Scene[];
  32137. /**
  32138. * Event raised when a new scene is created
  32139. */
  32140. onNewSceneAddedObservable: Observable<Scene>;
  32141. /**
  32142. * Gets the list of created postprocesses
  32143. */
  32144. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32145. /**
  32146. * Gets a boolean indicating if the pointer is currently locked
  32147. */
  32148. isPointerLock: boolean;
  32149. /**
  32150. * Observable event triggered each time the rendering canvas is resized
  32151. */
  32152. onResizeObservable: Observable<Engine>;
  32153. /**
  32154. * Observable event triggered each time the canvas loses focus
  32155. */
  32156. onCanvasBlurObservable: Observable<Engine>;
  32157. /**
  32158. * Observable event triggered each time the canvas gains focus
  32159. */
  32160. onCanvasFocusObservable: Observable<Engine>;
  32161. /**
  32162. * Observable event triggered each time the canvas receives pointerout event
  32163. */
  32164. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32165. /**
  32166. * Observable event triggered before each texture is initialized
  32167. */
  32168. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32169. /**
  32170. * Observable raised when the engine begins a new frame
  32171. */
  32172. onBeginFrameObservable: Observable<Engine>;
  32173. /**
  32174. * If set, will be used to request the next animation frame for the render loop
  32175. */
  32176. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32177. /**
  32178. * Observable raised when the engine ends the current frame
  32179. */
  32180. onEndFrameObservable: Observable<Engine>;
  32181. /**
  32182. * Observable raised when the engine is about to compile a shader
  32183. */
  32184. onBeforeShaderCompilationObservable: Observable<Engine>;
  32185. /**
  32186. * Observable raised when the engine has jsut compiled a shader
  32187. */
  32188. onAfterShaderCompilationObservable: Observable<Engine>;
  32189. /**
  32190. * Gets the audio engine
  32191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32192. * @ignorenaming
  32193. */
  32194. static audioEngine: IAudioEngine;
  32195. /**
  32196. * Default AudioEngine factory responsible of creating the Audio Engine.
  32197. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32198. */
  32199. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32200. /**
  32201. * Default offline support factory responsible of creating a tool used to store data locally.
  32202. * By default, this will create a Database object if the workload has been embedded.
  32203. */
  32204. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32205. private _loadingScreen;
  32206. private _pointerLockRequested;
  32207. private _dummyFramebuffer;
  32208. private _rescalePostProcess;
  32209. /** @hidden */
  32210. protected _alphaMode: number;
  32211. /** @hidden */
  32212. protected _alphaEquation: number;
  32213. private _deterministicLockstep;
  32214. private _lockstepMaxSteps;
  32215. protected readonly _supportsHardwareTextureRescaling: boolean;
  32216. private _fps;
  32217. private _deltaTime;
  32218. /**
  32219. * Turn this value on if you want to pause FPS computation when in background
  32220. */
  32221. disablePerformanceMonitorInBackground: boolean;
  32222. private _performanceMonitor;
  32223. /**
  32224. * Gets the performance monitor attached to this engine
  32225. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32226. */
  32227. readonly performanceMonitor: PerformanceMonitor;
  32228. private _onFocus;
  32229. private _onBlur;
  32230. private _onCanvasPointerOut;
  32231. private _onCanvasBlur;
  32232. private _onCanvasFocus;
  32233. private _onFullscreenChange;
  32234. private _onPointerLockChange;
  32235. /**
  32236. * Creates a new engine
  32237. * @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
  32238. * @param antialias defines enable antialiasing (default: false)
  32239. * @param options defines further options to be sent to the getContext() function
  32240. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32241. */
  32242. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32243. /**
  32244. * Gets current aspect ratio
  32245. * @param viewportOwner defines the camera to use to get the aspect ratio
  32246. * @param useScreen defines if screen size must be used (or the current render target if any)
  32247. * @returns a number defining the aspect ratio
  32248. */
  32249. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32250. /**
  32251. * Gets current screen aspect ratio
  32252. * @returns a number defining the aspect ratio
  32253. */
  32254. getScreenAspectRatio(): number;
  32255. /**
  32256. * Gets host document
  32257. * @returns the host document object
  32258. */
  32259. getHostDocument(): Document;
  32260. /**
  32261. * Gets the client rect of the HTML canvas attached with the current webGL context
  32262. * @returns a client rectanglee
  32263. */
  32264. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32265. /**
  32266. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32267. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32268. * @returns true if engine is in deterministic lock step mode
  32269. */
  32270. isDeterministicLockStep(): boolean;
  32271. /**
  32272. * Gets the max steps when engine is running in deterministic lock step
  32273. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32274. * @returns the max steps
  32275. */
  32276. getLockstepMaxSteps(): number;
  32277. /**
  32278. * Force the mipmap generation for the given render target texture
  32279. * @param texture defines the render target texture to use
  32280. */
  32281. generateMipMapsForCubemap(texture: InternalTexture): void;
  32282. /** States */
  32283. /**
  32284. * Set various states to the webGL context
  32285. * @param culling defines backface culling state
  32286. * @param zOffset defines the value to apply to zOffset (0 by default)
  32287. * @param force defines if states must be applied even if cache is up to date
  32288. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32289. */
  32290. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32291. /**
  32292. * Set the z offset to apply to current rendering
  32293. * @param value defines the offset to apply
  32294. */
  32295. setZOffset(value: number): void;
  32296. /**
  32297. * Gets the current value of the zOffset
  32298. * @returns the current zOffset state
  32299. */
  32300. getZOffset(): number;
  32301. /**
  32302. * Enable or disable depth buffering
  32303. * @param enable defines the state to set
  32304. */
  32305. setDepthBuffer(enable: boolean): void;
  32306. /**
  32307. * Gets a boolean indicating if depth writing is enabled
  32308. * @returns the current depth writing state
  32309. */
  32310. getDepthWrite(): boolean;
  32311. /**
  32312. * Enable or disable depth writing
  32313. * @param enable defines the state to set
  32314. */
  32315. setDepthWrite(enable: boolean): void;
  32316. /**
  32317. * Enable or disable color writing
  32318. * @param enable defines the state to set
  32319. */
  32320. setColorWrite(enable: boolean): void;
  32321. /**
  32322. * Gets a boolean indicating if color writing is enabled
  32323. * @returns the current color writing state
  32324. */
  32325. getColorWrite(): boolean;
  32326. /**
  32327. * Sets alpha constants used by some alpha blending modes
  32328. * @param r defines the red component
  32329. * @param g defines the green component
  32330. * @param b defines the blue component
  32331. * @param a defines the alpha component
  32332. */
  32333. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32334. /**
  32335. * Sets the current alpha mode
  32336. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32337. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32338. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32339. */
  32340. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32341. /**
  32342. * Gets the current alpha mode
  32343. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32344. * @returns the current alpha mode
  32345. */
  32346. getAlphaMode(): number;
  32347. /**
  32348. * Sets the current alpha equation
  32349. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32350. */
  32351. setAlphaEquation(equation: number): void;
  32352. /**
  32353. * Gets the current alpha equation.
  32354. * @returns the current alpha equation
  32355. */
  32356. getAlphaEquation(): number;
  32357. /**
  32358. * Gets a boolean indicating if stencil buffer is enabled
  32359. * @returns the current stencil buffer state
  32360. */
  32361. getStencilBuffer(): boolean;
  32362. /**
  32363. * Enable or disable the stencil buffer
  32364. * @param enable defines if the stencil buffer must be enabled or disabled
  32365. */
  32366. setStencilBuffer(enable: boolean): void;
  32367. /**
  32368. * Gets the current stencil mask
  32369. * @returns a number defining the new stencil mask to use
  32370. */
  32371. getStencilMask(): number;
  32372. /**
  32373. * Sets the current stencil mask
  32374. * @param mask defines the new stencil mask to use
  32375. */
  32376. setStencilMask(mask: number): void;
  32377. /**
  32378. * Gets the current stencil function
  32379. * @returns a number defining the stencil function to use
  32380. */
  32381. getStencilFunction(): number;
  32382. /**
  32383. * Gets the current stencil reference value
  32384. * @returns a number defining the stencil reference value to use
  32385. */
  32386. getStencilFunctionReference(): number;
  32387. /**
  32388. * Gets the current stencil mask
  32389. * @returns a number defining the stencil mask to use
  32390. */
  32391. getStencilFunctionMask(): number;
  32392. /**
  32393. * Sets the current stencil function
  32394. * @param stencilFunc defines the new stencil function to use
  32395. */
  32396. setStencilFunction(stencilFunc: number): void;
  32397. /**
  32398. * Sets the current stencil reference
  32399. * @param reference defines the new stencil reference to use
  32400. */
  32401. setStencilFunctionReference(reference: number): void;
  32402. /**
  32403. * Sets the current stencil mask
  32404. * @param mask defines the new stencil mask to use
  32405. */
  32406. setStencilFunctionMask(mask: number): void;
  32407. /**
  32408. * Gets the current stencil operation when stencil fails
  32409. * @returns a number defining stencil operation to use when stencil fails
  32410. */
  32411. getStencilOperationFail(): number;
  32412. /**
  32413. * Gets the current stencil operation when depth fails
  32414. * @returns a number defining stencil operation to use when depth fails
  32415. */
  32416. getStencilOperationDepthFail(): number;
  32417. /**
  32418. * Gets the current stencil operation when stencil passes
  32419. * @returns a number defining stencil operation to use when stencil passes
  32420. */
  32421. getStencilOperationPass(): number;
  32422. /**
  32423. * Sets the stencil operation to use when stencil fails
  32424. * @param operation defines the stencil operation to use when stencil fails
  32425. */
  32426. setStencilOperationFail(operation: number): void;
  32427. /**
  32428. * Sets the stencil operation to use when depth fails
  32429. * @param operation defines the stencil operation to use when depth fails
  32430. */
  32431. setStencilOperationDepthFail(operation: number): void;
  32432. /**
  32433. * Sets the stencil operation to use when stencil passes
  32434. * @param operation defines the stencil operation to use when stencil passes
  32435. */
  32436. setStencilOperationPass(operation: number): void;
  32437. /**
  32438. * Sets a boolean indicating if the dithering state is enabled or disabled
  32439. * @param value defines the dithering state
  32440. */
  32441. setDitheringState(value: boolean): void;
  32442. /**
  32443. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32444. * @param value defines the rasterizer state
  32445. */
  32446. setRasterizerState(value: boolean): void;
  32447. /**
  32448. * Gets the current depth function
  32449. * @returns a number defining the depth function
  32450. */
  32451. getDepthFunction(): Nullable<number>;
  32452. /**
  32453. * Sets the current depth function
  32454. * @param depthFunc defines the function to use
  32455. */
  32456. setDepthFunction(depthFunc: number): void;
  32457. /**
  32458. * Sets the current depth function to GREATER
  32459. */
  32460. setDepthFunctionToGreater(): void;
  32461. /**
  32462. * Sets the current depth function to GEQUAL
  32463. */
  32464. setDepthFunctionToGreaterOrEqual(): void;
  32465. /**
  32466. * Sets the current depth function to LESS
  32467. */
  32468. setDepthFunctionToLess(): void;
  32469. /**
  32470. * Sets the current depth function to LEQUAL
  32471. */
  32472. setDepthFunctionToLessOrEqual(): void;
  32473. private _cachedStencilBuffer;
  32474. private _cachedStencilFunction;
  32475. private _cachedStencilMask;
  32476. private _cachedStencilOperationPass;
  32477. private _cachedStencilOperationFail;
  32478. private _cachedStencilOperationDepthFail;
  32479. private _cachedStencilReference;
  32480. /**
  32481. * Caches the the state of the stencil buffer
  32482. */
  32483. cacheStencilState(): void;
  32484. /**
  32485. * Restores the state of the stencil buffer
  32486. */
  32487. restoreStencilState(): void;
  32488. /**
  32489. * Directly set the WebGL Viewport
  32490. * @param x defines the x coordinate of the viewport (in screen space)
  32491. * @param y defines the y coordinate of the viewport (in screen space)
  32492. * @param width defines the width of the viewport (in screen space)
  32493. * @param height defines the height of the viewport (in screen space)
  32494. * @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
  32495. */
  32496. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32497. /**
  32498. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32499. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32500. * @param y defines the y-coordinate of the corner of the clear rectangle
  32501. * @param width defines the width of the clear rectangle
  32502. * @param height defines the height of the clear rectangle
  32503. * @param clearColor defines the clear color
  32504. */
  32505. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32506. /**
  32507. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32508. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32509. * @param y defines the y-coordinate of the corner of the clear rectangle
  32510. * @param width defines the width of the clear rectangle
  32511. * @param height defines the height of the clear rectangle
  32512. */
  32513. enableScissor(x: number, y: number, width: number, height: number): void;
  32514. /**
  32515. * Disable previously set scissor test rectangle
  32516. */
  32517. disableScissor(): void;
  32518. /**
  32519. * Initializes a webVR display and starts listening to display change events
  32520. * The onVRDisplayChangedObservable will be notified upon these changes
  32521. * @returns The onVRDisplayChangedObservable
  32522. */
  32523. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32524. /** @hidden */
  32525. _prepareVRComponent(): void;
  32526. /** @hidden */
  32527. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32528. /** @hidden */
  32529. _submitVRFrame(): void;
  32530. /**
  32531. * Call this function to leave webVR mode
  32532. * Will do nothing if webVR is not supported or if there is no webVR device
  32533. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32534. */
  32535. disableVR(): void;
  32536. /**
  32537. * Gets a boolean indicating that the system is in VR mode and is presenting
  32538. * @returns true if VR mode is engaged
  32539. */
  32540. isVRPresenting(): boolean;
  32541. /** @hidden */
  32542. _requestVRFrame(): void;
  32543. /** @hidden */
  32544. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32545. /**
  32546. * Gets the source code of the vertex shader associated with a specific webGL program
  32547. * @param program defines the program to use
  32548. * @returns a string containing the source code of the vertex shader associated with the program
  32549. */
  32550. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32551. /**
  32552. * Gets the source code of the fragment shader associated with a specific webGL program
  32553. * @param program defines the program to use
  32554. * @returns a string containing the source code of the fragment shader associated with the program
  32555. */
  32556. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32557. /**
  32558. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32559. * @param x defines the x coordinate of the rectangle where pixels must be read
  32560. * @param y defines the y coordinate of the rectangle where pixels must be read
  32561. * @param width defines the width of the rectangle where pixels must be read
  32562. * @param height defines the height of the rectangle where pixels must be read
  32563. * @returns a Uint8Array containing RGBA colors
  32564. */
  32565. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32566. /**
  32567. * Sets a depth stencil texture from a render target to the according uniform.
  32568. * @param channel The texture channel
  32569. * @param uniform The uniform to set
  32570. * @param texture The render target texture containing the depth stencil texture to apply
  32571. */
  32572. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32573. /**
  32574. * Sets a texture to the webGL context from a postprocess
  32575. * @param channel defines the channel to use
  32576. * @param postProcess defines the source postprocess
  32577. */
  32578. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32579. /**
  32580. * Binds the output of the passed in post process to the texture channel specified
  32581. * @param channel The channel the texture should be bound to
  32582. * @param postProcess The post process which's output should be bound
  32583. */
  32584. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32585. /** @hidden */
  32586. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32587. protected _rebuildBuffers(): void;
  32588. _renderLoop(): void;
  32589. /**
  32590. * Toggle full screen mode
  32591. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32592. */
  32593. switchFullscreen(requestPointerLock: boolean): void;
  32594. /**
  32595. * Enters full screen mode
  32596. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32597. */
  32598. enterFullscreen(requestPointerLock: boolean): void;
  32599. /**
  32600. * Exits full screen mode
  32601. */
  32602. exitFullscreen(): void;
  32603. /**
  32604. * Enters Pointerlock mode
  32605. */
  32606. enterPointerlock(): void;
  32607. /**
  32608. * Exits Pointerlock mode
  32609. */
  32610. exitPointerlock(): void;
  32611. /**
  32612. * Begin a new frame
  32613. */
  32614. beginFrame(): void;
  32615. /**
  32616. * Enf the current frame
  32617. */
  32618. endFrame(): void;
  32619. resize(): void;
  32620. /**
  32621. * Set the compressed texture format to use, based on the formats you have, and the formats
  32622. * supported by the hardware / browser.
  32623. *
  32624. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32625. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32626. * to API arguments needed to compressed textures. This puts the burden on the container
  32627. * generator to house the arcane code for determining these for current & future formats.
  32628. *
  32629. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32630. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32631. *
  32632. * Note: The result of this call is not taken into account when a texture is base64.
  32633. *
  32634. * @param formatsAvailable defines the list of those format families you have created
  32635. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32636. *
  32637. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32638. * @returns The extension selected.
  32639. */
  32640. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32641. /**
  32642. * Force a specific size of the canvas
  32643. * @param width defines the new canvas' width
  32644. * @param height defines the new canvas' height
  32645. */
  32646. setSize(width: number, height: number): void;
  32647. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32648. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32649. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32650. _releaseTexture(texture: InternalTexture): void;
  32651. /**
  32652. * @hidden
  32653. * Rescales a texture
  32654. * @param source input texutre
  32655. * @param destination destination texture
  32656. * @param scene scene to use to render the resize
  32657. * @param internalFormat format to use when resizing
  32658. * @param onComplete callback to be called when resize has completed
  32659. */
  32660. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32661. /**
  32662. * Gets the current framerate
  32663. * @returns a number representing the framerate
  32664. */
  32665. getFps(): number;
  32666. /**
  32667. * Gets the time spent between current and previous frame
  32668. * @returns a number representing the delta time in ms
  32669. */
  32670. getDeltaTime(): number;
  32671. private _measureFps;
  32672. /**
  32673. * Creates a new render target texture
  32674. * @param size defines the size of the texture
  32675. * @param options defines the options used to create the texture
  32676. * @returns a new render target texture stored in an InternalTexture
  32677. */
  32678. createRenderTargetTexture(size: number | {
  32679. width: number;
  32680. height: number;
  32681. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32682. /**
  32683. * Updates the sample count of a render target texture
  32684. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32685. * @param texture defines the texture to update
  32686. * @param samples defines the sample count to set
  32687. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32688. */
  32689. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32690. /** @hidden */
  32691. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32692. dispose(): void;
  32693. private _disableTouchAction;
  32694. /**
  32695. * Display the loading screen
  32696. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32697. */
  32698. displayLoadingUI(): void;
  32699. /**
  32700. * Hide the loading screen
  32701. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32702. */
  32703. hideLoadingUI(): void;
  32704. /**
  32705. * Gets the current loading screen object
  32706. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32707. */
  32708. /**
  32709. * Sets the current loading screen object
  32710. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32711. */
  32712. loadingScreen: ILoadingScreen;
  32713. /**
  32714. * Sets the current loading screen text
  32715. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32716. */
  32717. loadingUIText: string;
  32718. /**
  32719. * Sets the current loading screen background color
  32720. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32721. */
  32722. loadingUIBackgroundColor: string;
  32723. /** Pointerlock and fullscreen */
  32724. /**
  32725. * Ask the browser to promote the current element to pointerlock mode
  32726. * @param element defines the DOM element to promote
  32727. */
  32728. static _RequestPointerlock(element: HTMLElement): void;
  32729. /**
  32730. * Asks the browser to exit pointerlock mode
  32731. */
  32732. static _ExitPointerlock(): void;
  32733. /**
  32734. * Ask the browser to promote the current element to fullscreen rendering mode
  32735. * @param element defines the DOM element to promote
  32736. */
  32737. static _RequestFullscreen(element: HTMLElement): void;
  32738. /**
  32739. * Asks the browser to exit fullscreen mode
  32740. */
  32741. static _ExitFullscreen(): void;
  32742. }
  32743. }
  32744. declare module "babylonjs/Engines/engineStore" {
  32745. import { Nullable } from "babylonjs/types";
  32746. import { Engine } from "babylonjs/Engines/engine";
  32747. import { Scene } from "babylonjs/scene";
  32748. /**
  32749. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32750. * during the life time of the application.
  32751. */
  32752. export class EngineStore {
  32753. /** Gets the list of created engines */
  32754. static Instances: import("babylonjs/Engines/engine").Engine[];
  32755. /** @hidden */
  32756. static _LastCreatedScene: Nullable<Scene>;
  32757. /**
  32758. * Gets the latest created engine
  32759. */
  32760. static readonly LastCreatedEngine: Nullable<Engine>;
  32761. /**
  32762. * Gets the latest created scene
  32763. */
  32764. static readonly LastCreatedScene: Nullable<Scene>;
  32765. /**
  32766. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32767. * @ignorenaming
  32768. */
  32769. static UseFallbackTexture: boolean;
  32770. /**
  32771. * Texture content used if a texture cannot loaded
  32772. * @ignorenaming
  32773. */
  32774. static FallbackTexture: string;
  32775. }
  32776. }
  32777. declare module "babylonjs/Misc/promise" {
  32778. /**
  32779. * Helper class that provides a small promise polyfill
  32780. */
  32781. export class PromisePolyfill {
  32782. /**
  32783. * Static function used to check if the polyfill is required
  32784. * If this is the case then the function will inject the polyfill to window.Promise
  32785. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32786. */
  32787. static Apply(force?: boolean): void;
  32788. }
  32789. }
  32790. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32791. /**
  32792. * Interface for screenshot methods with describe argument called `size` as object with options
  32793. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32794. */
  32795. export interface IScreenshotSize {
  32796. /**
  32797. * number in pixels for canvas height
  32798. */
  32799. height?: number;
  32800. /**
  32801. * multiplier allowing render at a higher or lower resolution
  32802. * If value is defined then height and width will be ignored and taken from camera
  32803. */
  32804. precision?: number;
  32805. /**
  32806. * number in pixels for canvas width
  32807. */
  32808. width?: number;
  32809. }
  32810. }
  32811. declare module "babylonjs/Misc/tools" {
  32812. import { Nullable, float } from "babylonjs/types";
  32813. import { DomManagement } from "babylonjs/Misc/domManagement";
  32814. import { WebRequest } from "babylonjs/Misc/webRequest";
  32815. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32816. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32817. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32818. import { Camera } from "babylonjs/Cameras/camera";
  32819. import { Engine } from "babylonjs/Engines/engine";
  32820. interface IColor4Like {
  32821. r: float;
  32822. g: float;
  32823. b: float;
  32824. a: float;
  32825. }
  32826. /**
  32827. * Class containing a set of static utilities functions
  32828. */
  32829. export class Tools {
  32830. /**
  32831. * Gets or sets the base URL to use to load assets
  32832. */
  32833. static BaseUrl: string;
  32834. /**
  32835. * Enable/Disable Custom HTTP Request Headers globally.
  32836. * default = false
  32837. * @see CustomRequestHeaders
  32838. */
  32839. static UseCustomRequestHeaders: boolean;
  32840. /**
  32841. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32842. * i.e. when loading files, where the server/service expects an Authorization header
  32843. */
  32844. static CustomRequestHeaders: {
  32845. [key: string]: string;
  32846. };
  32847. /**
  32848. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32849. */
  32850. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32851. /**
  32852. * Default behaviour for cors in the application.
  32853. * It can be a string if the expected behavior is identical in the entire app.
  32854. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32855. */
  32856. static CorsBehavior: string | ((url: string | string[]) => string);
  32857. /**
  32858. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32859. * @ignorenaming
  32860. */
  32861. static UseFallbackTexture: boolean;
  32862. /**
  32863. * Use this object to register external classes like custom textures or material
  32864. * to allow the laoders to instantiate them
  32865. */
  32866. static RegisteredExternalClasses: {
  32867. [key: string]: Object;
  32868. };
  32869. /**
  32870. * Texture content used if a texture cannot loaded
  32871. * @ignorenaming
  32872. */
  32873. static fallbackTexture: string;
  32874. /**
  32875. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32876. * @param u defines the coordinate on X axis
  32877. * @param v defines the coordinate on Y axis
  32878. * @param width defines the width of the source data
  32879. * @param height defines the height of the source data
  32880. * @param pixels defines the source byte array
  32881. * @param color defines the output color
  32882. */
  32883. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32884. /**
  32885. * Interpolates between a and b via alpha
  32886. * @param a The lower value (returned when alpha = 0)
  32887. * @param b The upper value (returned when alpha = 1)
  32888. * @param alpha The interpolation-factor
  32889. * @return The mixed value
  32890. */
  32891. static Mix(a: number, b: number, alpha: number): number;
  32892. /**
  32893. * Tries to instantiate a new object from a given class name
  32894. * @param className defines the class name to instantiate
  32895. * @returns the new object or null if the system was not able to do the instantiation
  32896. */
  32897. static Instantiate(className: string): any;
  32898. /**
  32899. * Provides a slice function that will work even on IE
  32900. * @param data defines the array to slice
  32901. * @param start defines the start of the data (optional)
  32902. * @param end defines the end of the data (optional)
  32903. * @returns the new sliced array
  32904. */
  32905. static Slice<T>(data: T, start?: number, end?: number): T;
  32906. /**
  32907. * Polyfill for setImmediate
  32908. * @param action defines the action to execute after the current execution block
  32909. */
  32910. static SetImmediate(action: () => void): void;
  32911. /**
  32912. * Function indicating if a number is an exponent of 2
  32913. * @param value defines the value to test
  32914. * @returns true if the value is an exponent of 2
  32915. */
  32916. static IsExponentOfTwo(value: number): boolean;
  32917. private static _tmpFloatArray;
  32918. /**
  32919. * Returns the nearest 32-bit single precision float representation of a Number
  32920. * @param value A Number. If the parameter is of a different type, it will get converted
  32921. * to a number or to NaN if it cannot be converted
  32922. * @returns number
  32923. */
  32924. static FloatRound(value: number): number;
  32925. /**
  32926. * Extracts the filename from a path
  32927. * @param path defines the path to use
  32928. * @returns the filename
  32929. */
  32930. static GetFilename(path: string): string;
  32931. /**
  32932. * Extracts the "folder" part of a path (everything before the filename).
  32933. * @param uri The URI to extract the info from
  32934. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32935. * @returns The "folder" part of the path
  32936. */
  32937. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32938. /**
  32939. * Extracts text content from a DOM element hierarchy
  32940. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32941. */
  32942. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32943. /**
  32944. * Convert an angle in radians to degrees
  32945. * @param angle defines the angle to convert
  32946. * @returns the angle in degrees
  32947. */
  32948. static ToDegrees(angle: number): number;
  32949. /**
  32950. * Convert an angle in degrees to radians
  32951. * @param angle defines the angle to convert
  32952. * @returns the angle in radians
  32953. */
  32954. static ToRadians(angle: number): number;
  32955. /**
  32956. * Encode a buffer to a base64 string
  32957. * @param buffer defines the buffer to encode
  32958. * @returns the encoded string
  32959. */
  32960. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32961. /**
  32962. * Returns an array if obj is not an array
  32963. * @param obj defines the object to evaluate as an array
  32964. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32965. * @returns either obj directly if obj is an array or a new array containing obj
  32966. */
  32967. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32968. /**
  32969. * Gets the pointer prefix to use
  32970. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32971. */
  32972. static GetPointerPrefix(): string;
  32973. /**
  32974. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32975. * @param url define the url we are trying
  32976. * @param element define the dom element where to configure the cors policy
  32977. */
  32978. static SetCorsBehavior(url: string | string[], element: {
  32979. crossOrigin: string | null;
  32980. }): void;
  32981. /**
  32982. * Removes unwanted characters from an url
  32983. * @param url defines the url to clean
  32984. * @returns the cleaned url
  32985. */
  32986. static CleanUrl(url: string): string;
  32987. /**
  32988. * Gets or sets a function used to pre-process url before using them to load assets
  32989. */
  32990. static PreprocessUrl: (url: string) => string;
  32991. /**
  32992. * Loads an image as an HTMLImageElement.
  32993. * @param input url string, ArrayBuffer, or Blob to load
  32994. * @param onLoad callback called when the image successfully loads
  32995. * @param onError callback called when the image fails to load
  32996. * @param offlineProvider offline provider for caching
  32997. * @returns the HTMLImageElement of the loaded image
  32998. */
  32999. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  33000. /**
  33001. * Loads a file
  33002. * @param url url string, ArrayBuffer, or Blob to load
  33003. * @param onSuccess callback called when the file successfully loads
  33004. * @param onProgress callback called while file is loading (if the server supports this mode)
  33005. * @param offlineProvider defines the offline provider for caching
  33006. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33007. * @param onError callback called when the file fails to load
  33008. * @returns a file request object
  33009. */
  33010. 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;
  33011. /**
  33012. * Loads a file from a url
  33013. * @param url the file url to load
  33014. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33015. */
  33016. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33017. /**
  33018. * Load a script (identified by an url). When the url returns, the
  33019. * content of this file is added into a new script element, attached to the DOM (body element)
  33020. * @param scriptUrl defines the url of the script to laod
  33021. * @param onSuccess defines the callback called when the script is loaded
  33022. * @param onError defines the callback to call if an error occurs
  33023. * @param scriptId defines the id of the script element
  33024. */
  33025. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33026. /**
  33027. * Load an asynchronous script (identified by an url). When the url returns, the
  33028. * content of this file is added into a new script element, attached to the DOM (body element)
  33029. * @param scriptUrl defines the url of the script to laod
  33030. * @param scriptId defines the id of the script element
  33031. * @returns a promise request object
  33032. */
  33033. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33034. /**
  33035. * Loads a file from a blob
  33036. * @param fileToLoad defines the blob to use
  33037. * @param callback defines the callback to call when data is loaded
  33038. * @param progressCallback defines the callback to call during loading process
  33039. * @returns a file request object
  33040. */
  33041. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33042. /**
  33043. * Loads a file
  33044. * @param fileToLoad defines the file to load
  33045. * @param callback defines the callback to call when data is loaded
  33046. * @param progressCallBack defines the callback to call during loading process
  33047. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33048. * @returns a file request object
  33049. */
  33050. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33051. /**
  33052. * Creates a data url from a given string content
  33053. * @param content defines the content to convert
  33054. * @returns the new data url link
  33055. */
  33056. static FileAsURL(content: string): string;
  33057. /**
  33058. * Format the given number to a specific decimal format
  33059. * @param value defines the number to format
  33060. * @param decimals defines the number of decimals to use
  33061. * @returns the formatted string
  33062. */
  33063. static Format(value: number, decimals?: number): string;
  33064. /**
  33065. * Tries to copy an object by duplicating every property
  33066. * @param source defines the source object
  33067. * @param destination defines the target object
  33068. * @param doNotCopyList defines a list of properties to avoid
  33069. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33070. */
  33071. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33072. /**
  33073. * Gets a boolean indicating if the given object has no own property
  33074. * @param obj defines the object to test
  33075. * @returns true if object has no own property
  33076. */
  33077. static IsEmpty(obj: any): boolean;
  33078. /**
  33079. * Function used to register events at window level
  33080. * @param windowElement defines the Window object to use
  33081. * @param events defines the events to register
  33082. */
  33083. static RegisterTopRootEvents(windowElement: Window, events: {
  33084. name: string;
  33085. handler: Nullable<(e: FocusEvent) => any>;
  33086. }[]): void;
  33087. /**
  33088. * Function used to unregister events from window level
  33089. * @param windowElement defines the Window object to use
  33090. * @param events defines the events to unregister
  33091. */
  33092. static UnregisterTopRootEvents(windowElement: Window, events: {
  33093. name: string;
  33094. handler: Nullable<(e: FocusEvent) => any>;
  33095. }[]): void;
  33096. /**
  33097. * @ignore
  33098. */
  33099. static _ScreenshotCanvas: HTMLCanvasElement;
  33100. /**
  33101. * Dumps the current bound framebuffer
  33102. * @param width defines the rendering width
  33103. * @param height defines the rendering height
  33104. * @param engine defines the hosting engine
  33105. * @param successCallback defines the callback triggered once the data are available
  33106. * @param mimeType defines the mime type of the result
  33107. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33108. */
  33109. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33110. /**
  33111. * Converts the canvas data to blob.
  33112. * This acts as a polyfill for browsers not supporting the to blob function.
  33113. * @param canvas Defines the canvas to extract the data from
  33114. * @param successCallback Defines the callback triggered once the data are available
  33115. * @param mimeType Defines the mime type of the result
  33116. */
  33117. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33118. /**
  33119. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33120. * @param successCallback defines the callback triggered once the data are available
  33121. * @param mimeType defines the mime type of the result
  33122. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33123. */
  33124. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33125. /**
  33126. * Downloads a blob in the browser
  33127. * @param blob defines the blob to download
  33128. * @param fileName defines the name of the downloaded file
  33129. */
  33130. static Download(blob: Blob, fileName: string): void;
  33131. /**
  33132. * Captures a screenshot of the current rendering
  33133. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33134. * @param engine defines the rendering engine
  33135. * @param camera defines the source camera
  33136. * @param size This parameter can be set to a single number or to an object with the
  33137. * following (optional) properties: precision, width, height. If a single number is passed,
  33138. * it will be used for both width and height. If an object is passed, the screenshot size
  33139. * will be derived from the parameters. The precision property is a multiplier allowing
  33140. * rendering at a higher or lower resolution
  33141. * @param successCallback defines the callback receives a single parameter which contains the
  33142. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33143. * src parameter of an <img> to display it
  33144. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33145. * Check your browser for supported MIME types
  33146. */
  33147. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33148. /**
  33149. * Captures a screenshot of the current rendering
  33150. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33151. * @param engine defines the rendering engine
  33152. * @param camera defines the source camera
  33153. * @param size This parameter can be set to a single number or to an object with the
  33154. * following (optional) properties: precision, width, height. If a single number is passed,
  33155. * it will be used for both width and height. If an object is passed, the screenshot size
  33156. * will be derived from the parameters. The precision property is a multiplier allowing
  33157. * rendering at a higher or lower resolution
  33158. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33159. * Check your browser for supported MIME types
  33160. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33161. * to the src parameter of an <img> to display it
  33162. */
  33163. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33164. /**
  33165. * Generates an image screenshot from the specified camera.
  33166. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33167. * @param engine The engine to use for rendering
  33168. * @param camera The camera to use for rendering
  33169. * @param size This parameter can be set to a single number or to an object with the
  33170. * following (optional) properties: precision, width, height. If a single number is passed,
  33171. * it will be used for both width and height. If an object is passed, the screenshot size
  33172. * will be derived from the parameters. The precision property is a multiplier allowing
  33173. * rendering at a higher or lower resolution
  33174. * @param successCallback The callback receives a single parameter which contains the
  33175. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33176. * src parameter of an <img> to display it
  33177. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33178. * Check your browser for supported MIME types
  33179. * @param samples Texture samples (default: 1)
  33180. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33181. * @param fileName A name for for the downloaded file.
  33182. */
  33183. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33184. /**
  33185. * Generates an image screenshot from the specified camera.
  33186. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33187. * @param engine The engine to use for rendering
  33188. * @param camera The camera to use for rendering
  33189. * @param size This parameter can be set to a single number or to an object with the
  33190. * following (optional) properties: precision, width, height. If a single number is passed,
  33191. * it will be used for both width and height. If an object is passed, the screenshot size
  33192. * will be derived from the parameters. The precision property is a multiplier allowing
  33193. * rendering at a higher or lower resolution
  33194. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33195. * Check your browser for supported MIME types
  33196. * @param samples Texture samples (default: 1)
  33197. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33198. * @param fileName A name for for the downloaded file.
  33199. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33200. * to the src parameter of an <img> to display it
  33201. */
  33202. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33203. /**
  33204. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33205. * Be aware Math.random() could cause collisions, but:
  33206. * "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"
  33207. * @returns a pseudo random id
  33208. */
  33209. static RandomId(): string;
  33210. /**
  33211. * Test if the given uri is a base64 string
  33212. * @param uri The uri to test
  33213. * @return True if the uri is a base64 string or false otherwise
  33214. */
  33215. static IsBase64(uri: string): boolean;
  33216. /**
  33217. * Decode the given base64 uri.
  33218. * @param uri The uri to decode
  33219. * @return The decoded base64 data.
  33220. */
  33221. static DecodeBase64(uri: string): ArrayBuffer;
  33222. /**
  33223. * Gets the absolute url.
  33224. * @param url the input url
  33225. * @return the absolute url
  33226. */
  33227. static GetAbsoluteUrl(url: string): string;
  33228. /**
  33229. * No log
  33230. */
  33231. static readonly NoneLogLevel: number;
  33232. /**
  33233. * Only message logs
  33234. */
  33235. static readonly MessageLogLevel: number;
  33236. /**
  33237. * Only warning logs
  33238. */
  33239. static readonly WarningLogLevel: number;
  33240. /**
  33241. * Only error logs
  33242. */
  33243. static readonly ErrorLogLevel: number;
  33244. /**
  33245. * All logs
  33246. */
  33247. static readonly AllLogLevel: number;
  33248. /**
  33249. * Gets a value indicating the number of loading errors
  33250. * @ignorenaming
  33251. */
  33252. static readonly errorsCount: number;
  33253. /**
  33254. * Callback called when a new log is added
  33255. */
  33256. static OnNewCacheEntry: (entry: string) => void;
  33257. /**
  33258. * Log a message to the console
  33259. * @param message defines the message to log
  33260. */
  33261. static Log(message: string): void;
  33262. /**
  33263. * Write a warning message to the console
  33264. * @param message defines the message to log
  33265. */
  33266. static Warn(message: string): void;
  33267. /**
  33268. * Write an error message to the console
  33269. * @param message defines the message to log
  33270. */
  33271. static Error(message: string): void;
  33272. /**
  33273. * Gets current log cache (list of logs)
  33274. */
  33275. static readonly LogCache: string;
  33276. /**
  33277. * Clears the log cache
  33278. */
  33279. static ClearLogCache(): void;
  33280. /**
  33281. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33282. */
  33283. static LogLevels: number;
  33284. /**
  33285. * Checks if the window object exists
  33286. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33287. */
  33288. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33289. /**
  33290. * No performance log
  33291. */
  33292. static readonly PerformanceNoneLogLevel: number;
  33293. /**
  33294. * Use user marks to log performance
  33295. */
  33296. static readonly PerformanceUserMarkLogLevel: number;
  33297. /**
  33298. * Log performance to the console
  33299. */
  33300. static readonly PerformanceConsoleLogLevel: number;
  33301. private static _performance;
  33302. /**
  33303. * Sets the current performance log level
  33304. */
  33305. static PerformanceLogLevel: number;
  33306. private static _StartPerformanceCounterDisabled;
  33307. private static _EndPerformanceCounterDisabled;
  33308. private static _StartUserMark;
  33309. private static _EndUserMark;
  33310. private static _StartPerformanceConsole;
  33311. private static _EndPerformanceConsole;
  33312. /**
  33313. * Starts a performance counter
  33314. */
  33315. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33316. /**
  33317. * Ends a specific performance coutner
  33318. */
  33319. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33320. /**
  33321. * Gets either window.performance.now() if supported or Date.now() else
  33322. */
  33323. static readonly Now: number;
  33324. /**
  33325. * This method will return the name of the class used to create the instance of the given object.
  33326. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33327. * @param object the object to get the class name from
  33328. * @param isType defines if the object is actually a type
  33329. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33330. */
  33331. static GetClassName(object: any, isType?: boolean): string;
  33332. /**
  33333. * Gets the first element of an array satisfying a given predicate
  33334. * @param array defines the array to browse
  33335. * @param predicate defines the predicate to use
  33336. * @returns null if not found or the element
  33337. */
  33338. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33339. /**
  33340. * This method will return the name of the full name of the class, including its owning module (if any).
  33341. * 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).
  33342. * @param object the object to get the class name from
  33343. * @param isType defines if the object is actually a type
  33344. * @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.
  33345. * @ignorenaming
  33346. */
  33347. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33348. /**
  33349. * Returns a promise that resolves after the given amount of time.
  33350. * @param delay Number of milliseconds to delay
  33351. * @returns Promise that resolves after the given amount of time
  33352. */
  33353. static DelayAsync(delay: number): Promise<void>;
  33354. }
  33355. /**
  33356. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33357. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33358. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33359. * @param name The name of the class, case should be preserved
  33360. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33361. */
  33362. export function className(name: string, module?: string): (target: Object) => void;
  33363. /**
  33364. * An implementation of a loop for asynchronous functions.
  33365. */
  33366. export class AsyncLoop {
  33367. /**
  33368. * Defines the number of iterations for the loop
  33369. */
  33370. iterations: number;
  33371. /**
  33372. * Defines the current index of the loop.
  33373. */
  33374. index: number;
  33375. private _done;
  33376. private _fn;
  33377. private _successCallback;
  33378. /**
  33379. * Constructor.
  33380. * @param iterations the number of iterations.
  33381. * @param func the function to run each iteration
  33382. * @param successCallback the callback that will be called upon succesful execution
  33383. * @param offset starting offset.
  33384. */
  33385. constructor(
  33386. /**
  33387. * Defines the number of iterations for the loop
  33388. */
  33389. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33390. /**
  33391. * Execute the next iteration. Must be called after the last iteration was finished.
  33392. */
  33393. executeNext(): void;
  33394. /**
  33395. * Break the loop and run the success callback.
  33396. */
  33397. breakLoop(): void;
  33398. /**
  33399. * Create and run an async loop.
  33400. * @param iterations the number of iterations.
  33401. * @param fn the function to run each iteration
  33402. * @param successCallback the callback that will be called upon succesful execution
  33403. * @param offset starting offset.
  33404. * @returns the created async loop object
  33405. */
  33406. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33407. /**
  33408. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33409. * @param iterations total number of iterations
  33410. * @param syncedIterations number of synchronous iterations in each async iteration.
  33411. * @param fn the function to call each iteration.
  33412. * @param callback a success call back that will be called when iterating stops.
  33413. * @param breakFunction a break condition (optional)
  33414. * @param timeout timeout settings for the setTimeout function. default - 0.
  33415. * @returns the created async loop object
  33416. */
  33417. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33418. }
  33419. }
  33420. declare module "babylonjs/Misc/stringDictionary" {
  33421. import { Nullable } from "babylonjs/types";
  33422. /**
  33423. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33424. * The underlying implementation relies on an associative array to ensure the best performances.
  33425. * The value can be anything including 'null' but except 'undefined'
  33426. */
  33427. export class StringDictionary<T> {
  33428. /**
  33429. * This will clear this dictionary and copy the content from the 'source' one.
  33430. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33431. * @param source the dictionary to take the content from and copy to this dictionary
  33432. */
  33433. copyFrom(source: StringDictionary<T>): void;
  33434. /**
  33435. * Get a value based from its key
  33436. * @param key the given key to get the matching value from
  33437. * @return the value if found, otherwise undefined is returned
  33438. */
  33439. get(key: string): T | undefined;
  33440. /**
  33441. * Get a value from its key or add it if it doesn't exist.
  33442. * This method will ensure you that a given key/data will be present in the dictionary.
  33443. * @param key the given key to get the matching value from
  33444. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33445. * The factory will only be invoked if there's no data for the given key.
  33446. * @return the value corresponding to the key.
  33447. */
  33448. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33449. /**
  33450. * Get a value from its key if present in the dictionary otherwise add it
  33451. * @param key the key to get the value from
  33452. * @param val if there's no such key/value pair in the dictionary add it with this value
  33453. * @return the value corresponding to the key
  33454. */
  33455. getOrAdd(key: string, val: T): T;
  33456. /**
  33457. * Check if there's a given key in the dictionary
  33458. * @param key the key to check for
  33459. * @return true if the key is present, false otherwise
  33460. */
  33461. contains(key: string): boolean;
  33462. /**
  33463. * Add a new key and its corresponding value
  33464. * @param key the key to add
  33465. * @param value the value corresponding to the key
  33466. * @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
  33467. */
  33468. add(key: string, value: T): boolean;
  33469. /**
  33470. * Update a specific value associated to a key
  33471. * @param key defines the key to use
  33472. * @param value defines the value to store
  33473. * @returns true if the value was updated (or false if the key was not found)
  33474. */
  33475. set(key: string, value: T): boolean;
  33476. /**
  33477. * Get the element of the given key and remove it from the dictionary
  33478. * @param key defines the key to search
  33479. * @returns the value associated with the key or null if not found
  33480. */
  33481. getAndRemove(key: string): Nullable<T>;
  33482. /**
  33483. * Remove a key/value from the dictionary.
  33484. * @param key the key to remove
  33485. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33486. */
  33487. remove(key: string): boolean;
  33488. /**
  33489. * Clear the whole content of the dictionary
  33490. */
  33491. clear(): void;
  33492. /**
  33493. * Gets the current count
  33494. */
  33495. readonly count: number;
  33496. /**
  33497. * Execute a callback on each key/val of the dictionary.
  33498. * Note that you can remove any element in this dictionary in the callback implementation
  33499. * @param callback the callback to execute on a given key/value pair
  33500. */
  33501. forEach(callback: (key: string, val: T) => void): void;
  33502. /**
  33503. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33504. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33505. * Note that you can remove any element in this dictionary in the callback implementation
  33506. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33507. * @returns the first item
  33508. */
  33509. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33510. private _count;
  33511. private _data;
  33512. }
  33513. }
  33514. declare module "babylonjs/Collisions/collisionCoordinator" {
  33515. import { Nullable } from "babylonjs/types";
  33516. import { Scene } from "babylonjs/scene";
  33517. import { Vector3 } from "babylonjs/Maths/math.vector";
  33518. import { Collider } from "babylonjs/Collisions/collider";
  33519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33520. /** @hidden */
  33521. export interface ICollisionCoordinator {
  33522. createCollider(): Collider;
  33523. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33524. init(scene: Scene): void;
  33525. }
  33526. /** @hidden */
  33527. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33528. private _scene;
  33529. private _scaledPosition;
  33530. private _scaledVelocity;
  33531. private _finalPosition;
  33532. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33533. createCollider(): Collider;
  33534. init(scene: Scene): void;
  33535. private _collideWithWorld;
  33536. }
  33537. }
  33538. declare module "babylonjs/Inputs/scene.inputManager" {
  33539. import { Nullable } from "babylonjs/types";
  33540. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33541. import { Vector2 } from "babylonjs/Maths/math.vector";
  33542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33543. import { Scene } from "babylonjs/scene";
  33544. /**
  33545. * Class used to manage all inputs for the scene.
  33546. */
  33547. export class InputManager {
  33548. /** The distance in pixel that you have to move to prevent some events */
  33549. static DragMovementThreshold: number;
  33550. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33551. static LongPressDelay: number;
  33552. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33553. static DoubleClickDelay: number;
  33554. /** If you need to check double click without raising a single click at first click, enable this flag */
  33555. static ExclusiveDoubleClickMode: boolean;
  33556. private _wheelEventName;
  33557. private _onPointerMove;
  33558. private _onPointerDown;
  33559. private _onPointerUp;
  33560. private _initClickEvent;
  33561. private _initActionManager;
  33562. private _delayedSimpleClick;
  33563. private _delayedSimpleClickTimeout;
  33564. private _previousDelayedSimpleClickTimeout;
  33565. private _meshPickProceed;
  33566. private _previousButtonPressed;
  33567. private _currentPickResult;
  33568. private _previousPickResult;
  33569. private _totalPointersPressed;
  33570. private _doubleClickOccured;
  33571. private _pointerOverMesh;
  33572. private _pickedDownMesh;
  33573. private _pickedUpMesh;
  33574. private _pointerX;
  33575. private _pointerY;
  33576. private _unTranslatedPointerX;
  33577. private _unTranslatedPointerY;
  33578. private _startingPointerPosition;
  33579. private _previousStartingPointerPosition;
  33580. private _startingPointerTime;
  33581. private _previousStartingPointerTime;
  33582. private _pointerCaptures;
  33583. private _onKeyDown;
  33584. private _onKeyUp;
  33585. private _onCanvasFocusObserver;
  33586. private _onCanvasBlurObserver;
  33587. private _scene;
  33588. /**
  33589. * Creates a new InputManager
  33590. * @param scene defines the hosting scene
  33591. */
  33592. constructor(scene: Scene);
  33593. /**
  33594. * Gets the mesh that is currently under the pointer
  33595. */
  33596. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33597. /**
  33598. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33599. */
  33600. readonly unTranslatedPointer: Vector2;
  33601. /**
  33602. * Gets or sets the current on-screen X position of the pointer
  33603. */
  33604. pointerX: number;
  33605. /**
  33606. * Gets or sets the current on-screen Y position of the pointer
  33607. */
  33608. pointerY: number;
  33609. private _updatePointerPosition;
  33610. private _processPointerMove;
  33611. private _setRayOnPointerInfo;
  33612. private _checkPrePointerObservable;
  33613. /**
  33614. * Use this method to simulate a pointer move on a mesh
  33615. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33616. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33617. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33618. */
  33619. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33620. /**
  33621. * Use this method to simulate a pointer down on a mesh
  33622. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33623. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33624. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33625. */
  33626. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33627. private _processPointerDown;
  33628. /** @hidden */
  33629. _isPointerSwiping(): boolean;
  33630. /**
  33631. * Use this method to simulate a pointer up on a mesh
  33632. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33633. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33634. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33635. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33636. */
  33637. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33638. private _processPointerUp;
  33639. /**
  33640. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33641. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33642. * @returns true if the pointer was captured
  33643. */
  33644. isPointerCaptured(pointerId?: number): boolean;
  33645. /**
  33646. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33647. * @param attachUp defines if you want to attach events to pointerup
  33648. * @param attachDown defines if you want to attach events to pointerdown
  33649. * @param attachMove defines if you want to attach events to pointermove
  33650. */
  33651. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33652. /**
  33653. * Detaches all event handlers
  33654. */
  33655. detachControl(): void;
  33656. /**
  33657. * Force the value of meshUnderPointer
  33658. * @param mesh defines the mesh to use
  33659. */
  33660. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33661. /**
  33662. * Gets the mesh under the pointer
  33663. * @returns a Mesh or null if no mesh is under the pointer
  33664. */
  33665. getPointerOverMesh(): Nullable<AbstractMesh>;
  33666. }
  33667. }
  33668. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33669. /**
  33670. * Helper class used to generate session unique ID
  33671. */
  33672. export class UniqueIdGenerator {
  33673. private static _UniqueIdCounter;
  33674. /**
  33675. * Gets an unique (relatively to the current scene) Id
  33676. */
  33677. static readonly UniqueId: number;
  33678. }
  33679. }
  33680. declare module "babylonjs/Animations/animationGroup" {
  33681. import { Animatable } from "babylonjs/Animations/animatable";
  33682. import { Animation } from "babylonjs/Animations/animation";
  33683. import { Scene, IDisposable } from "babylonjs/scene";
  33684. import { Observable } from "babylonjs/Misc/observable";
  33685. import { Nullable } from "babylonjs/types";
  33686. import "babylonjs/Animations/animatable";
  33687. /**
  33688. * This class defines the direct association between an animation and a target
  33689. */
  33690. export class TargetedAnimation {
  33691. /**
  33692. * Animation to perform
  33693. */
  33694. animation: Animation;
  33695. /**
  33696. * Target to animate
  33697. */
  33698. target: any;
  33699. /**
  33700. * Serialize the object
  33701. * @returns the JSON object representing the current entity
  33702. */
  33703. serialize(): any;
  33704. }
  33705. /**
  33706. * Use this class to create coordinated animations on multiple targets
  33707. */
  33708. export class AnimationGroup implements IDisposable {
  33709. /** The name of the animation group */
  33710. name: string;
  33711. private _scene;
  33712. private _targetedAnimations;
  33713. private _animatables;
  33714. private _from;
  33715. private _to;
  33716. private _isStarted;
  33717. private _isPaused;
  33718. private _speedRatio;
  33719. private _loopAnimation;
  33720. /**
  33721. * Gets or sets the unique id of the node
  33722. */
  33723. uniqueId: number;
  33724. /**
  33725. * This observable will notify when one animation have ended
  33726. */
  33727. onAnimationEndObservable: Observable<TargetedAnimation>;
  33728. /**
  33729. * Observer raised when one animation loops
  33730. */
  33731. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33732. /**
  33733. * This observable will notify when all animations have ended.
  33734. */
  33735. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33736. /**
  33737. * This observable will notify when all animations have paused.
  33738. */
  33739. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33740. /**
  33741. * This observable will notify when all animations are playing.
  33742. */
  33743. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33744. /**
  33745. * Gets the first frame
  33746. */
  33747. readonly from: number;
  33748. /**
  33749. * Gets the last frame
  33750. */
  33751. readonly to: number;
  33752. /**
  33753. * Define if the animations are started
  33754. */
  33755. readonly isStarted: boolean;
  33756. /**
  33757. * Gets a value indicating that the current group is playing
  33758. */
  33759. readonly isPlaying: boolean;
  33760. /**
  33761. * Gets or sets the speed ratio to use for all animations
  33762. */
  33763. /**
  33764. * Gets or sets the speed ratio to use for all animations
  33765. */
  33766. speedRatio: number;
  33767. /**
  33768. * Gets or sets if all animations should loop or not
  33769. */
  33770. loopAnimation: boolean;
  33771. /**
  33772. * Gets the targeted animations for this animation group
  33773. */
  33774. readonly targetedAnimations: Array<TargetedAnimation>;
  33775. /**
  33776. * returning the list of animatables controlled by this animation group.
  33777. */
  33778. readonly animatables: Array<Animatable>;
  33779. /**
  33780. * Instantiates a new Animation Group.
  33781. * This helps managing several animations at once.
  33782. * @see http://doc.babylonjs.com/how_to/group
  33783. * @param name Defines the name of the group
  33784. * @param scene Defines the scene the group belongs to
  33785. */
  33786. constructor(
  33787. /** The name of the animation group */
  33788. name: string, scene?: Nullable<Scene>);
  33789. /**
  33790. * Add an animation (with its target) in the group
  33791. * @param animation defines the animation we want to add
  33792. * @param target defines the target of the animation
  33793. * @returns the TargetedAnimation object
  33794. */
  33795. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33796. /**
  33797. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33798. * It can add constant keys at begin or end
  33799. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33800. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33801. * @returns the animation group
  33802. */
  33803. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33804. /**
  33805. * Start all animations on given targets
  33806. * @param loop defines if animations must loop
  33807. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33808. * @param from defines the from key (optional)
  33809. * @param to defines the to key (optional)
  33810. * @returns the current animation group
  33811. */
  33812. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33813. /**
  33814. * Pause all animations
  33815. * @returns the animation group
  33816. */
  33817. pause(): AnimationGroup;
  33818. /**
  33819. * Play all animations to initial state
  33820. * This function will start() the animations if they were not started or will restart() them if they were paused
  33821. * @param loop defines if animations must loop
  33822. * @returns the animation group
  33823. */
  33824. play(loop?: boolean): AnimationGroup;
  33825. /**
  33826. * Reset all animations to initial state
  33827. * @returns the animation group
  33828. */
  33829. reset(): AnimationGroup;
  33830. /**
  33831. * Restart animations from key 0
  33832. * @returns the animation group
  33833. */
  33834. restart(): AnimationGroup;
  33835. /**
  33836. * Stop all animations
  33837. * @returns the animation group
  33838. */
  33839. stop(): AnimationGroup;
  33840. /**
  33841. * Set animation weight for all animatables
  33842. * @param weight defines the weight to use
  33843. * @return the animationGroup
  33844. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33845. */
  33846. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33847. /**
  33848. * Synchronize and normalize all animatables with a source animatable
  33849. * @param root defines the root animatable to synchronize with
  33850. * @return the animationGroup
  33851. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33852. */
  33853. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33854. /**
  33855. * Goes to a specific frame in this animation group
  33856. * @param frame the frame number to go to
  33857. * @return the animationGroup
  33858. */
  33859. goToFrame(frame: number): AnimationGroup;
  33860. /**
  33861. * Dispose all associated resources
  33862. */
  33863. dispose(): void;
  33864. private _checkAnimationGroupEnded;
  33865. /**
  33866. * Clone the current animation group and returns a copy
  33867. * @param newName defines the name of the new group
  33868. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33869. * @returns the new aniamtion group
  33870. */
  33871. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33872. /**
  33873. * Serializes the animationGroup to an object
  33874. * @returns Serialized object
  33875. */
  33876. serialize(): any;
  33877. /**
  33878. * Returns a new AnimationGroup object parsed from the source provided.
  33879. * @param parsedAnimationGroup defines the source
  33880. * @param scene defines the scene that will receive the animationGroup
  33881. * @returns a new AnimationGroup
  33882. */
  33883. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33884. /**
  33885. * Returns the string "AnimationGroup"
  33886. * @returns "AnimationGroup"
  33887. */
  33888. getClassName(): string;
  33889. /**
  33890. * Creates a detailled string about the object
  33891. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33892. * @returns a string representing the object
  33893. */
  33894. toString(fullDetails?: boolean): string;
  33895. }
  33896. }
  33897. declare module "babylonjs/scene" {
  33898. import { Nullable } from "babylonjs/types";
  33899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33900. import { Observable } from "babylonjs/Misc/observable";
  33901. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33902. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33903. import { Geometry } from "babylonjs/Meshes/geometry";
  33904. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33907. import { Mesh } from "babylonjs/Meshes/mesh";
  33908. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33909. import { Bone } from "babylonjs/Bones/bone";
  33910. import { Skeleton } from "babylonjs/Bones/skeleton";
  33911. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33912. import { Camera } from "babylonjs/Cameras/camera";
  33913. import { AbstractScene } from "babylonjs/abstractScene";
  33914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33915. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33916. import { Material } from "babylonjs/Materials/material";
  33917. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33918. import { Effect } from "babylonjs/Materials/effect";
  33919. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33920. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33921. import { Light } from "babylonjs/Lights/light";
  33922. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33923. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33924. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33925. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33926. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33927. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33928. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33929. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33930. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33931. import { Engine } from "babylonjs/Engines/engine";
  33932. import { Node } from "babylonjs/node";
  33933. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33934. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33935. import { WebRequest } from "babylonjs/Misc/webRequest";
  33936. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33937. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33938. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33939. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33940. import { Plane } from "babylonjs/Maths/math.plane";
  33941. import { Ray } from "babylonjs/Culling/ray";
  33942. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33943. import { Animation } from "babylonjs/Animations/animation";
  33944. import { Animatable } from "babylonjs/Animations/animatable";
  33945. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33946. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33947. import { Collider } from "babylonjs/Collisions/collider";
  33948. /**
  33949. * Define an interface for all classes that will hold resources
  33950. */
  33951. export interface IDisposable {
  33952. /**
  33953. * Releases all held resources
  33954. */
  33955. dispose(): void;
  33956. }
  33957. /** Interface defining initialization parameters for Scene class */
  33958. export interface SceneOptions {
  33959. /**
  33960. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33961. * It will improve performance when the number of geometries becomes important.
  33962. */
  33963. useGeometryUniqueIdsMap?: boolean;
  33964. /**
  33965. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33966. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33967. */
  33968. useMaterialMeshMap?: boolean;
  33969. /**
  33970. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33971. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33972. */
  33973. useClonedMeshhMap?: boolean;
  33974. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33975. virtual?: boolean;
  33976. }
  33977. /**
  33978. * Represents a scene to be rendered by the engine.
  33979. * @see http://doc.babylonjs.com/features/scene
  33980. */
  33981. export class Scene extends AbstractScene implements IAnimatable {
  33982. /** The fog is deactivated */
  33983. static readonly FOGMODE_NONE: number;
  33984. /** The fog density is following an exponential function */
  33985. static readonly FOGMODE_EXP: number;
  33986. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33987. static readonly FOGMODE_EXP2: number;
  33988. /** The fog density is following a linear function. */
  33989. static readonly FOGMODE_LINEAR: number;
  33990. /**
  33991. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33993. */
  33994. static MinDeltaTime: number;
  33995. /**
  33996. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33997. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33998. */
  33999. static MaxDeltaTime: number;
  34000. /**
  34001. * Factory used to create the default material.
  34002. * @param name The name of the material to create
  34003. * @param scene The scene to create the material for
  34004. * @returns The default material
  34005. */
  34006. static DefaultMaterialFactory(scene: Scene): Material;
  34007. /**
  34008. * Factory used to create the a collision coordinator.
  34009. * @returns The collision coordinator
  34010. */
  34011. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34012. /** @hidden */
  34013. _inputManager: InputManager;
  34014. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34015. cameraToUseForPointers: Nullable<Camera>;
  34016. /** @hidden */
  34017. readonly _isScene: boolean;
  34018. /**
  34019. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34020. */
  34021. autoClear: boolean;
  34022. /**
  34023. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34024. */
  34025. autoClearDepthAndStencil: boolean;
  34026. /**
  34027. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34028. */
  34029. clearColor: Color4;
  34030. /**
  34031. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34032. */
  34033. ambientColor: Color3;
  34034. /**
  34035. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34036. * It should only be one of the following (if not the default embedded one):
  34037. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34038. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34039. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34040. * The material properties need to be setup according to the type of texture in use.
  34041. */
  34042. environmentBRDFTexture: BaseTexture;
  34043. /** @hidden */
  34044. protected _environmentTexture: Nullable<BaseTexture>;
  34045. /**
  34046. * Texture used in all pbr material as the reflection texture.
  34047. * As in the majority of the scene they are the same (exception for multi room and so on),
  34048. * this is easier to reference from here than from all the materials.
  34049. */
  34050. /**
  34051. * Texture used in all pbr material as the reflection texture.
  34052. * As in the majority of the scene they are the same (exception for multi room and so on),
  34053. * this is easier to set here than in all the materials.
  34054. */
  34055. environmentTexture: Nullable<BaseTexture>;
  34056. /** @hidden */
  34057. protected _environmentIntensity: number;
  34058. /**
  34059. * Intensity of the environment in all pbr material.
  34060. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34061. * As in the majority of the scene they are the same (exception for multi room and so on),
  34062. * this is easier to reference from here than from all the materials.
  34063. */
  34064. /**
  34065. * Intensity of the environment in all pbr material.
  34066. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34067. * As in the majority of the scene they are the same (exception for multi room and so on),
  34068. * this is easier to set here than in all the materials.
  34069. */
  34070. environmentIntensity: number;
  34071. /** @hidden */
  34072. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34073. /**
  34074. * Default image processing configuration used either in the rendering
  34075. * Forward main pass or through the imageProcessingPostProcess if present.
  34076. * As in the majority of the scene they are the same (exception for multi camera),
  34077. * this is easier to reference from here than from all the materials and post process.
  34078. *
  34079. * No setter as we it is a shared configuration, you can set the values instead.
  34080. */
  34081. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34082. private _forceWireframe;
  34083. /**
  34084. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34085. */
  34086. forceWireframe: boolean;
  34087. private _forcePointsCloud;
  34088. /**
  34089. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34090. */
  34091. forcePointsCloud: boolean;
  34092. /**
  34093. * Gets or sets the active clipplane 1
  34094. */
  34095. clipPlane: Nullable<Plane>;
  34096. /**
  34097. * Gets or sets the active clipplane 2
  34098. */
  34099. clipPlane2: Nullable<Plane>;
  34100. /**
  34101. * Gets or sets the active clipplane 3
  34102. */
  34103. clipPlane3: Nullable<Plane>;
  34104. /**
  34105. * Gets or sets the active clipplane 4
  34106. */
  34107. clipPlane4: Nullable<Plane>;
  34108. /**
  34109. * Gets or sets a boolean indicating if animations are enabled
  34110. */
  34111. animationsEnabled: boolean;
  34112. private _animationPropertiesOverride;
  34113. /**
  34114. * Gets or sets the animation properties override
  34115. */
  34116. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34117. /**
  34118. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34119. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34120. */
  34121. useConstantAnimationDeltaTime: boolean;
  34122. /**
  34123. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34124. * Please note that it requires to run a ray cast through the scene on every frame
  34125. */
  34126. constantlyUpdateMeshUnderPointer: boolean;
  34127. /**
  34128. * Defines the HTML cursor to use when hovering over interactive elements
  34129. */
  34130. hoverCursor: string;
  34131. /**
  34132. * Defines the HTML default cursor to use (empty by default)
  34133. */
  34134. defaultCursor: string;
  34135. /**
  34136. * This is used to call preventDefault() on pointer down
  34137. * in order to block unwanted artifacts like system double clicks
  34138. */
  34139. preventDefaultOnPointerDown: boolean;
  34140. /**
  34141. * This is used to call preventDefault() on pointer up
  34142. * in order to block unwanted artifacts like system double clicks
  34143. */
  34144. preventDefaultOnPointerUp: boolean;
  34145. /**
  34146. * Gets or sets user defined metadata
  34147. */
  34148. metadata: any;
  34149. /**
  34150. * For internal use only. Please do not use.
  34151. */
  34152. reservedDataStore: any;
  34153. /**
  34154. * Gets the name of the plugin used to load this scene (null by default)
  34155. */
  34156. loadingPluginName: string;
  34157. /**
  34158. * Use this array to add regular expressions used to disable offline support for specific urls
  34159. */
  34160. disableOfflineSupportExceptionRules: RegExp[];
  34161. /**
  34162. * An event triggered when the scene is disposed.
  34163. */
  34164. onDisposeObservable: Observable<Scene>;
  34165. private _onDisposeObserver;
  34166. /** Sets a function to be executed when this scene is disposed. */
  34167. onDispose: () => void;
  34168. /**
  34169. * An event triggered before rendering the scene (right after animations and physics)
  34170. */
  34171. onBeforeRenderObservable: Observable<Scene>;
  34172. private _onBeforeRenderObserver;
  34173. /** Sets a function to be executed before rendering this scene */
  34174. beforeRender: Nullable<() => void>;
  34175. /**
  34176. * An event triggered after rendering the scene
  34177. */
  34178. onAfterRenderObservable: Observable<Scene>;
  34179. /**
  34180. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34181. */
  34182. onAfterRenderCameraObservable: Observable<Camera>;
  34183. private _onAfterRenderObserver;
  34184. /** Sets a function to be executed after rendering this scene */
  34185. afterRender: Nullable<() => void>;
  34186. /**
  34187. * An event triggered before animating the scene
  34188. */
  34189. onBeforeAnimationsObservable: Observable<Scene>;
  34190. /**
  34191. * An event triggered after animations processing
  34192. */
  34193. onAfterAnimationsObservable: Observable<Scene>;
  34194. /**
  34195. * An event triggered before draw calls are ready to be sent
  34196. */
  34197. onBeforeDrawPhaseObservable: Observable<Scene>;
  34198. /**
  34199. * An event triggered after draw calls have been sent
  34200. */
  34201. onAfterDrawPhaseObservable: Observable<Scene>;
  34202. /**
  34203. * An event triggered when the scene is ready
  34204. */
  34205. onReadyObservable: Observable<Scene>;
  34206. /**
  34207. * An event triggered before rendering a camera
  34208. */
  34209. onBeforeCameraRenderObservable: Observable<Camera>;
  34210. private _onBeforeCameraRenderObserver;
  34211. /** Sets a function to be executed before rendering a camera*/
  34212. beforeCameraRender: () => void;
  34213. /**
  34214. * An event triggered after rendering a camera
  34215. */
  34216. onAfterCameraRenderObservable: Observable<Camera>;
  34217. private _onAfterCameraRenderObserver;
  34218. /** Sets a function to be executed after rendering a camera*/
  34219. afterCameraRender: () => void;
  34220. /**
  34221. * An event triggered when active meshes evaluation is about to start
  34222. */
  34223. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34224. /**
  34225. * An event triggered when active meshes evaluation is done
  34226. */
  34227. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34228. /**
  34229. * An event triggered when particles rendering is about to start
  34230. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34231. */
  34232. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34233. /**
  34234. * An event triggered when particles rendering is done
  34235. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34236. */
  34237. onAfterParticlesRenderingObservable: Observable<Scene>;
  34238. /**
  34239. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34240. */
  34241. onDataLoadedObservable: Observable<Scene>;
  34242. /**
  34243. * An event triggered when a camera is created
  34244. */
  34245. onNewCameraAddedObservable: Observable<Camera>;
  34246. /**
  34247. * An event triggered when a camera is removed
  34248. */
  34249. onCameraRemovedObservable: Observable<Camera>;
  34250. /**
  34251. * An event triggered when a light is created
  34252. */
  34253. onNewLightAddedObservable: Observable<Light>;
  34254. /**
  34255. * An event triggered when a light is removed
  34256. */
  34257. onLightRemovedObservable: Observable<Light>;
  34258. /**
  34259. * An event triggered when a geometry is created
  34260. */
  34261. onNewGeometryAddedObservable: Observable<Geometry>;
  34262. /**
  34263. * An event triggered when a geometry is removed
  34264. */
  34265. onGeometryRemovedObservable: Observable<Geometry>;
  34266. /**
  34267. * An event triggered when a transform node is created
  34268. */
  34269. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34270. /**
  34271. * An event triggered when a transform node is removed
  34272. */
  34273. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34274. /**
  34275. * An event triggered when a mesh is created
  34276. */
  34277. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34278. /**
  34279. * An event triggered when a mesh is removed
  34280. */
  34281. onMeshRemovedObservable: Observable<AbstractMesh>;
  34282. /**
  34283. * An event triggered when a skeleton is created
  34284. */
  34285. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34286. /**
  34287. * An event triggered when a skeleton is removed
  34288. */
  34289. onSkeletonRemovedObservable: Observable<Skeleton>;
  34290. /**
  34291. * An event triggered when a material is created
  34292. */
  34293. onNewMaterialAddedObservable: Observable<Material>;
  34294. /**
  34295. * An event triggered when a material is removed
  34296. */
  34297. onMaterialRemovedObservable: Observable<Material>;
  34298. /**
  34299. * An event triggered when a texture is created
  34300. */
  34301. onNewTextureAddedObservable: Observable<BaseTexture>;
  34302. /**
  34303. * An event triggered when a texture is removed
  34304. */
  34305. onTextureRemovedObservable: Observable<BaseTexture>;
  34306. /**
  34307. * An event triggered when render targets are about to be rendered
  34308. * Can happen multiple times per frame.
  34309. */
  34310. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34311. /**
  34312. * An event triggered when render targets were rendered.
  34313. * Can happen multiple times per frame.
  34314. */
  34315. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34316. /**
  34317. * An event triggered before calculating deterministic simulation step
  34318. */
  34319. onBeforeStepObservable: Observable<Scene>;
  34320. /**
  34321. * An event triggered after calculating deterministic simulation step
  34322. */
  34323. onAfterStepObservable: Observable<Scene>;
  34324. /**
  34325. * An event triggered when the activeCamera property is updated
  34326. */
  34327. onActiveCameraChanged: Observable<Scene>;
  34328. /**
  34329. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34330. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34331. * 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)
  34332. */
  34333. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34334. /**
  34335. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34336. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34337. * 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)
  34338. */
  34339. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34340. /**
  34341. * This Observable will when a mesh has been imported into the scene.
  34342. */
  34343. onMeshImportedObservable: Observable<AbstractMesh>;
  34344. /**
  34345. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34346. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34347. */
  34348. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34349. /** @hidden */
  34350. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34351. /**
  34352. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34353. */
  34354. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34355. /**
  34356. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34357. */
  34358. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34359. /**
  34360. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34361. */
  34362. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34363. /** Callback called when a pointer move is detected */
  34364. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34365. /** Callback called when a pointer down is detected */
  34366. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34367. /** Callback called when a pointer up is detected */
  34368. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34369. /** Callback called when a pointer pick is detected */
  34370. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34371. /**
  34372. * 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).
  34373. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34374. */
  34375. onPrePointerObservable: Observable<PointerInfoPre>;
  34376. /**
  34377. * Observable event triggered each time an input event is received from the rendering canvas
  34378. */
  34379. onPointerObservable: Observable<PointerInfo>;
  34380. /**
  34381. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34382. */
  34383. readonly unTranslatedPointer: Vector2;
  34384. /**
  34385. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34386. */
  34387. static DragMovementThreshold: number;
  34388. /**
  34389. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34390. */
  34391. static LongPressDelay: number;
  34392. /**
  34393. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34394. */
  34395. static DoubleClickDelay: number;
  34396. /** If you need to check double click without raising a single click at first click, enable this flag */
  34397. static ExclusiveDoubleClickMode: boolean;
  34398. /** @hidden */
  34399. _mirroredCameraPosition: Nullable<Vector3>;
  34400. /**
  34401. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34402. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34403. */
  34404. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34405. /**
  34406. * Observable event triggered each time an keyboard event is received from the hosting window
  34407. */
  34408. onKeyboardObservable: Observable<KeyboardInfo>;
  34409. private _useRightHandedSystem;
  34410. /**
  34411. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34412. */
  34413. useRightHandedSystem: boolean;
  34414. private _timeAccumulator;
  34415. private _currentStepId;
  34416. private _currentInternalStep;
  34417. /**
  34418. * Sets the step Id used by deterministic lock step
  34419. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34420. * @param newStepId defines the step Id
  34421. */
  34422. setStepId(newStepId: number): void;
  34423. /**
  34424. * Gets the step Id used by deterministic lock step
  34425. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34426. * @returns the step Id
  34427. */
  34428. getStepId(): number;
  34429. /**
  34430. * Gets the internal step used by deterministic lock step
  34431. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34432. * @returns the internal step
  34433. */
  34434. getInternalStep(): number;
  34435. private _fogEnabled;
  34436. /**
  34437. * Gets or sets a boolean indicating if fog is enabled on this scene
  34438. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34439. * (Default is true)
  34440. */
  34441. fogEnabled: boolean;
  34442. private _fogMode;
  34443. /**
  34444. * Gets or sets the fog mode to use
  34445. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34446. * | mode | value |
  34447. * | --- | --- |
  34448. * | FOGMODE_NONE | 0 |
  34449. * | FOGMODE_EXP | 1 |
  34450. * | FOGMODE_EXP2 | 2 |
  34451. * | FOGMODE_LINEAR | 3 |
  34452. */
  34453. fogMode: number;
  34454. /**
  34455. * Gets or sets the fog color to use
  34456. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34457. * (Default is Color3(0.2, 0.2, 0.3))
  34458. */
  34459. fogColor: Color3;
  34460. /**
  34461. * Gets or sets the fog density to use
  34462. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34463. * (Default is 0.1)
  34464. */
  34465. fogDensity: number;
  34466. /**
  34467. * Gets or sets the fog start distance to use
  34468. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34469. * (Default is 0)
  34470. */
  34471. fogStart: number;
  34472. /**
  34473. * Gets or sets the fog end distance to use
  34474. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34475. * (Default is 1000)
  34476. */
  34477. fogEnd: number;
  34478. private _shadowsEnabled;
  34479. /**
  34480. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34481. */
  34482. shadowsEnabled: boolean;
  34483. private _lightsEnabled;
  34484. /**
  34485. * Gets or sets a boolean indicating if lights are enabled on this scene
  34486. */
  34487. lightsEnabled: boolean;
  34488. /** All of the active cameras added to this scene. */
  34489. activeCameras: Camera[];
  34490. /** @hidden */
  34491. _activeCamera: Nullable<Camera>;
  34492. /** Gets or sets the current active camera */
  34493. activeCamera: Nullable<Camera>;
  34494. private _defaultMaterial;
  34495. /** The default material used on meshes when no material is affected */
  34496. /** The default material used on meshes when no material is affected */
  34497. defaultMaterial: Material;
  34498. private _texturesEnabled;
  34499. /**
  34500. * Gets or sets a boolean indicating if textures are enabled on this scene
  34501. */
  34502. texturesEnabled: boolean;
  34503. /**
  34504. * Gets or sets a boolean indicating if particles are enabled on this scene
  34505. */
  34506. particlesEnabled: boolean;
  34507. /**
  34508. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34509. */
  34510. spritesEnabled: boolean;
  34511. private _skeletonsEnabled;
  34512. /**
  34513. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34514. */
  34515. skeletonsEnabled: boolean;
  34516. /**
  34517. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34518. */
  34519. lensFlaresEnabled: boolean;
  34520. /**
  34521. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34522. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34523. */
  34524. collisionsEnabled: boolean;
  34525. private _collisionCoordinator;
  34526. /** @hidden */
  34527. readonly collisionCoordinator: ICollisionCoordinator;
  34528. /**
  34529. * Defines the gravity applied to this scene (used only for collisions)
  34530. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34531. */
  34532. gravity: Vector3;
  34533. /**
  34534. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34535. */
  34536. postProcessesEnabled: boolean;
  34537. /**
  34538. * The list of postprocesses added to the scene
  34539. */
  34540. postProcesses: PostProcess[];
  34541. /**
  34542. * Gets the current postprocess manager
  34543. */
  34544. postProcessManager: PostProcessManager;
  34545. /**
  34546. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34547. */
  34548. renderTargetsEnabled: boolean;
  34549. /**
  34550. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34551. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34552. */
  34553. dumpNextRenderTargets: boolean;
  34554. /**
  34555. * The list of user defined render targets added to the scene
  34556. */
  34557. customRenderTargets: RenderTargetTexture[];
  34558. /**
  34559. * Defines if texture loading must be delayed
  34560. * If true, textures will only be loaded when they need to be rendered
  34561. */
  34562. useDelayedTextureLoading: boolean;
  34563. /**
  34564. * Gets the list of meshes imported to the scene through SceneLoader
  34565. */
  34566. importedMeshesFiles: String[];
  34567. /**
  34568. * Gets or sets a boolean indicating if probes are enabled on this scene
  34569. */
  34570. probesEnabled: boolean;
  34571. /**
  34572. * Gets or sets the current offline provider to use to store scene data
  34573. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34574. */
  34575. offlineProvider: IOfflineProvider;
  34576. /**
  34577. * Gets or sets the action manager associated with the scene
  34578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34579. */
  34580. actionManager: AbstractActionManager;
  34581. private _meshesForIntersections;
  34582. /**
  34583. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34584. */
  34585. proceduralTexturesEnabled: boolean;
  34586. private _engine;
  34587. private _totalVertices;
  34588. /** @hidden */
  34589. _activeIndices: PerfCounter;
  34590. /** @hidden */
  34591. _activeParticles: PerfCounter;
  34592. /** @hidden */
  34593. _activeBones: PerfCounter;
  34594. private _animationRatio;
  34595. /** @hidden */
  34596. _animationTimeLast: number;
  34597. /** @hidden */
  34598. _animationTime: number;
  34599. /**
  34600. * Gets or sets a general scale for animation speed
  34601. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34602. */
  34603. animationTimeScale: number;
  34604. /** @hidden */
  34605. _cachedMaterial: Nullable<Material>;
  34606. /** @hidden */
  34607. _cachedEffect: Nullable<Effect>;
  34608. /** @hidden */
  34609. _cachedVisibility: Nullable<number>;
  34610. private _renderId;
  34611. private _frameId;
  34612. private _executeWhenReadyTimeoutId;
  34613. private _intermediateRendering;
  34614. private _viewUpdateFlag;
  34615. private _projectionUpdateFlag;
  34616. /** @hidden */
  34617. _toBeDisposed: Nullable<IDisposable>[];
  34618. private _activeRequests;
  34619. /** @hidden */
  34620. _pendingData: any[];
  34621. private _isDisposed;
  34622. /**
  34623. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34624. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34625. */
  34626. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34627. private _activeMeshes;
  34628. private _processedMaterials;
  34629. private _renderTargets;
  34630. /** @hidden */
  34631. _activeParticleSystems: SmartArray<IParticleSystem>;
  34632. private _activeSkeletons;
  34633. private _softwareSkinnedMeshes;
  34634. private _renderingManager;
  34635. /** @hidden */
  34636. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34637. private _transformMatrix;
  34638. private _sceneUbo;
  34639. /** @hidden */
  34640. _viewMatrix: Matrix;
  34641. private _projectionMatrix;
  34642. /** @hidden */
  34643. _forcedViewPosition: Nullable<Vector3>;
  34644. /** @hidden */
  34645. _frustumPlanes: Plane[];
  34646. /**
  34647. * Gets the list of frustum planes (built from the active camera)
  34648. */
  34649. readonly frustumPlanes: Plane[];
  34650. /**
  34651. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34652. * This is useful if there are more lights that the maximum simulteanous authorized
  34653. */
  34654. requireLightSorting: boolean;
  34655. /** @hidden */
  34656. readonly useMaterialMeshMap: boolean;
  34657. /** @hidden */
  34658. readonly useClonedMeshhMap: boolean;
  34659. private _externalData;
  34660. private _uid;
  34661. /**
  34662. * @hidden
  34663. * Backing store of defined scene components.
  34664. */
  34665. _components: ISceneComponent[];
  34666. /**
  34667. * @hidden
  34668. * Backing store of defined scene components.
  34669. */
  34670. _serializableComponents: ISceneSerializableComponent[];
  34671. /**
  34672. * List of components to register on the next registration step.
  34673. */
  34674. private _transientComponents;
  34675. /**
  34676. * Registers the transient components if needed.
  34677. */
  34678. private _registerTransientComponents;
  34679. /**
  34680. * @hidden
  34681. * Add a component to the scene.
  34682. * Note that the ccomponent could be registered on th next frame if this is called after
  34683. * the register component stage.
  34684. * @param component Defines the component to add to the scene
  34685. */
  34686. _addComponent(component: ISceneComponent): void;
  34687. /**
  34688. * @hidden
  34689. * Gets a component from the scene.
  34690. * @param name defines the name of the component to retrieve
  34691. * @returns the component or null if not present
  34692. */
  34693. _getComponent(name: string): Nullable<ISceneComponent>;
  34694. /**
  34695. * @hidden
  34696. * Defines the actions happening before camera updates.
  34697. */
  34698. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34699. /**
  34700. * @hidden
  34701. * Defines the actions happening before clear the canvas.
  34702. */
  34703. _beforeClearStage: Stage<SimpleStageAction>;
  34704. /**
  34705. * @hidden
  34706. * Defines the actions when collecting render targets for the frame.
  34707. */
  34708. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34709. /**
  34710. * @hidden
  34711. * Defines the actions happening for one camera in the frame.
  34712. */
  34713. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34714. /**
  34715. * @hidden
  34716. * Defines the actions happening during the per mesh ready checks.
  34717. */
  34718. _isReadyForMeshStage: Stage<MeshStageAction>;
  34719. /**
  34720. * @hidden
  34721. * Defines the actions happening before evaluate active mesh checks.
  34722. */
  34723. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34724. /**
  34725. * @hidden
  34726. * Defines the actions happening during the evaluate sub mesh checks.
  34727. */
  34728. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34729. /**
  34730. * @hidden
  34731. * Defines the actions happening during the active mesh stage.
  34732. */
  34733. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34734. /**
  34735. * @hidden
  34736. * Defines the actions happening during the per camera render target step.
  34737. */
  34738. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34739. /**
  34740. * @hidden
  34741. * Defines the actions happening just before the active camera is drawing.
  34742. */
  34743. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34744. /**
  34745. * @hidden
  34746. * Defines the actions happening just before a render target is drawing.
  34747. */
  34748. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34749. /**
  34750. * @hidden
  34751. * Defines the actions happening just before a rendering group is drawing.
  34752. */
  34753. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34754. /**
  34755. * @hidden
  34756. * Defines the actions happening just before a mesh is drawing.
  34757. */
  34758. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34759. /**
  34760. * @hidden
  34761. * Defines the actions happening just after a mesh has been drawn.
  34762. */
  34763. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34764. /**
  34765. * @hidden
  34766. * Defines the actions happening just after a rendering group has been drawn.
  34767. */
  34768. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34769. /**
  34770. * @hidden
  34771. * Defines the actions happening just after the active camera has been drawn.
  34772. */
  34773. _afterCameraDrawStage: Stage<CameraStageAction>;
  34774. /**
  34775. * @hidden
  34776. * Defines the actions happening just after a render target has been drawn.
  34777. */
  34778. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34779. /**
  34780. * @hidden
  34781. * Defines the actions happening just after rendering all cameras and computing intersections.
  34782. */
  34783. _afterRenderStage: Stage<SimpleStageAction>;
  34784. /**
  34785. * @hidden
  34786. * Defines the actions happening when a pointer move event happens.
  34787. */
  34788. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34789. /**
  34790. * @hidden
  34791. * Defines the actions happening when a pointer down event happens.
  34792. */
  34793. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34794. /**
  34795. * @hidden
  34796. * Defines the actions happening when a pointer up event happens.
  34797. */
  34798. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34799. /**
  34800. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34801. */
  34802. private geometriesByUniqueId;
  34803. /**
  34804. * Creates a new Scene
  34805. * @param engine defines the engine to use to render this scene
  34806. * @param options defines the scene options
  34807. */
  34808. constructor(engine: Engine, options?: SceneOptions);
  34809. /**
  34810. * Gets a string idenfifying the name of the class
  34811. * @returns "Scene" string
  34812. */
  34813. getClassName(): string;
  34814. private _defaultMeshCandidates;
  34815. /**
  34816. * @hidden
  34817. */
  34818. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34819. private _defaultSubMeshCandidates;
  34820. /**
  34821. * @hidden
  34822. */
  34823. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34824. /**
  34825. * Sets the default candidate providers for the scene.
  34826. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34827. * and getCollidingSubMeshCandidates to their default function
  34828. */
  34829. setDefaultCandidateProviders(): void;
  34830. /**
  34831. * Gets the mesh that is currently under the pointer
  34832. */
  34833. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34834. /**
  34835. * Gets or sets the current on-screen X position of the pointer
  34836. */
  34837. pointerX: number;
  34838. /**
  34839. * Gets or sets the current on-screen Y position of the pointer
  34840. */
  34841. pointerY: number;
  34842. /**
  34843. * Gets the cached material (ie. the latest rendered one)
  34844. * @returns the cached material
  34845. */
  34846. getCachedMaterial(): Nullable<Material>;
  34847. /**
  34848. * Gets the cached effect (ie. the latest rendered one)
  34849. * @returns the cached effect
  34850. */
  34851. getCachedEffect(): Nullable<Effect>;
  34852. /**
  34853. * Gets the cached visibility state (ie. the latest rendered one)
  34854. * @returns the cached visibility state
  34855. */
  34856. getCachedVisibility(): Nullable<number>;
  34857. /**
  34858. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34859. * @param material defines the current material
  34860. * @param effect defines the current effect
  34861. * @param visibility defines the current visibility state
  34862. * @returns true if one parameter is not cached
  34863. */
  34864. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34865. /**
  34866. * Gets the engine associated with the scene
  34867. * @returns an Engine
  34868. */
  34869. getEngine(): Engine;
  34870. /**
  34871. * Gets the total number of vertices rendered per frame
  34872. * @returns the total number of vertices rendered per frame
  34873. */
  34874. getTotalVertices(): number;
  34875. /**
  34876. * Gets the performance counter for total vertices
  34877. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34878. */
  34879. readonly totalVerticesPerfCounter: PerfCounter;
  34880. /**
  34881. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34882. * @returns the total number of active indices rendered per frame
  34883. */
  34884. getActiveIndices(): number;
  34885. /**
  34886. * Gets the performance counter for active indices
  34887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34888. */
  34889. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34890. /**
  34891. * Gets the total number of active particles rendered per frame
  34892. * @returns the total number of active particles rendered per frame
  34893. */
  34894. getActiveParticles(): number;
  34895. /**
  34896. * Gets the performance counter for active particles
  34897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34898. */
  34899. readonly activeParticlesPerfCounter: PerfCounter;
  34900. /**
  34901. * Gets the total number of active bones rendered per frame
  34902. * @returns the total number of active bones rendered per frame
  34903. */
  34904. getActiveBones(): number;
  34905. /**
  34906. * Gets the performance counter for active bones
  34907. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34908. */
  34909. readonly activeBonesPerfCounter: PerfCounter;
  34910. /**
  34911. * Gets the array of active meshes
  34912. * @returns an array of AbstractMesh
  34913. */
  34914. getActiveMeshes(): SmartArray<AbstractMesh>;
  34915. /**
  34916. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34917. * @returns a number
  34918. */
  34919. getAnimationRatio(): number;
  34920. /**
  34921. * Gets an unique Id for the current render phase
  34922. * @returns a number
  34923. */
  34924. getRenderId(): number;
  34925. /**
  34926. * Gets an unique Id for the current frame
  34927. * @returns a number
  34928. */
  34929. getFrameId(): number;
  34930. /** Call this function if you want to manually increment the render Id*/
  34931. incrementRenderId(): void;
  34932. private _createUbo;
  34933. /**
  34934. * Use this method to simulate a pointer move on a mesh
  34935. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34936. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34937. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34938. * @returns the current scene
  34939. */
  34940. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34941. /**
  34942. * Use this method to simulate a pointer down on a mesh
  34943. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34944. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34945. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34946. * @returns the current scene
  34947. */
  34948. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34949. /**
  34950. * Use this method to simulate a pointer up on a mesh
  34951. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34952. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34953. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34954. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34955. * @returns the current scene
  34956. */
  34957. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34958. /**
  34959. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34960. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34961. * @returns true if the pointer was captured
  34962. */
  34963. isPointerCaptured(pointerId?: number): boolean;
  34964. /**
  34965. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34966. * @param attachUp defines if you want to attach events to pointerup
  34967. * @param attachDown defines if you want to attach events to pointerdown
  34968. * @param attachMove defines if you want to attach events to pointermove
  34969. */
  34970. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34971. /** Detaches all event handlers*/
  34972. detachControl(): void;
  34973. /**
  34974. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34975. * Delay loaded resources are not taking in account
  34976. * @return true if all required resources are ready
  34977. */
  34978. isReady(): boolean;
  34979. /** Resets all cached information relative to material (including effect and visibility) */
  34980. resetCachedMaterial(): void;
  34981. /**
  34982. * Registers a function to be called before every frame render
  34983. * @param func defines the function to register
  34984. */
  34985. registerBeforeRender(func: () => void): void;
  34986. /**
  34987. * Unregisters a function called before every frame render
  34988. * @param func defines the function to unregister
  34989. */
  34990. unregisterBeforeRender(func: () => void): void;
  34991. /**
  34992. * Registers a function to be called after every frame render
  34993. * @param func defines the function to register
  34994. */
  34995. registerAfterRender(func: () => void): void;
  34996. /**
  34997. * Unregisters a function called after every frame render
  34998. * @param func defines the function to unregister
  34999. */
  35000. unregisterAfterRender(func: () => void): void;
  35001. private _executeOnceBeforeRender;
  35002. /**
  35003. * The provided function will run before render once and will be disposed afterwards.
  35004. * A timeout delay can be provided so that the function will be executed in N ms.
  35005. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35006. * @param func The function to be executed.
  35007. * @param timeout optional delay in ms
  35008. */
  35009. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35010. /** @hidden */
  35011. _addPendingData(data: any): void;
  35012. /** @hidden */
  35013. _removePendingData(data: any): void;
  35014. /**
  35015. * Returns the number of items waiting to be loaded
  35016. * @returns the number of items waiting to be loaded
  35017. */
  35018. getWaitingItemsCount(): number;
  35019. /**
  35020. * Returns a boolean indicating if the scene is still loading data
  35021. */
  35022. readonly isLoading: boolean;
  35023. /**
  35024. * Registers a function to be executed when the scene is ready
  35025. * @param {Function} func - the function to be executed
  35026. */
  35027. executeWhenReady(func: () => void): void;
  35028. /**
  35029. * Returns a promise that resolves when the scene is ready
  35030. * @returns A promise that resolves when the scene is ready
  35031. */
  35032. whenReadyAsync(): Promise<void>;
  35033. /** @hidden */
  35034. _checkIsReady(): void;
  35035. /**
  35036. * Gets all animatable attached to the scene
  35037. */
  35038. readonly animatables: Animatable[];
  35039. /**
  35040. * Resets the last animation time frame.
  35041. * Useful to override when animations start running when loading a scene for the first time.
  35042. */
  35043. resetLastAnimationTimeFrame(): void;
  35044. /**
  35045. * Gets the current view matrix
  35046. * @returns a Matrix
  35047. */
  35048. getViewMatrix(): Matrix;
  35049. /**
  35050. * Gets the current projection matrix
  35051. * @returns a Matrix
  35052. */
  35053. getProjectionMatrix(): Matrix;
  35054. /**
  35055. * Gets the current transform matrix
  35056. * @returns a Matrix made of View * Projection
  35057. */
  35058. getTransformMatrix(): Matrix;
  35059. /**
  35060. * Sets the current transform matrix
  35061. * @param viewL defines the View matrix to use
  35062. * @param projectionL defines the Projection matrix to use
  35063. * @param viewR defines the right View matrix to use (if provided)
  35064. * @param projectionR defines the right Projection matrix to use (if provided)
  35065. */
  35066. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35067. /**
  35068. * Gets the uniform buffer used to store scene data
  35069. * @returns a UniformBuffer
  35070. */
  35071. getSceneUniformBuffer(): UniformBuffer;
  35072. /**
  35073. * Gets an unique (relatively to the current scene) Id
  35074. * @returns an unique number for the scene
  35075. */
  35076. getUniqueId(): number;
  35077. /**
  35078. * Add a mesh to the list of scene's meshes
  35079. * @param newMesh defines the mesh to add
  35080. * @param recursive if all child meshes should also be added to the scene
  35081. */
  35082. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35083. /**
  35084. * Remove a mesh for the list of scene's meshes
  35085. * @param toRemove defines the mesh to remove
  35086. * @param recursive if all child meshes should also be removed from the scene
  35087. * @returns the index where the mesh was in the mesh list
  35088. */
  35089. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35090. /**
  35091. * Add a transform node to the list of scene's transform nodes
  35092. * @param newTransformNode defines the transform node to add
  35093. */
  35094. addTransformNode(newTransformNode: TransformNode): void;
  35095. /**
  35096. * Remove a transform node for the list of scene's transform nodes
  35097. * @param toRemove defines the transform node to remove
  35098. * @returns the index where the transform node was in the transform node list
  35099. */
  35100. removeTransformNode(toRemove: TransformNode): number;
  35101. /**
  35102. * Remove a skeleton for the list of scene's skeletons
  35103. * @param toRemove defines the skeleton to remove
  35104. * @returns the index where the skeleton was in the skeleton list
  35105. */
  35106. removeSkeleton(toRemove: Skeleton): number;
  35107. /**
  35108. * Remove a morph target for the list of scene's morph targets
  35109. * @param toRemove defines the morph target to remove
  35110. * @returns the index where the morph target was in the morph target list
  35111. */
  35112. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35113. /**
  35114. * Remove a light for the list of scene's lights
  35115. * @param toRemove defines the light to remove
  35116. * @returns the index where the light was in the light list
  35117. */
  35118. removeLight(toRemove: Light): number;
  35119. /**
  35120. * Remove a camera for the list of scene's cameras
  35121. * @param toRemove defines the camera to remove
  35122. * @returns the index where the camera was in the camera list
  35123. */
  35124. removeCamera(toRemove: Camera): number;
  35125. /**
  35126. * Remove a particle system for the list of scene's particle systems
  35127. * @param toRemove defines the particle system to remove
  35128. * @returns the index where the particle system was in the particle system list
  35129. */
  35130. removeParticleSystem(toRemove: IParticleSystem): number;
  35131. /**
  35132. * Remove a animation for the list of scene's animations
  35133. * @param toRemove defines the animation to remove
  35134. * @returns the index where the animation was in the animation list
  35135. */
  35136. removeAnimation(toRemove: Animation): number;
  35137. /**
  35138. * Will stop the animation of the given target
  35139. * @param target - the target
  35140. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35141. * @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)
  35142. */
  35143. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35144. /**
  35145. * Removes the given animation group from this scene.
  35146. * @param toRemove The animation group to remove
  35147. * @returns The index of the removed animation group
  35148. */
  35149. removeAnimationGroup(toRemove: AnimationGroup): number;
  35150. /**
  35151. * Removes the given multi-material from this scene.
  35152. * @param toRemove The multi-material to remove
  35153. * @returns The index of the removed multi-material
  35154. */
  35155. removeMultiMaterial(toRemove: MultiMaterial): number;
  35156. /**
  35157. * Removes the given material from this scene.
  35158. * @param toRemove The material to remove
  35159. * @returns The index of the removed material
  35160. */
  35161. removeMaterial(toRemove: Material): number;
  35162. /**
  35163. * Removes the given action manager from this scene.
  35164. * @param toRemove The action manager to remove
  35165. * @returns The index of the removed action manager
  35166. */
  35167. removeActionManager(toRemove: AbstractActionManager): number;
  35168. /**
  35169. * Removes the given texture from this scene.
  35170. * @param toRemove The texture to remove
  35171. * @returns The index of the removed texture
  35172. */
  35173. removeTexture(toRemove: BaseTexture): number;
  35174. /**
  35175. * Adds the given light to this scene
  35176. * @param newLight The light to add
  35177. */
  35178. addLight(newLight: Light): void;
  35179. /**
  35180. * Sorts the list list based on light priorities
  35181. */
  35182. sortLightsByPriority(): void;
  35183. /**
  35184. * Adds the given camera to this scene
  35185. * @param newCamera The camera to add
  35186. */
  35187. addCamera(newCamera: Camera): void;
  35188. /**
  35189. * Adds the given skeleton to this scene
  35190. * @param newSkeleton The skeleton to add
  35191. */
  35192. addSkeleton(newSkeleton: Skeleton): void;
  35193. /**
  35194. * Adds the given particle system to this scene
  35195. * @param newParticleSystem The particle system to add
  35196. */
  35197. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35198. /**
  35199. * Adds the given animation to this scene
  35200. * @param newAnimation The animation to add
  35201. */
  35202. addAnimation(newAnimation: Animation): void;
  35203. /**
  35204. * Adds the given animation group to this scene.
  35205. * @param newAnimationGroup The animation group to add
  35206. */
  35207. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35208. /**
  35209. * Adds the given multi-material to this scene
  35210. * @param newMultiMaterial The multi-material to add
  35211. */
  35212. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35213. /**
  35214. * Adds the given material to this scene
  35215. * @param newMaterial The material to add
  35216. */
  35217. addMaterial(newMaterial: Material): void;
  35218. /**
  35219. * Adds the given morph target to this scene
  35220. * @param newMorphTargetManager The morph target to add
  35221. */
  35222. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35223. /**
  35224. * Adds the given geometry to this scene
  35225. * @param newGeometry The geometry to add
  35226. */
  35227. addGeometry(newGeometry: Geometry): void;
  35228. /**
  35229. * Adds the given action manager to this scene
  35230. * @param newActionManager The action manager to add
  35231. */
  35232. addActionManager(newActionManager: AbstractActionManager): void;
  35233. /**
  35234. * Adds the given texture to this scene.
  35235. * @param newTexture The texture to add
  35236. */
  35237. addTexture(newTexture: BaseTexture): void;
  35238. /**
  35239. * Switch active camera
  35240. * @param newCamera defines the new active camera
  35241. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35242. */
  35243. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35244. /**
  35245. * sets the active camera of the scene using its ID
  35246. * @param id defines the camera's ID
  35247. * @return the new active camera or null if none found.
  35248. */
  35249. setActiveCameraByID(id: string): Nullable<Camera>;
  35250. /**
  35251. * sets the active camera of the scene using its name
  35252. * @param name defines the camera's name
  35253. * @returns the new active camera or null if none found.
  35254. */
  35255. setActiveCameraByName(name: string): Nullable<Camera>;
  35256. /**
  35257. * get an animation group using its name
  35258. * @param name defines the material's name
  35259. * @return the animation group or null if none found.
  35260. */
  35261. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35262. /**
  35263. * Get a material using its unique id
  35264. * @param uniqueId defines the material's unique id
  35265. * @return the material or null if none found.
  35266. */
  35267. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35268. /**
  35269. * get a material using its id
  35270. * @param id defines the material's ID
  35271. * @return the material or null if none found.
  35272. */
  35273. getMaterialByID(id: string): Nullable<Material>;
  35274. /**
  35275. * Gets a the last added material using a given id
  35276. * @param id defines the material's ID
  35277. * @return the last material with the given id or null if none found.
  35278. */
  35279. getLastMaterialByID(id: string): Nullable<Material>;
  35280. /**
  35281. * Gets a material using its name
  35282. * @param name defines the material's name
  35283. * @return the material or null if none found.
  35284. */
  35285. getMaterialByName(name: string): Nullable<Material>;
  35286. /**
  35287. * Get a texture using its unique id
  35288. * @param uniqueId defines the texture's unique id
  35289. * @return the texture or null if none found.
  35290. */
  35291. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35292. /**
  35293. * Gets a camera using its id
  35294. * @param id defines the id to look for
  35295. * @returns the camera or null if not found
  35296. */
  35297. getCameraByID(id: string): Nullable<Camera>;
  35298. /**
  35299. * Gets a camera using its unique id
  35300. * @param uniqueId defines the unique id to look for
  35301. * @returns the camera or null if not found
  35302. */
  35303. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35304. /**
  35305. * Gets a camera using its name
  35306. * @param name defines the camera's name
  35307. * @return the camera or null if none found.
  35308. */
  35309. getCameraByName(name: string): Nullable<Camera>;
  35310. /**
  35311. * Gets a bone using its id
  35312. * @param id defines the bone's id
  35313. * @return the bone or null if not found
  35314. */
  35315. getBoneByID(id: string): Nullable<Bone>;
  35316. /**
  35317. * Gets a bone using its id
  35318. * @param name defines the bone's name
  35319. * @return the bone or null if not found
  35320. */
  35321. getBoneByName(name: string): Nullable<Bone>;
  35322. /**
  35323. * Gets a light node using its name
  35324. * @param name defines the the light's name
  35325. * @return the light or null if none found.
  35326. */
  35327. getLightByName(name: string): Nullable<Light>;
  35328. /**
  35329. * Gets a light node using its id
  35330. * @param id defines the light's id
  35331. * @return the light or null if none found.
  35332. */
  35333. getLightByID(id: string): Nullable<Light>;
  35334. /**
  35335. * Gets a light node using its scene-generated unique ID
  35336. * @param uniqueId defines the light's unique id
  35337. * @return the light or null if none found.
  35338. */
  35339. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35340. /**
  35341. * Gets a particle system by id
  35342. * @param id defines the particle system id
  35343. * @return the corresponding system or null if none found
  35344. */
  35345. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35346. /**
  35347. * Gets a geometry using its ID
  35348. * @param id defines the geometry's id
  35349. * @return the geometry or null if none found.
  35350. */
  35351. getGeometryByID(id: string): Nullable<Geometry>;
  35352. private _getGeometryByUniqueID;
  35353. /**
  35354. * Add a new geometry to this scene
  35355. * @param geometry defines the geometry to be added to the scene.
  35356. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35357. * @return a boolean defining if the geometry was added or not
  35358. */
  35359. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35360. /**
  35361. * Removes an existing geometry
  35362. * @param geometry defines the geometry to be removed from the scene
  35363. * @return a boolean defining if the geometry was removed or not
  35364. */
  35365. removeGeometry(geometry: Geometry): boolean;
  35366. /**
  35367. * Gets the list of geometries attached to the scene
  35368. * @returns an array of Geometry
  35369. */
  35370. getGeometries(): Geometry[];
  35371. /**
  35372. * Gets the first added mesh found of a given ID
  35373. * @param id defines the id to search for
  35374. * @return the mesh found or null if not found at all
  35375. */
  35376. getMeshByID(id: string): Nullable<AbstractMesh>;
  35377. /**
  35378. * Gets a list of meshes using their id
  35379. * @param id defines the id to search for
  35380. * @returns a list of meshes
  35381. */
  35382. getMeshesByID(id: string): Array<AbstractMesh>;
  35383. /**
  35384. * Gets the first added transform node found of a given ID
  35385. * @param id defines the id to search for
  35386. * @return the found transform node or null if not found at all.
  35387. */
  35388. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35389. /**
  35390. * Gets a transform node with its auto-generated unique id
  35391. * @param uniqueId efines the unique id to search for
  35392. * @return the found transform node or null if not found at all.
  35393. */
  35394. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35395. /**
  35396. * Gets a list of transform nodes using their id
  35397. * @param id defines the id to search for
  35398. * @returns a list of transform nodes
  35399. */
  35400. getTransformNodesByID(id: string): Array<TransformNode>;
  35401. /**
  35402. * Gets a mesh with its auto-generated unique id
  35403. * @param uniqueId defines the unique id to search for
  35404. * @return the found mesh or null if not found at all.
  35405. */
  35406. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35407. /**
  35408. * Gets a the last added mesh using a given id
  35409. * @param id defines the id to search for
  35410. * @return the found mesh or null if not found at all.
  35411. */
  35412. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35413. /**
  35414. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35415. * @param id defines the id to search for
  35416. * @return the found node or null if not found at all
  35417. */
  35418. getLastEntryByID(id: string): Nullable<Node>;
  35419. /**
  35420. * Gets a node (Mesh, Camera, Light) using a given id
  35421. * @param id defines the id to search for
  35422. * @return the found node or null if not found at all
  35423. */
  35424. getNodeByID(id: string): Nullable<Node>;
  35425. /**
  35426. * Gets a node (Mesh, Camera, Light) using a given name
  35427. * @param name defines the name to search for
  35428. * @return the found node or null if not found at all.
  35429. */
  35430. getNodeByName(name: string): Nullable<Node>;
  35431. /**
  35432. * Gets a mesh using a given name
  35433. * @param name defines the name to search for
  35434. * @return the found mesh or null if not found at all.
  35435. */
  35436. getMeshByName(name: string): Nullable<AbstractMesh>;
  35437. /**
  35438. * Gets a transform node using a given name
  35439. * @param name defines the name to search for
  35440. * @return the found transform node or null if not found at all.
  35441. */
  35442. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35443. /**
  35444. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35445. * @param id defines the id to search for
  35446. * @return the found skeleton or null if not found at all.
  35447. */
  35448. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35449. /**
  35450. * Gets a skeleton using a given auto generated unique id
  35451. * @param uniqueId defines the unique id to search for
  35452. * @return the found skeleton or null if not found at all.
  35453. */
  35454. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35455. /**
  35456. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35457. * @param id defines the id to search for
  35458. * @return the found skeleton or null if not found at all.
  35459. */
  35460. getSkeletonById(id: string): Nullable<Skeleton>;
  35461. /**
  35462. * Gets a skeleton using a given name
  35463. * @param name defines the name to search for
  35464. * @return the found skeleton or null if not found at all.
  35465. */
  35466. getSkeletonByName(name: string): Nullable<Skeleton>;
  35467. /**
  35468. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35469. * @param id defines the id to search for
  35470. * @return the found morph target manager or null if not found at all.
  35471. */
  35472. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35473. /**
  35474. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35475. * @param id defines the id to search for
  35476. * @return the found morph target or null if not found at all.
  35477. */
  35478. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35479. /**
  35480. * Gets a boolean indicating if the given mesh is active
  35481. * @param mesh defines the mesh to look for
  35482. * @returns true if the mesh is in the active list
  35483. */
  35484. isActiveMesh(mesh: AbstractMesh): boolean;
  35485. /**
  35486. * Return a unique id as a string which can serve as an identifier for the scene
  35487. */
  35488. readonly uid: string;
  35489. /**
  35490. * Add an externaly attached data from its key.
  35491. * This method call will fail and return false, if such key already exists.
  35492. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35493. * @param key the unique key that identifies the data
  35494. * @param data the data object to associate to the key for this Engine instance
  35495. * @return true if no such key were already present and the data was added successfully, false otherwise
  35496. */
  35497. addExternalData<T>(key: string, data: T): boolean;
  35498. /**
  35499. * Get an externaly attached data from its key
  35500. * @param key the unique key that identifies the data
  35501. * @return the associated data, if present (can be null), or undefined if not present
  35502. */
  35503. getExternalData<T>(key: string): Nullable<T>;
  35504. /**
  35505. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35506. * @param key the unique key that identifies the data
  35507. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35508. * @return the associated data, can be null if the factory returned null.
  35509. */
  35510. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35511. /**
  35512. * Remove an externaly attached data from the Engine instance
  35513. * @param key the unique key that identifies the data
  35514. * @return true if the data was successfully removed, false if it doesn't exist
  35515. */
  35516. removeExternalData(key: string): boolean;
  35517. private _evaluateSubMesh;
  35518. /**
  35519. * Clear the processed materials smart array preventing retention point in material dispose.
  35520. */
  35521. freeProcessedMaterials(): void;
  35522. private _preventFreeActiveMeshesAndRenderingGroups;
  35523. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35524. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35525. * when disposing several meshes in a row or a hierarchy of meshes.
  35526. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35527. */
  35528. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35529. /**
  35530. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35531. */
  35532. freeActiveMeshes(): void;
  35533. /**
  35534. * Clear the info related to rendering groups preventing retention points during dispose.
  35535. */
  35536. freeRenderingGroups(): void;
  35537. /** @hidden */
  35538. _isInIntermediateRendering(): boolean;
  35539. /**
  35540. * Lambda returning the list of potentially active meshes.
  35541. */
  35542. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35543. /**
  35544. * Lambda returning the list of potentially active sub meshes.
  35545. */
  35546. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35547. /**
  35548. * Lambda returning the list of potentially intersecting sub meshes.
  35549. */
  35550. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35551. /**
  35552. * Lambda returning the list of potentially colliding sub meshes.
  35553. */
  35554. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35555. private _activeMeshesFrozen;
  35556. /**
  35557. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35558. * @returns the current scene
  35559. */
  35560. freezeActiveMeshes(): Scene;
  35561. /**
  35562. * Use this function to restart evaluating active meshes on every frame
  35563. * @returns the current scene
  35564. */
  35565. unfreezeActiveMeshes(): Scene;
  35566. private _evaluateActiveMeshes;
  35567. private _activeMesh;
  35568. /**
  35569. * Update the transform matrix to update from the current active camera
  35570. * @param force defines a boolean used to force the update even if cache is up to date
  35571. */
  35572. updateTransformMatrix(force?: boolean): void;
  35573. private _bindFrameBuffer;
  35574. /** @hidden */
  35575. _allowPostProcessClearColor: boolean;
  35576. /** @hidden */
  35577. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35578. private _processSubCameras;
  35579. private _checkIntersections;
  35580. /** @hidden */
  35581. _advancePhysicsEngineStep(step: number): void;
  35582. /**
  35583. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35584. */
  35585. getDeterministicFrameTime: () => number;
  35586. /** @hidden */
  35587. _animate(): void;
  35588. /** Execute all animations (for a frame) */
  35589. animate(): void;
  35590. /**
  35591. * Render the scene
  35592. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35593. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35594. */
  35595. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35596. /**
  35597. * Freeze all materials
  35598. * A frozen material will not be updatable but should be faster to render
  35599. */
  35600. freezeMaterials(): void;
  35601. /**
  35602. * Unfreeze all materials
  35603. * A frozen material will not be updatable but should be faster to render
  35604. */
  35605. unfreezeMaterials(): void;
  35606. /**
  35607. * Releases all held ressources
  35608. */
  35609. dispose(): void;
  35610. /**
  35611. * Gets if the scene is already disposed
  35612. */
  35613. readonly isDisposed: boolean;
  35614. /**
  35615. * Call this function to reduce memory footprint of the scene.
  35616. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35617. */
  35618. clearCachedVertexData(): void;
  35619. /**
  35620. * This function will remove the local cached buffer data from texture.
  35621. * It will save memory but will prevent the texture from being rebuilt
  35622. */
  35623. cleanCachedTextureBuffer(): void;
  35624. /**
  35625. * Get the world extend vectors with an optional filter
  35626. *
  35627. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35628. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35629. */
  35630. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35631. min: Vector3;
  35632. max: Vector3;
  35633. };
  35634. /**
  35635. * Creates a ray that can be used to pick in the scene
  35636. * @param x defines the x coordinate of the origin (on-screen)
  35637. * @param y defines the y coordinate of the origin (on-screen)
  35638. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35639. * @param camera defines the camera to use for the picking
  35640. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35641. * @returns a Ray
  35642. */
  35643. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35644. /**
  35645. * Creates a ray that can be used to pick in the scene
  35646. * @param x defines the x coordinate of the origin (on-screen)
  35647. * @param y defines the y coordinate of the origin (on-screen)
  35648. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35649. * @param result defines the ray where to store the picking ray
  35650. * @param camera defines the camera to use for the picking
  35651. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35652. * @returns the current scene
  35653. */
  35654. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35655. /**
  35656. * Creates a ray that can be used to pick in the scene
  35657. * @param x defines the x coordinate of the origin (on-screen)
  35658. * @param y defines the y coordinate of the origin (on-screen)
  35659. * @param camera defines the camera to use for the picking
  35660. * @returns a Ray
  35661. */
  35662. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35663. /**
  35664. * Creates a ray that can be used to pick in the scene
  35665. * @param x defines the x coordinate of the origin (on-screen)
  35666. * @param y defines the y coordinate of the origin (on-screen)
  35667. * @param result defines the ray where to store the picking ray
  35668. * @param camera defines the camera to use for the picking
  35669. * @returns the current scene
  35670. */
  35671. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35672. /** Launch a ray to try to pick a mesh in the scene
  35673. * @param x position on screen
  35674. * @param y position on screen
  35675. * @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
  35676. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35677. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35678. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35679. * @returns a PickingInfo
  35680. */
  35681. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35682. /** Use the given ray to pick a mesh in the scene
  35683. * @param ray The ray to use to pick meshes
  35684. * @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
  35685. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35686. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35687. * @returns a PickingInfo
  35688. */
  35689. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35690. /**
  35691. * Launch a ray to try to pick a mesh in the scene
  35692. * @param x X position on screen
  35693. * @param y Y position on screen
  35694. * @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
  35695. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35696. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35697. * @returns an array of PickingInfo
  35698. */
  35699. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35700. /**
  35701. * Launch a ray to try to pick a mesh in the scene
  35702. * @param ray Ray to use
  35703. * @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
  35704. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35705. * @returns an array of PickingInfo
  35706. */
  35707. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35708. /**
  35709. * Force the value of meshUnderPointer
  35710. * @param mesh defines the mesh to use
  35711. */
  35712. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35713. /**
  35714. * Gets the mesh under the pointer
  35715. * @returns a Mesh or null if no mesh is under the pointer
  35716. */
  35717. getPointerOverMesh(): Nullable<AbstractMesh>;
  35718. /** @hidden */
  35719. _rebuildGeometries(): void;
  35720. /** @hidden */
  35721. _rebuildTextures(): void;
  35722. private _getByTags;
  35723. /**
  35724. * Get a list of meshes by tags
  35725. * @param tagsQuery defines the tags query to use
  35726. * @param forEach defines a predicate used to filter results
  35727. * @returns an array of Mesh
  35728. */
  35729. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35730. /**
  35731. * Get a list of cameras by tags
  35732. * @param tagsQuery defines the tags query to use
  35733. * @param forEach defines a predicate used to filter results
  35734. * @returns an array of Camera
  35735. */
  35736. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35737. /**
  35738. * Get a list of lights by tags
  35739. * @param tagsQuery defines the tags query to use
  35740. * @param forEach defines a predicate used to filter results
  35741. * @returns an array of Light
  35742. */
  35743. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35744. /**
  35745. * Get a list of materials by tags
  35746. * @param tagsQuery defines the tags query to use
  35747. * @param forEach defines a predicate used to filter results
  35748. * @returns an array of Material
  35749. */
  35750. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35751. /**
  35752. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35753. * This allowed control for front to back rendering or reversly depending of the special needs.
  35754. *
  35755. * @param renderingGroupId The rendering group id corresponding to its index
  35756. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35757. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35758. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35759. */
  35760. 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;
  35761. /**
  35762. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35763. *
  35764. * @param renderingGroupId The rendering group id corresponding to its index
  35765. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35766. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35767. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35768. */
  35769. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35770. /**
  35771. * Gets the current auto clear configuration for one rendering group of the rendering
  35772. * manager.
  35773. * @param index the rendering group index to get the information for
  35774. * @returns The auto clear setup for the requested rendering group
  35775. */
  35776. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35777. private _blockMaterialDirtyMechanism;
  35778. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35779. blockMaterialDirtyMechanism: boolean;
  35780. /**
  35781. * Will flag all materials as dirty to trigger new shader compilation
  35782. * @param flag defines the flag used to specify which material part must be marked as dirty
  35783. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35784. */
  35785. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35786. /** @hidden */
  35787. _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;
  35788. /** @hidden */
  35789. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35790. }
  35791. }
  35792. declare module "babylonjs/assetContainer" {
  35793. import { AbstractScene } from "babylonjs/abstractScene";
  35794. import { Scene } from "babylonjs/scene";
  35795. import { Mesh } from "babylonjs/Meshes/mesh";
  35796. /**
  35797. * Set of assets to keep when moving a scene into an asset container.
  35798. */
  35799. export class KeepAssets extends AbstractScene {
  35800. }
  35801. /**
  35802. * Container with a set of assets that can be added or removed from a scene.
  35803. */
  35804. export class AssetContainer extends AbstractScene {
  35805. /**
  35806. * The scene the AssetContainer belongs to.
  35807. */
  35808. scene: Scene;
  35809. /**
  35810. * Instantiates an AssetContainer.
  35811. * @param scene The scene the AssetContainer belongs to.
  35812. */
  35813. constructor(scene: Scene);
  35814. /**
  35815. * Adds all the assets from the container to the scene.
  35816. */
  35817. addAllToScene(): void;
  35818. /**
  35819. * Removes all the assets in the container from the scene
  35820. */
  35821. removeAllFromScene(): void;
  35822. /**
  35823. * Disposes all the assets in the container
  35824. */
  35825. dispose(): void;
  35826. private _moveAssets;
  35827. /**
  35828. * Removes all the assets contained in the scene and adds them to the container.
  35829. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35830. */
  35831. moveAllFromScene(keepAssets?: KeepAssets): void;
  35832. /**
  35833. * 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.
  35834. * @returns the root mesh
  35835. */
  35836. createRootMesh(): Mesh;
  35837. }
  35838. }
  35839. declare module "babylonjs/abstractScene" {
  35840. import { Scene } from "babylonjs/scene";
  35841. import { Nullable } from "babylonjs/types";
  35842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35843. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35844. import { Geometry } from "babylonjs/Meshes/geometry";
  35845. import { Skeleton } from "babylonjs/Bones/skeleton";
  35846. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35847. import { AssetContainer } from "babylonjs/assetContainer";
  35848. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35849. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35851. import { Material } from "babylonjs/Materials/material";
  35852. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35853. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35854. import { Camera } from "babylonjs/Cameras/camera";
  35855. import { Light } from "babylonjs/Lights/light";
  35856. import { Node } from "babylonjs/node";
  35857. import { Animation } from "babylonjs/Animations/animation";
  35858. /**
  35859. * Defines how the parser contract is defined.
  35860. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35861. */
  35862. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35863. /**
  35864. * Defines how the individual parser contract is defined.
  35865. * These parser can parse an individual asset
  35866. */
  35867. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35868. /**
  35869. * Base class of the scene acting as a container for the different elements composing a scene.
  35870. * This class is dynamically extended by the different components of the scene increasing
  35871. * flexibility and reducing coupling
  35872. */
  35873. export abstract class AbstractScene {
  35874. /**
  35875. * Stores the list of available parsers in the application.
  35876. */
  35877. private static _BabylonFileParsers;
  35878. /**
  35879. * Stores the list of available individual parsers in the application.
  35880. */
  35881. private static _IndividualBabylonFileParsers;
  35882. /**
  35883. * Adds a parser in the list of available ones
  35884. * @param name Defines the name of the parser
  35885. * @param parser Defines the parser to add
  35886. */
  35887. static AddParser(name: string, parser: BabylonFileParser): void;
  35888. /**
  35889. * Gets a general parser from the list of avaialble ones
  35890. * @param name Defines the name of the parser
  35891. * @returns the requested parser or null
  35892. */
  35893. static GetParser(name: string): Nullable<BabylonFileParser>;
  35894. /**
  35895. * Adds n individual parser in the list of available ones
  35896. * @param name Defines the name of the parser
  35897. * @param parser Defines the parser to add
  35898. */
  35899. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35900. /**
  35901. * Gets an individual parser from the list of avaialble ones
  35902. * @param name Defines the name of the parser
  35903. * @returns the requested parser or null
  35904. */
  35905. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35906. /**
  35907. * Parser json data and populate both a scene and its associated container object
  35908. * @param jsonData Defines the data to parse
  35909. * @param scene Defines the scene to parse the data for
  35910. * @param container Defines the container attached to the parsing sequence
  35911. * @param rootUrl Defines the root url of the data
  35912. */
  35913. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35914. /**
  35915. * Gets the list of root nodes (ie. nodes with no parent)
  35916. */
  35917. rootNodes: Node[];
  35918. /** All of the cameras added to this scene
  35919. * @see http://doc.babylonjs.com/babylon101/cameras
  35920. */
  35921. cameras: Camera[];
  35922. /**
  35923. * All of the lights added to this scene
  35924. * @see http://doc.babylonjs.com/babylon101/lights
  35925. */
  35926. lights: Light[];
  35927. /**
  35928. * All of the (abstract) meshes added to this scene
  35929. */
  35930. meshes: AbstractMesh[];
  35931. /**
  35932. * The list of skeletons added to the scene
  35933. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35934. */
  35935. skeletons: Skeleton[];
  35936. /**
  35937. * All of the particle systems added to this scene
  35938. * @see http://doc.babylonjs.com/babylon101/particles
  35939. */
  35940. particleSystems: IParticleSystem[];
  35941. /**
  35942. * Gets a list of Animations associated with the scene
  35943. */
  35944. animations: Animation[];
  35945. /**
  35946. * All of the animation groups added to this scene
  35947. * @see http://doc.babylonjs.com/how_to/group
  35948. */
  35949. animationGroups: AnimationGroup[];
  35950. /**
  35951. * All of the multi-materials added to this scene
  35952. * @see http://doc.babylonjs.com/how_to/multi_materials
  35953. */
  35954. multiMaterials: MultiMaterial[];
  35955. /**
  35956. * All of the materials added to this scene
  35957. * In the context of a Scene, it is not supposed to be modified manually.
  35958. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35959. * Note also that the order of the Material wihin the array is not significant and might change.
  35960. * @see http://doc.babylonjs.com/babylon101/materials
  35961. */
  35962. materials: Material[];
  35963. /**
  35964. * The list of morph target managers added to the scene
  35965. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35966. */
  35967. morphTargetManagers: MorphTargetManager[];
  35968. /**
  35969. * The list of geometries used in the scene.
  35970. */
  35971. geometries: Geometry[];
  35972. /**
  35973. * All of the tranform nodes added to this scene
  35974. * In the context of a Scene, it is not supposed to be modified manually.
  35975. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35976. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35977. * @see http://doc.babylonjs.com/how_to/transformnode
  35978. */
  35979. transformNodes: TransformNode[];
  35980. /**
  35981. * ActionManagers available on the scene.
  35982. */
  35983. actionManagers: AbstractActionManager[];
  35984. /**
  35985. * Textures to keep.
  35986. */
  35987. textures: BaseTexture[];
  35988. /**
  35989. * Environment texture for the scene
  35990. */
  35991. environmentTexture: Nullable<BaseTexture>;
  35992. }
  35993. }
  35994. declare module "babylonjs/Audio/sound" {
  35995. import { Observable } from "babylonjs/Misc/observable";
  35996. import { Vector3 } from "babylonjs/Maths/math.vector";
  35997. import { Nullable } from "babylonjs/types";
  35998. import { Scene } from "babylonjs/scene";
  35999. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36000. /**
  36001. * Interface used to define options for Sound class
  36002. */
  36003. export interface ISoundOptions {
  36004. /**
  36005. * Does the sound autoplay once loaded.
  36006. */
  36007. autoplay?: boolean;
  36008. /**
  36009. * Does the sound loop after it finishes playing once.
  36010. */
  36011. loop?: boolean;
  36012. /**
  36013. * Sound's volume
  36014. */
  36015. volume?: number;
  36016. /**
  36017. * Is it a spatial sound?
  36018. */
  36019. spatialSound?: boolean;
  36020. /**
  36021. * Maximum distance to hear that sound
  36022. */
  36023. maxDistance?: number;
  36024. /**
  36025. * Uses user defined attenuation function
  36026. */
  36027. useCustomAttenuation?: boolean;
  36028. /**
  36029. * Define the roll off factor of spatial sounds.
  36030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36031. */
  36032. rolloffFactor?: number;
  36033. /**
  36034. * Define the reference distance the sound should be heard perfectly.
  36035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36036. */
  36037. refDistance?: number;
  36038. /**
  36039. * Define the distance attenuation model the sound will follow.
  36040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36041. */
  36042. distanceModel?: string;
  36043. /**
  36044. * Defines the playback speed (1 by default)
  36045. */
  36046. playbackRate?: number;
  36047. /**
  36048. * Defines if the sound is from a streaming source
  36049. */
  36050. streaming?: boolean;
  36051. /**
  36052. * Defines an optional length (in seconds) inside the sound file
  36053. */
  36054. length?: number;
  36055. /**
  36056. * Defines an optional offset (in seconds) inside the sound file
  36057. */
  36058. offset?: number;
  36059. /**
  36060. * If true, URLs will not be required to state the audio file codec to use.
  36061. */
  36062. skipCodecCheck?: boolean;
  36063. }
  36064. /**
  36065. * Defines a sound that can be played in the application.
  36066. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36068. */
  36069. export class Sound {
  36070. /**
  36071. * The name of the sound in the scene.
  36072. */
  36073. name: string;
  36074. /**
  36075. * Does the sound autoplay once loaded.
  36076. */
  36077. autoplay: boolean;
  36078. /**
  36079. * Does the sound loop after it finishes playing once.
  36080. */
  36081. loop: boolean;
  36082. /**
  36083. * Does the sound use a custom attenuation curve to simulate the falloff
  36084. * happening when the source gets further away from the camera.
  36085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36086. */
  36087. useCustomAttenuation: boolean;
  36088. /**
  36089. * The sound track id this sound belongs to.
  36090. */
  36091. soundTrackId: number;
  36092. /**
  36093. * Is this sound currently played.
  36094. */
  36095. isPlaying: boolean;
  36096. /**
  36097. * Is this sound currently paused.
  36098. */
  36099. isPaused: boolean;
  36100. /**
  36101. * Does this sound enables spatial sound.
  36102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36103. */
  36104. spatialSound: boolean;
  36105. /**
  36106. * Define the reference distance the sound should be heard perfectly.
  36107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36108. */
  36109. refDistance: number;
  36110. /**
  36111. * Define the roll off factor of spatial sounds.
  36112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36113. */
  36114. rolloffFactor: number;
  36115. /**
  36116. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36118. */
  36119. maxDistance: number;
  36120. /**
  36121. * Define the distance attenuation model the sound will follow.
  36122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36123. */
  36124. distanceModel: string;
  36125. /**
  36126. * @hidden
  36127. * Back Compat
  36128. **/
  36129. onended: () => any;
  36130. /**
  36131. * Observable event when the current playing sound finishes.
  36132. */
  36133. onEndedObservable: Observable<Sound>;
  36134. private _panningModel;
  36135. private _playbackRate;
  36136. private _streaming;
  36137. private _startTime;
  36138. private _startOffset;
  36139. private _position;
  36140. /** @hidden */
  36141. _positionInEmitterSpace: boolean;
  36142. private _localDirection;
  36143. private _volume;
  36144. private _isReadyToPlay;
  36145. private _isDirectional;
  36146. private _readyToPlayCallback;
  36147. private _audioBuffer;
  36148. private _soundSource;
  36149. private _streamingSource;
  36150. private _soundPanner;
  36151. private _soundGain;
  36152. private _inputAudioNode;
  36153. private _outputAudioNode;
  36154. private _coneInnerAngle;
  36155. private _coneOuterAngle;
  36156. private _coneOuterGain;
  36157. private _scene;
  36158. private _connectedTransformNode;
  36159. private _customAttenuationFunction;
  36160. private _registerFunc;
  36161. private _isOutputConnected;
  36162. private _htmlAudioElement;
  36163. private _urlType;
  36164. private _length?;
  36165. private _offset?;
  36166. /** @hidden */
  36167. static _SceneComponentInitialization: (scene: Scene) => void;
  36168. /**
  36169. * Create a sound and attach it to a scene
  36170. * @param name Name of your sound
  36171. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36172. * @param scene defines the scene the sound belongs to
  36173. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36174. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36175. */
  36176. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36177. /**
  36178. * Release the sound and its associated resources
  36179. */
  36180. dispose(): void;
  36181. /**
  36182. * Gets if the sounds is ready to be played or not.
  36183. * @returns true if ready, otherwise false
  36184. */
  36185. isReady(): boolean;
  36186. private _soundLoaded;
  36187. /**
  36188. * Sets the data of the sound from an audiobuffer
  36189. * @param audioBuffer The audioBuffer containing the data
  36190. */
  36191. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36192. /**
  36193. * Updates the current sounds options such as maxdistance, loop...
  36194. * @param options A JSON object containing values named as the object properties
  36195. */
  36196. updateOptions(options: ISoundOptions): void;
  36197. private _createSpatialParameters;
  36198. private _updateSpatialParameters;
  36199. /**
  36200. * Switch the panning model to HRTF:
  36201. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36203. */
  36204. switchPanningModelToHRTF(): void;
  36205. /**
  36206. * Switch the panning model to Equal Power:
  36207. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36209. */
  36210. switchPanningModelToEqualPower(): void;
  36211. private _switchPanningModel;
  36212. /**
  36213. * Connect this sound to a sound track audio node like gain...
  36214. * @param soundTrackAudioNode the sound track audio node to connect to
  36215. */
  36216. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36217. /**
  36218. * Transform this sound into a directional source
  36219. * @param coneInnerAngle Size of the inner cone in degree
  36220. * @param coneOuterAngle Size of the outer cone in degree
  36221. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36222. */
  36223. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36224. /**
  36225. * Gets or sets the inner angle for the directional cone.
  36226. */
  36227. /**
  36228. * Gets or sets the inner angle for the directional cone.
  36229. */
  36230. directionalConeInnerAngle: number;
  36231. /**
  36232. * Gets or sets the outer angle for the directional cone.
  36233. */
  36234. /**
  36235. * Gets or sets the outer angle for the directional cone.
  36236. */
  36237. directionalConeOuterAngle: number;
  36238. /**
  36239. * Sets the position of the emitter if spatial sound is enabled
  36240. * @param newPosition Defines the new posisiton
  36241. */
  36242. setPosition(newPosition: Vector3): void;
  36243. /**
  36244. * Sets the local direction of the emitter if spatial sound is enabled
  36245. * @param newLocalDirection Defines the new local direction
  36246. */
  36247. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36248. private _updateDirection;
  36249. /** @hidden */
  36250. updateDistanceFromListener(): void;
  36251. /**
  36252. * Sets a new custom attenuation function for the sound.
  36253. * @param callback Defines the function used for the attenuation
  36254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36255. */
  36256. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36257. /**
  36258. * Play the sound
  36259. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36260. * @param offset (optional) Start the sound at a specific time in seconds
  36261. * @param length (optional) Sound duration (in seconds)
  36262. */
  36263. play(time?: number, offset?: number, length?: number): void;
  36264. private _onended;
  36265. /**
  36266. * Stop the sound
  36267. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36268. */
  36269. stop(time?: number): void;
  36270. /**
  36271. * Put the sound in pause
  36272. */
  36273. pause(): void;
  36274. /**
  36275. * Sets a dedicated volume for this sounds
  36276. * @param newVolume Define the new volume of the sound
  36277. * @param time Define time for gradual change to new volume
  36278. */
  36279. setVolume(newVolume: number, time?: number): void;
  36280. /**
  36281. * Set the sound play back rate
  36282. * @param newPlaybackRate Define the playback rate the sound should be played at
  36283. */
  36284. setPlaybackRate(newPlaybackRate: number): void;
  36285. /**
  36286. * Gets the volume of the sound.
  36287. * @returns the volume of the sound
  36288. */
  36289. getVolume(): number;
  36290. /**
  36291. * Attach the sound to a dedicated mesh
  36292. * @param transformNode The transform node to connect the sound with
  36293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36294. */
  36295. attachToMesh(transformNode: TransformNode): void;
  36296. /**
  36297. * Detach the sound from the previously attached mesh
  36298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36299. */
  36300. detachFromMesh(): void;
  36301. private _onRegisterAfterWorldMatrixUpdate;
  36302. /**
  36303. * Clone the current sound in the scene.
  36304. * @returns the new sound clone
  36305. */
  36306. clone(): Nullable<Sound>;
  36307. /**
  36308. * Gets the current underlying audio buffer containing the data
  36309. * @returns the audio buffer
  36310. */
  36311. getAudioBuffer(): Nullable<AudioBuffer>;
  36312. /**
  36313. * Serializes the Sound in a JSON representation
  36314. * @returns the JSON representation of the sound
  36315. */
  36316. serialize(): any;
  36317. /**
  36318. * Parse a JSON representation of a sound to innstantiate in a given scene
  36319. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36320. * @param scene Define the scene the new parsed sound should be created in
  36321. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36322. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36323. * @returns the newly parsed sound
  36324. */
  36325. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36326. }
  36327. }
  36328. declare module "babylonjs/Actions/directAudioActions" {
  36329. import { Action } from "babylonjs/Actions/action";
  36330. import { Condition } from "babylonjs/Actions/condition";
  36331. import { Sound } from "babylonjs/Audio/sound";
  36332. /**
  36333. * This defines an action helpful to play a defined sound on a triggered action.
  36334. */
  36335. export class PlaySoundAction extends Action {
  36336. private _sound;
  36337. /**
  36338. * Instantiate the action
  36339. * @param triggerOptions defines the trigger options
  36340. * @param sound defines the sound to play
  36341. * @param condition defines the trigger related conditions
  36342. */
  36343. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36344. /** @hidden */
  36345. _prepare(): void;
  36346. /**
  36347. * Execute the action and play the sound.
  36348. */
  36349. execute(): void;
  36350. /**
  36351. * Serializes the actions and its related information.
  36352. * @param parent defines the object to serialize in
  36353. * @returns the serialized object
  36354. */
  36355. serialize(parent: any): any;
  36356. }
  36357. /**
  36358. * This defines an action helpful to stop a defined sound on a triggered action.
  36359. */
  36360. export class StopSoundAction extends Action {
  36361. private _sound;
  36362. /**
  36363. * Instantiate the action
  36364. * @param triggerOptions defines the trigger options
  36365. * @param sound defines the sound to stop
  36366. * @param condition defines the trigger related conditions
  36367. */
  36368. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36369. /** @hidden */
  36370. _prepare(): void;
  36371. /**
  36372. * Execute the action and stop the sound.
  36373. */
  36374. execute(): void;
  36375. /**
  36376. * Serializes the actions and its related information.
  36377. * @param parent defines the object to serialize in
  36378. * @returns the serialized object
  36379. */
  36380. serialize(parent: any): any;
  36381. }
  36382. }
  36383. declare module "babylonjs/Actions/interpolateValueAction" {
  36384. import { Action } from "babylonjs/Actions/action";
  36385. import { Condition } from "babylonjs/Actions/condition";
  36386. import { Observable } from "babylonjs/Misc/observable";
  36387. /**
  36388. * This defines an action responsible to change the value of a property
  36389. * by interpolating between its current value and the newly set one once triggered.
  36390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36391. */
  36392. export class InterpolateValueAction extends Action {
  36393. /**
  36394. * Defines the path of the property where the value should be interpolated
  36395. */
  36396. propertyPath: string;
  36397. /**
  36398. * Defines the target value at the end of the interpolation.
  36399. */
  36400. value: any;
  36401. /**
  36402. * Defines the time it will take for the property to interpolate to the value.
  36403. */
  36404. duration: number;
  36405. /**
  36406. * Defines if the other scene animations should be stopped when the action has been triggered
  36407. */
  36408. stopOtherAnimations?: boolean;
  36409. /**
  36410. * Defines a callback raised once the interpolation animation has been done.
  36411. */
  36412. onInterpolationDone?: () => void;
  36413. /**
  36414. * Observable triggered once the interpolation animation has been done.
  36415. */
  36416. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36417. private _target;
  36418. private _effectiveTarget;
  36419. private _property;
  36420. /**
  36421. * Instantiate the action
  36422. * @param triggerOptions defines the trigger options
  36423. * @param target defines the object containing the value to interpolate
  36424. * @param propertyPath defines the path to the property in the target object
  36425. * @param value defines the target value at the end of the interpolation
  36426. * @param duration deines the time it will take for the property to interpolate to the value.
  36427. * @param condition defines the trigger related conditions
  36428. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36429. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36430. */
  36431. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36432. /** @hidden */
  36433. _prepare(): void;
  36434. /**
  36435. * Execute the action starts the value interpolation.
  36436. */
  36437. execute(): void;
  36438. /**
  36439. * Serializes the actions and its related information.
  36440. * @param parent defines the object to serialize in
  36441. * @returns the serialized object
  36442. */
  36443. serialize(parent: any): any;
  36444. }
  36445. }
  36446. declare module "babylonjs/Actions/index" {
  36447. export * from "babylonjs/Actions/abstractActionManager";
  36448. export * from "babylonjs/Actions/action";
  36449. export * from "babylonjs/Actions/actionEvent";
  36450. export * from "babylonjs/Actions/actionManager";
  36451. export * from "babylonjs/Actions/condition";
  36452. export * from "babylonjs/Actions/directActions";
  36453. export * from "babylonjs/Actions/directAudioActions";
  36454. export * from "babylonjs/Actions/interpolateValueAction";
  36455. }
  36456. declare module "babylonjs/Animations/index" {
  36457. export * from "babylonjs/Animations/animatable";
  36458. export * from "babylonjs/Animations/animation";
  36459. export * from "babylonjs/Animations/animationGroup";
  36460. export * from "babylonjs/Animations/animationPropertiesOverride";
  36461. export * from "babylonjs/Animations/easing";
  36462. export * from "babylonjs/Animations/runtimeAnimation";
  36463. export * from "babylonjs/Animations/animationEvent";
  36464. export * from "babylonjs/Animations/animationGroup";
  36465. export * from "babylonjs/Animations/animationKey";
  36466. export * from "babylonjs/Animations/animationRange";
  36467. export * from "babylonjs/Animations/animatable.interface";
  36468. }
  36469. declare module "babylonjs/Audio/soundTrack" {
  36470. import { Sound } from "babylonjs/Audio/sound";
  36471. import { Analyser } from "babylonjs/Audio/analyser";
  36472. import { Scene } from "babylonjs/scene";
  36473. /**
  36474. * Options allowed during the creation of a sound track.
  36475. */
  36476. export interface ISoundTrackOptions {
  36477. /**
  36478. * The volume the sound track should take during creation
  36479. */
  36480. volume?: number;
  36481. /**
  36482. * Define if the sound track is the main sound track of the scene
  36483. */
  36484. mainTrack?: boolean;
  36485. }
  36486. /**
  36487. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36488. * It will be also used in a future release to apply effects on a specific track.
  36489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36490. */
  36491. export class SoundTrack {
  36492. /**
  36493. * The unique identifier of the sound track in the scene.
  36494. */
  36495. id: number;
  36496. /**
  36497. * The list of sounds included in the sound track.
  36498. */
  36499. soundCollection: Array<Sound>;
  36500. private _outputAudioNode;
  36501. private _scene;
  36502. private _isMainTrack;
  36503. private _connectedAnalyser;
  36504. private _options;
  36505. private _isInitialized;
  36506. /**
  36507. * Creates a new sound track.
  36508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36509. * @param scene Define the scene the sound track belongs to
  36510. * @param options
  36511. */
  36512. constructor(scene: Scene, options?: ISoundTrackOptions);
  36513. private _initializeSoundTrackAudioGraph;
  36514. /**
  36515. * Release the sound track and its associated resources
  36516. */
  36517. dispose(): void;
  36518. /**
  36519. * Adds a sound to this sound track
  36520. * @param sound define the cound to add
  36521. * @ignoreNaming
  36522. */
  36523. AddSound(sound: Sound): void;
  36524. /**
  36525. * Removes a sound to this sound track
  36526. * @param sound define the cound to remove
  36527. * @ignoreNaming
  36528. */
  36529. RemoveSound(sound: Sound): void;
  36530. /**
  36531. * Set a global volume for the full sound track.
  36532. * @param newVolume Define the new volume of the sound track
  36533. */
  36534. setVolume(newVolume: number): void;
  36535. /**
  36536. * Switch the panning model to HRTF:
  36537. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36539. */
  36540. switchPanningModelToHRTF(): void;
  36541. /**
  36542. * Switch the panning model to Equal Power:
  36543. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36545. */
  36546. switchPanningModelToEqualPower(): void;
  36547. /**
  36548. * Connect the sound track to an audio analyser allowing some amazing
  36549. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36551. * @param analyser The analyser to connect to the engine
  36552. */
  36553. connectToAnalyser(analyser: Analyser): void;
  36554. }
  36555. }
  36556. declare module "babylonjs/Audio/audioSceneComponent" {
  36557. import { Sound } from "babylonjs/Audio/sound";
  36558. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36559. import { Nullable } from "babylonjs/types";
  36560. import { Vector3 } from "babylonjs/Maths/math.vector";
  36561. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36562. import { Scene } from "babylonjs/scene";
  36563. import { AbstractScene } from "babylonjs/abstractScene";
  36564. import "babylonjs/Audio/audioEngine";
  36565. module "babylonjs/abstractScene" {
  36566. interface AbstractScene {
  36567. /**
  36568. * The list of sounds used in the scene.
  36569. */
  36570. sounds: Nullable<Array<Sound>>;
  36571. }
  36572. }
  36573. module "babylonjs/scene" {
  36574. interface Scene {
  36575. /**
  36576. * @hidden
  36577. * Backing field
  36578. */
  36579. _mainSoundTrack: SoundTrack;
  36580. /**
  36581. * The main sound track played by the scene.
  36582. * It cotains your primary collection of sounds.
  36583. */
  36584. mainSoundTrack: SoundTrack;
  36585. /**
  36586. * The list of sound tracks added to the scene
  36587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36588. */
  36589. soundTracks: Nullable<Array<SoundTrack>>;
  36590. /**
  36591. * Gets a sound using a given name
  36592. * @param name defines the name to search for
  36593. * @return the found sound or null if not found at all.
  36594. */
  36595. getSoundByName(name: string): Nullable<Sound>;
  36596. /**
  36597. * Gets or sets if audio support is enabled
  36598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36599. */
  36600. audioEnabled: boolean;
  36601. /**
  36602. * Gets or sets if audio will be output to headphones
  36603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36604. */
  36605. headphone: boolean;
  36606. /**
  36607. * Gets or sets custom audio listener position provider
  36608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36609. */
  36610. audioListenerPositionProvider: Nullable<() => Vector3>;
  36611. }
  36612. }
  36613. /**
  36614. * Defines the sound scene component responsible to manage any sounds
  36615. * in a given scene.
  36616. */
  36617. export class AudioSceneComponent implements ISceneSerializableComponent {
  36618. /**
  36619. * The component name helpfull to identify the component in the list of scene components.
  36620. */
  36621. readonly name: string;
  36622. /**
  36623. * The scene the component belongs to.
  36624. */
  36625. scene: Scene;
  36626. private _audioEnabled;
  36627. /**
  36628. * Gets whether audio is enabled or not.
  36629. * Please use related enable/disable method to switch state.
  36630. */
  36631. readonly audioEnabled: boolean;
  36632. private _headphone;
  36633. /**
  36634. * Gets whether audio is outputing to headphone or not.
  36635. * Please use the according Switch methods to change output.
  36636. */
  36637. readonly headphone: boolean;
  36638. private _audioListenerPositionProvider;
  36639. /**
  36640. * Gets the current audio listener position provider
  36641. */
  36642. /**
  36643. * Sets a custom listener position for all sounds in the scene
  36644. * By default, this is the position of the first active camera
  36645. */
  36646. audioListenerPositionProvider: Nullable<() => Vector3>;
  36647. /**
  36648. * Creates a new instance of the component for the given scene
  36649. * @param scene Defines the scene to register the component in
  36650. */
  36651. constructor(scene: Scene);
  36652. /**
  36653. * Registers the component in a given scene
  36654. */
  36655. register(): void;
  36656. /**
  36657. * Rebuilds the elements related to this component in case of
  36658. * context lost for instance.
  36659. */
  36660. rebuild(): void;
  36661. /**
  36662. * Serializes the component data to the specified json object
  36663. * @param serializationObject The object to serialize to
  36664. */
  36665. serialize(serializationObject: any): void;
  36666. /**
  36667. * Adds all the elements from the container to the scene
  36668. * @param container the container holding the elements
  36669. */
  36670. addFromContainer(container: AbstractScene): void;
  36671. /**
  36672. * Removes all the elements in the container from the scene
  36673. * @param container contains the elements to remove
  36674. * @param dispose if the removed element should be disposed (default: false)
  36675. */
  36676. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36677. /**
  36678. * Disposes the component and the associated ressources.
  36679. */
  36680. dispose(): void;
  36681. /**
  36682. * Disables audio in the associated scene.
  36683. */
  36684. disableAudio(): void;
  36685. /**
  36686. * Enables audio in the associated scene.
  36687. */
  36688. enableAudio(): void;
  36689. /**
  36690. * Switch audio to headphone output.
  36691. */
  36692. switchAudioModeForHeadphones(): void;
  36693. /**
  36694. * Switch audio to normal speakers.
  36695. */
  36696. switchAudioModeForNormalSpeakers(): void;
  36697. private _afterRender;
  36698. }
  36699. }
  36700. declare module "babylonjs/Audio/weightedsound" {
  36701. import { Sound } from "babylonjs/Audio/sound";
  36702. /**
  36703. * Wraps one or more Sound objects and selects one with random weight for playback.
  36704. */
  36705. export class WeightedSound {
  36706. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36707. loop: boolean;
  36708. private _coneInnerAngle;
  36709. private _coneOuterAngle;
  36710. private _volume;
  36711. /** A Sound is currently playing. */
  36712. isPlaying: boolean;
  36713. /** A Sound is currently paused. */
  36714. isPaused: boolean;
  36715. private _sounds;
  36716. private _weights;
  36717. private _currentIndex?;
  36718. /**
  36719. * Creates a new WeightedSound from the list of sounds given.
  36720. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36721. * @param sounds Array of Sounds that will be selected from.
  36722. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36723. */
  36724. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36725. /**
  36726. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36727. */
  36728. /**
  36729. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36730. */
  36731. directionalConeInnerAngle: number;
  36732. /**
  36733. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36734. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36735. */
  36736. /**
  36737. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36738. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36739. */
  36740. directionalConeOuterAngle: number;
  36741. /**
  36742. * Playback volume.
  36743. */
  36744. /**
  36745. * Playback volume.
  36746. */
  36747. volume: number;
  36748. private _onended;
  36749. /**
  36750. * Suspend playback
  36751. */
  36752. pause(): void;
  36753. /**
  36754. * Stop playback
  36755. */
  36756. stop(): void;
  36757. /**
  36758. * Start playback.
  36759. * @param startOffset Position the clip head at a specific time in seconds.
  36760. */
  36761. play(startOffset?: number): void;
  36762. }
  36763. }
  36764. declare module "babylonjs/Audio/index" {
  36765. export * from "babylonjs/Audio/analyser";
  36766. export * from "babylonjs/Audio/audioEngine";
  36767. export * from "babylonjs/Audio/audioSceneComponent";
  36768. export * from "babylonjs/Audio/sound";
  36769. export * from "babylonjs/Audio/soundTrack";
  36770. export * from "babylonjs/Audio/weightedsound";
  36771. }
  36772. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36773. import { Behavior } from "babylonjs/Behaviors/behavior";
  36774. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36775. import { BackEase } from "babylonjs/Animations/easing";
  36776. /**
  36777. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36778. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36779. */
  36780. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36781. /**
  36782. * Gets the name of the behavior.
  36783. */
  36784. readonly name: string;
  36785. /**
  36786. * The easing function used by animations
  36787. */
  36788. static EasingFunction: BackEase;
  36789. /**
  36790. * The easing mode used by animations
  36791. */
  36792. static EasingMode: number;
  36793. /**
  36794. * The duration of the animation, in milliseconds
  36795. */
  36796. transitionDuration: number;
  36797. /**
  36798. * Length of the distance animated by the transition when lower radius is reached
  36799. */
  36800. lowerRadiusTransitionRange: number;
  36801. /**
  36802. * Length of the distance animated by the transition when upper radius is reached
  36803. */
  36804. upperRadiusTransitionRange: number;
  36805. private _autoTransitionRange;
  36806. /**
  36807. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36808. */
  36809. /**
  36810. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36811. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36812. */
  36813. autoTransitionRange: boolean;
  36814. private _attachedCamera;
  36815. private _onAfterCheckInputsObserver;
  36816. private _onMeshTargetChangedObserver;
  36817. /**
  36818. * Initializes the behavior.
  36819. */
  36820. init(): void;
  36821. /**
  36822. * Attaches the behavior to its arc rotate camera.
  36823. * @param camera Defines the camera to attach the behavior to
  36824. */
  36825. attach(camera: ArcRotateCamera): void;
  36826. /**
  36827. * Detaches the behavior from its current arc rotate camera.
  36828. */
  36829. detach(): void;
  36830. private _radiusIsAnimating;
  36831. private _radiusBounceTransition;
  36832. private _animatables;
  36833. private _cachedWheelPrecision;
  36834. /**
  36835. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36836. * @param radiusLimit The limit to check against.
  36837. * @return Bool to indicate if at limit.
  36838. */
  36839. private _isRadiusAtLimit;
  36840. /**
  36841. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36842. * @param radiusDelta The delta by which to animate to. Can be negative.
  36843. */
  36844. private _applyBoundRadiusAnimation;
  36845. /**
  36846. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36847. */
  36848. protected _clearAnimationLocks(): void;
  36849. /**
  36850. * Stops and removes all animations that have been applied to the camera
  36851. */
  36852. stopAllAnimations(): void;
  36853. }
  36854. }
  36855. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36856. import { Behavior } from "babylonjs/Behaviors/behavior";
  36857. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36858. import { ExponentialEase } from "babylonjs/Animations/easing";
  36859. import { Nullable } from "babylonjs/types";
  36860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36861. import { Vector3 } from "babylonjs/Maths/math.vector";
  36862. /**
  36863. * 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.
  36864. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36865. */
  36866. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36867. /**
  36868. * Gets the name of the behavior.
  36869. */
  36870. readonly name: string;
  36871. private _mode;
  36872. private _radiusScale;
  36873. private _positionScale;
  36874. private _defaultElevation;
  36875. private _elevationReturnTime;
  36876. private _elevationReturnWaitTime;
  36877. private _zoomStopsAnimation;
  36878. private _framingTime;
  36879. /**
  36880. * The easing function used by animations
  36881. */
  36882. static EasingFunction: ExponentialEase;
  36883. /**
  36884. * The easing mode used by animations
  36885. */
  36886. static EasingMode: number;
  36887. /**
  36888. * Sets the current mode used by the behavior
  36889. */
  36890. /**
  36891. * Gets current mode used by the behavior.
  36892. */
  36893. mode: number;
  36894. /**
  36895. * Sets the scale applied to the radius (1 by default)
  36896. */
  36897. /**
  36898. * Gets the scale applied to the radius
  36899. */
  36900. radiusScale: number;
  36901. /**
  36902. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36903. */
  36904. /**
  36905. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36906. */
  36907. positionScale: number;
  36908. /**
  36909. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36910. * behaviour is triggered, in radians.
  36911. */
  36912. /**
  36913. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36914. * behaviour is triggered, in radians.
  36915. */
  36916. defaultElevation: number;
  36917. /**
  36918. * Sets the time (in milliseconds) taken to return to the default beta position.
  36919. * Negative value indicates camera should not return to default.
  36920. */
  36921. /**
  36922. * Gets the time (in milliseconds) taken to return to the default beta position.
  36923. * Negative value indicates camera should not return to default.
  36924. */
  36925. elevationReturnTime: number;
  36926. /**
  36927. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36928. */
  36929. /**
  36930. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36931. */
  36932. elevationReturnWaitTime: number;
  36933. /**
  36934. * Sets the flag that indicates if user zooming should stop animation.
  36935. */
  36936. /**
  36937. * Gets the flag that indicates if user zooming should stop animation.
  36938. */
  36939. zoomStopsAnimation: boolean;
  36940. /**
  36941. * Sets the transition time when framing the mesh, in milliseconds
  36942. */
  36943. /**
  36944. * Gets the transition time when framing the mesh, in milliseconds
  36945. */
  36946. framingTime: number;
  36947. /**
  36948. * Define if the behavior should automatically change the configured
  36949. * camera limits and sensibilities.
  36950. */
  36951. autoCorrectCameraLimitsAndSensibility: boolean;
  36952. private _onPrePointerObservableObserver;
  36953. private _onAfterCheckInputsObserver;
  36954. private _onMeshTargetChangedObserver;
  36955. private _attachedCamera;
  36956. private _isPointerDown;
  36957. private _lastInteractionTime;
  36958. /**
  36959. * Initializes the behavior.
  36960. */
  36961. init(): void;
  36962. /**
  36963. * Attaches the behavior to its arc rotate camera.
  36964. * @param camera Defines the camera to attach the behavior to
  36965. */
  36966. attach(camera: ArcRotateCamera): void;
  36967. /**
  36968. * Detaches the behavior from its current arc rotate camera.
  36969. */
  36970. detach(): void;
  36971. private _animatables;
  36972. private _betaIsAnimating;
  36973. private _betaTransition;
  36974. private _radiusTransition;
  36975. private _vectorTransition;
  36976. /**
  36977. * Targets the given mesh and updates zoom level accordingly.
  36978. * @param mesh The mesh to target.
  36979. * @param radius Optional. If a cached radius position already exists, overrides default.
  36980. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36981. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36982. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36983. */
  36984. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36985. /**
  36986. * Targets the given mesh with its children and updates zoom level accordingly.
  36987. * @param mesh The mesh to target.
  36988. * @param radius Optional. If a cached radius position already exists, overrides default.
  36989. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36990. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36991. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36992. */
  36993. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36994. /**
  36995. * Targets the given meshes with their children and updates zoom level accordingly.
  36996. * @param meshes The mesh to target.
  36997. * @param radius Optional. If a cached radius position already exists, overrides default.
  36998. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36999. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37000. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37001. */
  37002. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37003. /**
  37004. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37005. * @param minimumWorld Determines the smaller position of the bounding box extend
  37006. * @param maximumWorld Determines the bigger position of the bounding box extend
  37007. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37008. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37009. */
  37010. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37011. /**
  37012. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37013. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37014. * frustum width.
  37015. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37016. * to fully enclose the mesh in the viewing frustum.
  37017. */
  37018. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37019. /**
  37020. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37021. * is automatically returned to its default position (expected to be above ground plane).
  37022. */
  37023. private _maintainCameraAboveGround;
  37024. /**
  37025. * Returns the frustum slope based on the canvas ratio and camera FOV
  37026. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37027. */
  37028. private _getFrustumSlope;
  37029. /**
  37030. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37031. */
  37032. private _clearAnimationLocks;
  37033. /**
  37034. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37035. */
  37036. private _applyUserInteraction;
  37037. /**
  37038. * Stops and removes all animations that have been applied to the camera
  37039. */
  37040. stopAllAnimations(): void;
  37041. /**
  37042. * Gets a value indicating if the user is moving the camera
  37043. */
  37044. readonly isUserIsMoving: boolean;
  37045. /**
  37046. * The camera can move all the way towards the mesh.
  37047. */
  37048. static IgnoreBoundsSizeMode: number;
  37049. /**
  37050. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37051. */
  37052. static FitFrustumSidesMode: number;
  37053. }
  37054. }
  37055. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37056. import { Nullable } from "babylonjs/types";
  37057. import { Camera } from "babylonjs/Cameras/camera";
  37058. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37059. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37060. /**
  37061. * Base class for Camera Pointer Inputs.
  37062. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37063. * for example usage.
  37064. */
  37065. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37066. /**
  37067. * Defines the camera the input is attached to.
  37068. */
  37069. abstract camera: Camera;
  37070. /**
  37071. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37072. */
  37073. protected _altKey: boolean;
  37074. protected _ctrlKey: boolean;
  37075. protected _metaKey: boolean;
  37076. protected _shiftKey: boolean;
  37077. /**
  37078. * Which mouse buttons were pressed at time of last mouse event.
  37079. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37080. */
  37081. protected _buttonsPressed: number;
  37082. /**
  37083. * Defines the buttons associated with the input to handle camera move.
  37084. */
  37085. buttons: number[];
  37086. /**
  37087. * Attach the input controls to a specific dom element to get the input from.
  37088. * @param element Defines the element the controls should be listened from
  37089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37090. */
  37091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37092. /**
  37093. * Detach the current controls from the specified dom element.
  37094. * @param element Defines the element to stop listening the inputs from
  37095. */
  37096. detachControl(element: Nullable<HTMLElement>): void;
  37097. /**
  37098. * Gets the class name of the current input.
  37099. * @returns the class name
  37100. */
  37101. getClassName(): string;
  37102. /**
  37103. * Get the friendly name associated with the input class.
  37104. * @returns the input friendly name
  37105. */
  37106. getSimpleName(): string;
  37107. /**
  37108. * Called on pointer POINTERDOUBLETAP event.
  37109. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37110. */
  37111. protected onDoubleTap(type: string): void;
  37112. /**
  37113. * Called on pointer POINTERMOVE event if only a single touch is active.
  37114. * Override this method to provide functionality.
  37115. */
  37116. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37117. /**
  37118. * Called on pointer POINTERMOVE event if multiple touches are active.
  37119. * Override this method to provide functionality.
  37120. */
  37121. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37122. /**
  37123. * Called on JS contextmenu event.
  37124. * Override this method to provide functionality.
  37125. */
  37126. protected onContextMenu(evt: PointerEvent): void;
  37127. /**
  37128. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37129. * press.
  37130. * Override this method to provide functionality.
  37131. */
  37132. protected onButtonDown(evt: PointerEvent): void;
  37133. /**
  37134. * Called each time a new POINTERUP event occurs. Ie, for each button
  37135. * release.
  37136. * Override this method to provide functionality.
  37137. */
  37138. protected onButtonUp(evt: PointerEvent): void;
  37139. /**
  37140. * Called when window becomes inactive.
  37141. * Override this method to provide functionality.
  37142. */
  37143. protected onLostFocus(): void;
  37144. private _pointerInput;
  37145. private _observer;
  37146. private _onLostFocus;
  37147. private pointA;
  37148. private pointB;
  37149. }
  37150. }
  37151. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37152. import { Nullable } from "babylonjs/types";
  37153. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37154. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37155. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37156. /**
  37157. * Manage the pointers inputs to control an arc rotate camera.
  37158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37159. */
  37160. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37161. /**
  37162. * Defines the camera the input is attached to.
  37163. */
  37164. camera: ArcRotateCamera;
  37165. /**
  37166. * Gets the class name of the current input.
  37167. * @returns the class name
  37168. */
  37169. getClassName(): string;
  37170. /**
  37171. * Defines the buttons associated with the input to handle camera move.
  37172. */
  37173. buttons: number[];
  37174. /**
  37175. * Defines the pointer angular sensibility along the X axis or how fast is
  37176. * the camera rotating.
  37177. */
  37178. angularSensibilityX: number;
  37179. /**
  37180. * Defines the pointer angular sensibility along the Y axis or how fast is
  37181. * the camera rotating.
  37182. */
  37183. angularSensibilityY: number;
  37184. /**
  37185. * Defines the pointer pinch precision or how fast is the camera zooming.
  37186. */
  37187. pinchPrecision: number;
  37188. /**
  37189. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37190. * from 0.
  37191. * It defines the percentage of current camera.radius to use as delta when
  37192. * pinch zoom is used.
  37193. */
  37194. pinchDeltaPercentage: number;
  37195. /**
  37196. * Defines the pointer panning sensibility or how fast is the camera moving.
  37197. */
  37198. panningSensibility: number;
  37199. /**
  37200. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37201. */
  37202. multiTouchPanning: boolean;
  37203. /**
  37204. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37205. * zoom (pinch) through multitouch.
  37206. */
  37207. multiTouchPanAndZoom: boolean;
  37208. /**
  37209. * Revers pinch action direction.
  37210. */
  37211. pinchInwards: boolean;
  37212. private _isPanClick;
  37213. private _twoFingerActivityCount;
  37214. private _isPinching;
  37215. /**
  37216. * Called on pointer POINTERMOVE event if only a single touch is active.
  37217. */
  37218. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37219. /**
  37220. * Called on pointer POINTERDOUBLETAP event.
  37221. */
  37222. protected onDoubleTap(type: string): void;
  37223. /**
  37224. * Called on pointer POINTERMOVE event if multiple touches are active.
  37225. */
  37226. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37227. /**
  37228. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37229. * press.
  37230. */
  37231. protected onButtonDown(evt: PointerEvent): void;
  37232. /**
  37233. * Called each time a new POINTERUP event occurs. Ie, for each button
  37234. * release.
  37235. */
  37236. protected onButtonUp(evt: PointerEvent): void;
  37237. /**
  37238. * Called when window becomes inactive.
  37239. */
  37240. protected onLostFocus(): void;
  37241. }
  37242. }
  37243. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37244. import { Nullable } from "babylonjs/types";
  37245. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37246. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37247. /**
  37248. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37250. */
  37251. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37252. /**
  37253. * Defines the camera the input is attached to.
  37254. */
  37255. camera: ArcRotateCamera;
  37256. /**
  37257. * Defines the list of key codes associated with the up action (increase alpha)
  37258. */
  37259. keysUp: number[];
  37260. /**
  37261. * Defines the list of key codes associated with the down action (decrease alpha)
  37262. */
  37263. keysDown: number[];
  37264. /**
  37265. * Defines the list of key codes associated with the left action (increase beta)
  37266. */
  37267. keysLeft: number[];
  37268. /**
  37269. * Defines the list of key codes associated with the right action (decrease beta)
  37270. */
  37271. keysRight: number[];
  37272. /**
  37273. * Defines the list of key codes associated with the reset action.
  37274. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37275. */
  37276. keysReset: number[];
  37277. /**
  37278. * Defines the panning sensibility of the inputs.
  37279. * (How fast is the camera paning)
  37280. */
  37281. panningSensibility: number;
  37282. /**
  37283. * Defines the zooming sensibility of the inputs.
  37284. * (How fast is the camera zooming)
  37285. */
  37286. zoomingSensibility: number;
  37287. /**
  37288. * Defines wether maintaining the alt key down switch the movement mode from
  37289. * orientation to zoom.
  37290. */
  37291. useAltToZoom: boolean;
  37292. /**
  37293. * Rotation speed of the camera
  37294. */
  37295. angularSpeed: number;
  37296. private _keys;
  37297. private _ctrlPressed;
  37298. private _altPressed;
  37299. private _onCanvasBlurObserver;
  37300. private _onKeyboardObserver;
  37301. private _engine;
  37302. private _scene;
  37303. /**
  37304. * Attach the input controls to a specific dom element to get the input from.
  37305. * @param element Defines the element the controls should be listened from
  37306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37307. */
  37308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37309. /**
  37310. * Detach the current controls from the specified dom element.
  37311. * @param element Defines the element to stop listening the inputs from
  37312. */
  37313. detachControl(element: Nullable<HTMLElement>): void;
  37314. /**
  37315. * Update the current camera state depending on the inputs that have been used this frame.
  37316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37317. */
  37318. checkInputs(): void;
  37319. /**
  37320. * Gets the class name of the current intput.
  37321. * @returns the class name
  37322. */
  37323. getClassName(): string;
  37324. /**
  37325. * Get the friendly name associated with the input class.
  37326. * @returns the input friendly name
  37327. */
  37328. getSimpleName(): string;
  37329. }
  37330. }
  37331. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37332. import { Nullable } from "babylonjs/types";
  37333. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37334. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37335. /**
  37336. * Manage the mouse wheel inputs to control an arc rotate camera.
  37337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37338. */
  37339. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37340. /**
  37341. * Defines the camera the input is attached to.
  37342. */
  37343. camera: ArcRotateCamera;
  37344. /**
  37345. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37346. */
  37347. wheelPrecision: number;
  37348. /**
  37349. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37350. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37351. */
  37352. wheelDeltaPercentage: number;
  37353. private _wheel;
  37354. private _observer;
  37355. private computeDeltaFromMouseWheelLegacyEvent;
  37356. /**
  37357. * Attach the input controls to a specific dom element to get the input from.
  37358. * @param element Defines the element the controls should be listened from
  37359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37360. */
  37361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37362. /**
  37363. * Detach the current controls from the specified dom element.
  37364. * @param element Defines the element to stop listening the inputs from
  37365. */
  37366. detachControl(element: Nullable<HTMLElement>): void;
  37367. /**
  37368. * Gets the class name of the current intput.
  37369. * @returns the class name
  37370. */
  37371. getClassName(): string;
  37372. /**
  37373. * Get the friendly name associated with the input class.
  37374. * @returns the input friendly name
  37375. */
  37376. getSimpleName(): string;
  37377. }
  37378. }
  37379. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37380. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37381. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37382. /**
  37383. * Default Inputs manager for the ArcRotateCamera.
  37384. * It groups all the default supported inputs for ease of use.
  37385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37386. */
  37387. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37388. /**
  37389. * Instantiates a new ArcRotateCameraInputsManager.
  37390. * @param camera Defines the camera the inputs belong to
  37391. */
  37392. constructor(camera: ArcRotateCamera);
  37393. /**
  37394. * Add mouse wheel input support to the input manager.
  37395. * @returns the current input manager
  37396. */
  37397. addMouseWheel(): ArcRotateCameraInputsManager;
  37398. /**
  37399. * Add pointers input support to the input manager.
  37400. * @returns the current input manager
  37401. */
  37402. addPointers(): ArcRotateCameraInputsManager;
  37403. /**
  37404. * Add keyboard input support to the input manager.
  37405. * @returns the current input manager
  37406. */
  37407. addKeyboard(): ArcRotateCameraInputsManager;
  37408. }
  37409. }
  37410. declare module "babylonjs/Cameras/arcRotateCamera" {
  37411. import { Observable } from "babylonjs/Misc/observable";
  37412. import { Nullable } from "babylonjs/types";
  37413. import { Scene } from "babylonjs/scene";
  37414. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37416. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37417. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37418. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37419. import { Camera } from "babylonjs/Cameras/camera";
  37420. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37421. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37422. import { Collider } from "babylonjs/Collisions/collider";
  37423. /**
  37424. * This represents an orbital type of camera.
  37425. *
  37426. * 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.
  37427. * 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.
  37428. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37429. */
  37430. export class ArcRotateCamera extends TargetCamera {
  37431. /**
  37432. * Defines the rotation angle of the camera along the longitudinal axis.
  37433. */
  37434. alpha: number;
  37435. /**
  37436. * Defines the rotation angle of the camera along the latitudinal axis.
  37437. */
  37438. beta: number;
  37439. /**
  37440. * Defines the radius of the camera from it s target point.
  37441. */
  37442. radius: number;
  37443. protected _target: Vector3;
  37444. protected _targetHost: Nullable<AbstractMesh>;
  37445. /**
  37446. * Defines the target point of the camera.
  37447. * The camera looks towards it form the radius distance.
  37448. */
  37449. target: Vector3;
  37450. /**
  37451. * Define the current local position of the camera in the scene
  37452. */
  37453. position: Vector3;
  37454. protected _upVector: Vector3;
  37455. protected _upToYMatrix: Matrix;
  37456. protected _YToUpMatrix: Matrix;
  37457. /**
  37458. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37459. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37460. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37461. */
  37462. upVector: Vector3;
  37463. /**
  37464. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37465. */
  37466. setMatUp(): void;
  37467. /**
  37468. * Current inertia value on the longitudinal axis.
  37469. * The bigger this number the longer it will take for the camera to stop.
  37470. */
  37471. inertialAlphaOffset: number;
  37472. /**
  37473. * Current inertia value on the latitudinal axis.
  37474. * The bigger this number the longer it will take for the camera to stop.
  37475. */
  37476. inertialBetaOffset: number;
  37477. /**
  37478. * Current inertia value on the radius axis.
  37479. * The bigger this number the longer it will take for the camera to stop.
  37480. */
  37481. inertialRadiusOffset: number;
  37482. /**
  37483. * Minimum allowed angle on the longitudinal axis.
  37484. * This can help limiting how the Camera is able to move in the scene.
  37485. */
  37486. lowerAlphaLimit: Nullable<number>;
  37487. /**
  37488. * Maximum allowed angle on the longitudinal axis.
  37489. * This can help limiting how the Camera is able to move in the scene.
  37490. */
  37491. upperAlphaLimit: Nullable<number>;
  37492. /**
  37493. * Minimum allowed angle on the latitudinal axis.
  37494. * This can help limiting how the Camera is able to move in the scene.
  37495. */
  37496. lowerBetaLimit: number;
  37497. /**
  37498. * Maximum allowed angle on the latitudinal axis.
  37499. * This can help limiting how the Camera is able to move in the scene.
  37500. */
  37501. upperBetaLimit: number;
  37502. /**
  37503. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37504. * This can help limiting how the Camera is able to move in the scene.
  37505. */
  37506. lowerRadiusLimit: Nullable<number>;
  37507. /**
  37508. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37509. * This can help limiting how the Camera is able to move in the scene.
  37510. */
  37511. upperRadiusLimit: Nullable<number>;
  37512. /**
  37513. * Defines the current inertia value used during panning of the camera along the X axis.
  37514. */
  37515. inertialPanningX: number;
  37516. /**
  37517. * Defines the current inertia value used during panning of the camera along the Y axis.
  37518. */
  37519. inertialPanningY: number;
  37520. /**
  37521. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37522. * Basically if your fingers moves away from more than this distance you will be considered
  37523. * in pinch mode.
  37524. */
  37525. pinchToPanMaxDistance: number;
  37526. /**
  37527. * Defines the maximum distance the camera can pan.
  37528. * This could help keeping the cammera always in your scene.
  37529. */
  37530. panningDistanceLimit: Nullable<number>;
  37531. /**
  37532. * Defines the target of the camera before paning.
  37533. */
  37534. panningOriginTarget: Vector3;
  37535. /**
  37536. * Defines the value of the inertia used during panning.
  37537. * 0 would mean stop inertia and one would mean no decelleration at all.
  37538. */
  37539. panningInertia: number;
  37540. /**
  37541. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37542. */
  37543. angularSensibilityX: number;
  37544. /**
  37545. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37546. */
  37547. angularSensibilityY: number;
  37548. /**
  37549. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37550. */
  37551. pinchPrecision: number;
  37552. /**
  37553. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37554. * It will be used instead of pinchDeltaPrecision if different from 0.
  37555. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37556. */
  37557. pinchDeltaPercentage: number;
  37558. /**
  37559. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37560. */
  37561. panningSensibility: number;
  37562. /**
  37563. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37564. */
  37565. keysUp: number[];
  37566. /**
  37567. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37568. */
  37569. keysDown: number[];
  37570. /**
  37571. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37572. */
  37573. keysLeft: number[];
  37574. /**
  37575. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37576. */
  37577. keysRight: number[];
  37578. /**
  37579. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37580. */
  37581. wheelPrecision: number;
  37582. /**
  37583. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37584. * It will be used instead of pinchDeltaPrecision if different from 0.
  37585. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37586. */
  37587. wheelDeltaPercentage: number;
  37588. /**
  37589. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37590. */
  37591. zoomOnFactor: number;
  37592. /**
  37593. * Defines a screen offset for the camera position.
  37594. */
  37595. targetScreenOffset: Vector2;
  37596. /**
  37597. * Allows the camera to be completely reversed.
  37598. * If false the camera can not arrive upside down.
  37599. */
  37600. allowUpsideDown: boolean;
  37601. /**
  37602. * Define if double tap/click is used to restore the previously saved state of the camera.
  37603. */
  37604. useInputToRestoreState: boolean;
  37605. /** @hidden */
  37606. _viewMatrix: Matrix;
  37607. /** @hidden */
  37608. _useCtrlForPanning: boolean;
  37609. /** @hidden */
  37610. _panningMouseButton: number;
  37611. /**
  37612. * Defines the input associated to the camera.
  37613. */
  37614. inputs: ArcRotateCameraInputsManager;
  37615. /** @hidden */
  37616. _reset: () => void;
  37617. /**
  37618. * Defines the allowed panning axis.
  37619. */
  37620. panningAxis: Vector3;
  37621. protected _localDirection: Vector3;
  37622. protected _transformedDirection: Vector3;
  37623. private _bouncingBehavior;
  37624. /**
  37625. * Gets the bouncing behavior of the camera if it has been enabled.
  37626. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37627. */
  37628. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37629. /**
  37630. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37631. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37632. */
  37633. useBouncingBehavior: boolean;
  37634. private _framingBehavior;
  37635. /**
  37636. * Gets the framing behavior of the camera if it has been enabled.
  37637. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37638. */
  37639. readonly framingBehavior: Nullable<FramingBehavior>;
  37640. /**
  37641. * Defines if the framing behavior of the camera is enabled on the camera.
  37642. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37643. */
  37644. useFramingBehavior: boolean;
  37645. private _autoRotationBehavior;
  37646. /**
  37647. * Gets the auto rotation behavior of the camera if it has been enabled.
  37648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37649. */
  37650. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37651. /**
  37652. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37653. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37654. */
  37655. useAutoRotationBehavior: boolean;
  37656. /**
  37657. * Observable triggered when the mesh target has been changed on the camera.
  37658. */
  37659. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37660. /**
  37661. * Event raised when the camera is colliding with a mesh.
  37662. */
  37663. onCollide: (collidedMesh: AbstractMesh) => void;
  37664. /**
  37665. * Defines whether the camera should check collision with the objects oh the scene.
  37666. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37667. */
  37668. checkCollisions: boolean;
  37669. /**
  37670. * Defines the collision radius of the camera.
  37671. * This simulates a sphere around the camera.
  37672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37673. */
  37674. collisionRadius: Vector3;
  37675. protected _collider: Collider;
  37676. protected _previousPosition: Vector3;
  37677. protected _collisionVelocity: Vector3;
  37678. protected _newPosition: Vector3;
  37679. protected _previousAlpha: number;
  37680. protected _previousBeta: number;
  37681. protected _previousRadius: number;
  37682. protected _collisionTriggered: boolean;
  37683. protected _targetBoundingCenter: Nullable<Vector3>;
  37684. private _computationVector;
  37685. /**
  37686. * Instantiates a new ArcRotateCamera in a given scene
  37687. * @param name Defines the name of the camera
  37688. * @param alpha Defines the camera rotation along the logitudinal axis
  37689. * @param beta Defines the camera rotation along the latitudinal axis
  37690. * @param radius Defines the camera distance from its target
  37691. * @param target Defines the camera target
  37692. * @param scene Defines the scene the camera belongs to
  37693. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37694. */
  37695. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37696. /** @hidden */
  37697. _initCache(): void;
  37698. /** @hidden */
  37699. _updateCache(ignoreParentClass?: boolean): void;
  37700. protected _getTargetPosition(): Vector3;
  37701. private _storedAlpha;
  37702. private _storedBeta;
  37703. private _storedRadius;
  37704. private _storedTarget;
  37705. private _storedTargetScreenOffset;
  37706. /**
  37707. * Stores the current state of the camera (alpha, beta, radius and target)
  37708. * @returns the camera itself
  37709. */
  37710. storeState(): Camera;
  37711. /**
  37712. * @hidden
  37713. * Restored camera state. You must call storeState() first
  37714. */
  37715. _restoreStateValues(): boolean;
  37716. /** @hidden */
  37717. _isSynchronizedViewMatrix(): boolean;
  37718. /**
  37719. * Attached controls to the current camera.
  37720. * @param element Defines the element the controls should be listened from
  37721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37722. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37723. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37724. */
  37725. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37726. /**
  37727. * Detach the current controls from the camera.
  37728. * The camera will stop reacting to inputs.
  37729. * @param element Defines the element to stop listening the inputs from
  37730. */
  37731. detachControl(element: HTMLElement): void;
  37732. /** @hidden */
  37733. _checkInputs(): void;
  37734. protected _checkLimits(): void;
  37735. /**
  37736. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37737. */
  37738. rebuildAnglesAndRadius(): void;
  37739. /**
  37740. * Use a position to define the current camera related information like aplha, beta and radius
  37741. * @param position Defines the position to set the camera at
  37742. */
  37743. setPosition(position: Vector3): void;
  37744. /**
  37745. * Defines the target the camera should look at.
  37746. * This will automatically adapt alpha beta and radius to fit within the new target.
  37747. * @param target Defines the new target as a Vector or a mesh
  37748. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37749. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37750. */
  37751. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37752. /** @hidden */
  37753. _getViewMatrix(): Matrix;
  37754. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37755. /**
  37756. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37757. * @param meshes Defines the mesh to zoom on
  37758. * @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)
  37759. */
  37760. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37761. /**
  37762. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37763. * The target will be changed but the radius
  37764. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37765. * @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)
  37766. */
  37767. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37768. min: Vector3;
  37769. max: Vector3;
  37770. distance: number;
  37771. }, doNotUpdateMaxZ?: boolean): void;
  37772. /**
  37773. * @override
  37774. * Override Camera.createRigCamera
  37775. */
  37776. createRigCamera(name: string, cameraIndex: number): Camera;
  37777. /**
  37778. * @hidden
  37779. * @override
  37780. * Override Camera._updateRigCameras
  37781. */
  37782. _updateRigCameras(): void;
  37783. /**
  37784. * Destroy the camera and release the current resources hold by it.
  37785. */
  37786. dispose(): void;
  37787. /**
  37788. * Gets the current object class name.
  37789. * @return the class name
  37790. */
  37791. getClassName(): string;
  37792. }
  37793. }
  37794. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37795. import { Behavior } from "babylonjs/Behaviors/behavior";
  37796. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37797. /**
  37798. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37800. */
  37801. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37802. /**
  37803. * Gets the name of the behavior.
  37804. */
  37805. readonly name: string;
  37806. private _zoomStopsAnimation;
  37807. private _idleRotationSpeed;
  37808. private _idleRotationWaitTime;
  37809. private _idleRotationSpinupTime;
  37810. /**
  37811. * Sets the flag that indicates if user zooming should stop animation.
  37812. */
  37813. /**
  37814. * Gets the flag that indicates if user zooming should stop animation.
  37815. */
  37816. zoomStopsAnimation: boolean;
  37817. /**
  37818. * Sets the default speed at which the camera rotates around the model.
  37819. */
  37820. /**
  37821. * Gets the default speed at which the camera rotates around the model.
  37822. */
  37823. idleRotationSpeed: number;
  37824. /**
  37825. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37826. */
  37827. /**
  37828. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37829. */
  37830. idleRotationWaitTime: number;
  37831. /**
  37832. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37833. */
  37834. /**
  37835. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37836. */
  37837. idleRotationSpinupTime: number;
  37838. /**
  37839. * Gets a value indicating if the camera is currently rotating because of this behavior
  37840. */
  37841. readonly rotationInProgress: boolean;
  37842. private _onPrePointerObservableObserver;
  37843. private _onAfterCheckInputsObserver;
  37844. private _attachedCamera;
  37845. private _isPointerDown;
  37846. private _lastFrameTime;
  37847. private _lastInteractionTime;
  37848. private _cameraRotationSpeed;
  37849. /**
  37850. * Initializes the behavior.
  37851. */
  37852. init(): void;
  37853. /**
  37854. * Attaches the behavior to its arc rotate camera.
  37855. * @param camera Defines the camera to attach the behavior to
  37856. */
  37857. attach(camera: ArcRotateCamera): void;
  37858. /**
  37859. * Detaches the behavior from its current arc rotate camera.
  37860. */
  37861. detach(): void;
  37862. /**
  37863. * Returns true if user is scrolling.
  37864. * @return true if user is scrolling.
  37865. */
  37866. private _userIsZooming;
  37867. private _lastFrameRadius;
  37868. private _shouldAnimationStopForInteraction;
  37869. /**
  37870. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37871. */
  37872. private _applyUserInteraction;
  37873. private _userIsMoving;
  37874. }
  37875. }
  37876. declare module "babylonjs/Behaviors/Cameras/index" {
  37877. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37878. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37879. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37880. }
  37881. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37882. import { Mesh } from "babylonjs/Meshes/mesh";
  37883. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37884. import { Behavior } from "babylonjs/Behaviors/behavior";
  37885. /**
  37886. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37887. */
  37888. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37889. private ui;
  37890. /**
  37891. * The name of the behavior
  37892. */
  37893. name: string;
  37894. /**
  37895. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37896. */
  37897. distanceAwayFromFace: number;
  37898. /**
  37899. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37900. */
  37901. distanceAwayFromBottomOfFace: number;
  37902. private _faceVectors;
  37903. private _target;
  37904. private _scene;
  37905. private _onRenderObserver;
  37906. private _tmpMatrix;
  37907. private _tmpVector;
  37908. /**
  37909. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37910. * @param ui The transform node that should be attched to the mesh
  37911. */
  37912. constructor(ui: TransformNode);
  37913. /**
  37914. * Initializes the behavior
  37915. */
  37916. init(): void;
  37917. private _closestFace;
  37918. private _zeroVector;
  37919. private _lookAtTmpMatrix;
  37920. private _lookAtToRef;
  37921. /**
  37922. * Attaches the AttachToBoxBehavior to the passed in mesh
  37923. * @param target The mesh that the specified node will be attached to
  37924. */
  37925. attach(target: Mesh): void;
  37926. /**
  37927. * Detaches the behavior from the mesh
  37928. */
  37929. detach(): void;
  37930. }
  37931. }
  37932. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37933. import { Behavior } from "babylonjs/Behaviors/behavior";
  37934. import { Mesh } from "babylonjs/Meshes/mesh";
  37935. /**
  37936. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37937. */
  37938. export class FadeInOutBehavior implements Behavior<Mesh> {
  37939. /**
  37940. * Time in milliseconds to delay before fading in (Default: 0)
  37941. */
  37942. delay: number;
  37943. /**
  37944. * Time in milliseconds for the mesh to fade in (Default: 300)
  37945. */
  37946. fadeInTime: number;
  37947. private _millisecondsPerFrame;
  37948. private _hovered;
  37949. private _hoverValue;
  37950. private _ownerNode;
  37951. /**
  37952. * Instatiates the FadeInOutBehavior
  37953. */
  37954. constructor();
  37955. /**
  37956. * The name of the behavior
  37957. */
  37958. readonly name: string;
  37959. /**
  37960. * Initializes the behavior
  37961. */
  37962. init(): void;
  37963. /**
  37964. * Attaches the fade behavior on the passed in mesh
  37965. * @param ownerNode The mesh that will be faded in/out once attached
  37966. */
  37967. attach(ownerNode: Mesh): void;
  37968. /**
  37969. * Detaches the behavior from the mesh
  37970. */
  37971. detach(): void;
  37972. /**
  37973. * Triggers the mesh to begin fading in or out
  37974. * @param value if the object should fade in or out (true to fade in)
  37975. */
  37976. fadeIn(value: boolean): void;
  37977. private _update;
  37978. private _setAllVisibility;
  37979. }
  37980. }
  37981. declare module "babylonjs/Misc/pivotTools" {
  37982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37983. /**
  37984. * Class containing a set of static utilities functions for managing Pivots
  37985. * @hidden
  37986. */
  37987. export class PivotTools {
  37988. private static _PivotCached;
  37989. private static _OldPivotPoint;
  37990. private static _PivotTranslation;
  37991. private static _PivotTmpVector;
  37992. /** @hidden */
  37993. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37994. /** @hidden */
  37995. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37996. }
  37997. }
  37998. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37999. import { Scene } from "babylonjs/scene";
  38000. import { Vector4 } from "babylonjs/Maths/math.vector";
  38001. import { Mesh } from "babylonjs/Meshes/mesh";
  38002. import { Nullable } from "babylonjs/types";
  38003. import { Plane } from "babylonjs/Maths/math.plane";
  38004. /**
  38005. * Class containing static functions to help procedurally build meshes
  38006. */
  38007. export class PlaneBuilder {
  38008. /**
  38009. * Creates a plane mesh
  38010. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38011. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38012. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38016. * @param name defines the name of the mesh
  38017. * @param options defines the options used to create the mesh
  38018. * @param scene defines the hosting scene
  38019. * @returns the plane mesh
  38020. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38021. */
  38022. static CreatePlane(name: string, options: {
  38023. size?: number;
  38024. width?: number;
  38025. height?: number;
  38026. sideOrientation?: number;
  38027. frontUVs?: Vector4;
  38028. backUVs?: Vector4;
  38029. updatable?: boolean;
  38030. sourcePlane?: Plane;
  38031. }, scene?: Nullable<Scene>): Mesh;
  38032. }
  38033. }
  38034. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38035. import { Behavior } from "babylonjs/Behaviors/behavior";
  38036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38037. import { Observable } from "babylonjs/Misc/observable";
  38038. import { Vector3 } from "babylonjs/Maths/math.vector";
  38039. import { Ray } from "babylonjs/Culling/ray";
  38040. import "babylonjs/Meshes/Builders/planeBuilder";
  38041. /**
  38042. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38043. */
  38044. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38045. private static _AnyMouseID;
  38046. /**
  38047. * Abstract mesh the behavior is set on
  38048. */
  38049. attachedNode: AbstractMesh;
  38050. private _dragPlane;
  38051. private _scene;
  38052. private _pointerObserver;
  38053. private _beforeRenderObserver;
  38054. private static _planeScene;
  38055. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38056. /**
  38057. * 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)
  38058. */
  38059. maxDragAngle: number;
  38060. /**
  38061. * @hidden
  38062. */
  38063. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38064. /**
  38065. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38066. */
  38067. currentDraggingPointerID: number;
  38068. /**
  38069. * The last position where the pointer hit the drag plane in world space
  38070. */
  38071. lastDragPosition: Vector3;
  38072. /**
  38073. * If the behavior is currently in a dragging state
  38074. */
  38075. dragging: boolean;
  38076. /**
  38077. * 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)
  38078. */
  38079. dragDeltaRatio: number;
  38080. /**
  38081. * If the drag plane orientation should be updated during the dragging (Default: true)
  38082. */
  38083. updateDragPlane: boolean;
  38084. private _debugMode;
  38085. private _moving;
  38086. /**
  38087. * Fires each time the attached mesh is dragged with the pointer
  38088. * * delta between last drag position and current drag position in world space
  38089. * * dragDistance along the drag axis
  38090. * * dragPlaneNormal normal of the current drag plane used during the drag
  38091. * * dragPlanePoint in world space where the drag intersects the drag plane
  38092. */
  38093. onDragObservable: Observable<{
  38094. delta: Vector3;
  38095. dragPlanePoint: Vector3;
  38096. dragPlaneNormal: Vector3;
  38097. dragDistance: number;
  38098. pointerId: number;
  38099. }>;
  38100. /**
  38101. * Fires each time a drag begins (eg. mouse down on mesh)
  38102. */
  38103. onDragStartObservable: Observable<{
  38104. dragPlanePoint: Vector3;
  38105. pointerId: number;
  38106. }>;
  38107. /**
  38108. * Fires each time a drag ends (eg. mouse release after drag)
  38109. */
  38110. onDragEndObservable: Observable<{
  38111. dragPlanePoint: Vector3;
  38112. pointerId: number;
  38113. }>;
  38114. /**
  38115. * If the attached mesh should be moved when dragged
  38116. */
  38117. moveAttached: boolean;
  38118. /**
  38119. * If the drag behavior will react to drag events (Default: true)
  38120. */
  38121. enabled: boolean;
  38122. /**
  38123. * If pointer events should start and release the drag (Default: true)
  38124. */
  38125. startAndReleaseDragOnPointerEvents: boolean;
  38126. /**
  38127. * If camera controls should be detached during the drag
  38128. */
  38129. detachCameraControls: boolean;
  38130. /**
  38131. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38132. */
  38133. useObjectOrienationForDragging: boolean;
  38134. private _options;
  38135. /**
  38136. * Creates a pointer drag behavior that can be attached to a mesh
  38137. * @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)
  38138. */
  38139. constructor(options?: {
  38140. dragAxis?: Vector3;
  38141. dragPlaneNormal?: Vector3;
  38142. });
  38143. /**
  38144. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38145. */
  38146. validateDrag: (targetPosition: Vector3) => boolean;
  38147. /**
  38148. * The name of the behavior
  38149. */
  38150. readonly name: string;
  38151. /**
  38152. * Initializes the behavior
  38153. */
  38154. init(): void;
  38155. private _tmpVector;
  38156. private _alternatePickedPoint;
  38157. private _worldDragAxis;
  38158. private _targetPosition;
  38159. private _attachedElement;
  38160. /**
  38161. * Attaches the drag behavior the passed in mesh
  38162. * @param ownerNode The mesh that will be dragged around once attached
  38163. * @param predicate Predicate to use for pick filtering
  38164. */
  38165. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38166. /**
  38167. * Force relase the drag action by code.
  38168. */
  38169. releaseDrag(): void;
  38170. private _startDragRay;
  38171. private _lastPointerRay;
  38172. /**
  38173. * Simulates the start of a pointer drag event on the behavior
  38174. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38175. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38176. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38177. */
  38178. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38179. private _startDrag;
  38180. private _dragDelta;
  38181. private _moveDrag;
  38182. private _pickWithRayOnDragPlane;
  38183. private _pointA;
  38184. private _pointB;
  38185. private _pointC;
  38186. private _lineA;
  38187. private _lineB;
  38188. private _localAxis;
  38189. private _lookAt;
  38190. private _updateDragPlanePosition;
  38191. /**
  38192. * Detaches the behavior from the mesh
  38193. */
  38194. detach(): void;
  38195. }
  38196. }
  38197. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38198. import { Mesh } from "babylonjs/Meshes/mesh";
  38199. import { Behavior } from "babylonjs/Behaviors/behavior";
  38200. /**
  38201. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38202. */
  38203. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38204. private _dragBehaviorA;
  38205. private _dragBehaviorB;
  38206. private _startDistance;
  38207. private _initialScale;
  38208. private _targetScale;
  38209. private _ownerNode;
  38210. private _sceneRenderObserver;
  38211. /**
  38212. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38213. */
  38214. constructor();
  38215. /**
  38216. * The name of the behavior
  38217. */
  38218. readonly name: string;
  38219. /**
  38220. * Initializes the behavior
  38221. */
  38222. init(): void;
  38223. private _getCurrentDistance;
  38224. /**
  38225. * Attaches the scale behavior the passed in mesh
  38226. * @param ownerNode The mesh that will be scaled around once attached
  38227. */
  38228. attach(ownerNode: Mesh): void;
  38229. /**
  38230. * Detaches the behavior from the mesh
  38231. */
  38232. detach(): void;
  38233. }
  38234. }
  38235. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38236. import { Behavior } from "babylonjs/Behaviors/behavior";
  38237. import { Mesh } from "babylonjs/Meshes/mesh";
  38238. import { Observable } from "babylonjs/Misc/observable";
  38239. /**
  38240. * 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
  38241. */
  38242. export class SixDofDragBehavior implements Behavior<Mesh> {
  38243. private static _virtualScene;
  38244. private _ownerNode;
  38245. private _sceneRenderObserver;
  38246. private _scene;
  38247. private _targetPosition;
  38248. private _virtualOriginMesh;
  38249. private _virtualDragMesh;
  38250. private _pointerObserver;
  38251. private _moving;
  38252. private _startingOrientation;
  38253. /**
  38254. * 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)
  38255. */
  38256. private zDragFactor;
  38257. /**
  38258. * If the object should rotate to face the drag origin
  38259. */
  38260. rotateDraggedObject: boolean;
  38261. /**
  38262. * If the behavior is currently in a dragging state
  38263. */
  38264. dragging: boolean;
  38265. /**
  38266. * 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)
  38267. */
  38268. dragDeltaRatio: number;
  38269. /**
  38270. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38271. */
  38272. currentDraggingPointerID: number;
  38273. /**
  38274. * If camera controls should be detached during the drag
  38275. */
  38276. detachCameraControls: boolean;
  38277. /**
  38278. * Fires each time a drag starts
  38279. */
  38280. onDragStartObservable: Observable<{}>;
  38281. /**
  38282. * Fires each time a drag ends (eg. mouse release after drag)
  38283. */
  38284. onDragEndObservable: Observable<{}>;
  38285. /**
  38286. * 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
  38287. */
  38288. constructor();
  38289. /**
  38290. * The name of the behavior
  38291. */
  38292. readonly name: string;
  38293. /**
  38294. * Initializes the behavior
  38295. */
  38296. init(): void;
  38297. /**
  38298. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38299. */
  38300. private readonly _pointerCamera;
  38301. /**
  38302. * Attaches the scale behavior the passed in mesh
  38303. * @param ownerNode The mesh that will be scaled around once attached
  38304. */
  38305. attach(ownerNode: Mesh): void;
  38306. /**
  38307. * Detaches the behavior from the mesh
  38308. */
  38309. detach(): void;
  38310. }
  38311. }
  38312. declare module "babylonjs/Behaviors/Meshes/index" {
  38313. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38314. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38315. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38316. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38317. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38318. }
  38319. declare module "babylonjs/Behaviors/index" {
  38320. export * from "babylonjs/Behaviors/behavior";
  38321. export * from "babylonjs/Behaviors/Cameras/index";
  38322. export * from "babylonjs/Behaviors/Meshes/index";
  38323. }
  38324. declare module "babylonjs/Bones/boneIKController" {
  38325. import { Bone } from "babylonjs/Bones/bone";
  38326. import { Vector3 } from "babylonjs/Maths/math.vector";
  38327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38328. import { Nullable } from "babylonjs/types";
  38329. /**
  38330. * Class used to apply inverse kinematics to bones
  38331. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38332. */
  38333. export class BoneIKController {
  38334. private static _tmpVecs;
  38335. private static _tmpQuat;
  38336. private static _tmpMats;
  38337. /**
  38338. * Gets or sets the target mesh
  38339. */
  38340. targetMesh: AbstractMesh;
  38341. /** Gets or sets the mesh used as pole */
  38342. poleTargetMesh: AbstractMesh;
  38343. /**
  38344. * Gets or sets the bone used as pole
  38345. */
  38346. poleTargetBone: Nullable<Bone>;
  38347. /**
  38348. * Gets or sets the target position
  38349. */
  38350. targetPosition: Vector3;
  38351. /**
  38352. * Gets or sets the pole target position
  38353. */
  38354. poleTargetPosition: Vector3;
  38355. /**
  38356. * Gets or sets the pole target local offset
  38357. */
  38358. poleTargetLocalOffset: Vector3;
  38359. /**
  38360. * Gets or sets the pole angle
  38361. */
  38362. poleAngle: number;
  38363. /**
  38364. * Gets or sets the mesh associated with the controller
  38365. */
  38366. mesh: AbstractMesh;
  38367. /**
  38368. * 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)
  38369. */
  38370. slerpAmount: number;
  38371. private _bone1Quat;
  38372. private _bone1Mat;
  38373. private _bone2Ang;
  38374. private _bone1;
  38375. private _bone2;
  38376. private _bone1Length;
  38377. private _bone2Length;
  38378. private _maxAngle;
  38379. private _maxReach;
  38380. private _rightHandedSystem;
  38381. private _bendAxis;
  38382. private _slerping;
  38383. private _adjustRoll;
  38384. /**
  38385. * Gets or sets maximum allowed angle
  38386. */
  38387. maxAngle: number;
  38388. /**
  38389. * Creates a new BoneIKController
  38390. * @param mesh defines the mesh to control
  38391. * @param bone defines the bone to control
  38392. * @param options defines options to set up the controller
  38393. */
  38394. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38395. targetMesh?: AbstractMesh;
  38396. poleTargetMesh?: AbstractMesh;
  38397. poleTargetBone?: Bone;
  38398. poleTargetLocalOffset?: Vector3;
  38399. poleAngle?: number;
  38400. bendAxis?: Vector3;
  38401. maxAngle?: number;
  38402. slerpAmount?: number;
  38403. });
  38404. private _setMaxAngle;
  38405. /**
  38406. * Force the controller to update the bones
  38407. */
  38408. update(): void;
  38409. }
  38410. }
  38411. declare module "babylonjs/Bones/boneLookController" {
  38412. import { Vector3 } from "babylonjs/Maths/math.vector";
  38413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38414. import { Bone } from "babylonjs/Bones/bone";
  38415. import { Space } from "babylonjs/Maths/math.axis";
  38416. /**
  38417. * Class used to make a bone look toward a point in space
  38418. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38419. */
  38420. export class BoneLookController {
  38421. private static _tmpVecs;
  38422. private static _tmpQuat;
  38423. private static _tmpMats;
  38424. /**
  38425. * The target Vector3 that the bone will look at
  38426. */
  38427. target: Vector3;
  38428. /**
  38429. * The mesh that the bone is attached to
  38430. */
  38431. mesh: AbstractMesh;
  38432. /**
  38433. * The bone that will be looking to the target
  38434. */
  38435. bone: Bone;
  38436. /**
  38437. * The up axis of the coordinate system that is used when the bone is rotated
  38438. */
  38439. upAxis: Vector3;
  38440. /**
  38441. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38442. */
  38443. upAxisSpace: Space;
  38444. /**
  38445. * Used to make an adjustment to the yaw of the bone
  38446. */
  38447. adjustYaw: number;
  38448. /**
  38449. * Used to make an adjustment to the pitch of the bone
  38450. */
  38451. adjustPitch: number;
  38452. /**
  38453. * Used to make an adjustment to the roll of the bone
  38454. */
  38455. adjustRoll: number;
  38456. /**
  38457. * 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)
  38458. */
  38459. slerpAmount: number;
  38460. private _minYaw;
  38461. private _maxYaw;
  38462. private _minPitch;
  38463. private _maxPitch;
  38464. private _minYawSin;
  38465. private _minYawCos;
  38466. private _maxYawSin;
  38467. private _maxYawCos;
  38468. private _midYawConstraint;
  38469. private _minPitchTan;
  38470. private _maxPitchTan;
  38471. private _boneQuat;
  38472. private _slerping;
  38473. private _transformYawPitch;
  38474. private _transformYawPitchInv;
  38475. private _firstFrameSkipped;
  38476. private _yawRange;
  38477. private _fowardAxis;
  38478. /**
  38479. * Gets or sets the minimum yaw angle that the bone can look to
  38480. */
  38481. minYaw: number;
  38482. /**
  38483. * Gets or sets the maximum yaw angle that the bone can look to
  38484. */
  38485. maxYaw: number;
  38486. /**
  38487. * Gets or sets the minimum pitch angle that the bone can look to
  38488. */
  38489. minPitch: number;
  38490. /**
  38491. * Gets or sets the maximum pitch angle that the bone can look to
  38492. */
  38493. maxPitch: number;
  38494. /**
  38495. * Create a BoneLookController
  38496. * @param mesh the mesh that the bone belongs to
  38497. * @param bone the bone that will be looking to the target
  38498. * @param target the target Vector3 to look at
  38499. * @param options optional settings:
  38500. * * maxYaw: the maximum angle the bone will yaw to
  38501. * * minYaw: the minimum angle the bone will yaw to
  38502. * * maxPitch: the maximum angle the bone will pitch to
  38503. * * minPitch: the minimum angle the bone will yaw to
  38504. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38505. * * upAxis: the up axis of the coordinate system
  38506. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38507. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38508. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38509. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38510. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38511. * * adjustRoll: used to make an adjustment to the roll of the bone
  38512. **/
  38513. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38514. maxYaw?: number;
  38515. minYaw?: number;
  38516. maxPitch?: number;
  38517. minPitch?: number;
  38518. slerpAmount?: number;
  38519. upAxis?: Vector3;
  38520. upAxisSpace?: Space;
  38521. yawAxis?: Vector3;
  38522. pitchAxis?: Vector3;
  38523. adjustYaw?: number;
  38524. adjustPitch?: number;
  38525. adjustRoll?: number;
  38526. });
  38527. /**
  38528. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38529. */
  38530. update(): void;
  38531. private _getAngleDiff;
  38532. private _getAngleBetween;
  38533. private _isAngleBetween;
  38534. }
  38535. }
  38536. declare module "babylonjs/Bones/index" {
  38537. export * from "babylonjs/Bones/bone";
  38538. export * from "babylonjs/Bones/boneIKController";
  38539. export * from "babylonjs/Bones/boneLookController";
  38540. export * from "babylonjs/Bones/skeleton";
  38541. }
  38542. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38543. import { Nullable } from "babylonjs/types";
  38544. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38545. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38546. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38547. /**
  38548. * Manage the gamepad inputs to control an arc rotate camera.
  38549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38550. */
  38551. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38552. /**
  38553. * Defines the camera the input is attached to.
  38554. */
  38555. camera: ArcRotateCamera;
  38556. /**
  38557. * Defines the gamepad the input is gathering event from.
  38558. */
  38559. gamepad: Nullable<Gamepad>;
  38560. /**
  38561. * Defines the gamepad rotation sensiblity.
  38562. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38563. */
  38564. gamepadRotationSensibility: number;
  38565. /**
  38566. * Defines the gamepad move sensiblity.
  38567. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38568. */
  38569. gamepadMoveSensibility: number;
  38570. private _onGamepadConnectedObserver;
  38571. private _onGamepadDisconnectedObserver;
  38572. /**
  38573. * Attach the input controls to a specific dom element to get the input from.
  38574. * @param element Defines the element the controls should be listened from
  38575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38576. */
  38577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38578. /**
  38579. * Detach the current controls from the specified dom element.
  38580. * @param element Defines the element to stop listening the inputs from
  38581. */
  38582. detachControl(element: Nullable<HTMLElement>): void;
  38583. /**
  38584. * Update the current camera state depending on the inputs that have been used this frame.
  38585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38586. */
  38587. checkInputs(): void;
  38588. /**
  38589. * Gets the class name of the current intput.
  38590. * @returns the class name
  38591. */
  38592. getClassName(): string;
  38593. /**
  38594. * Get the friendly name associated with the input class.
  38595. * @returns the input friendly name
  38596. */
  38597. getSimpleName(): string;
  38598. }
  38599. }
  38600. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38601. import { Nullable } from "babylonjs/types";
  38602. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38603. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38604. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38605. interface ArcRotateCameraInputsManager {
  38606. /**
  38607. * Add orientation input support to the input manager.
  38608. * @returns the current input manager
  38609. */
  38610. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38611. }
  38612. }
  38613. /**
  38614. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38616. */
  38617. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38618. /**
  38619. * Defines the camera the input is attached to.
  38620. */
  38621. camera: ArcRotateCamera;
  38622. /**
  38623. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38624. */
  38625. alphaCorrection: number;
  38626. /**
  38627. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38628. */
  38629. gammaCorrection: number;
  38630. private _alpha;
  38631. private _gamma;
  38632. private _dirty;
  38633. private _deviceOrientationHandler;
  38634. /**
  38635. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38636. */
  38637. constructor();
  38638. /**
  38639. * Attach the input controls to a specific dom element to get the input from.
  38640. * @param element Defines the element the controls should be listened from
  38641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38642. */
  38643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38644. /** @hidden */
  38645. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38646. /**
  38647. * Update the current camera state depending on the inputs that have been used this frame.
  38648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38649. */
  38650. checkInputs(): void;
  38651. /**
  38652. * Detach the current controls from the specified dom element.
  38653. * @param element Defines the element to stop listening the inputs from
  38654. */
  38655. detachControl(element: Nullable<HTMLElement>): void;
  38656. /**
  38657. * Gets the class name of the current intput.
  38658. * @returns the class name
  38659. */
  38660. getClassName(): string;
  38661. /**
  38662. * Get the friendly name associated with the input class.
  38663. * @returns the input friendly name
  38664. */
  38665. getSimpleName(): string;
  38666. }
  38667. }
  38668. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38669. import { Nullable } from "babylonjs/types";
  38670. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38671. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38672. /**
  38673. * Listen to mouse events to control the camera.
  38674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38675. */
  38676. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38677. /**
  38678. * Defines the camera the input is attached to.
  38679. */
  38680. camera: FlyCamera;
  38681. /**
  38682. * Defines if touch is enabled. (Default is true.)
  38683. */
  38684. touchEnabled: boolean;
  38685. /**
  38686. * Defines the buttons associated with the input to handle camera rotation.
  38687. */
  38688. buttons: number[];
  38689. /**
  38690. * Assign buttons for Yaw control.
  38691. */
  38692. buttonsYaw: number[];
  38693. /**
  38694. * Assign buttons for Pitch control.
  38695. */
  38696. buttonsPitch: number[];
  38697. /**
  38698. * Assign buttons for Roll control.
  38699. */
  38700. buttonsRoll: number[];
  38701. /**
  38702. * Detect if any button is being pressed while mouse is moved.
  38703. * -1 = Mouse locked.
  38704. * 0 = Left button.
  38705. * 1 = Middle Button.
  38706. * 2 = Right Button.
  38707. */
  38708. activeButton: number;
  38709. /**
  38710. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38711. * Higher values reduce its sensitivity.
  38712. */
  38713. angularSensibility: number;
  38714. private _mousemoveCallback;
  38715. private _observer;
  38716. private _rollObserver;
  38717. private previousPosition;
  38718. private noPreventDefault;
  38719. private element;
  38720. /**
  38721. * Listen to mouse events to control the camera.
  38722. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38724. */
  38725. constructor(touchEnabled?: boolean);
  38726. /**
  38727. * Attach the mouse control to the HTML DOM element.
  38728. * @param element Defines the element that listens to the input events.
  38729. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38730. */
  38731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38732. /**
  38733. * Detach the current controls from the specified dom element.
  38734. * @param element Defines the element to stop listening the inputs from
  38735. */
  38736. detachControl(element: Nullable<HTMLElement>): void;
  38737. /**
  38738. * Gets the class name of the current input.
  38739. * @returns the class name.
  38740. */
  38741. getClassName(): string;
  38742. /**
  38743. * Get the friendly name associated with the input class.
  38744. * @returns the input's friendly name.
  38745. */
  38746. getSimpleName(): string;
  38747. private _pointerInput;
  38748. private _onMouseMove;
  38749. /**
  38750. * Rotate camera by mouse offset.
  38751. */
  38752. private rotateCamera;
  38753. }
  38754. }
  38755. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38756. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38757. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38758. /**
  38759. * Default Inputs manager for the FlyCamera.
  38760. * It groups all the default supported inputs for ease of use.
  38761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38762. */
  38763. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38764. /**
  38765. * Instantiates a new FlyCameraInputsManager.
  38766. * @param camera Defines the camera the inputs belong to.
  38767. */
  38768. constructor(camera: FlyCamera);
  38769. /**
  38770. * Add keyboard input support to the input manager.
  38771. * @returns the new FlyCameraKeyboardMoveInput().
  38772. */
  38773. addKeyboard(): FlyCameraInputsManager;
  38774. /**
  38775. * Add mouse input support to the input manager.
  38776. * @param touchEnabled Enable touch screen support.
  38777. * @returns the new FlyCameraMouseInput().
  38778. */
  38779. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38780. }
  38781. }
  38782. declare module "babylonjs/Cameras/flyCamera" {
  38783. import { Scene } from "babylonjs/scene";
  38784. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38786. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38787. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38788. /**
  38789. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38790. * such as in a 3D Space Shooter or a Flight Simulator.
  38791. */
  38792. export class FlyCamera extends TargetCamera {
  38793. /**
  38794. * Define the collision ellipsoid of the camera.
  38795. * This is helpful for simulating a camera body, like a player's body.
  38796. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38797. */
  38798. ellipsoid: Vector3;
  38799. /**
  38800. * Define an offset for the position of the ellipsoid around the camera.
  38801. * This can be helpful if the camera is attached away from the player's body center,
  38802. * such as at its head.
  38803. */
  38804. ellipsoidOffset: Vector3;
  38805. /**
  38806. * Enable or disable collisions of the camera with the rest of the scene objects.
  38807. */
  38808. checkCollisions: boolean;
  38809. /**
  38810. * Enable or disable gravity on the camera.
  38811. */
  38812. applyGravity: boolean;
  38813. /**
  38814. * Define the current direction the camera is moving to.
  38815. */
  38816. cameraDirection: Vector3;
  38817. /**
  38818. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38819. * This overrides and empties cameraRotation.
  38820. */
  38821. rotationQuaternion: Quaternion;
  38822. /**
  38823. * Track Roll to maintain the wanted Rolling when looking around.
  38824. */
  38825. _trackRoll: number;
  38826. /**
  38827. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38828. */
  38829. rollCorrect: number;
  38830. /**
  38831. * Mimic a banked turn, Rolling the camera when Yawing.
  38832. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38833. */
  38834. bankedTurn: boolean;
  38835. /**
  38836. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38837. */
  38838. bankedTurnLimit: number;
  38839. /**
  38840. * Value of 0 disables the banked Roll.
  38841. * Value of 1 is equal to the Yaw angle in radians.
  38842. */
  38843. bankedTurnMultiplier: number;
  38844. /**
  38845. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38846. */
  38847. inputs: FlyCameraInputsManager;
  38848. /**
  38849. * Gets the input sensibility for mouse input.
  38850. * Higher values reduce sensitivity.
  38851. */
  38852. /**
  38853. * Sets the input sensibility for a mouse input.
  38854. * Higher values reduce sensitivity.
  38855. */
  38856. angularSensibility: number;
  38857. /**
  38858. * Get the keys for camera movement forward.
  38859. */
  38860. /**
  38861. * Set the keys for camera movement forward.
  38862. */
  38863. keysForward: number[];
  38864. /**
  38865. * Get the keys for camera movement backward.
  38866. */
  38867. keysBackward: number[];
  38868. /**
  38869. * Get the keys for camera movement up.
  38870. */
  38871. /**
  38872. * Set the keys for camera movement up.
  38873. */
  38874. keysUp: number[];
  38875. /**
  38876. * Get the keys for camera movement down.
  38877. */
  38878. /**
  38879. * Set the keys for camera movement down.
  38880. */
  38881. keysDown: number[];
  38882. /**
  38883. * Get the keys for camera movement left.
  38884. */
  38885. /**
  38886. * Set the keys for camera movement left.
  38887. */
  38888. keysLeft: number[];
  38889. /**
  38890. * Set the keys for camera movement right.
  38891. */
  38892. /**
  38893. * Set the keys for camera movement right.
  38894. */
  38895. keysRight: number[];
  38896. /**
  38897. * Event raised when the camera collides with a mesh in the scene.
  38898. */
  38899. onCollide: (collidedMesh: AbstractMesh) => void;
  38900. private _collider;
  38901. private _needMoveForGravity;
  38902. private _oldPosition;
  38903. private _diffPosition;
  38904. private _newPosition;
  38905. /** @hidden */
  38906. _localDirection: Vector3;
  38907. /** @hidden */
  38908. _transformedDirection: Vector3;
  38909. /**
  38910. * Instantiates a FlyCamera.
  38911. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38912. * such as in a 3D Space Shooter or a Flight Simulator.
  38913. * @param name Define the name of the camera in the scene.
  38914. * @param position Define the starting position of the camera in the scene.
  38915. * @param scene Define the scene the camera belongs to.
  38916. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38917. */
  38918. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38919. /**
  38920. * Attach a control to the HTML DOM element.
  38921. * @param element Defines the element that listens to the input events.
  38922. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38923. */
  38924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38925. /**
  38926. * Detach a control from the HTML DOM element.
  38927. * The camera will stop reacting to that input.
  38928. * @param element Defines the element that listens to the input events.
  38929. */
  38930. detachControl(element: HTMLElement): void;
  38931. private _collisionMask;
  38932. /**
  38933. * Get the mask that the camera ignores in collision events.
  38934. */
  38935. /**
  38936. * Set the mask that the camera ignores in collision events.
  38937. */
  38938. collisionMask: number;
  38939. /** @hidden */
  38940. _collideWithWorld(displacement: Vector3): void;
  38941. /** @hidden */
  38942. private _onCollisionPositionChange;
  38943. /** @hidden */
  38944. _checkInputs(): void;
  38945. /** @hidden */
  38946. _decideIfNeedsToMove(): boolean;
  38947. /** @hidden */
  38948. _updatePosition(): void;
  38949. /**
  38950. * Restore the Roll to its target value at the rate specified.
  38951. * @param rate - Higher means slower restoring.
  38952. * @hidden
  38953. */
  38954. restoreRoll(rate: number): void;
  38955. /**
  38956. * Destroy the camera and release the current resources held by it.
  38957. */
  38958. dispose(): void;
  38959. /**
  38960. * Get the current object class name.
  38961. * @returns the class name.
  38962. */
  38963. getClassName(): string;
  38964. }
  38965. }
  38966. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38967. import { Nullable } from "babylonjs/types";
  38968. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38969. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38970. /**
  38971. * Listen to keyboard events to control the camera.
  38972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38973. */
  38974. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38975. /**
  38976. * Defines the camera the input is attached to.
  38977. */
  38978. camera: FlyCamera;
  38979. /**
  38980. * The list of keyboard keys used to control the forward move of the camera.
  38981. */
  38982. keysForward: number[];
  38983. /**
  38984. * The list of keyboard keys used to control the backward move of the camera.
  38985. */
  38986. keysBackward: number[];
  38987. /**
  38988. * The list of keyboard keys used to control the forward move of the camera.
  38989. */
  38990. keysUp: number[];
  38991. /**
  38992. * The list of keyboard keys used to control the backward move of the camera.
  38993. */
  38994. keysDown: number[];
  38995. /**
  38996. * The list of keyboard keys used to control the right strafe move of the camera.
  38997. */
  38998. keysRight: number[];
  38999. /**
  39000. * The list of keyboard keys used to control the left strafe move of the camera.
  39001. */
  39002. keysLeft: number[];
  39003. private _keys;
  39004. private _onCanvasBlurObserver;
  39005. private _onKeyboardObserver;
  39006. private _engine;
  39007. private _scene;
  39008. /**
  39009. * Attach the input controls to a specific dom element to get the input from.
  39010. * @param element Defines the element the controls should be listened from
  39011. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39012. */
  39013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39014. /**
  39015. * Detach the current controls from the specified dom element.
  39016. * @param element Defines the element to stop listening the inputs from
  39017. */
  39018. detachControl(element: Nullable<HTMLElement>): void;
  39019. /**
  39020. * Gets the class name of the current intput.
  39021. * @returns the class name
  39022. */
  39023. getClassName(): string;
  39024. /** @hidden */
  39025. _onLostFocus(e: FocusEvent): void;
  39026. /**
  39027. * Get the friendly name associated with the input class.
  39028. * @returns the input friendly name
  39029. */
  39030. getSimpleName(): string;
  39031. /**
  39032. * Update the current camera state depending on the inputs that have been used this frame.
  39033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39034. */
  39035. checkInputs(): void;
  39036. }
  39037. }
  39038. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39039. import { Nullable } from "babylonjs/types";
  39040. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39041. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39042. /**
  39043. * Manage the mouse wheel inputs to control a follow camera.
  39044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39045. */
  39046. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39047. /**
  39048. * Defines the camera the input is attached to.
  39049. */
  39050. camera: FollowCamera;
  39051. /**
  39052. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39053. */
  39054. axisControlRadius: boolean;
  39055. /**
  39056. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39057. */
  39058. axisControlHeight: boolean;
  39059. /**
  39060. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39061. */
  39062. axisControlRotation: boolean;
  39063. /**
  39064. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39065. * relation to mouseWheel events.
  39066. */
  39067. wheelPrecision: number;
  39068. /**
  39069. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39070. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39071. */
  39072. wheelDeltaPercentage: number;
  39073. private _wheel;
  39074. private _observer;
  39075. /**
  39076. * Attach the input controls to a specific dom element to get the input from.
  39077. * @param element Defines the element the controls should be listened from
  39078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39079. */
  39080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39081. /**
  39082. * Detach the current controls from the specified dom element.
  39083. * @param element Defines the element to stop listening the inputs from
  39084. */
  39085. detachControl(element: Nullable<HTMLElement>): void;
  39086. /**
  39087. * Gets the class name of the current intput.
  39088. * @returns the class name
  39089. */
  39090. getClassName(): string;
  39091. /**
  39092. * Get the friendly name associated with the input class.
  39093. * @returns the input friendly name
  39094. */
  39095. getSimpleName(): string;
  39096. }
  39097. }
  39098. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39099. import { Nullable } from "babylonjs/types";
  39100. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39101. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39102. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39103. /**
  39104. * Manage the pointers inputs to control an follow camera.
  39105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39106. */
  39107. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39108. /**
  39109. * Defines the camera the input is attached to.
  39110. */
  39111. camera: FollowCamera;
  39112. /**
  39113. * Gets the class name of the current input.
  39114. * @returns the class name
  39115. */
  39116. getClassName(): string;
  39117. /**
  39118. * Defines the pointer angular sensibility along the X axis or how fast is
  39119. * the camera rotating.
  39120. * A negative number will reverse the axis direction.
  39121. */
  39122. angularSensibilityX: number;
  39123. /**
  39124. * Defines the pointer angular sensibility along the Y axis or how fast is
  39125. * the camera rotating.
  39126. * A negative number will reverse the axis direction.
  39127. */
  39128. angularSensibilityY: number;
  39129. /**
  39130. * Defines the pointer pinch precision or how fast is the camera zooming.
  39131. * A negative number will reverse the axis direction.
  39132. */
  39133. pinchPrecision: number;
  39134. /**
  39135. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39136. * from 0.
  39137. * It defines the percentage of current camera.radius to use as delta when
  39138. * pinch zoom is used.
  39139. */
  39140. pinchDeltaPercentage: number;
  39141. /**
  39142. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39143. */
  39144. axisXControlRadius: boolean;
  39145. /**
  39146. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39147. */
  39148. axisXControlHeight: boolean;
  39149. /**
  39150. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39151. */
  39152. axisXControlRotation: boolean;
  39153. /**
  39154. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39155. */
  39156. axisYControlRadius: boolean;
  39157. /**
  39158. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39159. */
  39160. axisYControlHeight: boolean;
  39161. /**
  39162. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39163. */
  39164. axisYControlRotation: boolean;
  39165. /**
  39166. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39167. */
  39168. axisPinchControlRadius: boolean;
  39169. /**
  39170. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39171. */
  39172. axisPinchControlHeight: boolean;
  39173. /**
  39174. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39175. */
  39176. axisPinchControlRotation: boolean;
  39177. /**
  39178. * Log error messages if basic misconfiguration has occurred.
  39179. */
  39180. warningEnable: boolean;
  39181. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39182. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39183. private _warningCounter;
  39184. private _warning;
  39185. }
  39186. }
  39187. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39188. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39189. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39190. /**
  39191. * Default Inputs manager for the FollowCamera.
  39192. * It groups all the default supported inputs for ease of use.
  39193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39194. */
  39195. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39196. /**
  39197. * Instantiates a new FollowCameraInputsManager.
  39198. * @param camera Defines the camera the inputs belong to
  39199. */
  39200. constructor(camera: FollowCamera);
  39201. /**
  39202. * Add keyboard input support to the input manager.
  39203. * @returns the current input manager
  39204. */
  39205. addKeyboard(): FollowCameraInputsManager;
  39206. /**
  39207. * Add mouse wheel input support to the input manager.
  39208. * @returns the current input manager
  39209. */
  39210. addMouseWheel(): FollowCameraInputsManager;
  39211. /**
  39212. * Add pointers input support to the input manager.
  39213. * @returns the current input manager
  39214. */
  39215. addPointers(): FollowCameraInputsManager;
  39216. /**
  39217. * Add orientation input support to the input manager.
  39218. * @returns the current input manager
  39219. */
  39220. addVRDeviceOrientation(): FollowCameraInputsManager;
  39221. }
  39222. }
  39223. declare module "babylonjs/Cameras/followCamera" {
  39224. import { Nullable } from "babylonjs/types";
  39225. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39226. import { Scene } from "babylonjs/scene";
  39227. import { Vector3 } from "babylonjs/Maths/math.vector";
  39228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39229. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39230. /**
  39231. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39232. * an arc rotate version arcFollowCamera are available.
  39233. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39234. */
  39235. export class FollowCamera extends TargetCamera {
  39236. /**
  39237. * Distance the follow camera should follow an object at
  39238. */
  39239. radius: number;
  39240. /**
  39241. * Minimum allowed distance of the camera to the axis of rotation
  39242. * (The camera can not get closer).
  39243. * This can help limiting how the Camera is able to move in the scene.
  39244. */
  39245. lowerRadiusLimit: Nullable<number>;
  39246. /**
  39247. * Maximum allowed distance of the camera to the axis of rotation
  39248. * (The camera can not get further).
  39249. * This can help limiting how the Camera is able to move in the scene.
  39250. */
  39251. upperRadiusLimit: Nullable<number>;
  39252. /**
  39253. * Define a rotation offset between the camera and the object it follows
  39254. */
  39255. rotationOffset: number;
  39256. /**
  39257. * Minimum allowed angle to camera position relative to target object.
  39258. * This can help limiting how the Camera is able to move in the scene.
  39259. */
  39260. lowerRotationOffsetLimit: Nullable<number>;
  39261. /**
  39262. * Maximum allowed angle to camera position relative to target object.
  39263. * This can help limiting how the Camera is able to move in the scene.
  39264. */
  39265. upperRotationOffsetLimit: Nullable<number>;
  39266. /**
  39267. * Define a height offset between the camera and the object it follows.
  39268. * It can help following an object from the top (like a car chaing a plane)
  39269. */
  39270. heightOffset: number;
  39271. /**
  39272. * Minimum allowed height of camera position relative to target object.
  39273. * This can help limiting how the Camera is able to move in the scene.
  39274. */
  39275. lowerHeightOffsetLimit: Nullable<number>;
  39276. /**
  39277. * Maximum allowed height of camera position relative to target object.
  39278. * This can help limiting how the Camera is able to move in the scene.
  39279. */
  39280. upperHeightOffsetLimit: Nullable<number>;
  39281. /**
  39282. * Define how fast the camera can accelerate to follow it s target.
  39283. */
  39284. cameraAcceleration: number;
  39285. /**
  39286. * Define the speed limit of the camera following an object.
  39287. */
  39288. maxCameraSpeed: number;
  39289. /**
  39290. * Define the target of the camera.
  39291. */
  39292. lockedTarget: Nullable<AbstractMesh>;
  39293. /**
  39294. * Defines the input associated with the camera.
  39295. */
  39296. inputs: FollowCameraInputsManager;
  39297. /**
  39298. * Instantiates the follow camera.
  39299. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39300. * @param name Define the name of the camera in the scene
  39301. * @param position Define the position of the camera
  39302. * @param scene Define the scene the camera belong to
  39303. * @param lockedTarget Define the target of the camera
  39304. */
  39305. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39306. private _follow;
  39307. /**
  39308. * Attached controls to the current camera.
  39309. * @param element Defines the element the controls should be listened from
  39310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39311. */
  39312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39313. /**
  39314. * Detach the current controls from the camera.
  39315. * The camera will stop reacting to inputs.
  39316. * @param element Defines the element to stop listening the inputs from
  39317. */
  39318. detachControl(element: HTMLElement): void;
  39319. /** @hidden */
  39320. _checkInputs(): void;
  39321. private _checkLimits;
  39322. /**
  39323. * Gets the camera class name.
  39324. * @returns the class name
  39325. */
  39326. getClassName(): string;
  39327. }
  39328. /**
  39329. * Arc Rotate version of the follow camera.
  39330. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39331. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39332. */
  39333. export class ArcFollowCamera extends TargetCamera {
  39334. /** The longitudinal angle of the camera */
  39335. alpha: number;
  39336. /** The latitudinal angle of the camera */
  39337. beta: number;
  39338. /** The radius of the camera from its target */
  39339. radius: number;
  39340. /** Define the camera target (the messh it should follow) */
  39341. target: Nullable<AbstractMesh>;
  39342. private _cartesianCoordinates;
  39343. /**
  39344. * Instantiates a new ArcFollowCamera
  39345. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39346. * @param name Define the name of the camera
  39347. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39348. * @param beta Define the rotation angle of the camera around the elevation axis
  39349. * @param radius Define the radius of the camera from its target point
  39350. * @param target Define the target of the camera
  39351. * @param scene Define the scene the camera belongs to
  39352. */
  39353. constructor(name: string,
  39354. /** The longitudinal angle of the camera */
  39355. alpha: number,
  39356. /** The latitudinal angle of the camera */
  39357. beta: number,
  39358. /** The radius of the camera from its target */
  39359. radius: number,
  39360. /** Define the camera target (the messh it should follow) */
  39361. target: Nullable<AbstractMesh>, scene: Scene);
  39362. private _follow;
  39363. /** @hidden */
  39364. _checkInputs(): void;
  39365. /**
  39366. * Returns the class name of the object.
  39367. * It is mostly used internally for serialization purposes.
  39368. */
  39369. getClassName(): string;
  39370. }
  39371. }
  39372. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39373. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39374. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39375. import { Nullable } from "babylonjs/types";
  39376. /**
  39377. * Manage the keyboard inputs to control the movement of a follow camera.
  39378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39379. */
  39380. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39381. /**
  39382. * Defines the camera the input is attached to.
  39383. */
  39384. camera: FollowCamera;
  39385. /**
  39386. * Defines the list of key codes associated with the up action (increase heightOffset)
  39387. */
  39388. keysHeightOffsetIncr: number[];
  39389. /**
  39390. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39391. */
  39392. keysHeightOffsetDecr: number[];
  39393. /**
  39394. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39395. */
  39396. keysHeightOffsetModifierAlt: boolean;
  39397. /**
  39398. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39399. */
  39400. keysHeightOffsetModifierCtrl: boolean;
  39401. /**
  39402. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39403. */
  39404. keysHeightOffsetModifierShift: boolean;
  39405. /**
  39406. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39407. */
  39408. keysRotationOffsetIncr: number[];
  39409. /**
  39410. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39411. */
  39412. keysRotationOffsetDecr: number[];
  39413. /**
  39414. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39415. */
  39416. keysRotationOffsetModifierAlt: boolean;
  39417. /**
  39418. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39419. */
  39420. keysRotationOffsetModifierCtrl: boolean;
  39421. /**
  39422. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39423. */
  39424. keysRotationOffsetModifierShift: boolean;
  39425. /**
  39426. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39427. */
  39428. keysRadiusIncr: number[];
  39429. /**
  39430. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39431. */
  39432. keysRadiusDecr: number[];
  39433. /**
  39434. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39435. */
  39436. keysRadiusModifierAlt: boolean;
  39437. /**
  39438. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39439. */
  39440. keysRadiusModifierCtrl: boolean;
  39441. /**
  39442. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39443. */
  39444. keysRadiusModifierShift: boolean;
  39445. /**
  39446. * Defines the rate of change of heightOffset.
  39447. */
  39448. heightSensibility: number;
  39449. /**
  39450. * Defines the rate of change of rotationOffset.
  39451. */
  39452. rotationSensibility: number;
  39453. /**
  39454. * Defines the rate of change of radius.
  39455. */
  39456. radiusSensibility: number;
  39457. private _keys;
  39458. private _ctrlPressed;
  39459. private _altPressed;
  39460. private _shiftPressed;
  39461. private _onCanvasBlurObserver;
  39462. private _onKeyboardObserver;
  39463. private _engine;
  39464. private _scene;
  39465. /**
  39466. * Attach the input controls to a specific dom element to get the input from.
  39467. * @param element Defines the element the controls should be listened from
  39468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39469. */
  39470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39471. /**
  39472. * Detach the current controls from the specified dom element.
  39473. * @param element Defines the element to stop listening the inputs from
  39474. */
  39475. detachControl(element: Nullable<HTMLElement>): void;
  39476. /**
  39477. * Update the current camera state depending on the inputs that have been used this frame.
  39478. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39479. */
  39480. checkInputs(): void;
  39481. /**
  39482. * Gets the class name of the current input.
  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. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39493. * allow modification of the heightOffset value.
  39494. */
  39495. private _modifierHeightOffset;
  39496. /**
  39497. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39498. * allow modification of the rotationOffset value.
  39499. */
  39500. private _modifierRotationOffset;
  39501. /**
  39502. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39503. * allow modification of the radius value.
  39504. */
  39505. private _modifierRadius;
  39506. }
  39507. }
  39508. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39509. import { Nullable } from "babylonjs/types";
  39510. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39511. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39512. import { Observable } from "babylonjs/Misc/observable";
  39513. module "babylonjs/Cameras/freeCameraInputsManager" {
  39514. interface FreeCameraInputsManager {
  39515. /**
  39516. * @hidden
  39517. */
  39518. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39519. /**
  39520. * Add orientation input support to the input manager.
  39521. * @returns the current input manager
  39522. */
  39523. addDeviceOrientation(): FreeCameraInputsManager;
  39524. }
  39525. }
  39526. /**
  39527. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39528. * Screen rotation is taken into account.
  39529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39530. */
  39531. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39532. private _camera;
  39533. private _screenOrientationAngle;
  39534. private _constantTranform;
  39535. private _screenQuaternion;
  39536. private _alpha;
  39537. private _beta;
  39538. private _gamma;
  39539. /**
  39540. * Can be used to detect if a device orientation sensor is availible on a device
  39541. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39542. * @returns a promise that will resolve on orientation change
  39543. */
  39544. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39545. /**
  39546. * @hidden
  39547. */
  39548. _onDeviceOrientationChangedObservable: Observable<void>;
  39549. /**
  39550. * Instantiates a new input
  39551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39552. */
  39553. constructor();
  39554. /**
  39555. * Define the camera controlled by the input.
  39556. */
  39557. camera: FreeCamera;
  39558. /**
  39559. * Attach the input controls to a specific dom element to get the input from.
  39560. * @param element Defines the element the controls should be listened from
  39561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39562. */
  39563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39564. private _orientationChanged;
  39565. private _deviceOrientation;
  39566. /**
  39567. * Detach the current controls from the specified dom element.
  39568. * @param element Defines the element to stop listening the inputs from
  39569. */
  39570. detachControl(element: Nullable<HTMLElement>): void;
  39571. /**
  39572. * Update the current camera state depending on the inputs that have been used this frame.
  39573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39574. */
  39575. checkInputs(): void;
  39576. /**
  39577. * Gets the class name of the current intput.
  39578. * @returns the class name
  39579. */
  39580. getClassName(): string;
  39581. /**
  39582. * Get the friendly name associated with the input class.
  39583. * @returns the input friendly name
  39584. */
  39585. getSimpleName(): string;
  39586. }
  39587. }
  39588. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39589. import { Nullable } from "babylonjs/types";
  39590. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39591. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39592. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39593. /**
  39594. * Manage the gamepad inputs to control a free camera.
  39595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39596. */
  39597. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39598. /**
  39599. * Define the camera the input is attached to.
  39600. */
  39601. camera: FreeCamera;
  39602. /**
  39603. * Define the Gamepad controlling the input
  39604. */
  39605. gamepad: Nullable<Gamepad>;
  39606. /**
  39607. * Defines the gamepad rotation sensiblity.
  39608. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39609. */
  39610. gamepadAngularSensibility: number;
  39611. /**
  39612. * Defines the gamepad move sensiblity.
  39613. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39614. */
  39615. gamepadMoveSensibility: number;
  39616. private _onGamepadConnectedObserver;
  39617. private _onGamepadDisconnectedObserver;
  39618. private _cameraTransform;
  39619. private _deltaTransform;
  39620. private _vector3;
  39621. private _vector2;
  39622. /**
  39623. * Attach the input controls to a specific dom element to get the input from.
  39624. * @param element Defines the element the controls should be listened from
  39625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39626. */
  39627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39628. /**
  39629. * Detach the current controls from the specified dom element.
  39630. * @param element Defines the element to stop listening the inputs from
  39631. */
  39632. detachControl(element: Nullable<HTMLElement>): void;
  39633. /**
  39634. * Update the current camera state depending on the inputs that have been used this frame.
  39635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39636. */
  39637. checkInputs(): void;
  39638. /**
  39639. * Gets the class name of the current intput.
  39640. * @returns the class name
  39641. */
  39642. getClassName(): string;
  39643. /**
  39644. * Get the friendly name associated with the input class.
  39645. * @returns the input friendly name
  39646. */
  39647. getSimpleName(): string;
  39648. }
  39649. }
  39650. declare module "babylonjs/Misc/virtualJoystick" {
  39651. import { Nullable } from "babylonjs/types";
  39652. import { Vector3 } from "babylonjs/Maths/math.vector";
  39653. /**
  39654. * Defines the potential axis of a Joystick
  39655. */
  39656. export enum JoystickAxis {
  39657. /** X axis */
  39658. X = 0,
  39659. /** Y axis */
  39660. Y = 1,
  39661. /** Z axis */
  39662. Z = 2
  39663. }
  39664. /**
  39665. * Class used to define virtual joystick (used in touch mode)
  39666. */
  39667. export class VirtualJoystick {
  39668. /**
  39669. * Gets or sets a boolean indicating that left and right values must be inverted
  39670. */
  39671. reverseLeftRight: boolean;
  39672. /**
  39673. * Gets or sets a boolean indicating that up and down values must be inverted
  39674. */
  39675. reverseUpDown: boolean;
  39676. /**
  39677. * Gets the offset value for the position (ie. the change of the position value)
  39678. */
  39679. deltaPosition: Vector3;
  39680. /**
  39681. * Gets a boolean indicating if the virtual joystick was pressed
  39682. */
  39683. pressed: boolean;
  39684. /**
  39685. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39686. */
  39687. static Canvas: Nullable<HTMLCanvasElement>;
  39688. private static _globalJoystickIndex;
  39689. private static vjCanvasContext;
  39690. private static vjCanvasWidth;
  39691. private static vjCanvasHeight;
  39692. private static halfWidth;
  39693. private _action;
  39694. private _axisTargetedByLeftAndRight;
  39695. private _axisTargetedByUpAndDown;
  39696. private _joystickSensibility;
  39697. private _inversedSensibility;
  39698. private _joystickPointerID;
  39699. private _joystickColor;
  39700. private _joystickPointerPos;
  39701. private _joystickPreviousPointerPos;
  39702. private _joystickPointerStartPos;
  39703. private _deltaJoystickVector;
  39704. private _leftJoystick;
  39705. private _touches;
  39706. private _onPointerDownHandlerRef;
  39707. private _onPointerMoveHandlerRef;
  39708. private _onPointerUpHandlerRef;
  39709. private _onResize;
  39710. /**
  39711. * Creates a new virtual joystick
  39712. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39713. */
  39714. constructor(leftJoystick?: boolean);
  39715. /**
  39716. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39717. * @param newJoystickSensibility defines the new sensibility
  39718. */
  39719. setJoystickSensibility(newJoystickSensibility: number): void;
  39720. private _onPointerDown;
  39721. private _onPointerMove;
  39722. private _onPointerUp;
  39723. /**
  39724. * Change the color of the virtual joystick
  39725. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39726. */
  39727. setJoystickColor(newColor: string): void;
  39728. /**
  39729. * Defines a callback to call when the joystick is touched
  39730. * @param action defines the callback
  39731. */
  39732. setActionOnTouch(action: () => any): void;
  39733. /**
  39734. * Defines which axis you'd like to control for left & right
  39735. * @param axis defines the axis to use
  39736. */
  39737. setAxisForLeftRight(axis: JoystickAxis): void;
  39738. /**
  39739. * Defines which axis you'd like to control for up & down
  39740. * @param axis defines the axis to use
  39741. */
  39742. setAxisForUpDown(axis: JoystickAxis): void;
  39743. private _drawVirtualJoystick;
  39744. /**
  39745. * Release internal HTML canvas
  39746. */
  39747. releaseCanvas(): void;
  39748. }
  39749. }
  39750. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39751. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39752. import { Nullable } from "babylonjs/types";
  39753. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39754. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39755. module "babylonjs/Cameras/freeCameraInputsManager" {
  39756. interface FreeCameraInputsManager {
  39757. /**
  39758. * Add virtual joystick input support to the input manager.
  39759. * @returns the current input manager
  39760. */
  39761. addVirtualJoystick(): FreeCameraInputsManager;
  39762. }
  39763. }
  39764. /**
  39765. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39767. */
  39768. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39769. /**
  39770. * Defines the camera the input is attached to.
  39771. */
  39772. camera: FreeCamera;
  39773. private _leftjoystick;
  39774. private _rightjoystick;
  39775. /**
  39776. * Gets the left stick of the virtual joystick.
  39777. * @returns The virtual Joystick
  39778. */
  39779. getLeftJoystick(): VirtualJoystick;
  39780. /**
  39781. * Gets the right stick of the virtual joystick.
  39782. * @returns The virtual Joystick
  39783. */
  39784. getRightJoystick(): VirtualJoystick;
  39785. /**
  39786. * Update the current camera state depending on the inputs that have been used this frame.
  39787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39788. */
  39789. checkInputs(): void;
  39790. /**
  39791. * Attach the input controls to a specific dom element to get the input from.
  39792. * @param element Defines the element the controls should be listened from
  39793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39794. */
  39795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39796. /**
  39797. * Detach the current controls from the specified dom element.
  39798. * @param element Defines the element to stop listening the inputs from
  39799. */
  39800. detachControl(element: Nullable<HTMLElement>): void;
  39801. /**
  39802. * Gets the class name of the current intput.
  39803. * @returns the class name
  39804. */
  39805. getClassName(): string;
  39806. /**
  39807. * Get the friendly name associated with the input class.
  39808. * @returns the input friendly name
  39809. */
  39810. getSimpleName(): string;
  39811. }
  39812. }
  39813. declare module "babylonjs/Cameras/Inputs/index" {
  39814. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39815. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39816. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39817. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39818. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39819. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39820. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39821. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39822. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39823. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39824. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39825. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39826. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39827. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39828. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39829. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39830. }
  39831. declare module "babylonjs/Cameras/touchCamera" {
  39832. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39833. import { Scene } from "babylonjs/scene";
  39834. import { Vector3 } from "babylonjs/Maths/math.vector";
  39835. /**
  39836. * This represents a FPS type of camera controlled by touch.
  39837. * This is like a universal camera minus the Gamepad controls.
  39838. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39839. */
  39840. export class TouchCamera extends FreeCamera {
  39841. /**
  39842. * Defines the touch sensibility for rotation.
  39843. * The higher the faster.
  39844. */
  39845. touchAngularSensibility: number;
  39846. /**
  39847. * Defines the touch sensibility for move.
  39848. * The higher the faster.
  39849. */
  39850. touchMoveSensibility: number;
  39851. /**
  39852. * Instantiates a new touch camera.
  39853. * This represents a FPS type of camera controlled by touch.
  39854. * This is like a universal camera minus the Gamepad controls.
  39855. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39856. * @param name Define the name of the camera in the scene
  39857. * @param position Define the start position of the camera in the scene
  39858. * @param scene Define the scene the camera belongs to
  39859. */
  39860. constructor(name: string, position: Vector3, scene: Scene);
  39861. /**
  39862. * Gets the current object class name.
  39863. * @return the class name
  39864. */
  39865. getClassName(): string;
  39866. /** @hidden */
  39867. _setupInputs(): void;
  39868. }
  39869. }
  39870. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39871. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39872. import { Scene } from "babylonjs/scene";
  39873. import { Vector3 } from "babylonjs/Maths/math.vector";
  39874. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39875. import { Axis } from "babylonjs/Maths/math.axis";
  39876. /**
  39877. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39878. * being tilted forward or back and left or right.
  39879. */
  39880. export class DeviceOrientationCamera extends FreeCamera {
  39881. private _initialQuaternion;
  39882. private _quaternionCache;
  39883. private _tmpDragQuaternion;
  39884. private _disablePointerInputWhenUsingDeviceOrientation;
  39885. /**
  39886. * Creates a new device orientation camera
  39887. * @param name The name of the camera
  39888. * @param position The start position camera
  39889. * @param scene The scene the camera belongs to
  39890. */
  39891. constructor(name: string, position: Vector3, scene: Scene);
  39892. /**
  39893. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39894. */
  39895. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39896. private _dragFactor;
  39897. /**
  39898. * Enabled turning on the y axis when the orientation sensor is active
  39899. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39900. */
  39901. enableHorizontalDragging(dragFactor?: number): void;
  39902. /**
  39903. * Gets the current instance class name ("DeviceOrientationCamera").
  39904. * This helps avoiding instanceof at run time.
  39905. * @returns the class name
  39906. */
  39907. getClassName(): string;
  39908. /**
  39909. * @hidden
  39910. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39911. */
  39912. _checkInputs(): void;
  39913. /**
  39914. * Reset the camera to its default orientation on the specified axis only.
  39915. * @param axis The axis to reset
  39916. */
  39917. resetToCurrentRotation(axis?: Axis): void;
  39918. }
  39919. }
  39920. declare module "babylonjs/Gamepads/xboxGamepad" {
  39921. import { Observable } from "babylonjs/Misc/observable";
  39922. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39923. /**
  39924. * Defines supported buttons for XBox360 compatible gamepads
  39925. */
  39926. export enum Xbox360Button {
  39927. /** A */
  39928. A = 0,
  39929. /** B */
  39930. B = 1,
  39931. /** X */
  39932. X = 2,
  39933. /** Y */
  39934. Y = 3,
  39935. /** Start */
  39936. Start = 4,
  39937. /** Back */
  39938. Back = 5,
  39939. /** Left button */
  39940. LB = 6,
  39941. /** Right button */
  39942. RB = 7,
  39943. /** Left stick */
  39944. LeftStick = 8,
  39945. /** Right stick */
  39946. RightStick = 9
  39947. }
  39948. /** Defines values for XBox360 DPad */
  39949. export enum Xbox360Dpad {
  39950. /** Up */
  39951. Up = 0,
  39952. /** Down */
  39953. Down = 1,
  39954. /** Left */
  39955. Left = 2,
  39956. /** Right */
  39957. Right = 3
  39958. }
  39959. /**
  39960. * Defines a XBox360 gamepad
  39961. */
  39962. export class Xbox360Pad extends Gamepad {
  39963. private _leftTrigger;
  39964. private _rightTrigger;
  39965. private _onlefttriggerchanged;
  39966. private _onrighttriggerchanged;
  39967. private _onbuttondown;
  39968. private _onbuttonup;
  39969. private _ondpaddown;
  39970. private _ondpadup;
  39971. /** Observable raised when a button is pressed */
  39972. onButtonDownObservable: Observable<Xbox360Button>;
  39973. /** Observable raised when a button is released */
  39974. onButtonUpObservable: Observable<Xbox360Button>;
  39975. /** Observable raised when a pad is pressed */
  39976. onPadDownObservable: Observable<Xbox360Dpad>;
  39977. /** Observable raised when a pad is released */
  39978. onPadUpObservable: Observable<Xbox360Dpad>;
  39979. private _buttonA;
  39980. private _buttonB;
  39981. private _buttonX;
  39982. private _buttonY;
  39983. private _buttonBack;
  39984. private _buttonStart;
  39985. private _buttonLB;
  39986. private _buttonRB;
  39987. private _buttonLeftStick;
  39988. private _buttonRightStick;
  39989. private _dPadUp;
  39990. private _dPadDown;
  39991. private _dPadLeft;
  39992. private _dPadRight;
  39993. private _isXboxOnePad;
  39994. /**
  39995. * Creates a new XBox360 gamepad object
  39996. * @param id defines the id of this gamepad
  39997. * @param index defines its index
  39998. * @param gamepad defines the internal HTML gamepad object
  39999. * @param xboxOne defines if it is a XBox One gamepad
  40000. */
  40001. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40002. /**
  40003. * Defines the callback to call when left trigger is pressed
  40004. * @param callback defines the callback to use
  40005. */
  40006. onlefttriggerchanged(callback: (value: number) => void): void;
  40007. /**
  40008. * Defines the callback to call when right trigger is pressed
  40009. * @param callback defines the callback to use
  40010. */
  40011. onrighttriggerchanged(callback: (value: number) => void): void;
  40012. /**
  40013. * Gets the left trigger value
  40014. */
  40015. /**
  40016. * Sets the left trigger value
  40017. */
  40018. leftTrigger: number;
  40019. /**
  40020. * Gets the right trigger value
  40021. */
  40022. /**
  40023. * Sets the right trigger value
  40024. */
  40025. rightTrigger: number;
  40026. /**
  40027. * Defines the callback to call when a button is pressed
  40028. * @param callback defines the callback to use
  40029. */
  40030. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40031. /**
  40032. * Defines the callback to call when a button is released
  40033. * @param callback defines the callback to use
  40034. */
  40035. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40036. /**
  40037. * Defines the callback to call when a pad is pressed
  40038. * @param callback defines the callback to use
  40039. */
  40040. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40041. /**
  40042. * Defines the callback to call when a pad is released
  40043. * @param callback defines the callback to use
  40044. */
  40045. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40046. private _setButtonValue;
  40047. private _setDPadValue;
  40048. /**
  40049. * Gets the value of the `A` button
  40050. */
  40051. /**
  40052. * Sets the value of the `A` button
  40053. */
  40054. buttonA: number;
  40055. /**
  40056. * Gets the value of the `B` button
  40057. */
  40058. /**
  40059. * Sets the value of the `B` button
  40060. */
  40061. buttonB: number;
  40062. /**
  40063. * Gets the value of the `X` button
  40064. */
  40065. /**
  40066. * Sets the value of the `X` button
  40067. */
  40068. buttonX: number;
  40069. /**
  40070. * Gets the value of the `Y` button
  40071. */
  40072. /**
  40073. * Sets the value of the `Y` button
  40074. */
  40075. buttonY: number;
  40076. /**
  40077. * Gets the value of the `Start` button
  40078. */
  40079. /**
  40080. * Sets the value of the `Start` button
  40081. */
  40082. buttonStart: number;
  40083. /**
  40084. * Gets the value of the `Back` button
  40085. */
  40086. /**
  40087. * Sets the value of the `Back` button
  40088. */
  40089. buttonBack: number;
  40090. /**
  40091. * Gets the value of the `Left` button
  40092. */
  40093. /**
  40094. * Sets the value of the `Left` button
  40095. */
  40096. buttonLB: number;
  40097. /**
  40098. * Gets the value of the `Right` button
  40099. */
  40100. /**
  40101. * Sets the value of the `Right` button
  40102. */
  40103. buttonRB: number;
  40104. /**
  40105. * Gets the value of the Left joystick
  40106. */
  40107. /**
  40108. * Sets the value of the Left joystick
  40109. */
  40110. buttonLeftStick: number;
  40111. /**
  40112. * Gets the value of the Right joystick
  40113. */
  40114. /**
  40115. * Sets the value of the Right joystick
  40116. */
  40117. buttonRightStick: number;
  40118. /**
  40119. * Gets the value of D-pad up
  40120. */
  40121. /**
  40122. * Sets the value of D-pad up
  40123. */
  40124. dPadUp: number;
  40125. /**
  40126. * Gets the value of D-pad down
  40127. */
  40128. /**
  40129. * Sets the value of D-pad down
  40130. */
  40131. dPadDown: number;
  40132. /**
  40133. * Gets the value of D-pad left
  40134. */
  40135. /**
  40136. * Sets the value of D-pad left
  40137. */
  40138. dPadLeft: number;
  40139. /**
  40140. * Gets the value of D-pad right
  40141. */
  40142. /**
  40143. * Sets the value of D-pad right
  40144. */
  40145. dPadRight: number;
  40146. /**
  40147. * Force the gamepad to synchronize with device values
  40148. */
  40149. update(): void;
  40150. /**
  40151. * Disposes the gamepad
  40152. */
  40153. dispose(): void;
  40154. }
  40155. }
  40156. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40157. import { Observable } from "babylonjs/Misc/observable";
  40158. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40159. /**
  40160. * Defines supported buttons for DualShock compatible gamepads
  40161. */
  40162. export enum DualShockButton {
  40163. /** Cross */
  40164. Cross = 0,
  40165. /** Circle */
  40166. Circle = 1,
  40167. /** Square */
  40168. Square = 2,
  40169. /** Triangle */
  40170. Triangle = 3,
  40171. /** Options */
  40172. Options = 4,
  40173. /** Share */
  40174. Share = 5,
  40175. /** L1 */
  40176. L1 = 6,
  40177. /** R1 */
  40178. R1 = 7,
  40179. /** Left stick */
  40180. LeftStick = 8,
  40181. /** Right stick */
  40182. RightStick = 9
  40183. }
  40184. /** Defines values for DualShock DPad */
  40185. export enum DualShockDpad {
  40186. /** Up */
  40187. Up = 0,
  40188. /** Down */
  40189. Down = 1,
  40190. /** Left */
  40191. Left = 2,
  40192. /** Right */
  40193. Right = 3
  40194. }
  40195. /**
  40196. * Defines a DualShock gamepad
  40197. */
  40198. export class DualShockPad extends Gamepad {
  40199. private _leftTrigger;
  40200. private _rightTrigger;
  40201. private _onlefttriggerchanged;
  40202. private _onrighttriggerchanged;
  40203. private _onbuttondown;
  40204. private _onbuttonup;
  40205. private _ondpaddown;
  40206. private _ondpadup;
  40207. /** Observable raised when a button is pressed */
  40208. onButtonDownObservable: Observable<DualShockButton>;
  40209. /** Observable raised when a button is released */
  40210. onButtonUpObservable: Observable<DualShockButton>;
  40211. /** Observable raised when a pad is pressed */
  40212. onPadDownObservable: Observable<DualShockDpad>;
  40213. /** Observable raised when a pad is released */
  40214. onPadUpObservable: Observable<DualShockDpad>;
  40215. private _buttonCross;
  40216. private _buttonCircle;
  40217. private _buttonSquare;
  40218. private _buttonTriangle;
  40219. private _buttonShare;
  40220. private _buttonOptions;
  40221. private _buttonL1;
  40222. private _buttonR1;
  40223. private _buttonLeftStick;
  40224. private _buttonRightStick;
  40225. private _dPadUp;
  40226. private _dPadDown;
  40227. private _dPadLeft;
  40228. private _dPadRight;
  40229. /**
  40230. * Creates a new DualShock gamepad object
  40231. * @param id defines the id of this gamepad
  40232. * @param index defines its index
  40233. * @param gamepad defines the internal HTML gamepad object
  40234. */
  40235. constructor(id: string, index: number, gamepad: any);
  40236. /**
  40237. * Defines the callback to call when left trigger is pressed
  40238. * @param callback defines the callback to use
  40239. */
  40240. onlefttriggerchanged(callback: (value: number) => void): void;
  40241. /**
  40242. * Defines the callback to call when right trigger is pressed
  40243. * @param callback defines the callback to use
  40244. */
  40245. onrighttriggerchanged(callback: (value: number) => void): void;
  40246. /**
  40247. * Gets the left trigger value
  40248. */
  40249. /**
  40250. * Sets the left trigger value
  40251. */
  40252. leftTrigger: number;
  40253. /**
  40254. * Gets the right trigger value
  40255. */
  40256. /**
  40257. * Sets the right trigger value
  40258. */
  40259. rightTrigger: number;
  40260. /**
  40261. * Defines the callback to call when a button is pressed
  40262. * @param callback defines the callback to use
  40263. */
  40264. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40265. /**
  40266. * Defines the callback to call when a button is released
  40267. * @param callback defines the callback to use
  40268. */
  40269. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40270. /**
  40271. * Defines the callback to call when a pad is pressed
  40272. * @param callback defines the callback to use
  40273. */
  40274. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40275. /**
  40276. * Defines the callback to call when a pad is released
  40277. * @param callback defines the callback to use
  40278. */
  40279. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40280. private _setButtonValue;
  40281. private _setDPadValue;
  40282. /**
  40283. * Gets the value of the `Cross` button
  40284. */
  40285. /**
  40286. * Sets the value of the `Cross` button
  40287. */
  40288. buttonCross: number;
  40289. /**
  40290. * Gets the value of the `Circle` button
  40291. */
  40292. /**
  40293. * Sets the value of the `Circle` button
  40294. */
  40295. buttonCircle: number;
  40296. /**
  40297. * Gets the value of the `Square` button
  40298. */
  40299. /**
  40300. * Sets the value of the `Square` button
  40301. */
  40302. buttonSquare: number;
  40303. /**
  40304. * Gets the value of the `Triangle` button
  40305. */
  40306. /**
  40307. * Sets the value of the `Triangle` button
  40308. */
  40309. buttonTriangle: number;
  40310. /**
  40311. * Gets the value of the `Options` button
  40312. */
  40313. /**
  40314. * Sets the value of the `Options` button
  40315. */
  40316. buttonOptions: number;
  40317. /**
  40318. * Gets the value of the `Share` button
  40319. */
  40320. /**
  40321. * Sets the value of the `Share` button
  40322. */
  40323. buttonShare: number;
  40324. /**
  40325. * Gets the value of the `L1` button
  40326. */
  40327. /**
  40328. * Sets the value of the `L1` button
  40329. */
  40330. buttonL1: number;
  40331. /**
  40332. * Gets the value of the `R1` button
  40333. */
  40334. /**
  40335. * Sets the value of the `R1` button
  40336. */
  40337. buttonR1: number;
  40338. /**
  40339. * Gets the value of the Left joystick
  40340. */
  40341. /**
  40342. * Sets the value of the Left joystick
  40343. */
  40344. buttonLeftStick: number;
  40345. /**
  40346. * Gets the value of the Right joystick
  40347. */
  40348. /**
  40349. * Sets the value of the Right joystick
  40350. */
  40351. buttonRightStick: number;
  40352. /**
  40353. * Gets the value of D-pad up
  40354. */
  40355. /**
  40356. * Sets the value of D-pad up
  40357. */
  40358. dPadUp: number;
  40359. /**
  40360. * Gets the value of D-pad down
  40361. */
  40362. /**
  40363. * Sets the value of D-pad down
  40364. */
  40365. dPadDown: number;
  40366. /**
  40367. * Gets the value of D-pad left
  40368. */
  40369. /**
  40370. * Sets the value of D-pad left
  40371. */
  40372. dPadLeft: number;
  40373. /**
  40374. * Gets the value of D-pad right
  40375. */
  40376. /**
  40377. * Sets the value of D-pad right
  40378. */
  40379. dPadRight: number;
  40380. /**
  40381. * Force the gamepad to synchronize with device values
  40382. */
  40383. update(): void;
  40384. /**
  40385. * Disposes the gamepad
  40386. */
  40387. dispose(): void;
  40388. }
  40389. }
  40390. declare module "babylonjs/Gamepads/gamepadManager" {
  40391. import { Observable } from "babylonjs/Misc/observable";
  40392. import { Nullable } from "babylonjs/types";
  40393. import { Scene } from "babylonjs/scene";
  40394. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40395. /**
  40396. * Manager for handling gamepads
  40397. */
  40398. export class GamepadManager {
  40399. private _scene?;
  40400. private _babylonGamepads;
  40401. private _oneGamepadConnected;
  40402. /** @hidden */
  40403. _isMonitoring: boolean;
  40404. private _gamepadEventSupported;
  40405. private _gamepadSupport;
  40406. /**
  40407. * observable to be triggered when the gamepad controller has been connected
  40408. */
  40409. onGamepadConnectedObservable: Observable<Gamepad>;
  40410. /**
  40411. * observable to be triggered when the gamepad controller has been disconnected
  40412. */
  40413. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40414. private _onGamepadConnectedEvent;
  40415. private _onGamepadDisconnectedEvent;
  40416. /**
  40417. * Initializes the gamepad manager
  40418. * @param _scene BabylonJS scene
  40419. */
  40420. constructor(_scene?: Scene | undefined);
  40421. /**
  40422. * The gamepads in the game pad manager
  40423. */
  40424. readonly gamepads: Gamepad[];
  40425. /**
  40426. * Get the gamepad controllers based on type
  40427. * @param type The type of gamepad controller
  40428. * @returns Nullable gamepad
  40429. */
  40430. getGamepadByType(type?: number): Nullable<Gamepad>;
  40431. /**
  40432. * Disposes the gamepad manager
  40433. */
  40434. dispose(): void;
  40435. private _addNewGamepad;
  40436. private _startMonitoringGamepads;
  40437. private _stopMonitoringGamepads;
  40438. /** @hidden */
  40439. _checkGamepadsStatus(): void;
  40440. private _updateGamepadObjects;
  40441. }
  40442. }
  40443. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40444. import { Nullable } from "babylonjs/types";
  40445. import { Scene } from "babylonjs/scene";
  40446. import { ISceneComponent } from "babylonjs/sceneComponent";
  40447. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40448. module "babylonjs/scene" {
  40449. interface Scene {
  40450. /** @hidden */
  40451. _gamepadManager: Nullable<GamepadManager>;
  40452. /**
  40453. * Gets the gamepad manager associated with the scene
  40454. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40455. */
  40456. gamepadManager: GamepadManager;
  40457. }
  40458. }
  40459. module "babylonjs/Cameras/freeCameraInputsManager" {
  40460. /**
  40461. * Interface representing a free camera inputs manager
  40462. */
  40463. interface FreeCameraInputsManager {
  40464. /**
  40465. * Adds gamepad input support to the FreeCameraInputsManager.
  40466. * @returns the FreeCameraInputsManager
  40467. */
  40468. addGamepad(): FreeCameraInputsManager;
  40469. }
  40470. }
  40471. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40472. /**
  40473. * Interface representing an arc rotate camera inputs manager
  40474. */
  40475. interface ArcRotateCameraInputsManager {
  40476. /**
  40477. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40478. * @returns the camera inputs manager
  40479. */
  40480. addGamepad(): ArcRotateCameraInputsManager;
  40481. }
  40482. }
  40483. /**
  40484. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40485. */
  40486. export class GamepadSystemSceneComponent implements ISceneComponent {
  40487. /**
  40488. * The component name helpfull to identify the component in the list of scene components.
  40489. */
  40490. readonly name: string;
  40491. /**
  40492. * The scene the component belongs to.
  40493. */
  40494. scene: Scene;
  40495. /**
  40496. * Creates a new instance of the component for the given scene
  40497. * @param scene Defines the scene to register the component in
  40498. */
  40499. constructor(scene: Scene);
  40500. /**
  40501. * Registers the component in a given scene
  40502. */
  40503. register(): void;
  40504. /**
  40505. * Rebuilds the elements related to this component in case of
  40506. * context lost for instance.
  40507. */
  40508. rebuild(): void;
  40509. /**
  40510. * Disposes the component and the associated ressources
  40511. */
  40512. dispose(): void;
  40513. private _beforeCameraUpdate;
  40514. }
  40515. }
  40516. declare module "babylonjs/Cameras/universalCamera" {
  40517. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40518. import { Scene } from "babylonjs/scene";
  40519. import { Vector3 } from "babylonjs/Maths/math.vector";
  40520. import "babylonjs/Gamepads/gamepadSceneComponent";
  40521. /**
  40522. * 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,
  40523. * which still works and will still be found in many Playgrounds.
  40524. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40525. */
  40526. export class UniversalCamera extends TouchCamera {
  40527. /**
  40528. * Defines the gamepad rotation sensiblity.
  40529. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40530. */
  40531. gamepadAngularSensibility: number;
  40532. /**
  40533. * Defines the gamepad move sensiblity.
  40534. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40535. */
  40536. gamepadMoveSensibility: number;
  40537. /**
  40538. * 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,
  40539. * which still works and will still be found in many Playgrounds.
  40540. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40541. * @param name Define the name of the camera in the scene
  40542. * @param position Define the start position of the camera in the scene
  40543. * @param scene Define the scene the camera belongs to
  40544. */
  40545. constructor(name: string, position: Vector3, scene: Scene);
  40546. /**
  40547. * Gets the current object class name.
  40548. * @return the class name
  40549. */
  40550. getClassName(): string;
  40551. }
  40552. }
  40553. declare module "babylonjs/Cameras/gamepadCamera" {
  40554. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40555. import { Scene } from "babylonjs/scene";
  40556. import { Vector3 } from "babylonjs/Maths/math.vector";
  40557. /**
  40558. * This represents a FPS type of camera. This is only here for back compat purpose.
  40559. * Please use the UniversalCamera instead as both are identical.
  40560. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40561. */
  40562. export class GamepadCamera extends UniversalCamera {
  40563. /**
  40564. * Instantiates a new Gamepad Camera
  40565. * This represents a FPS type of camera. This is only here for back compat purpose.
  40566. * Please use the UniversalCamera instead as both are identical.
  40567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40568. * @param name Define the name of the camera in the scene
  40569. * @param position Define the start position of the camera in the scene
  40570. * @param scene Define the scene the camera belongs to
  40571. */
  40572. constructor(name: string, position: Vector3, scene: Scene);
  40573. /**
  40574. * Gets the current object class name.
  40575. * @return the class name
  40576. */
  40577. getClassName(): string;
  40578. }
  40579. }
  40580. declare module "babylonjs/Shaders/pass.fragment" {
  40581. /** @hidden */
  40582. export var passPixelShader: {
  40583. name: string;
  40584. shader: string;
  40585. };
  40586. }
  40587. declare module "babylonjs/Shaders/passCube.fragment" {
  40588. /** @hidden */
  40589. export var passCubePixelShader: {
  40590. name: string;
  40591. shader: string;
  40592. };
  40593. }
  40594. declare module "babylonjs/PostProcesses/passPostProcess" {
  40595. import { Nullable } from "babylonjs/types";
  40596. import { Camera } from "babylonjs/Cameras/camera";
  40597. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40598. import { Engine } from "babylonjs/Engines/engine";
  40599. import "babylonjs/Shaders/pass.fragment";
  40600. import "babylonjs/Shaders/passCube.fragment";
  40601. /**
  40602. * PassPostProcess which produces an output the same as it's input
  40603. */
  40604. export class PassPostProcess extends PostProcess {
  40605. /**
  40606. * Creates the PassPostProcess
  40607. * @param name The name of the effect.
  40608. * @param options The required width/height ratio to downsize to before computing the render pass.
  40609. * @param camera The camera to apply the render pass to.
  40610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40611. * @param engine The engine which the post process will be applied. (default: current engine)
  40612. * @param reusable If the post process can be reused on the same frame. (default: false)
  40613. * @param textureType The type of texture to be used when performing the post processing.
  40614. * @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)
  40615. */
  40616. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40617. }
  40618. /**
  40619. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40620. */
  40621. export class PassCubePostProcess extends PostProcess {
  40622. private _face;
  40623. /**
  40624. * Gets or sets the cube face to display.
  40625. * * 0 is +X
  40626. * * 1 is -X
  40627. * * 2 is +Y
  40628. * * 3 is -Y
  40629. * * 4 is +Z
  40630. * * 5 is -Z
  40631. */
  40632. face: number;
  40633. /**
  40634. * Creates the PassCubePostProcess
  40635. * @param name The name of the effect.
  40636. * @param options The required width/height ratio to downsize to before computing the render pass.
  40637. * @param camera The camera to apply the render pass to.
  40638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40639. * @param engine The engine which the post process will be applied. (default: current engine)
  40640. * @param reusable If the post process can be reused on the same frame. (default: false)
  40641. * @param textureType The type of texture to be used when performing the post processing.
  40642. * @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)
  40643. */
  40644. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40645. }
  40646. }
  40647. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40648. /** @hidden */
  40649. export var anaglyphPixelShader: {
  40650. name: string;
  40651. shader: string;
  40652. };
  40653. }
  40654. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40655. import { Engine } from "babylonjs/Engines/engine";
  40656. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40657. import { Camera } from "babylonjs/Cameras/camera";
  40658. import "babylonjs/Shaders/anaglyph.fragment";
  40659. /**
  40660. * Postprocess used to generate anaglyphic rendering
  40661. */
  40662. export class AnaglyphPostProcess extends PostProcess {
  40663. private _passedProcess;
  40664. /**
  40665. * Creates a new AnaglyphPostProcess
  40666. * @param name defines postprocess name
  40667. * @param options defines creation options or target ratio scale
  40668. * @param rigCameras defines cameras using this postprocess
  40669. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40670. * @param engine defines hosting engine
  40671. * @param reusable defines if the postprocess will be reused multiple times per frame
  40672. */
  40673. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40674. }
  40675. }
  40676. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40677. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40678. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40679. import { Scene } from "babylonjs/scene";
  40680. import { Vector3 } from "babylonjs/Maths/math.vector";
  40681. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40682. /**
  40683. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40684. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40685. */
  40686. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40687. /**
  40688. * Creates a new AnaglyphArcRotateCamera
  40689. * @param name defines camera name
  40690. * @param alpha defines alpha angle (in radians)
  40691. * @param beta defines beta angle (in radians)
  40692. * @param radius defines radius
  40693. * @param target defines camera target
  40694. * @param interaxialDistance defines distance between each color axis
  40695. * @param scene defines the hosting scene
  40696. */
  40697. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40698. /**
  40699. * Gets camera class name
  40700. * @returns AnaglyphArcRotateCamera
  40701. */
  40702. getClassName(): string;
  40703. }
  40704. }
  40705. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40706. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40707. import { Scene } from "babylonjs/scene";
  40708. import { Vector3 } from "babylonjs/Maths/math.vector";
  40709. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40710. /**
  40711. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40712. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40713. */
  40714. export class AnaglyphFreeCamera extends FreeCamera {
  40715. /**
  40716. * Creates a new AnaglyphFreeCamera
  40717. * @param name defines camera name
  40718. * @param position defines initial position
  40719. * @param interaxialDistance defines distance between each color axis
  40720. * @param scene defines the hosting scene
  40721. */
  40722. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40723. /**
  40724. * Gets camera class name
  40725. * @returns AnaglyphFreeCamera
  40726. */
  40727. getClassName(): string;
  40728. }
  40729. }
  40730. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40731. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40732. import { Scene } from "babylonjs/scene";
  40733. import { Vector3 } from "babylonjs/Maths/math.vector";
  40734. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40735. /**
  40736. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40737. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40738. */
  40739. export class AnaglyphGamepadCamera extends GamepadCamera {
  40740. /**
  40741. * Creates a new AnaglyphGamepadCamera
  40742. * @param name defines camera name
  40743. * @param position defines initial position
  40744. * @param interaxialDistance defines distance between each color axis
  40745. * @param scene defines the hosting scene
  40746. */
  40747. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40748. /**
  40749. * Gets camera class name
  40750. * @returns AnaglyphGamepadCamera
  40751. */
  40752. getClassName(): string;
  40753. }
  40754. }
  40755. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40756. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40757. import { Scene } from "babylonjs/scene";
  40758. import { Vector3 } from "babylonjs/Maths/math.vector";
  40759. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40760. /**
  40761. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40762. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40763. */
  40764. export class AnaglyphUniversalCamera extends UniversalCamera {
  40765. /**
  40766. * Creates a new AnaglyphUniversalCamera
  40767. * @param name defines camera name
  40768. * @param position defines initial position
  40769. * @param interaxialDistance defines distance between each color axis
  40770. * @param scene defines the hosting scene
  40771. */
  40772. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40773. /**
  40774. * Gets camera class name
  40775. * @returns AnaglyphUniversalCamera
  40776. */
  40777. getClassName(): string;
  40778. }
  40779. }
  40780. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40781. /** @hidden */
  40782. export var stereoscopicInterlacePixelShader: {
  40783. name: string;
  40784. shader: string;
  40785. };
  40786. }
  40787. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40788. import { Camera } from "babylonjs/Cameras/camera";
  40789. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40790. import { Engine } from "babylonjs/Engines/engine";
  40791. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40792. /**
  40793. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40794. */
  40795. export class StereoscopicInterlacePostProcess extends PostProcess {
  40796. private _stepSize;
  40797. private _passedProcess;
  40798. /**
  40799. * Initializes a StereoscopicInterlacePostProcess
  40800. * @param name The name of the effect.
  40801. * @param rigCameras The rig cameras to be appled to the post process
  40802. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40804. * @param engine The engine which the post process will be applied. (default: current engine)
  40805. * @param reusable If the post process can be reused on the same frame. (default: false)
  40806. */
  40807. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40808. }
  40809. }
  40810. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40811. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40812. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40813. import { Scene } from "babylonjs/scene";
  40814. import { Vector3 } from "babylonjs/Maths/math.vector";
  40815. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40816. /**
  40817. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40818. * @see http://doc.babylonjs.com/features/cameras
  40819. */
  40820. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40821. /**
  40822. * Creates a new StereoscopicArcRotateCamera
  40823. * @param name defines camera name
  40824. * @param alpha defines alpha angle (in radians)
  40825. * @param beta defines beta angle (in radians)
  40826. * @param radius defines radius
  40827. * @param target defines camera target
  40828. * @param interaxialDistance defines distance between each color axis
  40829. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40830. * @param scene defines the hosting scene
  40831. */
  40832. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40833. /**
  40834. * Gets camera class name
  40835. * @returns StereoscopicArcRotateCamera
  40836. */
  40837. getClassName(): string;
  40838. }
  40839. }
  40840. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40841. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40842. import { Scene } from "babylonjs/scene";
  40843. import { Vector3 } from "babylonjs/Maths/math.vector";
  40844. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40845. /**
  40846. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40847. * @see http://doc.babylonjs.com/features/cameras
  40848. */
  40849. export class StereoscopicFreeCamera extends FreeCamera {
  40850. /**
  40851. * Creates a new StereoscopicFreeCamera
  40852. * @param name defines camera name
  40853. * @param position defines initial position
  40854. * @param interaxialDistance defines distance between each color axis
  40855. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40856. * @param scene defines the hosting scene
  40857. */
  40858. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40859. /**
  40860. * Gets camera class name
  40861. * @returns StereoscopicFreeCamera
  40862. */
  40863. getClassName(): string;
  40864. }
  40865. }
  40866. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40867. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40868. import { Scene } from "babylonjs/scene";
  40869. import { Vector3 } from "babylonjs/Maths/math.vector";
  40870. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40871. /**
  40872. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40873. * @see http://doc.babylonjs.com/features/cameras
  40874. */
  40875. export class StereoscopicGamepadCamera extends GamepadCamera {
  40876. /**
  40877. * Creates a new StereoscopicGamepadCamera
  40878. * @param name defines camera name
  40879. * @param position defines initial position
  40880. * @param interaxialDistance defines distance between each color axis
  40881. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40882. * @param scene defines the hosting scene
  40883. */
  40884. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40885. /**
  40886. * Gets camera class name
  40887. * @returns StereoscopicGamepadCamera
  40888. */
  40889. getClassName(): string;
  40890. }
  40891. }
  40892. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40893. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40894. import { Scene } from "babylonjs/scene";
  40895. import { Vector3 } from "babylonjs/Maths/math.vector";
  40896. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40897. /**
  40898. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40899. * @see http://doc.babylonjs.com/features/cameras
  40900. */
  40901. export class StereoscopicUniversalCamera extends UniversalCamera {
  40902. /**
  40903. * Creates a new StereoscopicUniversalCamera
  40904. * @param name defines camera name
  40905. * @param position defines initial position
  40906. * @param interaxialDistance defines distance between each color axis
  40907. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40908. * @param scene defines the hosting scene
  40909. */
  40910. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40911. /**
  40912. * Gets camera class name
  40913. * @returns StereoscopicUniversalCamera
  40914. */
  40915. getClassName(): string;
  40916. }
  40917. }
  40918. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40919. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40920. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40921. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40922. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40923. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40924. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40925. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40926. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40927. }
  40928. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40929. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40930. import { Scene } from "babylonjs/scene";
  40931. import { Vector3 } from "babylonjs/Maths/math.vector";
  40932. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40933. /**
  40934. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40935. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40936. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40937. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40938. */
  40939. export class VirtualJoysticksCamera extends FreeCamera {
  40940. /**
  40941. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40942. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40943. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40944. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40945. * @param name Define the name of the camera in the scene
  40946. * @param position Define the start position of the camera in the scene
  40947. * @param scene Define the scene the camera belongs to
  40948. */
  40949. constructor(name: string, position: Vector3, scene: Scene);
  40950. /**
  40951. * Gets the current object class name.
  40952. * @return the class name
  40953. */
  40954. getClassName(): string;
  40955. }
  40956. }
  40957. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40958. import { Matrix } from "babylonjs/Maths/math.vector";
  40959. /**
  40960. * This represents all the required metrics to create a VR camera.
  40961. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40962. */
  40963. export class VRCameraMetrics {
  40964. /**
  40965. * Define the horizontal resolution off the screen.
  40966. */
  40967. hResolution: number;
  40968. /**
  40969. * Define the vertical resolution off the screen.
  40970. */
  40971. vResolution: number;
  40972. /**
  40973. * Define the horizontal screen size.
  40974. */
  40975. hScreenSize: number;
  40976. /**
  40977. * Define the vertical screen size.
  40978. */
  40979. vScreenSize: number;
  40980. /**
  40981. * Define the vertical screen center position.
  40982. */
  40983. vScreenCenter: number;
  40984. /**
  40985. * Define the distance of the eyes to the screen.
  40986. */
  40987. eyeToScreenDistance: number;
  40988. /**
  40989. * Define the distance between both lenses
  40990. */
  40991. lensSeparationDistance: number;
  40992. /**
  40993. * Define the distance between both viewer's eyes.
  40994. */
  40995. interpupillaryDistance: number;
  40996. /**
  40997. * Define the distortion factor of the VR postprocess.
  40998. * Please, touch with care.
  40999. */
  41000. distortionK: number[];
  41001. /**
  41002. * Define the chromatic aberration correction factors for the VR post process.
  41003. */
  41004. chromaAbCorrection: number[];
  41005. /**
  41006. * Define the scale factor of the post process.
  41007. * The smaller the better but the slower.
  41008. */
  41009. postProcessScaleFactor: number;
  41010. /**
  41011. * Define an offset for the lens center.
  41012. */
  41013. lensCenterOffset: number;
  41014. /**
  41015. * Define if the current vr camera should compensate the distortion of the lense or not.
  41016. */
  41017. compensateDistortion: boolean;
  41018. /**
  41019. * Defines if multiview should be enabled when rendering (Default: false)
  41020. */
  41021. multiviewEnabled: boolean;
  41022. /**
  41023. * Gets the rendering aspect ratio based on the provided resolutions.
  41024. */
  41025. readonly aspectRatio: number;
  41026. /**
  41027. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41028. */
  41029. readonly aspectRatioFov: number;
  41030. /**
  41031. * @hidden
  41032. */
  41033. readonly leftHMatrix: Matrix;
  41034. /**
  41035. * @hidden
  41036. */
  41037. readonly rightHMatrix: Matrix;
  41038. /**
  41039. * @hidden
  41040. */
  41041. readonly leftPreViewMatrix: Matrix;
  41042. /**
  41043. * @hidden
  41044. */
  41045. readonly rightPreViewMatrix: Matrix;
  41046. /**
  41047. * Get the default VRMetrics based on the most generic setup.
  41048. * @returns the default vr metrics
  41049. */
  41050. static GetDefault(): VRCameraMetrics;
  41051. }
  41052. }
  41053. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41054. /** @hidden */
  41055. export var vrDistortionCorrectionPixelShader: {
  41056. name: string;
  41057. shader: string;
  41058. };
  41059. }
  41060. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41061. import { Camera } from "babylonjs/Cameras/camera";
  41062. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41064. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41065. /**
  41066. * VRDistortionCorrectionPostProcess used for mobile VR
  41067. */
  41068. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41069. private _isRightEye;
  41070. private _distortionFactors;
  41071. private _postProcessScaleFactor;
  41072. private _lensCenterOffset;
  41073. private _scaleIn;
  41074. private _scaleFactor;
  41075. private _lensCenter;
  41076. /**
  41077. * Initializes the VRDistortionCorrectionPostProcess
  41078. * @param name The name of the effect.
  41079. * @param camera The camera to apply the render pass to.
  41080. * @param isRightEye If this is for the right eye distortion
  41081. * @param vrMetrics All the required metrics for the VR camera
  41082. */
  41083. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41084. }
  41085. }
  41086. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41087. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41088. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41089. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41090. import { Scene } from "babylonjs/scene";
  41091. import { Vector3 } from "babylonjs/Maths/math.vector";
  41092. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41093. import "babylonjs/Cameras/RigModes/vrRigMode";
  41094. /**
  41095. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41096. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41097. */
  41098. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41099. /**
  41100. * Creates a new VRDeviceOrientationArcRotateCamera
  41101. * @param name defines camera name
  41102. * @param alpha defines the camera rotation along the logitudinal axis
  41103. * @param beta defines the camera rotation along the latitudinal axis
  41104. * @param radius defines the camera distance from its target
  41105. * @param target defines the camera target
  41106. * @param scene defines the scene the camera belongs to
  41107. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41108. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41109. */
  41110. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41111. /**
  41112. * Gets camera class name
  41113. * @returns VRDeviceOrientationArcRotateCamera
  41114. */
  41115. getClassName(): string;
  41116. }
  41117. }
  41118. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41119. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41120. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41121. import { Scene } from "babylonjs/scene";
  41122. import { Vector3 } from "babylonjs/Maths/math.vector";
  41123. import "babylonjs/Cameras/RigModes/vrRigMode";
  41124. /**
  41125. * Camera used to simulate VR rendering (based on FreeCamera)
  41126. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41127. */
  41128. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41129. /**
  41130. * Creates a new VRDeviceOrientationFreeCamera
  41131. * @param name defines camera name
  41132. * @param position defines the start position of the camera
  41133. * @param scene defines the scene the camera belongs to
  41134. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41135. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41136. */
  41137. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41138. /**
  41139. * Gets camera class name
  41140. * @returns VRDeviceOrientationFreeCamera
  41141. */
  41142. getClassName(): string;
  41143. }
  41144. }
  41145. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41146. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41147. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41148. import { Scene } from "babylonjs/scene";
  41149. import { Vector3 } from "babylonjs/Maths/math.vector";
  41150. import "babylonjs/Gamepads/gamepadSceneComponent";
  41151. /**
  41152. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41153. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41154. */
  41155. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41156. /**
  41157. * Creates a new VRDeviceOrientationGamepadCamera
  41158. * @param name defines camera name
  41159. * @param position defines the start position of the camera
  41160. * @param scene defines the scene the camera belongs to
  41161. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41162. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41163. */
  41164. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41165. /**
  41166. * Gets camera class name
  41167. * @returns VRDeviceOrientationGamepadCamera
  41168. */
  41169. getClassName(): string;
  41170. }
  41171. }
  41172. declare module "babylonjs/Materials/pushMaterial" {
  41173. import { Nullable } from "babylonjs/types";
  41174. import { Scene } from "babylonjs/scene";
  41175. import { Matrix } from "babylonjs/Maths/math.vector";
  41176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41177. import { Mesh } from "babylonjs/Meshes/mesh";
  41178. import { Material } from "babylonjs/Materials/material";
  41179. import { Effect } from "babylonjs/Materials/effect";
  41180. /**
  41181. * Base class of materials working in push mode in babylon JS
  41182. * @hidden
  41183. */
  41184. export class PushMaterial extends Material {
  41185. protected _activeEffect: Effect;
  41186. protected _normalMatrix: Matrix;
  41187. /**
  41188. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41189. * This means that the material can keep using a previous shader while a new one is being compiled.
  41190. * This is mostly used when shader parallel compilation is supported (true by default)
  41191. */
  41192. allowShaderHotSwapping: boolean;
  41193. constructor(name: string, scene: Scene);
  41194. getEffect(): Effect;
  41195. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41196. /**
  41197. * Binds the given world matrix to the active effect
  41198. *
  41199. * @param world the matrix to bind
  41200. */
  41201. bindOnlyWorldMatrix(world: Matrix): void;
  41202. /**
  41203. * Binds the given normal matrix to the active effect
  41204. *
  41205. * @param normalMatrix the matrix to bind
  41206. */
  41207. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41208. bind(world: Matrix, mesh?: Mesh): void;
  41209. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41210. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41211. }
  41212. }
  41213. declare module "babylonjs/Materials/materialFlags" {
  41214. /**
  41215. * This groups all the flags used to control the materials channel.
  41216. */
  41217. export class MaterialFlags {
  41218. private static _DiffuseTextureEnabled;
  41219. /**
  41220. * Are diffuse textures enabled in the application.
  41221. */
  41222. static DiffuseTextureEnabled: boolean;
  41223. private static _AmbientTextureEnabled;
  41224. /**
  41225. * Are ambient textures enabled in the application.
  41226. */
  41227. static AmbientTextureEnabled: boolean;
  41228. private static _OpacityTextureEnabled;
  41229. /**
  41230. * Are opacity textures enabled in the application.
  41231. */
  41232. static OpacityTextureEnabled: boolean;
  41233. private static _ReflectionTextureEnabled;
  41234. /**
  41235. * Are reflection textures enabled in the application.
  41236. */
  41237. static ReflectionTextureEnabled: boolean;
  41238. private static _EmissiveTextureEnabled;
  41239. /**
  41240. * Are emissive textures enabled in the application.
  41241. */
  41242. static EmissiveTextureEnabled: boolean;
  41243. private static _SpecularTextureEnabled;
  41244. /**
  41245. * Are specular textures enabled in the application.
  41246. */
  41247. static SpecularTextureEnabled: boolean;
  41248. private static _BumpTextureEnabled;
  41249. /**
  41250. * Are bump textures enabled in the application.
  41251. */
  41252. static BumpTextureEnabled: boolean;
  41253. private static _LightmapTextureEnabled;
  41254. /**
  41255. * Are lightmap textures enabled in the application.
  41256. */
  41257. static LightmapTextureEnabled: boolean;
  41258. private static _RefractionTextureEnabled;
  41259. /**
  41260. * Are refraction textures enabled in the application.
  41261. */
  41262. static RefractionTextureEnabled: boolean;
  41263. private static _ColorGradingTextureEnabled;
  41264. /**
  41265. * Are color grading textures enabled in the application.
  41266. */
  41267. static ColorGradingTextureEnabled: boolean;
  41268. private static _FresnelEnabled;
  41269. /**
  41270. * Are fresnels enabled in the application.
  41271. */
  41272. static FresnelEnabled: boolean;
  41273. private static _ClearCoatTextureEnabled;
  41274. /**
  41275. * Are clear coat textures enabled in the application.
  41276. */
  41277. static ClearCoatTextureEnabled: boolean;
  41278. private static _ClearCoatBumpTextureEnabled;
  41279. /**
  41280. * Are clear coat bump textures enabled in the application.
  41281. */
  41282. static ClearCoatBumpTextureEnabled: boolean;
  41283. private static _ClearCoatTintTextureEnabled;
  41284. /**
  41285. * Are clear coat tint textures enabled in the application.
  41286. */
  41287. static ClearCoatTintTextureEnabled: boolean;
  41288. private static _SheenTextureEnabled;
  41289. /**
  41290. * Are sheen textures enabled in the application.
  41291. */
  41292. static SheenTextureEnabled: boolean;
  41293. private static _AnisotropicTextureEnabled;
  41294. /**
  41295. * Are anisotropic textures enabled in the application.
  41296. */
  41297. static AnisotropicTextureEnabled: boolean;
  41298. private static _ThicknessTextureEnabled;
  41299. /**
  41300. * Are thickness textures enabled in the application.
  41301. */
  41302. static ThicknessTextureEnabled: boolean;
  41303. }
  41304. }
  41305. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41306. /** @hidden */
  41307. export var defaultFragmentDeclaration: {
  41308. name: string;
  41309. shader: string;
  41310. };
  41311. }
  41312. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41313. /** @hidden */
  41314. export var defaultUboDeclaration: {
  41315. name: string;
  41316. shader: string;
  41317. };
  41318. }
  41319. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41320. /** @hidden */
  41321. export var lightFragmentDeclaration: {
  41322. name: string;
  41323. shader: string;
  41324. };
  41325. }
  41326. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41327. /** @hidden */
  41328. export var lightUboDeclaration: {
  41329. name: string;
  41330. shader: string;
  41331. };
  41332. }
  41333. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41334. /** @hidden */
  41335. export var lightsFragmentFunctions: {
  41336. name: string;
  41337. shader: string;
  41338. };
  41339. }
  41340. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41341. /** @hidden */
  41342. export var shadowsFragmentFunctions: {
  41343. name: string;
  41344. shader: string;
  41345. };
  41346. }
  41347. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41348. /** @hidden */
  41349. export var fresnelFunction: {
  41350. name: string;
  41351. shader: string;
  41352. };
  41353. }
  41354. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41355. /** @hidden */
  41356. export var reflectionFunction: {
  41357. name: string;
  41358. shader: string;
  41359. };
  41360. }
  41361. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41362. /** @hidden */
  41363. export var bumpFragmentFunctions: {
  41364. name: string;
  41365. shader: string;
  41366. };
  41367. }
  41368. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41369. /** @hidden */
  41370. export var logDepthDeclaration: {
  41371. name: string;
  41372. shader: string;
  41373. };
  41374. }
  41375. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41376. /** @hidden */
  41377. export var bumpFragment: {
  41378. name: string;
  41379. shader: string;
  41380. };
  41381. }
  41382. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41383. /** @hidden */
  41384. export var depthPrePass: {
  41385. name: string;
  41386. shader: string;
  41387. };
  41388. }
  41389. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41390. /** @hidden */
  41391. export var lightFragment: {
  41392. name: string;
  41393. shader: string;
  41394. };
  41395. }
  41396. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41397. /** @hidden */
  41398. export var logDepthFragment: {
  41399. name: string;
  41400. shader: string;
  41401. };
  41402. }
  41403. declare module "babylonjs/Shaders/default.fragment" {
  41404. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41405. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41406. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41409. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41410. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41411. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41412. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41413. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41414. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41415. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41416. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41417. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41418. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41419. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41420. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41421. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41422. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41423. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41424. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41425. /** @hidden */
  41426. export var defaultPixelShader: {
  41427. name: string;
  41428. shader: string;
  41429. };
  41430. }
  41431. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41432. /** @hidden */
  41433. export var defaultVertexDeclaration: {
  41434. name: string;
  41435. shader: string;
  41436. };
  41437. }
  41438. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41439. /** @hidden */
  41440. export var bumpVertexDeclaration: {
  41441. name: string;
  41442. shader: string;
  41443. };
  41444. }
  41445. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41446. /** @hidden */
  41447. export var bumpVertex: {
  41448. name: string;
  41449. shader: string;
  41450. };
  41451. }
  41452. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41453. /** @hidden */
  41454. export var fogVertex: {
  41455. name: string;
  41456. shader: string;
  41457. };
  41458. }
  41459. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41460. /** @hidden */
  41461. export var shadowsVertex: {
  41462. name: string;
  41463. shader: string;
  41464. };
  41465. }
  41466. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41467. /** @hidden */
  41468. export var pointCloudVertex: {
  41469. name: string;
  41470. shader: string;
  41471. };
  41472. }
  41473. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41474. /** @hidden */
  41475. export var logDepthVertex: {
  41476. name: string;
  41477. shader: string;
  41478. };
  41479. }
  41480. declare module "babylonjs/Shaders/default.vertex" {
  41481. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41482. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41483. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41484. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41485. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41486. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41487. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41488. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41489. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41490. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41491. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41493. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41494. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41495. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41496. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41497. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41498. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41499. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41500. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41501. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41502. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41503. /** @hidden */
  41504. export var defaultVertexShader: {
  41505. name: string;
  41506. shader: string;
  41507. };
  41508. }
  41509. declare module "babylonjs/Materials/standardMaterial" {
  41510. import { SmartArray } from "babylonjs/Misc/smartArray";
  41511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41512. import { Nullable } from "babylonjs/types";
  41513. import { Scene } from "babylonjs/scene";
  41514. import { Matrix } from "babylonjs/Maths/math.vector";
  41515. import { Color3 } from "babylonjs/Maths/math.color";
  41516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41518. import { Mesh } from "babylonjs/Meshes/mesh";
  41519. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41520. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41521. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41522. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41523. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41526. import "babylonjs/Shaders/default.fragment";
  41527. import "babylonjs/Shaders/default.vertex";
  41528. /** @hidden */
  41529. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41530. MAINUV1: boolean;
  41531. MAINUV2: boolean;
  41532. DIFFUSE: boolean;
  41533. DIFFUSEDIRECTUV: number;
  41534. AMBIENT: boolean;
  41535. AMBIENTDIRECTUV: number;
  41536. OPACITY: boolean;
  41537. OPACITYDIRECTUV: number;
  41538. OPACITYRGB: boolean;
  41539. REFLECTION: boolean;
  41540. EMISSIVE: boolean;
  41541. EMISSIVEDIRECTUV: number;
  41542. SPECULAR: boolean;
  41543. SPECULARDIRECTUV: number;
  41544. BUMP: boolean;
  41545. BUMPDIRECTUV: number;
  41546. PARALLAX: boolean;
  41547. PARALLAXOCCLUSION: boolean;
  41548. SPECULAROVERALPHA: boolean;
  41549. CLIPPLANE: boolean;
  41550. CLIPPLANE2: boolean;
  41551. CLIPPLANE3: boolean;
  41552. CLIPPLANE4: boolean;
  41553. ALPHATEST: boolean;
  41554. DEPTHPREPASS: boolean;
  41555. ALPHAFROMDIFFUSE: boolean;
  41556. POINTSIZE: boolean;
  41557. FOG: boolean;
  41558. SPECULARTERM: boolean;
  41559. DIFFUSEFRESNEL: boolean;
  41560. OPACITYFRESNEL: boolean;
  41561. REFLECTIONFRESNEL: boolean;
  41562. REFRACTIONFRESNEL: boolean;
  41563. EMISSIVEFRESNEL: boolean;
  41564. FRESNEL: boolean;
  41565. NORMAL: boolean;
  41566. UV1: boolean;
  41567. UV2: boolean;
  41568. VERTEXCOLOR: boolean;
  41569. VERTEXALPHA: boolean;
  41570. NUM_BONE_INFLUENCERS: number;
  41571. BonesPerMesh: number;
  41572. BONETEXTURE: boolean;
  41573. INSTANCES: boolean;
  41574. GLOSSINESS: boolean;
  41575. ROUGHNESS: boolean;
  41576. EMISSIVEASILLUMINATION: boolean;
  41577. LINKEMISSIVEWITHDIFFUSE: boolean;
  41578. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41579. LIGHTMAP: boolean;
  41580. LIGHTMAPDIRECTUV: number;
  41581. OBJECTSPACE_NORMALMAP: boolean;
  41582. USELIGHTMAPASSHADOWMAP: boolean;
  41583. REFLECTIONMAP_3D: boolean;
  41584. REFLECTIONMAP_SPHERICAL: boolean;
  41585. REFLECTIONMAP_PLANAR: boolean;
  41586. REFLECTIONMAP_CUBIC: boolean;
  41587. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41588. REFLECTIONMAP_PROJECTION: boolean;
  41589. REFLECTIONMAP_SKYBOX: boolean;
  41590. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41591. REFLECTIONMAP_EXPLICIT: boolean;
  41592. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41593. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41594. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41595. INVERTCUBICMAP: boolean;
  41596. LOGARITHMICDEPTH: boolean;
  41597. REFRACTION: boolean;
  41598. REFRACTIONMAP_3D: boolean;
  41599. REFLECTIONOVERALPHA: boolean;
  41600. TWOSIDEDLIGHTING: boolean;
  41601. SHADOWFLOAT: boolean;
  41602. MORPHTARGETS: boolean;
  41603. MORPHTARGETS_NORMAL: boolean;
  41604. MORPHTARGETS_TANGENT: boolean;
  41605. MORPHTARGETS_UV: boolean;
  41606. NUM_MORPH_INFLUENCERS: number;
  41607. NONUNIFORMSCALING: boolean;
  41608. PREMULTIPLYALPHA: boolean;
  41609. IMAGEPROCESSING: boolean;
  41610. VIGNETTE: boolean;
  41611. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41612. VIGNETTEBLENDMODEOPAQUE: boolean;
  41613. TONEMAPPING: boolean;
  41614. TONEMAPPING_ACES: boolean;
  41615. CONTRAST: boolean;
  41616. COLORCURVES: boolean;
  41617. COLORGRADING: boolean;
  41618. COLORGRADING3D: boolean;
  41619. SAMPLER3DGREENDEPTH: boolean;
  41620. SAMPLER3DBGRMAP: boolean;
  41621. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41622. MULTIVIEW: boolean;
  41623. /**
  41624. * If the reflection texture on this material is in linear color space
  41625. * @hidden
  41626. */
  41627. IS_REFLECTION_LINEAR: boolean;
  41628. /**
  41629. * If the refraction texture on this material is in linear color space
  41630. * @hidden
  41631. */
  41632. IS_REFRACTION_LINEAR: boolean;
  41633. EXPOSURE: boolean;
  41634. constructor();
  41635. setReflectionMode(modeToEnable: string): void;
  41636. }
  41637. /**
  41638. * This is the default material used in Babylon. It is the best trade off between quality
  41639. * and performances.
  41640. * @see http://doc.babylonjs.com/babylon101/materials
  41641. */
  41642. export class StandardMaterial extends PushMaterial {
  41643. private _diffuseTexture;
  41644. /**
  41645. * The basic texture of the material as viewed under a light.
  41646. */
  41647. diffuseTexture: Nullable<BaseTexture>;
  41648. private _ambientTexture;
  41649. /**
  41650. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41651. */
  41652. ambientTexture: Nullable<BaseTexture>;
  41653. private _opacityTexture;
  41654. /**
  41655. * Define the transparency of the material from a texture.
  41656. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41657. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41658. */
  41659. opacityTexture: Nullable<BaseTexture>;
  41660. private _reflectionTexture;
  41661. /**
  41662. * Define the texture used to display the reflection.
  41663. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41664. */
  41665. reflectionTexture: Nullable<BaseTexture>;
  41666. private _emissiveTexture;
  41667. /**
  41668. * Define texture of the material as if self lit.
  41669. * This will be mixed in the final result even in the absence of light.
  41670. */
  41671. emissiveTexture: Nullable<BaseTexture>;
  41672. private _specularTexture;
  41673. /**
  41674. * Define how the color and intensity of the highlight given by the light in the material.
  41675. */
  41676. specularTexture: Nullable<BaseTexture>;
  41677. private _bumpTexture;
  41678. /**
  41679. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41680. * 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.
  41681. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41682. */
  41683. bumpTexture: Nullable<BaseTexture>;
  41684. private _lightmapTexture;
  41685. /**
  41686. * Complex lighting can be computationally expensive to compute at runtime.
  41687. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41688. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41689. */
  41690. lightmapTexture: Nullable<BaseTexture>;
  41691. private _refractionTexture;
  41692. /**
  41693. * Define the texture used to display the refraction.
  41694. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41695. */
  41696. refractionTexture: Nullable<BaseTexture>;
  41697. /**
  41698. * The color of the material lit by the environmental background lighting.
  41699. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41700. */
  41701. ambientColor: Color3;
  41702. /**
  41703. * The basic color of the material as viewed under a light.
  41704. */
  41705. diffuseColor: Color3;
  41706. /**
  41707. * Define how the color and intensity of the highlight given by the light in the material.
  41708. */
  41709. specularColor: Color3;
  41710. /**
  41711. * Define the color of the material as if self lit.
  41712. * This will be mixed in the final result even in the absence of light.
  41713. */
  41714. emissiveColor: Color3;
  41715. /**
  41716. * Defines how sharp are the highlights in the material.
  41717. * The bigger the value the sharper giving a more glossy feeling to the result.
  41718. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41719. */
  41720. specularPower: number;
  41721. private _useAlphaFromDiffuseTexture;
  41722. /**
  41723. * Does the transparency come from the diffuse texture alpha channel.
  41724. */
  41725. useAlphaFromDiffuseTexture: boolean;
  41726. private _useEmissiveAsIllumination;
  41727. /**
  41728. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41729. */
  41730. useEmissiveAsIllumination: boolean;
  41731. private _linkEmissiveWithDiffuse;
  41732. /**
  41733. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41734. * the emissive level when the final color is close to one.
  41735. */
  41736. linkEmissiveWithDiffuse: boolean;
  41737. private _useSpecularOverAlpha;
  41738. /**
  41739. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41740. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41741. */
  41742. useSpecularOverAlpha: boolean;
  41743. private _useReflectionOverAlpha;
  41744. /**
  41745. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41746. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41747. */
  41748. useReflectionOverAlpha: boolean;
  41749. private _disableLighting;
  41750. /**
  41751. * Does lights from the scene impacts this material.
  41752. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41753. */
  41754. disableLighting: boolean;
  41755. private _useObjectSpaceNormalMap;
  41756. /**
  41757. * Allows using an object space normal map (instead of tangent space).
  41758. */
  41759. useObjectSpaceNormalMap: boolean;
  41760. private _useParallax;
  41761. /**
  41762. * Is parallax enabled or not.
  41763. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41764. */
  41765. useParallax: boolean;
  41766. private _useParallaxOcclusion;
  41767. /**
  41768. * Is parallax occlusion enabled or not.
  41769. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41770. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41771. */
  41772. useParallaxOcclusion: boolean;
  41773. /**
  41774. * 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.
  41775. */
  41776. parallaxScaleBias: number;
  41777. private _roughness;
  41778. /**
  41779. * Helps to define how blurry the reflections should appears in the material.
  41780. */
  41781. roughness: number;
  41782. /**
  41783. * In case of refraction, define the value of the index of refraction.
  41784. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41785. */
  41786. indexOfRefraction: number;
  41787. /**
  41788. * Invert the refraction texture alongside the y axis.
  41789. * It can be useful with procedural textures or probe for instance.
  41790. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41791. */
  41792. invertRefractionY: boolean;
  41793. /**
  41794. * Defines the alpha limits in alpha test mode.
  41795. */
  41796. alphaCutOff: number;
  41797. private _useLightmapAsShadowmap;
  41798. /**
  41799. * In case of light mapping, define whether the map contains light or shadow informations.
  41800. */
  41801. useLightmapAsShadowmap: boolean;
  41802. private _diffuseFresnelParameters;
  41803. /**
  41804. * Define the diffuse fresnel parameters of the material.
  41805. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41806. */
  41807. diffuseFresnelParameters: FresnelParameters;
  41808. private _opacityFresnelParameters;
  41809. /**
  41810. * Define the opacity fresnel parameters of the material.
  41811. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41812. */
  41813. opacityFresnelParameters: FresnelParameters;
  41814. private _reflectionFresnelParameters;
  41815. /**
  41816. * Define the reflection fresnel parameters of the material.
  41817. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41818. */
  41819. reflectionFresnelParameters: FresnelParameters;
  41820. private _refractionFresnelParameters;
  41821. /**
  41822. * Define the refraction fresnel parameters of the material.
  41823. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41824. */
  41825. refractionFresnelParameters: FresnelParameters;
  41826. private _emissiveFresnelParameters;
  41827. /**
  41828. * Define the emissive fresnel parameters of the material.
  41829. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41830. */
  41831. emissiveFresnelParameters: FresnelParameters;
  41832. private _useReflectionFresnelFromSpecular;
  41833. /**
  41834. * If true automatically deducts the fresnels values from the material specularity.
  41835. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41836. */
  41837. useReflectionFresnelFromSpecular: boolean;
  41838. private _useGlossinessFromSpecularMapAlpha;
  41839. /**
  41840. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41841. */
  41842. useGlossinessFromSpecularMapAlpha: boolean;
  41843. private _maxSimultaneousLights;
  41844. /**
  41845. * Defines the maximum number of lights that can be used in the material
  41846. */
  41847. maxSimultaneousLights: number;
  41848. private _invertNormalMapX;
  41849. /**
  41850. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41851. */
  41852. invertNormalMapX: boolean;
  41853. private _invertNormalMapY;
  41854. /**
  41855. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41856. */
  41857. invertNormalMapY: boolean;
  41858. private _twoSidedLighting;
  41859. /**
  41860. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41861. */
  41862. twoSidedLighting: boolean;
  41863. /**
  41864. * Default configuration related to image processing available in the standard Material.
  41865. */
  41866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41867. /**
  41868. * Gets the image processing configuration used either in this material.
  41869. */
  41870. /**
  41871. * Sets the Default image processing configuration used either in the this material.
  41872. *
  41873. * If sets to null, the scene one is in use.
  41874. */
  41875. imageProcessingConfiguration: ImageProcessingConfiguration;
  41876. /**
  41877. * Keep track of the image processing observer to allow dispose and replace.
  41878. */
  41879. private _imageProcessingObserver;
  41880. /**
  41881. * Attaches a new image processing configuration to the Standard Material.
  41882. * @param configuration
  41883. */
  41884. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41885. /**
  41886. * Gets wether the color curves effect is enabled.
  41887. */
  41888. /**
  41889. * Sets wether the color curves effect is enabled.
  41890. */
  41891. cameraColorCurvesEnabled: boolean;
  41892. /**
  41893. * Gets wether the color grading effect is enabled.
  41894. */
  41895. /**
  41896. * Gets wether the color grading effect is enabled.
  41897. */
  41898. cameraColorGradingEnabled: boolean;
  41899. /**
  41900. * Gets wether tonemapping is enabled or not.
  41901. */
  41902. /**
  41903. * Sets wether tonemapping is enabled or not
  41904. */
  41905. cameraToneMappingEnabled: boolean;
  41906. /**
  41907. * The camera exposure used on this material.
  41908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41909. * This corresponds to a photographic exposure.
  41910. */
  41911. /**
  41912. * The camera exposure used on this material.
  41913. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41914. * This corresponds to a photographic exposure.
  41915. */
  41916. cameraExposure: number;
  41917. /**
  41918. * Gets The camera contrast used on this material.
  41919. */
  41920. /**
  41921. * Sets The camera contrast used on this material.
  41922. */
  41923. cameraContrast: number;
  41924. /**
  41925. * Gets the Color Grading 2D Lookup Texture.
  41926. */
  41927. /**
  41928. * Sets the Color Grading 2D Lookup Texture.
  41929. */
  41930. cameraColorGradingTexture: Nullable<BaseTexture>;
  41931. /**
  41932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41934. * 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;
  41935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41936. */
  41937. /**
  41938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41940. * 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;
  41941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41942. */
  41943. cameraColorCurves: Nullable<ColorCurves>;
  41944. /**
  41945. * Custom callback helping to override the default shader used in the material.
  41946. */
  41947. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41948. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41949. protected _worldViewProjectionMatrix: Matrix;
  41950. protected _globalAmbientColor: Color3;
  41951. protected _useLogarithmicDepth: boolean;
  41952. protected _rebuildInParallel: boolean;
  41953. /**
  41954. * Instantiates a new standard material.
  41955. * This is the default material used in Babylon. It is the best trade off between quality
  41956. * and performances.
  41957. * @see http://doc.babylonjs.com/babylon101/materials
  41958. * @param name Define the name of the material in the scene
  41959. * @param scene Define the scene the material belong to
  41960. */
  41961. constructor(name: string, scene: Scene);
  41962. /**
  41963. * Gets a boolean indicating that current material needs to register RTT
  41964. */
  41965. readonly hasRenderTargetTextures: boolean;
  41966. /**
  41967. * Gets the current class name of the material e.g. "StandardMaterial"
  41968. * Mainly use in serialization.
  41969. * @returns the class name
  41970. */
  41971. getClassName(): string;
  41972. /**
  41973. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41974. * You can try switching to logarithmic depth.
  41975. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41976. */
  41977. useLogarithmicDepth: boolean;
  41978. /**
  41979. * Specifies if the material will require alpha blending
  41980. * @returns a boolean specifying if alpha blending is needed
  41981. */
  41982. needAlphaBlending(): boolean;
  41983. /**
  41984. * Specifies if this material should be rendered in alpha test mode
  41985. * @returns a boolean specifying if an alpha test is needed.
  41986. */
  41987. needAlphaTesting(): boolean;
  41988. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41989. /**
  41990. * Get the texture used for alpha test purpose.
  41991. * @returns the diffuse texture in case of the standard material.
  41992. */
  41993. getAlphaTestTexture(): Nullable<BaseTexture>;
  41994. /**
  41995. * Get if the submesh is ready to be used and all its information available.
  41996. * Child classes can use it to update shaders
  41997. * @param mesh defines the mesh to check
  41998. * @param subMesh defines which submesh to check
  41999. * @param useInstances specifies that instances should be used
  42000. * @returns a boolean indicating that the submesh is ready or not
  42001. */
  42002. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42003. /**
  42004. * Builds the material UBO layouts.
  42005. * Used internally during the effect preparation.
  42006. */
  42007. buildUniformLayout(): void;
  42008. /**
  42009. * Unbinds the material from the mesh
  42010. */
  42011. unbind(): void;
  42012. /**
  42013. * Binds the submesh to this material by preparing the effect and shader to draw
  42014. * @param world defines the world transformation matrix
  42015. * @param mesh defines the mesh containing the submesh
  42016. * @param subMesh defines the submesh to bind the material to
  42017. */
  42018. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42019. /**
  42020. * Get the list of animatables in the material.
  42021. * @returns the list of animatables object used in the material
  42022. */
  42023. getAnimatables(): IAnimatable[];
  42024. /**
  42025. * Gets the active textures from the material
  42026. * @returns an array of textures
  42027. */
  42028. getActiveTextures(): BaseTexture[];
  42029. /**
  42030. * Specifies if the material uses a texture
  42031. * @param texture defines the texture to check against the material
  42032. * @returns a boolean specifying if the material uses the texture
  42033. */
  42034. hasTexture(texture: BaseTexture): boolean;
  42035. /**
  42036. * Disposes the material
  42037. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42038. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42039. */
  42040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42041. /**
  42042. * Makes a duplicate of the material, and gives it a new name
  42043. * @param name defines the new name for the duplicated material
  42044. * @returns the cloned material
  42045. */
  42046. clone(name: string): StandardMaterial;
  42047. /**
  42048. * Serializes this material in a JSON representation
  42049. * @returns the serialized material object
  42050. */
  42051. serialize(): any;
  42052. /**
  42053. * Creates a standard material from parsed material data
  42054. * @param source defines the JSON representation of the material
  42055. * @param scene defines the hosting scene
  42056. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42057. * @returns a new standard material
  42058. */
  42059. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42060. /**
  42061. * Are diffuse textures enabled in the application.
  42062. */
  42063. static DiffuseTextureEnabled: boolean;
  42064. /**
  42065. * Are ambient textures enabled in the application.
  42066. */
  42067. static AmbientTextureEnabled: boolean;
  42068. /**
  42069. * Are opacity textures enabled in the application.
  42070. */
  42071. static OpacityTextureEnabled: boolean;
  42072. /**
  42073. * Are reflection textures enabled in the application.
  42074. */
  42075. static ReflectionTextureEnabled: boolean;
  42076. /**
  42077. * Are emissive textures enabled in the application.
  42078. */
  42079. static EmissiveTextureEnabled: boolean;
  42080. /**
  42081. * Are specular textures enabled in the application.
  42082. */
  42083. static SpecularTextureEnabled: boolean;
  42084. /**
  42085. * Are bump textures enabled in the application.
  42086. */
  42087. static BumpTextureEnabled: boolean;
  42088. /**
  42089. * Are lightmap textures enabled in the application.
  42090. */
  42091. static LightmapTextureEnabled: boolean;
  42092. /**
  42093. * Are refraction textures enabled in the application.
  42094. */
  42095. static RefractionTextureEnabled: boolean;
  42096. /**
  42097. * Are color grading textures enabled in the application.
  42098. */
  42099. static ColorGradingTextureEnabled: boolean;
  42100. /**
  42101. * Are fresnels enabled in the application.
  42102. */
  42103. static FresnelEnabled: boolean;
  42104. }
  42105. }
  42106. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42107. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42108. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42109. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42110. /** @hidden */
  42111. export var imageProcessingPixelShader: {
  42112. name: string;
  42113. shader: string;
  42114. };
  42115. }
  42116. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42117. import { Nullable } from "babylonjs/types";
  42118. import { Color4 } from "babylonjs/Maths/math.color";
  42119. import { Camera } from "babylonjs/Cameras/camera";
  42120. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42121. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42122. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42123. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42124. import { Engine } from "babylonjs/Engines/engine";
  42125. import "babylonjs/Shaders/imageProcessing.fragment";
  42126. import "babylonjs/Shaders/postprocess.vertex";
  42127. /**
  42128. * ImageProcessingPostProcess
  42129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42130. */
  42131. export class ImageProcessingPostProcess extends PostProcess {
  42132. /**
  42133. * Default configuration related to image processing available in the PBR Material.
  42134. */
  42135. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42136. /**
  42137. * Gets the image processing configuration used either in this material.
  42138. */
  42139. /**
  42140. * Sets the Default image processing configuration used either in the this material.
  42141. *
  42142. * If sets to null, the scene one is in use.
  42143. */
  42144. imageProcessingConfiguration: ImageProcessingConfiguration;
  42145. /**
  42146. * Keep track of the image processing observer to allow dispose and replace.
  42147. */
  42148. private _imageProcessingObserver;
  42149. /**
  42150. * Attaches a new image processing configuration to the PBR Material.
  42151. * @param configuration
  42152. */
  42153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42154. /**
  42155. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42156. */
  42157. /**
  42158. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42159. */
  42160. colorCurves: Nullable<ColorCurves>;
  42161. /**
  42162. * Gets wether the color curves effect is enabled.
  42163. */
  42164. /**
  42165. * Sets wether the color curves effect is enabled.
  42166. */
  42167. colorCurvesEnabled: boolean;
  42168. /**
  42169. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42170. */
  42171. /**
  42172. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42173. */
  42174. colorGradingTexture: Nullable<BaseTexture>;
  42175. /**
  42176. * Gets wether the color grading effect is enabled.
  42177. */
  42178. /**
  42179. * Gets wether the color grading effect is enabled.
  42180. */
  42181. colorGradingEnabled: boolean;
  42182. /**
  42183. * Gets exposure used in the effect.
  42184. */
  42185. /**
  42186. * Sets exposure used in the effect.
  42187. */
  42188. exposure: number;
  42189. /**
  42190. * Gets wether tonemapping is enabled or not.
  42191. */
  42192. /**
  42193. * Sets wether tonemapping is enabled or not
  42194. */
  42195. toneMappingEnabled: boolean;
  42196. /**
  42197. * Gets the type of tone mapping effect.
  42198. */
  42199. /**
  42200. * Sets the type of tone mapping effect.
  42201. */
  42202. toneMappingType: number;
  42203. /**
  42204. * Gets contrast used in the effect.
  42205. */
  42206. /**
  42207. * Sets contrast used in the effect.
  42208. */
  42209. contrast: number;
  42210. /**
  42211. * Gets Vignette stretch size.
  42212. */
  42213. /**
  42214. * Sets Vignette stretch size.
  42215. */
  42216. vignetteStretch: number;
  42217. /**
  42218. * Gets Vignette centre X Offset.
  42219. */
  42220. /**
  42221. * Sets Vignette centre X Offset.
  42222. */
  42223. vignetteCentreX: number;
  42224. /**
  42225. * Gets Vignette centre Y Offset.
  42226. */
  42227. /**
  42228. * Sets Vignette centre Y Offset.
  42229. */
  42230. vignetteCentreY: number;
  42231. /**
  42232. * Gets Vignette weight or intensity of the vignette effect.
  42233. */
  42234. /**
  42235. * Sets Vignette weight or intensity of the vignette effect.
  42236. */
  42237. vignetteWeight: number;
  42238. /**
  42239. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42240. * if vignetteEnabled is set to true.
  42241. */
  42242. /**
  42243. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42244. * if vignetteEnabled is set to true.
  42245. */
  42246. vignetteColor: Color4;
  42247. /**
  42248. * Gets Camera field of view used by the Vignette effect.
  42249. */
  42250. /**
  42251. * Sets Camera field of view used by the Vignette effect.
  42252. */
  42253. vignetteCameraFov: number;
  42254. /**
  42255. * Gets the vignette blend mode allowing different kind of effect.
  42256. */
  42257. /**
  42258. * Sets the vignette blend mode allowing different kind of effect.
  42259. */
  42260. vignetteBlendMode: number;
  42261. /**
  42262. * Gets wether the vignette effect is enabled.
  42263. */
  42264. /**
  42265. * Sets wether the vignette effect is enabled.
  42266. */
  42267. vignetteEnabled: boolean;
  42268. private _fromLinearSpace;
  42269. /**
  42270. * Gets wether the input of the processing is in Gamma or Linear Space.
  42271. */
  42272. /**
  42273. * Sets wether the input of the processing is in Gamma or Linear Space.
  42274. */
  42275. fromLinearSpace: boolean;
  42276. /**
  42277. * Defines cache preventing GC.
  42278. */
  42279. private _defines;
  42280. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42281. /**
  42282. * "ImageProcessingPostProcess"
  42283. * @returns "ImageProcessingPostProcess"
  42284. */
  42285. getClassName(): string;
  42286. protected _updateParameters(): void;
  42287. dispose(camera?: Camera): void;
  42288. }
  42289. }
  42290. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42291. import { Scene } from "babylonjs/scene";
  42292. import { Color3 } from "babylonjs/Maths/math.color";
  42293. import { Mesh } from "babylonjs/Meshes/mesh";
  42294. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42295. import { Nullable } from "babylonjs/types";
  42296. /**
  42297. * Class containing static functions to help procedurally build meshes
  42298. */
  42299. export class GroundBuilder {
  42300. /**
  42301. * Creates a ground mesh
  42302. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42303. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42305. * @param name defines the name of the mesh
  42306. * @param options defines the options used to create the mesh
  42307. * @param scene defines the hosting scene
  42308. * @returns the ground mesh
  42309. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42310. */
  42311. static CreateGround(name: string, options: {
  42312. width?: number;
  42313. height?: number;
  42314. subdivisions?: number;
  42315. subdivisionsX?: number;
  42316. subdivisionsY?: number;
  42317. updatable?: boolean;
  42318. }, scene: any): Mesh;
  42319. /**
  42320. * Creates a tiled ground mesh
  42321. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42322. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42323. * * 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
  42324. * * 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
  42325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42326. * @param name defines the name of the mesh
  42327. * @param options defines the options used to create the mesh
  42328. * @param scene defines the hosting scene
  42329. * @returns the tiled ground mesh
  42330. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42331. */
  42332. static CreateTiledGround(name: string, options: {
  42333. xmin: number;
  42334. zmin: number;
  42335. xmax: number;
  42336. zmax: number;
  42337. subdivisions?: {
  42338. w: number;
  42339. h: number;
  42340. };
  42341. precision?: {
  42342. w: number;
  42343. h: number;
  42344. };
  42345. updatable?: boolean;
  42346. }, scene?: Nullable<Scene>): Mesh;
  42347. /**
  42348. * Creates a ground mesh from a height map
  42349. * * The parameter `url` sets the URL of the height map image resource.
  42350. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42351. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42352. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42353. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42354. * * 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.
  42355. * * 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).
  42356. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42358. * @param name defines the name of the mesh
  42359. * @param url defines the url to the height map
  42360. * @param options defines the options used to create the mesh
  42361. * @param scene defines the hosting scene
  42362. * @returns the ground mesh
  42363. * @see https://doc.babylonjs.com/babylon101/height_map
  42364. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42365. */
  42366. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42367. width?: number;
  42368. height?: number;
  42369. subdivisions?: number;
  42370. minHeight?: number;
  42371. maxHeight?: number;
  42372. colorFilter?: Color3;
  42373. alphaFilter?: number;
  42374. updatable?: boolean;
  42375. onReady?: (mesh: GroundMesh) => void;
  42376. }, scene?: Nullable<Scene>): GroundMesh;
  42377. }
  42378. }
  42379. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42380. import { Vector4 } from "babylonjs/Maths/math.vector";
  42381. import { Mesh } from "babylonjs/Meshes/mesh";
  42382. /**
  42383. * Class containing static functions to help procedurally build meshes
  42384. */
  42385. export class TorusBuilder {
  42386. /**
  42387. * Creates a torus mesh
  42388. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42389. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42390. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42394. * @param name defines the name of the mesh
  42395. * @param options defines the options used to create the mesh
  42396. * @param scene defines the hosting scene
  42397. * @returns the torus mesh
  42398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42399. */
  42400. static CreateTorus(name: string, options: {
  42401. diameter?: number;
  42402. thickness?: number;
  42403. tessellation?: number;
  42404. updatable?: boolean;
  42405. sideOrientation?: number;
  42406. frontUVs?: Vector4;
  42407. backUVs?: Vector4;
  42408. }, scene: any): Mesh;
  42409. }
  42410. }
  42411. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42412. import { Vector4 } from "babylonjs/Maths/math.vector";
  42413. import { Color4 } from "babylonjs/Maths/math.color";
  42414. import { Mesh } from "babylonjs/Meshes/mesh";
  42415. /**
  42416. * Class containing static functions to help procedurally build meshes
  42417. */
  42418. export class CylinderBuilder {
  42419. /**
  42420. * Creates a cylinder or a cone mesh
  42421. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42422. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42423. * * 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.
  42424. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42425. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42426. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42427. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42428. * * 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).
  42429. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42430. * * 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).
  42431. * * 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
  42432. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42433. * * 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
  42434. * * 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.
  42435. * * If `enclose` is false, a ring surface is one element.
  42436. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42437. * * 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
  42438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42441. * @param name defines the name of the mesh
  42442. * @param options defines the options used to create the mesh
  42443. * @param scene defines the hosting scene
  42444. * @returns the cylinder mesh
  42445. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42446. */
  42447. static CreateCylinder(name: string, options: {
  42448. height?: number;
  42449. diameterTop?: number;
  42450. diameterBottom?: number;
  42451. diameter?: number;
  42452. tessellation?: number;
  42453. subdivisions?: number;
  42454. arc?: number;
  42455. faceColors?: Color4[];
  42456. faceUV?: Vector4[];
  42457. updatable?: boolean;
  42458. hasRings?: boolean;
  42459. enclose?: boolean;
  42460. cap?: number;
  42461. sideOrientation?: number;
  42462. frontUVs?: Vector4;
  42463. backUVs?: Vector4;
  42464. }, scene: any): Mesh;
  42465. }
  42466. }
  42467. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42468. import { Observable } from "babylonjs/Misc/observable";
  42469. import { Nullable } from "babylonjs/types";
  42470. import { Camera } from "babylonjs/Cameras/camera";
  42471. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42472. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42473. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42474. import { Scene } from "babylonjs/scene";
  42475. import { Vector3 } from "babylonjs/Maths/math.vector";
  42476. import { Color3 } from "babylonjs/Maths/math.color";
  42477. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42479. import { Mesh } from "babylonjs/Meshes/mesh";
  42480. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42481. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42482. import "babylonjs/Meshes/Builders/groundBuilder";
  42483. import "babylonjs/Meshes/Builders/torusBuilder";
  42484. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42485. import "babylonjs/Gamepads/gamepadSceneComponent";
  42486. import "babylonjs/Animations/animatable";
  42487. /**
  42488. * Options to modify the vr teleportation behavior.
  42489. */
  42490. export interface VRTeleportationOptions {
  42491. /**
  42492. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42493. */
  42494. floorMeshName?: string;
  42495. /**
  42496. * A list of meshes to be used as the teleportation floor. (default: empty)
  42497. */
  42498. floorMeshes?: Mesh[];
  42499. }
  42500. /**
  42501. * Options to modify the vr experience helper's behavior.
  42502. */
  42503. export interface VRExperienceHelperOptions extends WebVROptions {
  42504. /**
  42505. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42506. */
  42507. createDeviceOrientationCamera?: boolean;
  42508. /**
  42509. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42510. */
  42511. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42512. /**
  42513. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42514. */
  42515. laserToggle?: boolean;
  42516. /**
  42517. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42518. */
  42519. floorMeshes?: Mesh[];
  42520. /**
  42521. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42522. */
  42523. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42524. }
  42525. /**
  42526. * Event containing information after VR has been entered
  42527. */
  42528. export class OnAfterEnteringVRObservableEvent {
  42529. /**
  42530. * If entering vr was successful
  42531. */
  42532. success: boolean;
  42533. }
  42534. /**
  42535. * Helps to quickly add VR support to an existing scene.
  42536. * See http://doc.babylonjs.com/how_to/webvr_helper
  42537. */
  42538. export class VRExperienceHelper {
  42539. /** Options to modify the vr experience helper's behavior. */
  42540. webVROptions: VRExperienceHelperOptions;
  42541. private _scene;
  42542. private _position;
  42543. private _btnVR;
  42544. private _btnVRDisplayed;
  42545. private _webVRsupported;
  42546. private _webVRready;
  42547. private _webVRrequesting;
  42548. private _webVRpresenting;
  42549. private _hasEnteredVR;
  42550. private _fullscreenVRpresenting;
  42551. private _canvas;
  42552. private _webVRCamera;
  42553. private _vrDeviceOrientationCamera;
  42554. private _deviceOrientationCamera;
  42555. private _existingCamera;
  42556. private _onKeyDown;
  42557. private _onVrDisplayPresentChange;
  42558. private _onVRDisplayChanged;
  42559. private _onVRRequestPresentStart;
  42560. private _onVRRequestPresentComplete;
  42561. /**
  42562. * 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)
  42563. */
  42564. enableGazeEvenWhenNoPointerLock: boolean;
  42565. /**
  42566. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42567. */
  42568. exitVROnDoubleTap: boolean;
  42569. /**
  42570. * Observable raised right before entering VR.
  42571. */
  42572. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42573. /**
  42574. * Observable raised when entering VR has completed.
  42575. */
  42576. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42577. /**
  42578. * Observable raised when exiting VR.
  42579. */
  42580. onExitingVRObservable: Observable<VRExperienceHelper>;
  42581. /**
  42582. * Observable raised when controller mesh is loaded.
  42583. */
  42584. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42585. /** Return this.onEnteringVRObservable
  42586. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42587. */
  42588. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42589. /** Return this.onExitingVRObservable
  42590. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42591. */
  42592. readonly onExitingVR: Observable<VRExperienceHelper>;
  42593. /** Return this.onControllerMeshLoadedObservable
  42594. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42595. */
  42596. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42597. private _rayLength;
  42598. private _useCustomVRButton;
  42599. private _teleportationRequested;
  42600. private _teleportActive;
  42601. private _floorMeshName;
  42602. private _floorMeshesCollection;
  42603. private _rotationAllowed;
  42604. private _teleportBackwardsVector;
  42605. private _teleportationTarget;
  42606. private _isDefaultTeleportationTarget;
  42607. private _postProcessMove;
  42608. private _teleportationFillColor;
  42609. private _teleportationBorderColor;
  42610. private _rotationAngle;
  42611. private _haloCenter;
  42612. private _cameraGazer;
  42613. private _padSensibilityUp;
  42614. private _padSensibilityDown;
  42615. private _leftController;
  42616. private _rightController;
  42617. /**
  42618. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42619. */
  42620. onNewMeshSelected: Observable<AbstractMesh>;
  42621. /**
  42622. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42623. * This observable will provide the mesh and the controller used to select the mesh
  42624. */
  42625. onMeshSelectedWithController: Observable<{
  42626. mesh: AbstractMesh;
  42627. controller: WebVRController;
  42628. }>;
  42629. /**
  42630. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42631. */
  42632. onNewMeshPicked: Observable<PickingInfo>;
  42633. private _circleEase;
  42634. /**
  42635. * Observable raised before camera teleportation
  42636. */
  42637. onBeforeCameraTeleport: Observable<Vector3>;
  42638. /**
  42639. * Observable raised after camera teleportation
  42640. */
  42641. onAfterCameraTeleport: Observable<Vector3>;
  42642. /**
  42643. * Observable raised when current selected mesh gets unselected
  42644. */
  42645. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42646. private _raySelectionPredicate;
  42647. /**
  42648. * To be optionaly changed by user to define custom ray selection
  42649. */
  42650. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42651. /**
  42652. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42653. */
  42654. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42655. /**
  42656. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42657. */
  42658. teleportationEnabled: boolean;
  42659. private _defaultHeight;
  42660. private _teleportationInitialized;
  42661. private _interactionsEnabled;
  42662. private _interactionsRequested;
  42663. private _displayGaze;
  42664. private _displayLaserPointer;
  42665. /**
  42666. * The mesh used to display where the user is going to teleport.
  42667. */
  42668. /**
  42669. * Sets the mesh to be used to display where the user is going to teleport.
  42670. */
  42671. teleportationTarget: Mesh;
  42672. /**
  42673. * 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
  42674. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42675. * See http://doc.babylonjs.com/resources/baking_transformations
  42676. */
  42677. gazeTrackerMesh: Mesh;
  42678. /**
  42679. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42680. */
  42681. updateGazeTrackerScale: boolean;
  42682. /**
  42683. * If the gaze trackers color should be updated when selecting meshes
  42684. */
  42685. updateGazeTrackerColor: boolean;
  42686. /**
  42687. * If the controller laser color should be updated when selecting meshes
  42688. */
  42689. updateControllerLaserColor: boolean;
  42690. /**
  42691. * The gaze tracking mesh corresponding to the left controller
  42692. */
  42693. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42694. /**
  42695. * The gaze tracking mesh corresponding to the right controller
  42696. */
  42697. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42698. /**
  42699. * If the ray of the gaze should be displayed.
  42700. */
  42701. /**
  42702. * Sets if the ray of the gaze should be displayed.
  42703. */
  42704. displayGaze: boolean;
  42705. /**
  42706. * If the ray of the LaserPointer should be displayed.
  42707. */
  42708. /**
  42709. * Sets if the ray of the LaserPointer should be displayed.
  42710. */
  42711. displayLaserPointer: boolean;
  42712. /**
  42713. * The deviceOrientationCamera used as the camera when not in VR.
  42714. */
  42715. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42716. /**
  42717. * Based on the current WebVR support, returns the current VR camera used.
  42718. */
  42719. readonly currentVRCamera: Nullable<Camera>;
  42720. /**
  42721. * The webVRCamera which is used when in VR.
  42722. */
  42723. readonly webVRCamera: WebVRFreeCamera;
  42724. /**
  42725. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42726. */
  42727. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42728. /**
  42729. * The html button that is used to trigger entering into VR.
  42730. */
  42731. readonly vrButton: Nullable<HTMLButtonElement>;
  42732. private readonly _teleportationRequestInitiated;
  42733. /**
  42734. * Defines wether or not Pointer lock should be requested when switching to
  42735. * full screen.
  42736. */
  42737. requestPointerLockOnFullScreen: boolean;
  42738. /**
  42739. * Instantiates a VRExperienceHelper.
  42740. * Helps to quickly add VR support to an existing scene.
  42741. * @param scene The scene the VRExperienceHelper belongs to.
  42742. * @param webVROptions Options to modify the vr experience helper's behavior.
  42743. */
  42744. constructor(scene: Scene,
  42745. /** Options to modify the vr experience helper's behavior. */
  42746. webVROptions?: VRExperienceHelperOptions);
  42747. private _onDefaultMeshLoaded;
  42748. private _onResize;
  42749. private _onFullscreenChange;
  42750. /**
  42751. * Gets a value indicating if we are currently in VR mode.
  42752. */
  42753. readonly isInVRMode: boolean;
  42754. private onVrDisplayPresentChange;
  42755. private onVRDisplayChanged;
  42756. private moveButtonToBottomRight;
  42757. private displayVRButton;
  42758. private updateButtonVisibility;
  42759. private _cachedAngularSensibility;
  42760. /**
  42761. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42762. * Otherwise, will use the fullscreen API.
  42763. */
  42764. enterVR(): void;
  42765. /**
  42766. * Attempt to exit VR, or fullscreen.
  42767. */
  42768. exitVR(): void;
  42769. /**
  42770. * The position of the vr experience helper.
  42771. */
  42772. /**
  42773. * Sets the position of the vr experience helper.
  42774. */
  42775. position: Vector3;
  42776. /**
  42777. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42778. */
  42779. enableInteractions(): void;
  42780. private readonly _noControllerIsActive;
  42781. private beforeRender;
  42782. private _isTeleportationFloor;
  42783. /**
  42784. * Adds a floor mesh to be used for teleportation.
  42785. * @param floorMesh the mesh to be used for teleportation.
  42786. */
  42787. addFloorMesh(floorMesh: Mesh): void;
  42788. /**
  42789. * Removes a floor mesh from being used for teleportation.
  42790. * @param floorMesh the mesh to be removed.
  42791. */
  42792. removeFloorMesh(floorMesh: Mesh): void;
  42793. /**
  42794. * Enables interactions and teleportation using the VR controllers and gaze.
  42795. * @param vrTeleportationOptions options to modify teleportation behavior.
  42796. */
  42797. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42798. private _onNewGamepadConnected;
  42799. private _tryEnableInteractionOnController;
  42800. private _onNewGamepadDisconnected;
  42801. private _enableInteractionOnController;
  42802. private _checkTeleportWithRay;
  42803. private _checkRotate;
  42804. private _checkTeleportBackwards;
  42805. private _enableTeleportationOnController;
  42806. private _createTeleportationCircles;
  42807. private _displayTeleportationTarget;
  42808. private _hideTeleportationTarget;
  42809. private _rotateCamera;
  42810. private _moveTeleportationSelectorTo;
  42811. private _workingVector;
  42812. private _workingQuaternion;
  42813. private _workingMatrix;
  42814. /**
  42815. * Teleports the users feet to the desired location
  42816. * @param location The location where the user's feet should be placed
  42817. */
  42818. teleportCamera(location: Vector3): void;
  42819. private _convertNormalToDirectionOfRay;
  42820. private _castRayAndSelectObject;
  42821. private _notifySelectedMeshUnselected;
  42822. /**
  42823. * Sets the color of the laser ray from the vr controllers.
  42824. * @param color new color for the ray.
  42825. */
  42826. changeLaserColor(color: Color3): void;
  42827. /**
  42828. * Sets the color of the ray from the vr headsets gaze.
  42829. * @param color new color for the ray.
  42830. */
  42831. changeGazeColor(color: Color3): void;
  42832. /**
  42833. * Exits VR and disposes of the vr experience helper
  42834. */
  42835. dispose(): void;
  42836. /**
  42837. * Gets the name of the VRExperienceHelper class
  42838. * @returns "VRExperienceHelper"
  42839. */
  42840. getClassName(): string;
  42841. }
  42842. }
  42843. declare module "babylonjs/Cameras/VR/index" {
  42844. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42845. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42846. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42847. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42848. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42849. export * from "babylonjs/Cameras/VR/webVRCamera";
  42850. }
  42851. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42852. import { Observable } from "babylonjs/Misc/observable";
  42853. import { Nullable } from "babylonjs/types";
  42854. import { IDisposable, Scene } from "babylonjs/scene";
  42855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42856. /**
  42857. * Manages an XRSession to work with Babylon's engine
  42858. * @see https://doc.babylonjs.com/how_to/webxr
  42859. */
  42860. export class WebXRSessionManager implements IDisposable {
  42861. private scene;
  42862. /**
  42863. * Fires every time a new xrFrame arrives which can be used to update the camera
  42864. */
  42865. onXRFrameObservable: Observable<any>;
  42866. /**
  42867. * Fires when the xr session is ended either by the device or manually done
  42868. */
  42869. onXRSessionEnded: Observable<any>;
  42870. /**
  42871. * Underlying xr session
  42872. */
  42873. session: XRSession;
  42874. /**
  42875. * Type of reference space used when creating the session
  42876. */
  42877. referenceSpace: XRReferenceSpace;
  42878. /** @hidden */
  42879. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42880. /**
  42881. * Current XR frame
  42882. */
  42883. currentFrame: Nullable<XRFrame>;
  42884. private _xrNavigator;
  42885. private baseLayer;
  42886. /**
  42887. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42888. * @param scene The scene which the session should be created for
  42889. */
  42890. constructor(scene: Scene);
  42891. /**
  42892. * Initializes the manager
  42893. * After initialization enterXR can be called to start an XR session
  42894. * @returns Promise which resolves after it is initialized
  42895. */
  42896. initializeAsync(): Promise<void>;
  42897. /**
  42898. * Initializes an xr session
  42899. * @param xrSessionMode mode to initialize
  42900. * @returns a promise which will resolve once the session has been initialized
  42901. */
  42902. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42903. /**
  42904. * Sets the reference space on the xr session
  42905. * @param referenceSpace space to set
  42906. * @returns a promise that will resolve once the reference space has been set
  42907. */
  42908. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42909. /**
  42910. * Updates the render state of the session
  42911. * @param state state to set
  42912. * @returns a promise that resolves once the render state has been updated
  42913. */
  42914. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42915. /**
  42916. * Starts rendering to the xr layer
  42917. * @returns a promise that will resolve once rendering has started
  42918. */
  42919. startRenderingToXRAsync(): Promise<void>;
  42920. /**
  42921. * Stops the xrSession and restores the renderloop
  42922. * @returns Promise which resolves after it exits XR
  42923. */
  42924. exitXRAsync(): Promise<unknown>;
  42925. /**
  42926. * Checks if a session would be supported for the creation options specified
  42927. * @param sessionMode session mode to check if supported eg. immersive-vr
  42928. * @returns true if supported
  42929. */
  42930. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42931. /**
  42932. * @hidden
  42933. * Converts the render layer of xrSession to a render target
  42934. * @param session session to create render target for
  42935. * @param scene scene the new render target should be created for
  42936. */
  42937. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42938. /**
  42939. * Disposes of the session manager
  42940. */
  42941. dispose(): void;
  42942. }
  42943. }
  42944. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42945. import { Scene } from "babylonjs/scene";
  42946. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42947. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42948. /**
  42949. * WebXR Camera which holds the views for the xrSession
  42950. * @see https://doc.babylonjs.com/how_to/webxr
  42951. */
  42952. export class WebXRCamera extends FreeCamera {
  42953. private static _TmpMatrix;
  42954. /**
  42955. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42956. * @param name the name of the camera
  42957. * @param scene the scene to add the camera to
  42958. */
  42959. constructor(name: string, scene: Scene);
  42960. private _updateNumberOfRigCameras;
  42961. /** @hidden */
  42962. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42963. /**
  42964. * Updates the cameras position from the current pose information of the XR session
  42965. * @param xrSessionManager the session containing pose information
  42966. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42967. */
  42968. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42969. }
  42970. }
  42971. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42972. import { Nullable } from "babylonjs/types";
  42973. import { IDisposable } from "babylonjs/scene";
  42974. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42975. /**
  42976. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42977. */
  42978. export class WebXRManagedOutputCanvas implements IDisposable {
  42979. private helper;
  42980. private _canvas;
  42981. /**
  42982. * xrpresent context of the canvas which can be used to display/mirror xr content
  42983. */
  42984. canvasContext: WebGLRenderingContext;
  42985. /**
  42986. * xr layer for the canvas
  42987. */
  42988. xrLayer: Nullable<XRWebGLLayer>;
  42989. /**
  42990. * Initializes the xr layer for the session
  42991. * @param xrSession xr session
  42992. * @returns a promise that will resolve once the XR Layer has been created
  42993. */
  42994. initializeXRLayerAsync(xrSession: any): any;
  42995. /**
  42996. * Initializes the canvas to be added/removed upon entering/exiting xr
  42997. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42998. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42999. */
  43000. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43001. /**
  43002. * Disposes of the object
  43003. */
  43004. dispose(): void;
  43005. private _setManagedOutputCanvas;
  43006. private _addCanvas;
  43007. private _removeCanvas;
  43008. }
  43009. }
  43010. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43011. import { Observable } from "babylonjs/Misc/observable";
  43012. import { IDisposable, Scene } from "babylonjs/scene";
  43013. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43015. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43016. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43017. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43018. /**
  43019. * States of the webXR experience
  43020. */
  43021. export enum WebXRState {
  43022. /**
  43023. * Transitioning to being in XR mode
  43024. */
  43025. ENTERING_XR = 0,
  43026. /**
  43027. * Transitioning to non XR mode
  43028. */
  43029. EXITING_XR = 1,
  43030. /**
  43031. * In XR mode and presenting
  43032. */
  43033. IN_XR = 2,
  43034. /**
  43035. * Not entered XR mode
  43036. */
  43037. NOT_IN_XR = 3
  43038. }
  43039. /**
  43040. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43041. * @see https://doc.babylonjs.com/how_to/webxr
  43042. */
  43043. export class WebXRExperienceHelper implements IDisposable {
  43044. private scene;
  43045. /**
  43046. * 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
  43047. */
  43048. container: AbstractMesh;
  43049. /**
  43050. * Camera used to render xr content
  43051. */
  43052. camera: WebXRCamera;
  43053. /**
  43054. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43055. */
  43056. state: WebXRState;
  43057. private _setState;
  43058. private static _TmpVector;
  43059. /**
  43060. * Fires when the state of the experience helper has changed
  43061. */
  43062. onStateChangedObservable: Observable<WebXRState>;
  43063. /** Session manager used to keep track of xr session */
  43064. sessionManager: WebXRSessionManager;
  43065. private _nonVRCamera;
  43066. private _originalSceneAutoClear;
  43067. private _supported;
  43068. /**
  43069. * Creates the experience helper
  43070. * @param scene the scene to attach the experience helper to
  43071. * @returns a promise for the experience helper
  43072. */
  43073. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43074. /**
  43075. * Creates a WebXRExperienceHelper
  43076. * @param scene The scene the helper should be created in
  43077. */
  43078. private constructor();
  43079. /**
  43080. * Exits XR mode and returns the scene to its original state
  43081. * @returns promise that resolves after xr mode has exited
  43082. */
  43083. exitXRAsync(): Promise<unknown>;
  43084. /**
  43085. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43086. * @param sessionCreationOptions options for the XR session
  43087. * @param referenceSpaceType frame of reference of the XR session
  43088. * @param outputCanvas the output canvas that will be used to enter XR mode
  43089. * @returns promise that resolves after xr mode has entered
  43090. */
  43091. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43092. /**
  43093. * Updates the global position of the camera by moving the camera's container
  43094. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43095. * @param position The desired global position of the camera
  43096. */
  43097. setPositionOfCameraUsingContainer(position: Vector3): void;
  43098. /**
  43099. * Rotates the xr camera by rotating the camera's container around the camera's position
  43100. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43101. * @param rotation the desired quaternion rotation to apply to the camera
  43102. */
  43103. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43104. /**
  43105. * Disposes of the experience helper
  43106. */
  43107. dispose(): void;
  43108. }
  43109. }
  43110. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43111. import { Nullable } from "babylonjs/types";
  43112. import { Observable } from "babylonjs/Misc/observable";
  43113. import { IDisposable, Scene } from "babylonjs/scene";
  43114. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43115. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43116. /**
  43117. * Button which can be used to enter a different mode of XR
  43118. */
  43119. export class WebXREnterExitUIButton {
  43120. /** button element */
  43121. element: HTMLElement;
  43122. /** XR initialization options for the button */
  43123. sessionMode: XRSessionMode;
  43124. /** Reference space type */
  43125. referenceSpaceType: XRReferenceSpaceType;
  43126. /**
  43127. * Creates a WebXREnterExitUIButton
  43128. * @param element button element
  43129. * @param sessionMode XR initialization session mode
  43130. * @param referenceSpaceType the type of reference space to be used
  43131. */
  43132. constructor(
  43133. /** button element */
  43134. element: HTMLElement,
  43135. /** XR initialization options for the button */
  43136. sessionMode: XRSessionMode,
  43137. /** Reference space type */
  43138. referenceSpaceType: XRReferenceSpaceType);
  43139. /**
  43140. * Overwritable function which can be used to update the button's visuals when the state changes
  43141. * @param activeButton the current active button in the UI
  43142. */
  43143. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43144. }
  43145. /**
  43146. * Options to create the webXR UI
  43147. */
  43148. export class WebXREnterExitUIOptions {
  43149. /**
  43150. * Context to enter xr with
  43151. */
  43152. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43153. /**
  43154. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43155. */
  43156. customButtons?: Array<WebXREnterExitUIButton>;
  43157. }
  43158. /**
  43159. * UI to allow the user to enter/exit XR mode
  43160. */
  43161. export class WebXREnterExitUI implements IDisposable {
  43162. private scene;
  43163. private _overlay;
  43164. private _buttons;
  43165. private _activeButton;
  43166. /**
  43167. * Fired every time the active button is changed.
  43168. *
  43169. * When xr is entered via a button that launches xr that button will be the callback parameter
  43170. *
  43171. * When exiting xr the callback parameter will be null)
  43172. */
  43173. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43174. /**
  43175. * Creates UI to allow the user to enter/exit XR mode
  43176. * @param scene the scene to add the ui to
  43177. * @param helper the xr experience helper to enter/exit xr with
  43178. * @param options options to configure the UI
  43179. * @returns the created ui
  43180. */
  43181. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43182. private constructor();
  43183. private _updateButtons;
  43184. /**
  43185. * Disposes of the object
  43186. */
  43187. dispose(): void;
  43188. }
  43189. }
  43190. declare module "babylonjs/Cameras/XR/webXRController" {
  43191. import { Nullable } from "babylonjs/types";
  43192. import { Observable } from "babylonjs/Misc/observable";
  43193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43194. import { Ray } from "babylonjs/Culling/ray";
  43195. import { Scene } from "babylonjs/scene";
  43196. /**
  43197. * Represents an XR input
  43198. */
  43199. export class WebXRController {
  43200. private scene;
  43201. /** The underlying input source for the controller */
  43202. inputSource: XRInputSource;
  43203. private parentContainer;
  43204. /**
  43205. * 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
  43206. */
  43207. grip?: AbstractMesh;
  43208. /**
  43209. * Pointer which can be used to select objects or attach a visible laser to
  43210. */
  43211. pointer: AbstractMesh;
  43212. /**
  43213. * Event that fires when the controller is removed/disposed
  43214. */
  43215. onDisposeObservable: Observable<{}>;
  43216. private _tmpMatrix;
  43217. private _tmpQuaternion;
  43218. private _tmpVector;
  43219. /**
  43220. * Creates the controller
  43221. * @see https://doc.babylonjs.com/how_to/webxr
  43222. * @param scene the scene which the controller should be associated to
  43223. * @param inputSource the underlying input source for the controller
  43224. * @param parentContainer parent that the controller meshes should be children of
  43225. */
  43226. constructor(scene: Scene,
  43227. /** The underlying input source for the controller */
  43228. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43229. /**
  43230. * Updates the controller pose based on the given XRFrame
  43231. * @param xrFrame xr frame to update the pose with
  43232. * @param referenceSpace reference space to use
  43233. */
  43234. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43235. /**
  43236. * Gets a world space ray coming from the controller
  43237. * @param result the resulting ray
  43238. */
  43239. getWorldPointerRayToRef(result: Ray): void;
  43240. /**
  43241. * Disposes of the object
  43242. */
  43243. dispose(): void;
  43244. }
  43245. }
  43246. declare module "babylonjs/Cameras/XR/webXRInput" {
  43247. import { Observable } from "babylonjs/Misc/observable";
  43248. import { IDisposable } from "babylonjs/scene";
  43249. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43250. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43251. /**
  43252. * XR input used to track XR inputs such as controllers/rays
  43253. */
  43254. export class WebXRInput implements IDisposable {
  43255. /**
  43256. * Base experience the input listens to
  43257. */
  43258. baseExperience: WebXRExperienceHelper;
  43259. /**
  43260. * XR controllers being tracked
  43261. */
  43262. controllers: Array<WebXRController>;
  43263. private _frameObserver;
  43264. private _stateObserver;
  43265. /**
  43266. * Event when a controller has been connected/added
  43267. */
  43268. onControllerAddedObservable: Observable<WebXRController>;
  43269. /**
  43270. * Event when a controller has been removed/disconnected
  43271. */
  43272. onControllerRemovedObservable: Observable<WebXRController>;
  43273. /**
  43274. * Initializes the WebXRInput
  43275. * @param baseExperience experience helper which the input should be created for
  43276. */
  43277. constructor(
  43278. /**
  43279. * Base experience the input listens to
  43280. */
  43281. baseExperience: WebXRExperienceHelper);
  43282. private _onInputSourcesChange;
  43283. private _addAndRemoveControllers;
  43284. /**
  43285. * Disposes of the object
  43286. */
  43287. dispose(): void;
  43288. }
  43289. }
  43290. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43292. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43293. /**
  43294. * Enables teleportation
  43295. */
  43296. export class WebXRControllerTeleportation {
  43297. private _teleportationFillColor;
  43298. private _teleportationBorderColor;
  43299. private _tmpRay;
  43300. private _tmpVector;
  43301. /**
  43302. * Creates a WebXRControllerTeleportation
  43303. * @param input input manager to add teleportation to
  43304. * @param floorMeshes floormeshes which can be teleported to
  43305. */
  43306. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43307. }
  43308. }
  43309. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43310. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43311. /**
  43312. * Handles pointer input automatically for the pointer of XR controllers
  43313. */
  43314. export class WebXRControllerPointerSelection {
  43315. private static _idCounter;
  43316. private _tmpRay;
  43317. /**
  43318. * Creates a WebXRControllerPointerSelection
  43319. * @param input input manager to setup pointer selection
  43320. */
  43321. constructor(input: WebXRInput);
  43322. private _convertNormalToDirectionOfRay;
  43323. private _updatePointerDistance;
  43324. }
  43325. }
  43326. declare module "babylonjs/Loading/sceneLoader" {
  43327. import { Observable } from "babylonjs/Misc/observable";
  43328. import { Nullable } from "babylonjs/types";
  43329. import { Scene } from "babylonjs/scene";
  43330. import { Engine } from "babylonjs/Engines/engine";
  43331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43332. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43333. import { AssetContainer } from "babylonjs/assetContainer";
  43334. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43335. import { Skeleton } from "babylonjs/Bones/skeleton";
  43336. /**
  43337. * Class used to represent data loading progression
  43338. */
  43339. export class SceneLoaderProgressEvent {
  43340. /** defines if data length to load can be evaluated */
  43341. readonly lengthComputable: boolean;
  43342. /** defines the loaded data length */
  43343. readonly loaded: number;
  43344. /** defines the data length to load */
  43345. readonly total: number;
  43346. /**
  43347. * Create a new progress event
  43348. * @param lengthComputable defines if data length to load can be evaluated
  43349. * @param loaded defines the loaded data length
  43350. * @param total defines the data length to load
  43351. */
  43352. constructor(
  43353. /** defines if data length to load can be evaluated */
  43354. lengthComputable: boolean,
  43355. /** defines the loaded data length */
  43356. loaded: number,
  43357. /** defines the data length to load */
  43358. total: number);
  43359. /**
  43360. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43361. * @param event defines the source event
  43362. * @returns a new SceneLoaderProgressEvent
  43363. */
  43364. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43365. }
  43366. /**
  43367. * Interface used by SceneLoader plugins to define supported file extensions
  43368. */
  43369. export interface ISceneLoaderPluginExtensions {
  43370. /**
  43371. * Defines the list of supported extensions
  43372. */
  43373. [extension: string]: {
  43374. isBinary: boolean;
  43375. };
  43376. }
  43377. /**
  43378. * Interface used by SceneLoader plugin factory
  43379. */
  43380. export interface ISceneLoaderPluginFactory {
  43381. /**
  43382. * Defines the name of the factory
  43383. */
  43384. name: string;
  43385. /**
  43386. * Function called to create a new plugin
  43387. * @return the new plugin
  43388. */
  43389. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43390. /**
  43391. * Boolean indicating if the plugin can direct load specific data
  43392. */
  43393. canDirectLoad?: (data: string) => boolean;
  43394. }
  43395. /**
  43396. * Interface used to define a SceneLoader plugin
  43397. */
  43398. export interface ISceneLoaderPlugin {
  43399. /**
  43400. * The friendly name of this plugin.
  43401. */
  43402. name: string;
  43403. /**
  43404. * The file extensions supported by this plugin.
  43405. */
  43406. extensions: string | ISceneLoaderPluginExtensions;
  43407. /**
  43408. * Import meshes into a scene.
  43409. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43410. * @param scene The scene to import into
  43411. * @param data The data to import
  43412. * @param rootUrl The root url for scene and resources
  43413. * @param meshes The meshes array to import into
  43414. * @param particleSystems The particle systems array to import into
  43415. * @param skeletons The skeletons array to import into
  43416. * @param onError The callback when import fails
  43417. * @returns True if successful or false otherwise
  43418. */
  43419. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43420. /**
  43421. * Load into a scene.
  43422. * @param scene The scene to load into
  43423. * @param data The data to import
  43424. * @param rootUrl The root url for scene and resources
  43425. * @param onError The callback when import fails
  43426. * @returns true if successful or false otherwise
  43427. */
  43428. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43429. /**
  43430. * The callback that returns true if the data can be directly loaded.
  43431. */
  43432. canDirectLoad?: (data: string) => boolean;
  43433. /**
  43434. * The callback that allows custom handling of the root url based on the response url.
  43435. */
  43436. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43437. /**
  43438. * Load into an asset container.
  43439. * @param scene The scene to load into
  43440. * @param data The data to import
  43441. * @param rootUrl The root url for scene and resources
  43442. * @param onError The callback when import fails
  43443. * @returns The loaded asset container
  43444. */
  43445. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43446. }
  43447. /**
  43448. * Interface used to define an async SceneLoader plugin
  43449. */
  43450. export interface ISceneLoaderPluginAsync {
  43451. /**
  43452. * The friendly name of this plugin.
  43453. */
  43454. name: string;
  43455. /**
  43456. * The file extensions supported by this plugin.
  43457. */
  43458. extensions: string | ISceneLoaderPluginExtensions;
  43459. /**
  43460. * Import meshes into a scene.
  43461. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43462. * @param scene The scene to import into
  43463. * @param data The data to import
  43464. * @param rootUrl The root url for scene and resources
  43465. * @param onProgress The callback when the load progresses
  43466. * @param fileName Defines the name of the file to load
  43467. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43468. */
  43469. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43470. meshes: AbstractMesh[];
  43471. particleSystems: IParticleSystem[];
  43472. skeletons: Skeleton[];
  43473. animationGroups: AnimationGroup[];
  43474. }>;
  43475. /**
  43476. * Load into a scene.
  43477. * @param scene The scene to load into
  43478. * @param data The data to import
  43479. * @param rootUrl The root url for scene and resources
  43480. * @param onProgress The callback when the load progresses
  43481. * @param fileName Defines the name of the file to load
  43482. * @returns Nothing
  43483. */
  43484. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43485. /**
  43486. * The callback that returns true if the data can be directly loaded.
  43487. */
  43488. canDirectLoad?: (data: string) => boolean;
  43489. /**
  43490. * The callback that allows custom handling of the root url based on the response url.
  43491. */
  43492. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43493. /**
  43494. * Load into an asset container.
  43495. * @param scene The scene to load into
  43496. * @param data The data to import
  43497. * @param rootUrl The root url for scene and resources
  43498. * @param onProgress The callback when the load progresses
  43499. * @param fileName Defines the name of the file to load
  43500. * @returns The loaded asset container
  43501. */
  43502. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43503. }
  43504. /**
  43505. * Class used to load scene from various file formats using registered plugins
  43506. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43507. */
  43508. export class SceneLoader {
  43509. /**
  43510. * No logging while loading
  43511. */
  43512. static readonly NO_LOGGING: number;
  43513. /**
  43514. * Minimal logging while loading
  43515. */
  43516. static readonly MINIMAL_LOGGING: number;
  43517. /**
  43518. * Summary logging while loading
  43519. */
  43520. static readonly SUMMARY_LOGGING: number;
  43521. /**
  43522. * Detailled logging while loading
  43523. */
  43524. static readonly DETAILED_LOGGING: number;
  43525. /**
  43526. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43527. */
  43528. static ForceFullSceneLoadingForIncremental: boolean;
  43529. /**
  43530. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43531. */
  43532. static ShowLoadingScreen: boolean;
  43533. /**
  43534. * Defines the current logging level (while loading the scene)
  43535. * @ignorenaming
  43536. */
  43537. static loggingLevel: number;
  43538. /**
  43539. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43540. */
  43541. static CleanBoneMatrixWeights: boolean;
  43542. /**
  43543. * Event raised when a plugin is used to load a scene
  43544. */
  43545. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43546. private static _registeredPlugins;
  43547. private static _getDefaultPlugin;
  43548. private static _getPluginForExtension;
  43549. private static _getPluginForDirectLoad;
  43550. private static _getPluginForFilename;
  43551. private static _getDirectLoad;
  43552. private static _loadData;
  43553. private static _getFileInfo;
  43554. /**
  43555. * Gets a plugin that can load the given extension
  43556. * @param extension defines the extension to load
  43557. * @returns a plugin or null if none works
  43558. */
  43559. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43560. /**
  43561. * Gets a boolean indicating that the given extension can be loaded
  43562. * @param extension defines the extension to load
  43563. * @returns true if the extension is supported
  43564. */
  43565. static IsPluginForExtensionAvailable(extension: string): boolean;
  43566. /**
  43567. * Adds a new plugin to the list of registered plugins
  43568. * @param plugin defines the plugin to add
  43569. */
  43570. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43571. /**
  43572. * Import meshes into a scene
  43573. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43574. * @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)
  43575. * @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)
  43576. * @param scene the instance of BABYLON.Scene to append to
  43577. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43578. * @param onProgress a callback with a progress event for each file being loaded
  43579. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43580. * @param pluginExtension the extension used to determine the plugin
  43581. * @returns The loaded plugin
  43582. */
  43583. 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>;
  43584. /**
  43585. * Import meshes into a scene
  43586. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43587. * @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)
  43588. * @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)
  43589. * @param scene the instance of BABYLON.Scene to append to
  43590. * @param onProgress a callback with a progress event for each file being loaded
  43591. * @param pluginExtension the extension used to determine the plugin
  43592. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43593. */
  43594. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43595. meshes: AbstractMesh[];
  43596. particleSystems: IParticleSystem[];
  43597. skeletons: Skeleton[];
  43598. animationGroups: AnimationGroup[];
  43599. }>;
  43600. /**
  43601. * Load a scene
  43602. * @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)
  43603. * @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)
  43604. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43605. * @param onSuccess a callback with the scene when import succeeds
  43606. * @param onProgress a callback with a progress event for each file being loaded
  43607. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43608. * @param pluginExtension the extension used to determine the plugin
  43609. * @returns The loaded plugin
  43610. */
  43611. 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>;
  43612. /**
  43613. * Load a scene
  43614. * @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)
  43615. * @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)
  43616. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43617. * @param onProgress a callback with a progress event for each file being loaded
  43618. * @param pluginExtension the extension used to determine the plugin
  43619. * @returns The loaded scene
  43620. */
  43621. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43622. /**
  43623. * Append a scene
  43624. * @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)
  43625. * @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)
  43626. * @param scene is the instance of BABYLON.Scene to append to
  43627. * @param onSuccess a callback with the scene when import succeeds
  43628. * @param onProgress a callback with a progress event for each file being loaded
  43629. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43630. * @param pluginExtension the extension used to determine the plugin
  43631. * @returns The loaded plugin
  43632. */
  43633. 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>;
  43634. /**
  43635. * Append a scene
  43636. * @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)
  43637. * @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)
  43638. * @param scene is the instance of BABYLON.Scene to append to
  43639. * @param onProgress a callback with a progress event for each file being loaded
  43640. * @param pluginExtension the extension used to determine the plugin
  43641. * @returns The given scene
  43642. */
  43643. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43644. /**
  43645. * Load a scene into an asset container
  43646. * @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)
  43647. * @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)
  43648. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43649. * @param onSuccess a callback with the scene when import succeeds
  43650. * @param onProgress a callback with a progress event for each file being loaded
  43651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43652. * @param pluginExtension the extension used to determine the plugin
  43653. * @returns The loaded plugin
  43654. */
  43655. 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>;
  43656. /**
  43657. * Load a scene into an asset container
  43658. * @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)
  43659. * @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)
  43660. * @param scene is the instance of Scene to append to
  43661. * @param onProgress a callback with a progress event for each file being loaded
  43662. * @param pluginExtension the extension used to determine the plugin
  43663. * @returns The loaded asset container
  43664. */
  43665. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43666. }
  43667. }
  43668. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43669. import { Scene } from "babylonjs/scene";
  43670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43671. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43672. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43673. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43674. /**
  43675. * Generic Controller
  43676. */
  43677. export class GenericController extends WebVRController {
  43678. /**
  43679. * Base Url for the controller model.
  43680. */
  43681. static readonly MODEL_BASE_URL: string;
  43682. /**
  43683. * File name for the controller model.
  43684. */
  43685. static readonly MODEL_FILENAME: string;
  43686. /**
  43687. * Creates a new GenericController from a gamepad
  43688. * @param vrGamepad the gamepad that the controller should be created from
  43689. */
  43690. constructor(vrGamepad: any);
  43691. /**
  43692. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43693. * @param scene scene in which to add meshes
  43694. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43695. */
  43696. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43697. /**
  43698. * Called once for each button that changed state since the last frame
  43699. * @param buttonIdx Which button index changed
  43700. * @param state New state of the button
  43701. * @param changes Which properties on the state changed since last frame
  43702. */
  43703. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43704. }
  43705. }
  43706. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43707. import { Observable } from "babylonjs/Misc/observable";
  43708. import { Scene } from "babylonjs/scene";
  43709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43710. import { Ray } from "babylonjs/Culling/ray";
  43711. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43712. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43713. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43714. /**
  43715. * Defines the WindowsMotionController object that the state of the windows motion controller
  43716. */
  43717. export class WindowsMotionController extends WebVRController {
  43718. /**
  43719. * The base url used to load the left and right controller models
  43720. */
  43721. static MODEL_BASE_URL: string;
  43722. /**
  43723. * The name of the left controller model file
  43724. */
  43725. static MODEL_LEFT_FILENAME: string;
  43726. /**
  43727. * The name of the right controller model file
  43728. */
  43729. static MODEL_RIGHT_FILENAME: string;
  43730. /**
  43731. * The controller name prefix for this controller type
  43732. */
  43733. static readonly GAMEPAD_ID_PREFIX: string;
  43734. /**
  43735. * The controller id pattern for this controller type
  43736. */
  43737. private static readonly GAMEPAD_ID_PATTERN;
  43738. private _loadedMeshInfo;
  43739. private readonly _mapping;
  43740. /**
  43741. * Fired when the trackpad on this controller is clicked
  43742. */
  43743. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43744. /**
  43745. * Fired when the trackpad on this controller is modified
  43746. */
  43747. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43748. /**
  43749. * The current x and y values of this controller's trackpad
  43750. */
  43751. trackpad: StickValues;
  43752. /**
  43753. * Creates a new WindowsMotionController from a gamepad
  43754. * @param vrGamepad the gamepad that the controller should be created from
  43755. */
  43756. constructor(vrGamepad: any);
  43757. /**
  43758. * Fired when the trigger on this controller is modified
  43759. */
  43760. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43761. /**
  43762. * Fired when the menu button on this controller is modified
  43763. */
  43764. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43765. /**
  43766. * Fired when the grip button on this controller is modified
  43767. */
  43768. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43769. /**
  43770. * Fired when the thumbstick button on this controller is modified
  43771. */
  43772. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43773. /**
  43774. * Fired when the touchpad button on this controller is modified
  43775. */
  43776. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43777. /**
  43778. * Fired when the touchpad values on this controller are modified
  43779. */
  43780. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43781. private _updateTrackpad;
  43782. /**
  43783. * Called once per frame by the engine.
  43784. */
  43785. update(): void;
  43786. /**
  43787. * Called once for each button that changed state since the last frame
  43788. * @param buttonIdx Which button index changed
  43789. * @param state New state of the button
  43790. * @param changes Which properties on the state changed since last frame
  43791. */
  43792. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43793. /**
  43794. * Moves the buttons on the controller mesh based on their current state
  43795. * @param buttonName the name of the button to move
  43796. * @param buttonValue the value of the button which determines the buttons new position
  43797. */
  43798. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43799. /**
  43800. * Moves the axis on the controller mesh based on its current state
  43801. * @param axis the index of the axis
  43802. * @param axisValue the value of the axis which determines the meshes new position
  43803. * @hidden
  43804. */
  43805. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43806. /**
  43807. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43808. * @param scene scene in which to add meshes
  43809. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43810. */
  43811. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43812. /**
  43813. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43814. * can be transformed by button presses and axes values, based on this._mapping.
  43815. *
  43816. * @param scene scene in which the meshes exist
  43817. * @param meshes list of meshes that make up the controller model to process
  43818. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43819. */
  43820. private processModel;
  43821. private createMeshInfo;
  43822. /**
  43823. * Gets the ray of the controller in the direction the controller is pointing
  43824. * @param length the length the resulting ray should be
  43825. * @returns a ray in the direction the controller is pointing
  43826. */
  43827. getForwardRay(length?: number): Ray;
  43828. /**
  43829. * Disposes of the controller
  43830. */
  43831. dispose(): void;
  43832. }
  43833. }
  43834. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43835. import { Observable } from "babylonjs/Misc/observable";
  43836. import { Scene } from "babylonjs/scene";
  43837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43838. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43839. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43840. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43841. /**
  43842. * Oculus Touch Controller
  43843. */
  43844. export class OculusTouchController extends WebVRController {
  43845. /**
  43846. * Base Url for the controller model.
  43847. */
  43848. static MODEL_BASE_URL: string;
  43849. /**
  43850. * File name for the left controller model.
  43851. */
  43852. static MODEL_LEFT_FILENAME: string;
  43853. /**
  43854. * File name for the right controller model.
  43855. */
  43856. static MODEL_RIGHT_FILENAME: string;
  43857. /**
  43858. * Base Url for the Quest controller model.
  43859. */
  43860. static QUEST_MODEL_BASE_URL: string;
  43861. /**
  43862. * @hidden
  43863. * If the controllers are running on a device that needs the updated Quest controller models
  43864. */
  43865. static _IsQuest: boolean;
  43866. /**
  43867. * Fired when the secondary trigger on this controller is modified
  43868. */
  43869. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43870. /**
  43871. * Fired when the thumb rest on this controller is modified
  43872. */
  43873. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43874. /**
  43875. * Creates a new OculusTouchController from a gamepad
  43876. * @param vrGamepad the gamepad that the controller should be created from
  43877. */
  43878. constructor(vrGamepad: any);
  43879. /**
  43880. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43881. * @param scene scene in which to add meshes
  43882. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43883. */
  43884. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43885. /**
  43886. * Fired when the A button on this controller is modified
  43887. */
  43888. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43889. /**
  43890. * Fired when the B button on this controller is modified
  43891. */
  43892. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43893. /**
  43894. * Fired when the X button on this controller is modified
  43895. */
  43896. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43897. /**
  43898. * Fired when the Y button on this controller is modified
  43899. */
  43900. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43901. /**
  43902. * Called once for each button that changed state since the last frame
  43903. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43904. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43905. * 2) secondary trigger (same)
  43906. * 3) A (right) X (left), touch, pressed = value
  43907. * 4) B / Y
  43908. * 5) thumb rest
  43909. * @param buttonIdx Which button index changed
  43910. * @param state New state of the button
  43911. * @param changes Which properties on the state changed since last frame
  43912. */
  43913. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43914. }
  43915. }
  43916. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43917. import { Scene } from "babylonjs/scene";
  43918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43919. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43920. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43921. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43922. import { Observable } from "babylonjs/Misc/observable";
  43923. /**
  43924. * Vive Controller
  43925. */
  43926. export class ViveController extends WebVRController {
  43927. /**
  43928. * Base Url for the controller model.
  43929. */
  43930. static MODEL_BASE_URL: string;
  43931. /**
  43932. * File name for the controller model.
  43933. */
  43934. static MODEL_FILENAME: string;
  43935. /**
  43936. * Creates a new ViveController from a gamepad
  43937. * @param vrGamepad the gamepad that the controller should be created from
  43938. */
  43939. constructor(vrGamepad: any);
  43940. /**
  43941. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43942. * @param scene scene in which to add meshes
  43943. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43944. */
  43945. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43946. /**
  43947. * Fired when the left button on this controller is modified
  43948. */
  43949. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43950. /**
  43951. * Fired when the right button on this controller is modified
  43952. */
  43953. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43954. /**
  43955. * Fired when the menu button on this controller is modified
  43956. */
  43957. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43958. /**
  43959. * Called once for each button that changed state since the last frame
  43960. * Vive mapping:
  43961. * 0: touchpad
  43962. * 1: trigger
  43963. * 2: left AND right buttons
  43964. * 3: menu button
  43965. * @param buttonIdx Which button index changed
  43966. * @param state New state of the button
  43967. * @param changes Which properties on the state changed since last frame
  43968. */
  43969. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43970. }
  43971. }
  43972. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43973. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43974. /**
  43975. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43976. */
  43977. export class WebXRControllerModelLoader {
  43978. /**
  43979. * Creates the WebXRControllerModelLoader
  43980. * @param input xr input that creates the controllers
  43981. */
  43982. constructor(input: WebXRInput);
  43983. }
  43984. }
  43985. declare module "babylonjs/Cameras/XR/index" {
  43986. export * from "babylonjs/Cameras/XR/webXRCamera";
  43987. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43988. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43989. export * from "babylonjs/Cameras/XR/webXRInput";
  43990. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43991. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43992. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43993. export * from "babylonjs/Cameras/XR/webXRController";
  43994. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43995. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43996. }
  43997. declare module "babylonjs/Cameras/RigModes/index" {
  43998. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43999. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44000. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44001. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44002. }
  44003. declare module "babylonjs/Cameras/index" {
  44004. export * from "babylonjs/Cameras/Inputs/index";
  44005. export * from "babylonjs/Cameras/cameraInputsManager";
  44006. export * from "babylonjs/Cameras/camera";
  44007. export * from "babylonjs/Cameras/targetCamera";
  44008. export * from "babylonjs/Cameras/freeCamera";
  44009. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44010. export * from "babylonjs/Cameras/touchCamera";
  44011. export * from "babylonjs/Cameras/arcRotateCamera";
  44012. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44013. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44014. export * from "babylonjs/Cameras/flyCamera";
  44015. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44016. export * from "babylonjs/Cameras/followCamera";
  44017. export * from "babylonjs/Cameras/followCameraInputsManager";
  44018. export * from "babylonjs/Cameras/gamepadCamera";
  44019. export * from "babylonjs/Cameras/Stereoscopic/index";
  44020. export * from "babylonjs/Cameras/universalCamera";
  44021. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44022. export * from "babylonjs/Cameras/VR/index";
  44023. export * from "babylonjs/Cameras/XR/index";
  44024. export * from "babylonjs/Cameras/RigModes/index";
  44025. }
  44026. declare module "babylonjs/Collisions/index" {
  44027. export * from "babylonjs/Collisions/collider";
  44028. export * from "babylonjs/Collisions/collisionCoordinator";
  44029. export * from "babylonjs/Collisions/pickingInfo";
  44030. export * from "babylonjs/Collisions/intersectionInfo";
  44031. export * from "babylonjs/Collisions/meshCollisionData";
  44032. }
  44033. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44034. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44035. import { Vector3 } from "babylonjs/Maths/math.vector";
  44036. import { Ray } from "babylonjs/Culling/ray";
  44037. import { Plane } from "babylonjs/Maths/math.plane";
  44038. /**
  44039. * Contains an array of blocks representing the octree
  44040. */
  44041. export interface IOctreeContainer<T> {
  44042. /**
  44043. * Blocks within the octree
  44044. */
  44045. blocks: Array<OctreeBlock<T>>;
  44046. }
  44047. /**
  44048. * Class used to store a cell in an octree
  44049. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44050. */
  44051. export class OctreeBlock<T> {
  44052. /**
  44053. * Gets the content of the current block
  44054. */
  44055. entries: T[];
  44056. /**
  44057. * Gets the list of block children
  44058. */
  44059. blocks: Array<OctreeBlock<T>>;
  44060. private _depth;
  44061. private _maxDepth;
  44062. private _capacity;
  44063. private _minPoint;
  44064. private _maxPoint;
  44065. private _boundingVectors;
  44066. private _creationFunc;
  44067. /**
  44068. * Creates a new block
  44069. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44070. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44071. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44072. * @param depth defines the current depth of this block in the octree
  44073. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44074. * @param creationFunc defines a callback to call when an element is added to the block
  44075. */
  44076. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44077. /**
  44078. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44079. */
  44080. readonly capacity: number;
  44081. /**
  44082. * Gets the minimum vector (in world space) of the block's bounding box
  44083. */
  44084. readonly minPoint: Vector3;
  44085. /**
  44086. * Gets the maximum vector (in world space) of the block's bounding box
  44087. */
  44088. readonly maxPoint: Vector3;
  44089. /**
  44090. * Add a new element to this block
  44091. * @param entry defines the element to add
  44092. */
  44093. addEntry(entry: T): void;
  44094. /**
  44095. * Remove an element from this block
  44096. * @param entry defines the element to remove
  44097. */
  44098. removeEntry(entry: T): void;
  44099. /**
  44100. * Add an array of elements to this block
  44101. * @param entries defines the array of elements to add
  44102. */
  44103. addEntries(entries: T[]): void;
  44104. /**
  44105. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44106. * @param frustumPlanes defines the frustum planes to test
  44107. * @param selection defines the array to store current content if selection is positive
  44108. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44109. */
  44110. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44111. /**
  44112. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44113. * @param sphereCenter defines the bounding sphere center
  44114. * @param sphereRadius defines the bounding sphere radius
  44115. * @param selection defines the array to store current content if selection is positive
  44116. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44117. */
  44118. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44119. /**
  44120. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44121. * @param ray defines the ray to test with
  44122. * @param selection defines the array to store current content if selection is positive
  44123. */
  44124. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44125. /**
  44126. * Subdivide the content into child blocks (this block will then be empty)
  44127. */
  44128. createInnerBlocks(): void;
  44129. /**
  44130. * @hidden
  44131. */
  44132. 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;
  44133. }
  44134. }
  44135. declare module "babylonjs/Culling/Octrees/octree" {
  44136. import { SmartArray } from "babylonjs/Misc/smartArray";
  44137. import { Vector3 } from "babylonjs/Maths/math.vector";
  44138. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44140. import { Ray } from "babylonjs/Culling/ray";
  44141. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44142. import { Plane } from "babylonjs/Maths/math.plane";
  44143. /**
  44144. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44146. */
  44147. export class Octree<T> {
  44148. /** 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.) */
  44149. maxDepth: number;
  44150. /**
  44151. * Blocks within the octree containing objects
  44152. */
  44153. blocks: Array<OctreeBlock<T>>;
  44154. /**
  44155. * Content stored in the octree
  44156. */
  44157. dynamicContent: T[];
  44158. private _maxBlockCapacity;
  44159. private _selectionContent;
  44160. private _creationFunc;
  44161. /**
  44162. * Creates a octree
  44163. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44164. * @param creationFunc function to be used to instatiate the octree
  44165. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44166. * @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.)
  44167. */
  44168. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44169. /** 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.) */
  44170. maxDepth?: number);
  44171. /**
  44172. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44173. * @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);
  44174. * @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);
  44175. * @param entries meshes to be added to the octree blocks
  44176. */
  44177. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44178. /**
  44179. * Adds a mesh to the octree
  44180. * @param entry Mesh to add to the octree
  44181. */
  44182. addMesh(entry: T): void;
  44183. /**
  44184. * Remove an element from the octree
  44185. * @param entry defines the element to remove
  44186. */
  44187. removeMesh(entry: T): void;
  44188. /**
  44189. * Selects an array of meshes within the frustum
  44190. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44191. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44192. * @returns array of meshes within the frustum
  44193. */
  44194. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44195. /**
  44196. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44197. * @param sphereCenter defines the bounding sphere center
  44198. * @param sphereRadius defines the bounding sphere radius
  44199. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44200. * @returns an array of objects that intersect the sphere
  44201. */
  44202. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44203. /**
  44204. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44205. * @param ray defines the ray to test with
  44206. * @returns array of intersected objects
  44207. */
  44208. intersectsRay(ray: Ray): SmartArray<T>;
  44209. /**
  44210. * Adds a mesh into the octree block if it intersects the block
  44211. */
  44212. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44213. /**
  44214. * Adds a submesh into the octree block if it intersects the block
  44215. */
  44216. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44217. }
  44218. }
  44219. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44220. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44221. import { Scene } from "babylonjs/scene";
  44222. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44224. import { Ray } from "babylonjs/Culling/ray";
  44225. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44226. import { Collider } from "babylonjs/Collisions/collider";
  44227. module "babylonjs/scene" {
  44228. interface Scene {
  44229. /**
  44230. * @hidden
  44231. * Backing Filed
  44232. */
  44233. _selectionOctree: Octree<AbstractMesh>;
  44234. /**
  44235. * Gets the octree used to boost mesh selection (picking)
  44236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44237. */
  44238. selectionOctree: Octree<AbstractMesh>;
  44239. /**
  44240. * Creates or updates the octree used to boost selection (picking)
  44241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44242. * @param maxCapacity defines the maximum capacity per leaf
  44243. * @param maxDepth defines the maximum depth of the octree
  44244. * @returns an octree of AbstractMesh
  44245. */
  44246. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44247. }
  44248. }
  44249. module "babylonjs/Meshes/abstractMesh" {
  44250. interface AbstractMesh {
  44251. /**
  44252. * @hidden
  44253. * Backing Field
  44254. */
  44255. _submeshesOctree: Octree<SubMesh>;
  44256. /**
  44257. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44258. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44259. * @param maxCapacity defines the maximum size of each block (64 by default)
  44260. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44261. * @returns the new octree
  44262. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44264. */
  44265. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44266. }
  44267. }
  44268. /**
  44269. * Defines the octree scene component responsible to manage any octrees
  44270. * in a given scene.
  44271. */
  44272. export class OctreeSceneComponent {
  44273. /**
  44274. * The component name help to identify the component in the list of scene components.
  44275. */
  44276. readonly name: string;
  44277. /**
  44278. * The scene the component belongs to.
  44279. */
  44280. scene: Scene;
  44281. /**
  44282. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44283. */
  44284. readonly checksIsEnabled: boolean;
  44285. /**
  44286. * Creates a new instance of the component for the given scene
  44287. * @param scene Defines the scene to register the component in
  44288. */
  44289. constructor(scene: Scene);
  44290. /**
  44291. * Registers the component in a given scene
  44292. */
  44293. register(): void;
  44294. /**
  44295. * Return the list of active meshes
  44296. * @returns the list of active meshes
  44297. */
  44298. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44299. /**
  44300. * Return the list of active sub meshes
  44301. * @param mesh The mesh to get the candidates sub meshes from
  44302. * @returns the list of active sub meshes
  44303. */
  44304. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44305. private _tempRay;
  44306. /**
  44307. * Return the list of sub meshes intersecting with a given local ray
  44308. * @param mesh defines the mesh to find the submesh for
  44309. * @param localRay defines the ray in local space
  44310. * @returns the list of intersecting sub meshes
  44311. */
  44312. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44313. /**
  44314. * Return the list of sub meshes colliding with a collider
  44315. * @param mesh defines the mesh to find the submesh for
  44316. * @param collider defines the collider to evaluate the collision against
  44317. * @returns the list of colliding sub meshes
  44318. */
  44319. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44320. /**
  44321. * Rebuilds the elements related to this component in case of
  44322. * context lost for instance.
  44323. */
  44324. rebuild(): void;
  44325. /**
  44326. * Disposes the component and the associated ressources.
  44327. */
  44328. dispose(): void;
  44329. }
  44330. }
  44331. declare module "babylonjs/Culling/Octrees/index" {
  44332. export * from "babylonjs/Culling/Octrees/octree";
  44333. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44334. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44335. }
  44336. declare module "babylonjs/Culling/index" {
  44337. export * from "babylonjs/Culling/boundingBox";
  44338. export * from "babylonjs/Culling/boundingInfo";
  44339. export * from "babylonjs/Culling/boundingSphere";
  44340. export * from "babylonjs/Culling/Octrees/index";
  44341. export * from "babylonjs/Culling/ray";
  44342. }
  44343. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44344. import { IDisposable, Scene } from "babylonjs/scene";
  44345. import { Nullable } from "babylonjs/types";
  44346. import { Observable } from "babylonjs/Misc/observable";
  44347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44348. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44349. import { Camera } from "babylonjs/Cameras/camera";
  44350. /**
  44351. * Renders a layer on top of an existing scene
  44352. */
  44353. export class UtilityLayerRenderer implements IDisposable {
  44354. /** the original scene that will be rendered on top of */
  44355. originalScene: Scene;
  44356. private _pointerCaptures;
  44357. private _lastPointerEvents;
  44358. private static _DefaultUtilityLayer;
  44359. private static _DefaultKeepDepthUtilityLayer;
  44360. private _sharedGizmoLight;
  44361. private _renderCamera;
  44362. /**
  44363. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44364. * @returns the camera that is used when rendering the utility layer
  44365. */
  44366. getRenderCamera(): Nullable<Camera>;
  44367. /**
  44368. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44369. * @param cam the camera that should be used when rendering the utility layer
  44370. */
  44371. setRenderCamera(cam: Nullable<Camera>): void;
  44372. /**
  44373. * @hidden
  44374. * Light which used by gizmos to get light shading
  44375. */
  44376. _getSharedGizmoLight(): HemisphericLight;
  44377. /**
  44378. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44379. */
  44380. pickUtilitySceneFirst: boolean;
  44381. /**
  44382. * 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)
  44383. */
  44384. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44385. /**
  44386. * 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)
  44387. */
  44388. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44389. /**
  44390. * The scene that is rendered on top of the original scene
  44391. */
  44392. utilityLayerScene: Scene;
  44393. /**
  44394. * If the utility layer should automatically be rendered on top of existing scene
  44395. */
  44396. shouldRender: boolean;
  44397. /**
  44398. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44399. */
  44400. onlyCheckPointerDownEvents: boolean;
  44401. /**
  44402. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44403. */
  44404. processAllEvents: boolean;
  44405. /**
  44406. * Observable raised when the pointer move from the utility layer scene to the main scene
  44407. */
  44408. onPointerOutObservable: Observable<number>;
  44409. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44410. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44411. private _afterRenderObserver;
  44412. private _sceneDisposeObserver;
  44413. private _originalPointerObserver;
  44414. /**
  44415. * Instantiates a UtilityLayerRenderer
  44416. * @param originalScene the original scene that will be rendered on top of
  44417. * @param handleEvents boolean indicating if the utility layer should handle events
  44418. */
  44419. constructor(
  44420. /** the original scene that will be rendered on top of */
  44421. originalScene: Scene, handleEvents?: boolean);
  44422. private _notifyObservers;
  44423. /**
  44424. * Renders the utility layers scene on top of the original scene
  44425. */
  44426. render(): void;
  44427. /**
  44428. * Disposes of the renderer
  44429. */
  44430. dispose(): void;
  44431. private _updateCamera;
  44432. }
  44433. }
  44434. declare module "babylonjs/Gizmos/gizmo" {
  44435. import { Nullable } from "babylonjs/types";
  44436. import { IDisposable } from "babylonjs/scene";
  44437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44438. import { Mesh } from "babylonjs/Meshes/mesh";
  44439. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44440. /**
  44441. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44442. */
  44443. export class Gizmo implements IDisposable {
  44444. /** The utility layer the gizmo will be added to */
  44445. gizmoLayer: UtilityLayerRenderer;
  44446. /**
  44447. * The root mesh of the gizmo
  44448. */
  44449. _rootMesh: Mesh;
  44450. private _attachedMesh;
  44451. /**
  44452. * Ratio for the scale of the gizmo (Default: 1)
  44453. */
  44454. scaleRatio: number;
  44455. /**
  44456. * If a custom mesh has been set (Default: false)
  44457. */
  44458. protected _customMeshSet: boolean;
  44459. /**
  44460. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44461. * * When set, interactions will be enabled
  44462. */
  44463. attachedMesh: Nullable<AbstractMesh>;
  44464. /**
  44465. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44466. * @param mesh The mesh to replace the default mesh of the gizmo
  44467. */
  44468. setCustomMesh(mesh: Mesh): void;
  44469. /**
  44470. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44471. */
  44472. updateGizmoRotationToMatchAttachedMesh: boolean;
  44473. /**
  44474. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44475. */
  44476. updateGizmoPositionToMatchAttachedMesh: boolean;
  44477. /**
  44478. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44479. */
  44480. updateScale: boolean;
  44481. protected _interactionsEnabled: boolean;
  44482. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44483. private _beforeRenderObserver;
  44484. private _tempVector;
  44485. /**
  44486. * Creates a gizmo
  44487. * @param gizmoLayer The utility layer the gizmo will be added to
  44488. */
  44489. constructor(
  44490. /** The utility layer the gizmo will be added to */
  44491. gizmoLayer?: UtilityLayerRenderer);
  44492. /**
  44493. * Updates the gizmo to match the attached mesh's position/rotation
  44494. */
  44495. protected _update(): void;
  44496. /**
  44497. * Disposes of the gizmo
  44498. */
  44499. dispose(): void;
  44500. }
  44501. }
  44502. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44503. import { Observable } from "babylonjs/Misc/observable";
  44504. import { Nullable } from "babylonjs/types";
  44505. import { Vector3 } from "babylonjs/Maths/math.vector";
  44506. import { Color3 } from "babylonjs/Maths/math.color";
  44507. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44509. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44510. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44511. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44512. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44513. import { Scene } from "babylonjs/scene";
  44514. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44515. /**
  44516. * Single plane drag gizmo
  44517. */
  44518. export class PlaneDragGizmo extends Gizmo {
  44519. /**
  44520. * Drag behavior responsible for the gizmos dragging interactions
  44521. */
  44522. dragBehavior: PointerDragBehavior;
  44523. private _pointerObserver;
  44524. /**
  44525. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44526. */
  44527. snapDistance: number;
  44528. /**
  44529. * Event that fires each time the gizmo snaps to a new location.
  44530. * * snapDistance is the the change in distance
  44531. */
  44532. onSnapObservable: Observable<{
  44533. snapDistance: number;
  44534. }>;
  44535. private _plane;
  44536. private _coloredMaterial;
  44537. private _hoverMaterial;
  44538. private _isEnabled;
  44539. private _parent;
  44540. /** @hidden */
  44541. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44542. /** @hidden */
  44543. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44544. /**
  44545. * Creates a PlaneDragGizmo
  44546. * @param gizmoLayer The utility layer the gizmo will be added to
  44547. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44548. * @param color The color of the gizmo
  44549. */
  44550. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44551. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44552. /**
  44553. * If the gizmo is enabled
  44554. */
  44555. isEnabled: boolean;
  44556. /**
  44557. * Disposes of the gizmo
  44558. */
  44559. dispose(): void;
  44560. }
  44561. }
  44562. declare module "babylonjs/Gizmos/positionGizmo" {
  44563. import { Observable } from "babylonjs/Misc/observable";
  44564. import { Nullable } from "babylonjs/types";
  44565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44566. import { Mesh } from "babylonjs/Meshes/mesh";
  44567. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44568. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44569. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44570. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44571. /**
  44572. * Gizmo that enables dragging a mesh along 3 axis
  44573. */
  44574. export class PositionGizmo extends Gizmo {
  44575. /**
  44576. * Internal gizmo used for interactions on the x axis
  44577. */
  44578. xGizmo: AxisDragGizmo;
  44579. /**
  44580. * Internal gizmo used for interactions on the y axis
  44581. */
  44582. yGizmo: AxisDragGizmo;
  44583. /**
  44584. * Internal gizmo used for interactions on the z axis
  44585. */
  44586. zGizmo: AxisDragGizmo;
  44587. /**
  44588. * Internal gizmo used for interactions on the yz plane
  44589. */
  44590. xPlaneGizmo: PlaneDragGizmo;
  44591. /**
  44592. * Internal gizmo used for interactions on the xz plane
  44593. */
  44594. yPlaneGizmo: PlaneDragGizmo;
  44595. /**
  44596. * Internal gizmo used for interactions on the xy plane
  44597. */
  44598. zPlaneGizmo: PlaneDragGizmo;
  44599. /**
  44600. * private variables
  44601. */
  44602. private _meshAttached;
  44603. private _updateGizmoRotationToMatchAttachedMesh;
  44604. private _snapDistance;
  44605. private _scaleRatio;
  44606. /** Fires an event when any of it's sub gizmos are dragged */
  44607. onDragStartObservable: Observable<unknown>;
  44608. /** Fires an event when any of it's sub gizmos are released from dragging */
  44609. onDragEndObservable: Observable<unknown>;
  44610. /**
  44611. * If set to true, planar drag is enabled
  44612. */
  44613. private _planarGizmoEnabled;
  44614. attachedMesh: Nullable<AbstractMesh>;
  44615. /**
  44616. * Creates a PositionGizmo
  44617. * @param gizmoLayer The utility layer the gizmo will be added to
  44618. */
  44619. constructor(gizmoLayer?: UtilityLayerRenderer);
  44620. /**
  44621. * If the planar drag gizmo is enabled
  44622. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44623. */
  44624. planarGizmoEnabled: boolean;
  44625. updateGizmoRotationToMatchAttachedMesh: boolean;
  44626. /**
  44627. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44628. */
  44629. snapDistance: number;
  44630. /**
  44631. * Ratio for the scale of the gizmo (Default: 1)
  44632. */
  44633. scaleRatio: number;
  44634. /**
  44635. * Disposes of the gizmo
  44636. */
  44637. dispose(): void;
  44638. /**
  44639. * CustomMeshes are not supported by this gizmo
  44640. * @param mesh The mesh to replace the default mesh of the gizmo
  44641. */
  44642. setCustomMesh(mesh: Mesh): void;
  44643. }
  44644. }
  44645. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44646. import { Observable } from "babylonjs/Misc/observable";
  44647. import { Nullable } from "babylonjs/types";
  44648. import { Vector3 } from "babylonjs/Maths/math.vector";
  44649. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44651. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44652. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44653. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44654. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44655. import { Scene } from "babylonjs/scene";
  44656. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44657. import { Color3 } from "babylonjs/Maths/math.color";
  44658. /**
  44659. * Single axis drag gizmo
  44660. */
  44661. export class AxisDragGizmo extends Gizmo {
  44662. /**
  44663. * Drag behavior responsible for the gizmos dragging interactions
  44664. */
  44665. dragBehavior: PointerDragBehavior;
  44666. private _pointerObserver;
  44667. /**
  44668. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44669. */
  44670. snapDistance: number;
  44671. /**
  44672. * Event that fires each time the gizmo snaps to a new location.
  44673. * * snapDistance is the the change in distance
  44674. */
  44675. onSnapObservable: Observable<{
  44676. snapDistance: number;
  44677. }>;
  44678. private _isEnabled;
  44679. private _parent;
  44680. private _arrow;
  44681. private _coloredMaterial;
  44682. private _hoverMaterial;
  44683. /** @hidden */
  44684. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44685. /** @hidden */
  44686. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44687. /**
  44688. * Creates an AxisDragGizmo
  44689. * @param gizmoLayer The utility layer the gizmo will be added to
  44690. * @param dragAxis The axis which the gizmo will be able to drag on
  44691. * @param color The color of the gizmo
  44692. */
  44693. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44694. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44695. /**
  44696. * If the gizmo is enabled
  44697. */
  44698. isEnabled: boolean;
  44699. /**
  44700. * Disposes of the gizmo
  44701. */
  44702. dispose(): void;
  44703. }
  44704. }
  44705. declare module "babylonjs/Debug/axesViewer" {
  44706. import { Vector3 } from "babylonjs/Maths/math.vector";
  44707. import { Nullable } from "babylonjs/types";
  44708. import { Scene } from "babylonjs/scene";
  44709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44710. /**
  44711. * The Axes viewer will show 3 axes in a specific point in space
  44712. */
  44713. export class AxesViewer {
  44714. private _xAxis;
  44715. private _yAxis;
  44716. private _zAxis;
  44717. private _scaleLinesFactor;
  44718. private _instanced;
  44719. /**
  44720. * Gets the hosting scene
  44721. */
  44722. scene: Scene;
  44723. /**
  44724. * Gets or sets a number used to scale line length
  44725. */
  44726. scaleLines: number;
  44727. /** Gets the node hierarchy used to render x-axis */
  44728. readonly xAxis: TransformNode;
  44729. /** Gets the node hierarchy used to render y-axis */
  44730. readonly yAxis: TransformNode;
  44731. /** Gets the node hierarchy used to render z-axis */
  44732. readonly zAxis: TransformNode;
  44733. /**
  44734. * Creates a new AxesViewer
  44735. * @param scene defines the hosting scene
  44736. * @param scaleLines defines a number used to scale line length (1 by default)
  44737. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44738. * @param xAxis defines the node hierarchy used to render the x-axis
  44739. * @param yAxis defines the node hierarchy used to render the y-axis
  44740. * @param zAxis defines the node hierarchy used to render the z-axis
  44741. */
  44742. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44743. /**
  44744. * Force the viewer to update
  44745. * @param position defines the position of the viewer
  44746. * @param xaxis defines the x axis of the viewer
  44747. * @param yaxis defines the y axis of the viewer
  44748. * @param zaxis defines the z axis of the viewer
  44749. */
  44750. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44751. /**
  44752. * Creates an instance of this axes viewer.
  44753. * @returns a new axes viewer with instanced meshes
  44754. */
  44755. createInstance(): AxesViewer;
  44756. /** Releases resources */
  44757. dispose(): void;
  44758. private static _SetRenderingGroupId;
  44759. }
  44760. }
  44761. declare module "babylonjs/Debug/boneAxesViewer" {
  44762. import { Nullable } from "babylonjs/types";
  44763. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44764. import { Vector3 } from "babylonjs/Maths/math.vector";
  44765. import { Mesh } from "babylonjs/Meshes/mesh";
  44766. import { Bone } from "babylonjs/Bones/bone";
  44767. import { Scene } from "babylonjs/scene";
  44768. /**
  44769. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44770. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44771. */
  44772. export class BoneAxesViewer extends AxesViewer {
  44773. /**
  44774. * Gets or sets the target mesh where to display the axes viewer
  44775. */
  44776. mesh: Nullable<Mesh>;
  44777. /**
  44778. * Gets or sets the target bone where to display the axes viewer
  44779. */
  44780. bone: Nullable<Bone>;
  44781. /** Gets current position */
  44782. pos: Vector3;
  44783. /** Gets direction of X axis */
  44784. xaxis: Vector3;
  44785. /** Gets direction of Y axis */
  44786. yaxis: Vector3;
  44787. /** Gets direction of Z axis */
  44788. zaxis: Vector3;
  44789. /**
  44790. * Creates a new BoneAxesViewer
  44791. * @param scene defines the hosting scene
  44792. * @param bone defines the target bone
  44793. * @param mesh defines the target mesh
  44794. * @param scaleLines defines a scaling factor for line length (1 by default)
  44795. */
  44796. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44797. /**
  44798. * Force the viewer to update
  44799. */
  44800. update(): void;
  44801. /** Releases resources */
  44802. dispose(): void;
  44803. }
  44804. }
  44805. declare module "babylonjs/Debug/debugLayer" {
  44806. import { Scene } from "babylonjs/scene";
  44807. /**
  44808. * Interface used to define scene explorer extensibility option
  44809. */
  44810. export interface IExplorerExtensibilityOption {
  44811. /**
  44812. * Define the option label
  44813. */
  44814. label: string;
  44815. /**
  44816. * Defines the action to execute on click
  44817. */
  44818. action: (entity: any) => void;
  44819. }
  44820. /**
  44821. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44822. */
  44823. export interface IExplorerExtensibilityGroup {
  44824. /**
  44825. * Defines a predicate to test if a given type mut be extended
  44826. */
  44827. predicate: (entity: any) => boolean;
  44828. /**
  44829. * Gets the list of options added to a type
  44830. */
  44831. entries: IExplorerExtensibilityOption[];
  44832. }
  44833. /**
  44834. * Interface used to define the options to use to create the Inspector
  44835. */
  44836. export interface IInspectorOptions {
  44837. /**
  44838. * Display in overlay mode (default: false)
  44839. */
  44840. overlay?: boolean;
  44841. /**
  44842. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44843. */
  44844. globalRoot?: HTMLElement;
  44845. /**
  44846. * Display the Scene explorer
  44847. */
  44848. showExplorer?: boolean;
  44849. /**
  44850. * Display the property inspector
  44851. */
  44852. showInspector?: boolean;
  44853. /**
  44854. * Display in embed mode (both panes on the right)
  44855. */
  44856. embedMode?: boolean;
  44857. /**
  44858. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44859. */
  44860. handleResize?: boolean;
  44861. /**
  44862. * Allow the panes to popup (default: true)
  44863. */
  44864. enablePopup?: boolean;
  44865. /**
  44866. * Allow the panes to be closed by users (default: true)
  44867. */
  44868. enableClose?: boolean;
  44869. /**
  44870. * Optional list of extensibility entries
  44871. */
  44872. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44873. /**
  44874. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44875. */
  44876. inspectorURL?: string;
  44877. }
  44878. module "babylonjs/scene" {
  44879. interface Scene {
  44880. /**
  44881. * @hidden
  44882. * Backing field
  44883. */
  44884. _debugLayer: DebugLayer;
  44885. /**
  44886. * Gets the debug layer (aka Inspector) associated with the scene
  44887. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44888. */
  44889. debugLayer: DebugLayer;
  44890. }
  44891. }
  44892. /**
  44893. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44894. * what is happening in your scene
  44895. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44896. */
  44897. export class DebugLayer {
  44898. /**
  44899. * Define the url to get the inspector script from.
  44900. * By default it uses the babylonjs CDN.
  44901. * @ignoreNaming
  44902. */
  44903. static InspectorURL: string;
  44904. private _scene;
  44905. private BJSINSPECTOR;
  44906. private _onPropertyChangedObservable?;
  44907. /**
  44908. * Observable triggered when a property is changed through the inspector.
  44909. */
  44910. readonly onPropertyChangedObservable: any;
  44911. /**
  44912. * Instantiates a new debug layer.
  44913. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44914. * what is happening in your scene
  44915. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44916. * @param scene Defines the scene to inspect
  44917. */
  44918. constructor(scene: Scene);
  44919. /** Creates the inspector window. */
  44920. private _createInspector;
  44921. /**
  44922. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44923. * @param entity defines the entity to select
  44924. * @param lineContainerTitle defines the specific block to highlight
  44925. */
  44926. select(entity: any, lineContainerTitle?: string): void;
  44927. /** Get the inspector from bundle or global */
  44928. private _getGlobalInspector;
  44929. /**
  44930. * Get if the inspector is visible or not.
  44931. * @returns true if visible otherwise, false
  44932. */
  44933. isVisible(): boolean;
  44934. /**
  44935. * Hide the inspector and close its window.
  44936. */
  44937. hide(): void;
  44938. /**
  44939. * Launch the debugLayer.
  44940. * @param config Define the configuration of the inspector
  44941. * @return a promise fulfilled when the debug layer is visible
  44942. */
  44943. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44944. }
  44945. }
  44946. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44947. import { Nullable } from "babylonjs/types";
  44948. import { Scene } from "babylonjs/scene";
  44949. import { Vector4 } from "babylonjs/Maths/math.vector";
  44950. import { Color4 } from "babylonjs/Maths/math.color";
  44951. import { Mesh } from "babylonjs/Meshes/mesh";
  44952. /**
  44953. * Class containing static functions to help procedurally build meshes
  44954. */
  44955. export class BoxBuilder {
  44956. /**
  44957. * Creates a box mesh
  44958. * * The parameter `size` sets the size (float) of each box side (default 1)
  44959. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44960. * * 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)
  44961. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44965. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44966. * @param name defines the name of the mesh
  44967. * @param options defines the options used to create the mesh
  44968. * @param scene defines the hosting scene
  44969. * @returns the box mesh
  44970. */
  44971. static CreateBox(name: string, options: {
  44972. size?: number;
  44973. width?: number;
  44974. height?: number;
  44975. depth?: number;
  44976. faceUV?: Vector4[];
  44977. faceColors?: Color4[];
  44978. sideOrientation?: number;
  44979. frontUVs?: Vector4;
  44980. backUVs?: Vector4;
  44981. wrap?: boolean;
  44982. topBaseAt?: number;
  44983. bottomBaseAt?: number;
  44984. updatable?: boolean;
  44985. }, scene?: Nullable<Scene>): Mesh;
  44986. }
  44987. }
  44988. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44989. import { Vector4 } from "babylonjs/Maths/math.vector";
  44990. import { Mesh } from "babylonjs/Meshes/mesh";
  44991. import { Scene } from "babylonjs/scene";
  44992. import { Nullable } from "babylonjs/types";
  44993. /**
  44994. * Class containing static functions to help procedurally build meshes
  44995. */
  44996. export class SphereBuilder {
  44997. /**
  44998. * Creates a sphere mesh
  44999. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45000. * * 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`)
  45001. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45002. * * 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
  45003. * * 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)
  45004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45007. * @param name defines the name of the mesh
  45008. * @param options defines the options used to create the mesh
  45009. * @param scene defines the hosting scene
  45010. * @returns the sphere mesh
  45011. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45012. */
  45013. static CreateSphere(name: string, options: {
  45014. segments?: number;
  45015. diameter?: number;
  45016. diameterX?: number;
  45017. diameterY?: number;
  45018. diameterZ?: number;
  45019. arc?: number;
  45020. slice?: number;
  45021. sideOrientation?: number;
  45022. frontUVs?: Vector4;
  45023. backUVs?: Vector4;
  45024. updatable?: boolean;
  45025. }, scene?: Nullable<Scene>): Mesh;
  45026. }
  45027. }
  45028. declare module "babylonjs/Debug/physicsViewer" {
  45029. import { Nullable } from "babylonjs/types";
  45030. import { Scene } from "babylonjs/scene";
  45031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45032. import { Mesh } from "babylonjs/Meshes/mesh";
  45033. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45034. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45035. /**
  45036. * Used to show the physics impostor around the specific mesh
  45037. */
  45038. export class PhysicsViewer {
  45039. /** @hidden */
  45040. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45041. /** @hidden */
  45042. protected _meshes: Array<Nullable<AbstractMesh>>;
  45043. /** @hidden */
  45044. protected _scene: Nullable<Scene>;
  45045. /** @hidden */
  45046. protected _numMeshes: number;
  45047. /** @hidden */
  45048. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45049. private _renderFunction;
  45050. private _utilityLayer;
  45051. private _debugBoxMesh;
  45052. private _debugSphereMesh;
  45053. private _debugCylinderMesh;
  45054. private _debugMaterial;
  45055. private _debugMeshMeshes;
  45056. /**
  45057. * Creates a new PhysicsViewer
  45058. * @param scene defines the hosting scene
  45059. */
  45060. constructor(scene: Scene);
  45061. /** @hidden */
  45062. protected _updateDebugMeshes(): void;
  45063. /**
  45064. * Renders a specified physic impostor
  45065. * @param impostor defines the impostor to render
  45066. * @param targetMesh defines the mesh represented by the impostor
  45067. * @returns the new debug mesh used to render the impostor
  45068. */
  45069. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45070. /**
  45071. * Hides a specified physic impostor
  45072. * @param impostor defines the impostor to hide
  45073. */
  45074. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45075. private _getDebugMaterial;
  45076. private _getDebugBoxMesh;
  45077. private _getDebugSphereMesh;
  45078. private _getDebugCylinderMesh;
  45079. private _getDebugMeshMesh;
  45080. private _getDebugMesh;
  45081. /** Releases all resources */
  45082. dispose(): void;
  45083. }
  45084. }
  45085. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45086. import { Vector3 } from "babylonjs/Maths/math.vector";
  45087. import { Color4 } from "babylonjs/Maths/math.color";
  45088. import { Nullable } from "babylonjs/types";
  45089. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45090. import { Scene } from "babylonjs/scene";
  45091. /**
  45092. * Class containing static functions to help procedurally build meshes
  45093. */
  45094. export class LinesBuilder {
  45095. /**
  45096. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45097. * * 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
  45098. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45099. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45100. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45101. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45102. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45103. * * 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
  45104. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45107. * @param name defines the name of the new line system
  45108. * @param options defines the options used to create the line system
  45109. * @param scene defines the hosting scene
  45110. * @returns a new line system mesh
  45111. */
  45112. static CreateLineSystem(name: string, options: {
  45113. lines: Vector3[][];
  45114. updatable?: boolean;
  45115. instance?: Nullable<LinesMesh>;
  45116. colors?: Nullable<Color4[][]>;
  45117. useVertexAlpha?: boolean;
  45118. }, scene: Nullable<Scene>): LinesMesh;
  45119. /**
  45120. * Creates a line mesh
  45121. * 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
  45122. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45123. * * The parameter `points` is an array successive Vector3
  45124. * * 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
  45125. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45126. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45127. * * When updating an instance, remember that only point positions can change, not the number of points
  45128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45130. * @param name defines the name of the new line system
  45131. * @param options defines the options used to create the line system
  45132. * @param scene defines the hosting scene
  45133. * @returns a new line mesh
  45134. */
  45135. static CreateLines(name: string, options: {
  45136. points: Vector3[];
  45137. updatable?: boolean;
  45138. instance?: Nullable<LinesMesh>;
  45139. colors?: Color4[];
  45140. useVertexAlpha?: boolean;
  45141. }, scene?: Nullable<Scene>): LinesMesh;
  45142. /**
  45143. * Creates a dashed line mesh
  45144. * * 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
  45145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45146. * * The parameter `points` is an array successive Vector3
  45147. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45148. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45149. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45150. * * 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
  45151. * * When updating an instance, remember that only point positions can change, not the number of points
  45152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45153. * @param name defines the name of the mesh
  45154. * @param options defines the options used to create the mesh
  45155. * @param scene defines the hosting scene
  45156. * @returns the dashed line mesh
  45157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45158. */
  45159. static CreateDashedLines(name: string, options: {
  45160. points: Vector3[];
  45161. dashSize?: number;
  45162. gapSize?: number;
  45163. dashNb?: number;
  45164. updatable?: boolean;
  45165. instance?: LinesMesh;
  45166. }, scene?: Nullable<Scene>): LinesMesh;
  45167. }
  45168. }
  45169. declare module "babylonjs/Debug/rayHelper" {
  45170. import { Nullable } from "babylonjs/types";
  45171. import { Ray } from "babylonjs/Culling/ray";
  45172. import { Vector3 } from "babylonjs/Maths/math.vector";
  45173. import { Color3 } from "babylonjs/Maths/math.color";
  45174. import { Scene } from "babylonjs/scene";
  45175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45176. import "babylonjs/Meshes/Builders/linesBuilder";
  45177. /**
  45178. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45179. * in order to better appreciate the issue one might have.
  45180. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45181. */
  45182. export class RayHelper {
  45183. /**
  45184. * Defines the ray we are currently tryin to visualize.
  45185. */
  45186. ray: Nullable<Ray>;
  45187. private _renderPoints;
  45188. private _renderLine;
  45189. private _renderFunction;
  45190. private _scene;
  45191. private _updateToMeshFunction;
  45192. private _attachedToMesh;
  45193. private _meshSpaceDirection;
  45194. private _meshSpaceOrigin;
  45195. /**
  45196. * Helper function to create a colored helper in a scene in one line.
  45197. * @param ray Defines the ray we are currently tryin to visualize
  45198. * @param scene Defines the scene the ray is used in
  45199. * @param color Defines the color we want to see the ray in
  45200. * @returns The newly created ray helper.
  45201. */
  45202. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45203. /**
  45204. * Instantiate a new ray helper.
  45205. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45206. * in order to better appreciate the issue one might have.
  45207. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45208. * @param ray Defines the ray we are currently tryin to visualize
  45209. */
  45210. constructor(ray: Ray);
  45211. /**
  45212. * Shows the ray we are willing to debug.
  45213. * @param scene Defines the scene the ray needs to be rendered in
  45214. * @param color Defines the color the ray needs to be rendered in
  45215. */
  45216. show(scene: Scene, color?: Color3): void;
  45217. /**
  45218. * Hides the ray we are debugging.
  45219. */
  45220. hide(): void;
  45221. private _render;
  45222. /**
  45223. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45224. * @param mesh Defines the mesh we want the helper attached to
  45225. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45226. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45227. * @param length Defines the length of the ray
  45228. */
  45229. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45230. /**
  45231. * Detach the ray helper from the mesh it has previously been attached to.
  45232. */
  45233. detachFromMesh(): void;
  45234. private _updateToMesh;
  45235. /**
  45236. * Dispose the helper and release its associated resources.
  45237. */
  45238. dispose(): void;
  45239. }
  45240. }
  45241. declare module "babylonjs/Debug/skeletonViewer" {
  45242. import { Color3 } from "babylonjs/Maths/math.color";
  45243. import { Scene } from "babylonjs/scene";
  45244. import { Nullable } from "babylonjs/types";
  45245. import { Skeleton } from "babylonjs/Bones/skeleton";
  45246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45247. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45248. /**
  45249. * Class used to render a debug view of a given skeleton
  45250. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45251. */
  45252. export class SkeletonViewer {
  45253. /** defines the skeleton to render */
  45254. skeleton: Skeleton;
  45255. /** defines the mesh attached to the skeleton */
  45256. mesh: AbstractMesh;
  45257. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45258. autoUpdateBonesMatrices: boolean;
  45259. /** defines the rendering group id to use with the viewer */
  45260. renderingGroupId: number;
  45261. /** Gets or sets the color used to render the skeleton */
  45262. color: Color3;
  45263. private _scene;
  45264. private _debugLines;
  45265. private _debugMesh;
  45266. private _isEnabled;
  45267. private _renderFunction;
  45268. private _utilityLayer;
  45269. /**
  45270. * Returns the mesh used to render the bones
  45271. */
  45272. readonly debugMesh: Nullable<LinesMesh>;
  45273. /**
  45274. * Creates a new SkeletonViewer
  45275. * @param skeleton defines the skeleton to render
  45276. * @param mesh defines the mesh attached to the skeleton
  45277. * @param scene defines the hosting scene
  45278. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45279. * @param renderingGroupId defines the rendering group id to use with the viewer
  45280. */
  45281. constructor(
  45282. /** defines the skeleton to render */
  45283. skeleton: Skeleton,
  45284. /** defines the mesh attached to the skeleton */
  45285. mesh: AbstractMesh, scene: Scene,
  45286. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45287. autoUpdateBonesMatrices?: boolean,
  45288. /** defines the rendering group id to use with the viewer */
  45289. renderingGroupId?: number);
  45290. /** Gets or sets a boolean indicating if the viewer is enabled */
  45291. isEnabled: boolean;
  45292. private _getBonePosition;
  45293. private _getLinesForBonesWithLength;
  45294. private _getLinesForBonesNoLength;
  45295. /** Update the viewer to sync with current skeleton state */
  45296. update(): void;
  45297. /** Release associated resources */
  45298. dispose(): void;
  45299. }
  45300. }
  45301. declare module "babylonjs/Debug/index" {
  45302. export * from "babylonjs/Debug/axesViewer";
  45303. export * from "babylonjs/Debug/boneAxesViewer";
  45304. export * from "babylonjs/Debug/debugLayer";
  45305. export * from "babylonjs/Debug/physicsViewer";
  45306. export * from "babylonjs/Debug/rayHelper";
  45307. export * from "babylonjs/Debug/skeletonViewer";
  45308. }
  45309. declare module "babylonjs/Engines/nullEngine" {
  45310. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45311. import { Scene } from "babylonjs/scene";
  45312. import { Engine } from "babylonjs/Engines/engine";
  45313. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45314. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45315. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45316. import { Effect } from "babylonjs/Materials/effect";
  45317. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45318. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45319. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45320. /**
  45321. * Options to create the null engine
  45322. */
  45323. export class NullEngineOptions {
  45324. /**
  45325. * Render width (Default: 512)
  45326. */
  45327. renderWidth: number;
  45328. /**
  45329. * Render height (Default: 256)
  45330. */
  45331. renderHeight: number;
  45332. /**
  45333. * Texture size (Default: 512)
  45334. */
  45335. textureSize: number;
  45336. /**
  45337. * If delta time between frames should be constant
  45338. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45339. */
  45340. deterministicLockstep: boolean;
  45341. /**
  45342. * Maximum about of steps between frames (Default: 4)
  45343. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45344. */
  45345. lockstepMaxSteps: number;
  45346. }
  45347. /**
  45348. * The null engine class provides support for headless version of babylon.js.
  45349. * This can be used in server side scenario or for testing purposes
  45350. */
  45351. export class NullEngine extends Engine {
  45352. private _options;
  45353. /**
  45354. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45355. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45356. * @returns true if engine is in deterministic lock step mode
  45357. */
  45358. isDeterministicLockStep(): boolean;
  45359. /**
  45360. * Gets the max steps when engine is running in deterministic lock step
  45361. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45362. * @returns the max steps
  45363. */
  45364. getLockstepMaxSteps(): number;
  45365. /**
  45366. * Gets the current hardware scaling level.
  45367. * By default the hardware scaling level is computed from the window device ratio.
  45368. * 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.
  45369. * @returns a number indicating the current hardware scaling level
  45370. */
  45371. getHardwareScalingLevel(): number;
  45372. constructor(options?: NullEngineOptions);
  45373. /**
  45374. * Creates a vertex buffer
  45375. * @param vertices the data for the vertex buffer
  45376. * @returns the new WebGL static buffer
  45377. */
  45378. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45379. /**
  45380. * Creates a new index buffer
  45381. * @param indices defines the content of the index buffer
  45382. * @param updatable defines if the index buffer must be updatable
  45383. * @returns a new webGL buffer
  45384. */
  45385. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45386. /**
  45387. * Clear the current render buffer or the current render target (if any is set up)
  45388. * @param color defines the color to use
  45389. * @param backBuffer defines if the back buffer must be cleared
  45390. * @param depth defines if the depth buffer must be cleared
  45391. * @param stencil defines if the stencil buffer must be cleared
  45392. */
  45393. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45394. /**
  45395. * Gets the current render width
  45396. * @param useScreen defines if screen size must be used (or the current render target if any)
  45397. * @returns a number defining the current render width
  45398. */
  45399. getRenderWidth(useScreen?: boolean): number;
  45400. /**
  45401. * Gets the current render height
  45402. * @param useScreen defines if screen size must be used (or the current render target if any)
  45403. * @returns a number defining the current render height
  45404. */
  45405. getRenderHeight(useScreen?: boolean): number;
  45406. /**
  45407. * Set the WebGL's viewport
  45408. * @param viewport defines the viewport element to be used
  45409. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45410. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45411. */
  45412. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45413. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45414. /**
  45415. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45416. * @param pipelineContext defines the pipeline context to use
  45417. * @param uniformsNames defines the list of uniform names
  45418. * @returns an array of webGL uniform locations
  45419. */
  45420. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45421. /**
  45422. * Gets the lsit of active attributes for a given webGL program
  45423. * @param pipelineContext defines the pipeline context to use
  45424. * @param attributesNames defines the list of attribute names to get
  45425. * @returns an array of indices indicating the offset of each attribute
  45426. */
  45427. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45428. /**
  45429. * Binds an effect to the webGL context
  45430. * @param effect defines the effect to bind
  45431. */
  45432. bindSamplers(effect: Effect): void;
  45433. /**
  45434. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45435. * @param effect defines the effect to activate
  45436. */
  45437. enableEffect(effect: Effect): void;
  45438. /**
  45439. * Set various states to the webGL context
  45440. * @param culling defines backface culling state
  45441. * @param zOffset defines the value to apply to zOffset (0 by default)
  45442. * @param force defines if states must be applied even if cache is up to date
  45443. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45444. */
  45445. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45446. /**
  45447. * Set the value of an uniform to an array of int32
  45448. * @param uniform defines the webGL uniform location where to store the value
  45449. * @param array defines the array of int32 to store
  45450. */
  45451. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45452. /**
  45453. * Set the value of an uniform to an array of int32 (stored as vec2)
  45454. * @param uniform defines the webGL uniform location where to store the value
  45455. * @param array defines the array of int32 to store
  45456. */
  45457. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45458. /**
  45459. * Set the value of an uniform to an array of int32 (stored as vec3)
  45460. * @param uniform defines the webGL uniform location where to store the value
  45461. * @param array defines the array of int32 to store
  45462. */
  45463. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45464. /**
  45465. * Set the value of an uniform to an array of int32 (stored as vec4)
  45466. * @param uniform defines the webGL uniform location where to store the value
  45467. * @param array defines the array of int32 to store
  45468. */
  45469. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45470. /**
  45471. * Set the value of an uniform to an array of float32
  45472. * @param uniform defines the webGL uniform location where to store the value
  45473. * @param array defines the array of float32 to store
  45474. */
  45475. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45476. /**
  45477. * Set the value of an uniform to an array of float32 (stored as vec2)
  45478. * @param uniform defines the webGL uniform location where to store the value
  45479. * @param array defines the array of float32 to store
  45480. */
  45481. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45482. /**
  45483. * Set the value of an uniform to an array of float32 (stored as vec3)
  45484. * @param uniform defines the webGL uniform location where to store the value
  45485. * @param array defines the array of float32 to store
  45486. */
  45487. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45488. /**
  45489. * Set the value of an uniform to an array of float32 (stored as vec4)
  45490. * @param uniform defines the webGL uniform location where to store the value
  45491. * @param array defines the array of float32 to store
  45492. */
  45493. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45494. /**
  45495. * Set the value of an uniform to an array of number
  45496. * @param uniform defines the webGL uniform location where to store the value
  45497. * @param array defines the array of number to store
  45498. */
  45499. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45500. /**
  45501. * Set the value of an uniform to an array of number (stored as vec2)
  45502. * @param uniform defines the webGL uniform location where to store the value
  45503. * @param array defines the array of number to store
  45504. */
  45505. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45506. /**
  45507. * Set the value of an uniform to an array of number (stored as vec3)
  45508. * @param uniform defines the webGL uniform location where to store the value
  45509. * @param array defines the array of number to store
  45510. */
  45511. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45512. /**
  45513. * Set the value of an uniform to an array of number (stored as vec4)
  45514. * @param uniform defines the webGL uniform location where to store the value
  45515. * @param array defines the array of number to store
  45516. */
  45517. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45518. /**
  45519. * Set the value of an uniform to an array of float32 (stored as matrices)
  45520. * @param uniform defines the webGL uniform location where to store the value
  45521. * @param matrices defines the array of float32 to store
  45522. */
  45523. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45524. /**
  45525. * Set the value of an uniform to a matrix (3x3)
  45526. * @param uniform defines the webGL uniform location where to store the value
  45527. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45528. */
  45529. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45530. /**
  45531. * Set the value of an uniform to a matrix (2x2)
  45532. * @param uniform defines the webGL uniform location where to store the value
  45533. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45534. */
  45535. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45536. /**
  45537. * Set the value of an uniform to a number (float)
  45538. * @param uniform defines the webGL uniform location where to store the value
  45539. * @param value defines the float number to store
  45540. */
  45541. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45542. /**
  45543. * Set the value of an uniform to a vec2
  45544. * @param uniform defines the webGL uniform location where to store the value
  45545. * @param x defines the 1st component of the value
  45546. * @param y defines the 2nd component of the value
  45547. */
  45548. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45549. /**
  45550. * Set the value of an uniform to a vec3
  45551. * @param uniform defines the webGL uniform location where to store the value
  45552. * @param x defines the 1st component of the value
  45553. * @param y defines the 2nd component of the value
  45554. * @param z defines the 3rd component of the value
  45555. */
  45556. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45557. /**
  45558. * Set the value of an uniform to a boolean
  45559. * @param uniform defines the webGL uniform location where to store the value
  45560. * @param bool defines the boolean to store
  45561. */
  45562. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45563. /**
  45564. * Set the value of an uniform to a vec4
  45565. * @param uniform defines the webGL uniform location where to store the value
  45566. * @param x defines the 1st component of the value
  45567. * @param y defines the 2nd component of the value
  45568. * @param z defines the 3rd component of the value
  45569. * @param w defines the 4th component of the value
  45570. */
  45571. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45572. /**
  45573. * Sets the current alpha mode
  45574. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45575. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45576. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45577. */
  45578. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45579. /**
  45580. * Bind webGl buffers directly to the webGL context
  45581. * @param vertexBuffers defines the vertex buffer to bind
  45582. * @param indexBuffer defines the index buffer to bind
  45583. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45584. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45585. * @param effect defines the effect associated with the vertex buffer
  45586. */
  45587. bindBuffers(vertexBuffers: {
  45588. [key: string]: VertexBuffer;
  45589. }, indexBuffer: DataBuffer, effect: Effect): void;
  45590. /**
  45591. * Force the entire cache to be cleared
  45592. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45593. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45594. */
  45595. wipeCaches(bruteForce?: boolean): void;
  45596. /**
  45597. * Send a draw order
  45598. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45599. * @param indexStart defines the starting index
  45600. * @param indexCount defines the number of index to draw
  45601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45602. */
  45603. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45604. /**
  45605. * Draw a list of indexed primitives
  45606. * @param fillMode defines the primitive to use
  45607. * @param indexStart defines the starting index
  45608. * @param indexCount defines the number of index to draw
  45609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45610. */
  45611. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45612. /**
  45613. * Draw a list of unindexed primitives
  45614. * @param fillMode defines the primitive to use
  45615. * @param verticesStart defines the index of first vertex to draw
  45616. * @param verticesCount defines the count of vertices to draw
  45617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45618. */
  45619. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45620. /** @hidden */
  45621. _createTexture(): WebGLTexture;
  45622. /** @hidden */
  45623. _releaseTexture(texture: InternalTexture): void;
  45624. /**
  45625. * Usually called from Texture.ts.
  45626. * Passed information to create a WebGLTexture
  45627. * @param urlArg defines a value which contains one of the following:
  45628. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45629. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45630. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45632. * @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)
  45633. * @param scene needed for loading to the correct scene
  45634. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45635. * @param onLoad optional callback to be called upon successful completion
  45636. * @param onError optional callback to be called upon failure
  45637. * @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
  45638. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45639. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45640. * @param forcedExtension defines the extension to use to pick the right loader
  45641. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45642. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45643. */
  45644. 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;
  45645. /**
  45646. * Creates a new render target texture
  45647. * @param size defines the size of the texture
  45648. * @param options defines the options used to create the texture
  45649. * @returns a new render target texture stored in an InternalTexture
  45650. */
  45651. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45652. /**
  45653. * Update the sampling mode of a given texture
  45654. * @param samplingMode defines the required sampling mode
  45655. * @param texture defines the texture to update
  45656. */
  45657. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45658. /**
  45659. * Binds the frame buffer to the specified texture.
  45660. * @param texture The texture to render to or null for the default canvas
  45661. * @param faceIndex The face of the texture to render to in case of cube texture
  45662. * @param requiredWidth The width of the target to render to
  45663. * @param requiredHeight The height of the target to render to
  45664. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45665. * @param depthStencilTexture The depth stencil texture to use to render
  45666. * @param lodLevel defines le lod level to bind to the frame buffer
  45667. */
  45668. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45669. /**
  45670. * Unbind the current render target texture from the webGL context
  45671. * @param texture defines the render target texture to unbind
  45672. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45673. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45674. */
  45675. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45676. /**
  45677. * Creates a dynamic vertex buffer
  45678. * @param vertices the data for the dynamic vertex buffer
  45679. * @returns the new WebGL dynamic buffer
  45680. */
  45681. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45682. /**
  45683. * Update the content of a dynamic texture
  45684. * @param texture defines the texture to update
  45685. * @param canvas defines the canvas containing the source
  45686. * @param invertY defines if data must be stored with Y axis inverted
  45687. * @param premulAlpha defines if alpha is stored as premultiplied
  45688. * @param format defines the format of the data
  45689. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45690. */
  45691. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45692. /**
  45693. * Gets a boolean indicating if all created effects are ready
  45694. * @returns true if all effects are ready
  45695. */
  45696. areAllEffectsReady(): boolean;
  45697. /**
  45698. * @hidden
  45699. * Get the current error code of the webGL context
  45700. * @returns the error code
  45701. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45702. */
  45703. getError(): number;
  45704. /** @hidden */
  45705. _getUnpackAlignement(): number;
  45706. /** @hidden */
  45707. _unpackFlipY(value: boolean): void;
  45708. /**
  45709. * Update a dynamic index buffer
  45710. * @param indexBuffer defines the target index buffer
  45711. * @param indices defines the data to update
  45712. * @param offset defines the offset in the target index buffer where update should start
  45713. */
  45714. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45715. /**
  45716. * Updates a dynamic vertex buffer.
  45717. * @param vertexBuffer the vertex buffer to update
  45718. * @param vertices the data used to update the vertex buffer
  45719. * @param byteOffset the byte offset of the data (optional)
  45720. * @param byteLength the byte length of the data (optional)
  45721. */
  45722. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45723. /** @hidden */
  45724. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45725. /** @hidden */
  45726. _bindTexture(channel: number, texture: InternalTexture): void;
  45727. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45728. /**
  45729. * 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
  45730. */
  45731. releaseEffects(): void;
  45732. displayLoadingUI(): void;
  45733. hideLoadingUI(): void;
  45734. /** @hidden */
  45735. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45736. /** @hidden */
  45737. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45738. /** @hidden */
  45739. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45740. /** @hidden */
  45741. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45742. }
  45743. }
  45744. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45745. import { Nullable, int } from "babylonjs/types";
  45746. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45747. /** @hidden */
  45748. export class _OcclusionDataStorage {
  45749. /** @hidden */
  45750. occlusionInternalRetryCounter: number;
  45751. /** @hidden */
  45752. isOcclusionQueryInProgress: boolean;
  45753. /** @hidden */
  45754. isOccluded: boolean;
  45755. /** @hidden */
  45756. occlusionRetryCount: number;
  45757. /** @hidden */
  45758. occlusionType: number;
  45759. /** @hidden */
  45760. occlusionQueryAlgorithmType: number;
  45761. }
  45762. module "babylonjs/Engines/engine" {
  45763. interface Engine {
  45764. /**
  45765. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45766. * @return the new query
  45767. */
  45768. createQuery(): WebGLQuery;
  45769. /**
  45770. * Delete and release a webGL query
  45771. * @param query defines the query to delete
  45772. * @return the current engine
  45773. */
  45774. deleteQuery(query: WebGLQuery): Engine;
  45775. /**
  45776. * Check if a given query has resolved and got its value
  45777. * @param query defines the query to check
  45778. * @returns true if the query got its value
  45779. */
  45780. isQueryResultAvailable(query: WebGLQuery): boolean;
  45781. /**
  45782. * Gets the value of a given query
  45783. * @param query defines the query to check
  45784. * @returns the value of the query
  45785. */
  45786. getQueryResult(query: WebGLQuery): number;
  45787. /**
  45788. * Initiates an occlusion query
  45789. * @param algorithmType defines the algorithm to use
  45790. * @param query defines the query to use
  45791. * @returns the current engine
  45792. * @see http://doc.babylonjs.com/features/occlusionquery
  45793. */
  45794. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45795. /**
  45796. * Ends an occlusion query
  45797. * @see http://doc.babylonjs.com/features/occlusionquery
  45798. * @param algorithmType defines the algorithm to use
  45799. * @returns the current engine
  45800. */
  45801. endOcclusionQuery(algorithmType: number): Engine;
  45802. /**
  45803. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45804. * Please note that only one query can be issued at a time
  45805. * @returns a time token used to track the time span
  45806. */
  45807. startTimeQuery(): Nullable<_TimeToken>;
  45808. /**
  45809. * Ends a time query
  45810. * @param token defines the token used to measure the time span
  45811. * @returns the time spent (in ns)
  45812. */
  45813. endTimeQuery(token: _TimeToken): int;
  45814. /** @hidden */
  45815. _currentNonTimestampToken: Nullable<_TimeToken>;
  45816. /** @hidden */
  45817. _createTimeQuery(): WebGLQuery;
  45818. /** @hidden */
  45819. _deleteTimeQuery(query: WebGLQuery): void;
  45820. /** @hidden */
  45821. _getGlAlgorithmType(algorithmType: number): number;
  45822. /** @hidden */
  45823. _getTimeQueryResult(query: WebGLQuery): any;
  45824. /** @hidden */
  45825. _getTimeQueryAvailability(query: WebGLQuery): any;
  45826. }
  45827. }
  45828. module "babylonjs/Meshes/abstractMesh" {
  45829. interface AbstractMesh {
  45830. /**
  45831. * Backing filed
  45832. * @hidden
  45833. */
  45834. __occlusionDataStorage: _OcclusionDataStorage;
  45835. /**
  45836. * Access property
  45837. * @hidden
  45838. */
  45839. _occlusionDataStorage: _OcclusionDataStorage;
  45840. /**
  45841. * 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.
  45842. * The default value is -1 which means don't break the query and wait till the result
  45843. * @see http://doc.babylonjs.com/features/occlusionquery
  45844. */
  45845. occlusionRetryCount: number;
  45846. /**
  45847. * 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:
  45848. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45849. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45850. * * 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.
  45851. * @see http://doc.babylonjs.com/features/occlusionquery
  45852. */
  45853. occlusionType: number;
  45854. /**
  45855. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45856. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45857. * * 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.
  45858. * @see http://doc.babylonjs.com/features/occlusionquery
  45859. */
  45860. occlusionQueryAlgorithmType: number;
  45861. /**
  45862. * 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
  45863. * @see http://doc.babylonjs.com/features/occlusionquery
  45864. */
  45865. isOccluded: boolean;
  45866. /**
  45867. * Flag to check the progress status of the query
  45868. * @see http://doc.babylonjs.com/features/occlusionquery
  45869. */
  45870. isOcclusionQueryInProgress: boolean;
  45871. }
  45872. }
  45873. }
  45874. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45875. import { Nullable } from "babylonjs/types";
  45876. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45877. /** @hidden */
  45878. export var _forceTransformFeedbackToBundle: boolean;
  45879. module "babylonjs/Engines/engine" {
  45880. interface Engine {
  45881. /**
  45882. * Creates a webGL transform feedback object
  45883. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45884. * @returns the webGL transform feedback object
  45885. */
  45886. createTransformFeedback(): WebGLTransformFeedback;
  45887. /**
  45888. * Delete a webGL transform feedback object
  45889. * @param value defines the webGL transform feedback object to delete
  45890. */
  45891. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45892. /**
  45893. * Bind a webGL transform feedback object to the webgl context
  45894. * @param value defines the webGL transform feedback object to bind
  45895. */
  45896. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45897. /**
  45898. * Begins a transform feedback operation
  45899. * @param usePoints defines if points or triangles must be used
  45900. */
  45901. beginTransformFeedback(usePoints: boolean): void;
  45902. /**
  45903. * Ends a transform feedback operation
  45904. */
  45905. endTransformFeedback(): void;
  45906. /**
  45907. * Specify the varyings to use with transform feedback
  45908. * @param program defines the associated webGL program
  45909. * @param value defines the list of strings representing the varying names
  45910. */
  45911. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45912. /**
  45913. * Bind a webGL buffer for a transform feedback operation
  45914. * @param value defines the webGL buffer to bind
  45915. */
  45916. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45917. }
  45918. }
  45919. }
  45920. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45921. import { Scene } from "babylonjs/scene";
  45922. import { Engine } from "babylonjs/Engines/engine";
  45923. import { Texture } from "babylonjs/Materials/Textures/texture";
  45924. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45925. import "babylonjs/Engines/Extensions/engine.multiRender";
  45926. /**
  45927. * Creation options of the multi render target texture.
  45928. */
  45929. export interface IMultiRenderTargetOptions {
  45930. /**
  45931. * Define if the texture needs to create mip maps after render.
  45932. */
  45933. generateMipMaps?: boolean;
  45934. /**
  45935. * Define the types of all the draw buffers we want to create
  45936. */
  45937. types?: number[];
  45938. /**
  45939. * Define the sampling modes of all the draw buffers we want to create
  45940. */
  45941. samplingModes?: number[];
  45942. /**
  45943. * Define if a depth buffer is required
  45944. */
  45945. generateDepthBuffer?: boolean;
  45946. /**
  45947. * Define if a stencil buffer is required
  45948. */
  45949. generateStencilBuffer?: boolean;
  45950. /**
  45951. * Define if a depth texture is required instead of a depth buffer
  45952. */
  45953. generateDepthTexture?: boolean;
  45954. /**
  45955. * Define the number of desired draw buffers
  45956. */
  45957. textureCount?: number;
  45958. /**
  45959. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45960. */
  45961. doNotChangeAspectRatio?: boolean;
  45962. /**
  45963. * Define the default type of the buffers we are creating
  45964. */
  45965. defaultType?: number;
  45966. }
  45967. /**
  45968. * A multi render target, like a render target provides the ability to render to a texture.
  45969. * Unlike the render target, it can render to several draw buffers in one draw.
  45970. * This is specially interesting in deferred rendering or for any effects requiring more than
  45971. * just one color from a single pass.
  45972. */
  45973. export class MultiRenderTarget extends RenderTargetTexture {
  45974. private _internalTextures;
  45975. private _textures;
  45976. private _multiRenderTargetOptions;
  45977. /**
  45978. * Get if draw buffers are currently supported by the used hardware and browser.
  45979. */
  45980. readonly isSupported: boolean;
  45981. /**
  45982. * Get the list of textures generated by the multi render target.
  45983. */
  45984. readonly textures: Texture[];
  45985. /**
  45986. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45987. */
  45988. readonly depthTexture: Texture;
  45989. /**
  45990. * Set the wrapping mode on U of all the textures we are rendering to.
  45991. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45992. */
  45993. wrapU: number;
  45994. /**
  45995. * Set the wrapping mode on V of all the textures we are rendering to.
  45996. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45997. */
  45998. wrapV: number;
  45999. /**
  46000. * Instantiate a new multi render target texture.
  46001. * A multi render target, like a render target provides the ability to render to a texture.
  46002. * Unlike the render target, it can render to several draw buffers in one draw.
  46003. * This is specially interesting in deferred rendering or for any effects requiring more than
  46004. * just one color from a single pass.
  46005. * @param name Define the name of the texture
  46006. * @param size Define the size of the buffers to render to
  46007. * @param count Define the number of target we are rendering into
  46008. * @param scene Define the scene the texture belongs to
  46009. * @param options Define the options used to create the multi render target
  46010. */
  46011. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46012. /** @hidden */
  46013. _rebuild(): void;
  46014. private _createInternalTextures;
  46015. private _createTextures;
  46016. /**
  46017. * Define the number of samples used if MSAA is enabled.
  46018. */
  46019. samples: number;
  46020. /**
  46021. * Resize all the textures in the multi render target.
  46022. * Be carrefull as it will recreate all the data in the new texture.
  46023. * @param size Define the new size
  46024. */
  46025. resize(size: any): void;
  46026. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46027. /**
  46028. * Dispose the render targets and their associated resources
  46029. */
  46030. dispose(): void;
  46031. /**
  46032. * Release all the underlying texture used as draw buffers.
  46033. */
  46034. releaseInternalTextures(): void;
  46035. }
  46036. }
  46037. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46038. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46039. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46040. import { Nullable } from "babylonjs/types";
  46041. module "babylonjs/Engines/thinEngine" {
  46042. interface ThinEngine {
  46043. /**
  46044. * Unbind a list of render target textures from the webGL context
  46045. * This is used only when drawBuffer extension or webGL2 are active
  46046. * @param textures defines the render target textures to unbind
  46047. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46048. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46049. */
  46050. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46051. /**
  46052. * Create a multi render target texture
  46053. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46054. * @param size defines the size of the texture
  46055. * @param options defines the creation options
  46056. * @returns the cube texture as an InternalTexture
  46057. */
  46058. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46059. /**
  46060. * Update the sample count for a given multiple render target texture
  46061. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46062. * @param textures defines the textures to update
  46063. * @param samples defines the sample count to set
  46064. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46065. */
  46066. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46067. }
  46068. }
  46069. }
  46070. declare module "babylonjs/Engines/Extensions/index" {
  46071. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46072. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46073. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46074. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46075. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46076. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46077. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46078. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46079. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46080. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46081. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46082. }
  46083. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46085. /** @hidden */
  46086. export var rgbdEncodePixelShader: {
  46087. name: string;
  46088. shader: string;
  46089. };
  46090. }
  46091. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46092. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46093. /** @hidden */
  46094. export var rgbdDecodePixelShader: {
  46095. name: string;
  46096. shader: string;
  46097. };
  46098. }
  46099. declare module "babylonjs/Misc/environmentTextureTools" {
  46100. import { Nullable } from "babylonjs/types";
  46101. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46102. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46103. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46104. import "babylonjs/Engines/Extensions/engine.renderTarget";
  46105. import "babylonjs/Shaders/rgbdEncode.fragment";
  46106. import "babylonjs/Shaders/rgbdDecode.fragment";
  46107. /**
  46108. * Raw texture data and descriptor sufficient for WebGL texture upload
  46109. */
  46110. export interface EnvironmentTextureInfo {
  46111. /**
  46112. * Version of the environment map
  46113. */
  46114. version: number;
  46115. /**
  46116. * Width of image
  46117. */
  46118. width: number;
  46119. /**
  46120. * Irradiance information stored in the file.
  46121. */
  46122. irradiance: any;
  46123. /**
  46124. * Specular information stored in the file.
  46125. */
  46126. specular: any;
  46127. }
  46128. /**
  46129. * Defines One Image in the file. It requires only the position in the file
  46130. * as well as the length.
  46131. */
  46132. interface BufferImageData {
  46133. /**
  46134. * Length of the image data.
  46135. */
  46136. length: number;
  46137. /**
  46138. * Position of the data from the null terminator delimiting the end of the JSON.
  46139. */
  46140. position: number;
  46141. }
  46142. /**
  46143. * Defines the specular data enclosed in the file.
  46144. * This corresponds to the version 1 of the data.
  46145. */
  46146. export interface EnvironmentTextureSpecularInfoV1 {
  46147. /**
  46148. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46149. */
  46150. specularDataPosition?: number;
  46151. /**
  46152. * This contains all the images data needed to reconstruct the cubemap.
  46153. */
  46154. mipmaps: Array<BufferImageData>;
  46155. /**
  46156. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46157. */
  46158. lodGenerationScale: number;
  46159. }
  46160. /**
  46161. * Sets of helpers addressing the serialization and deserialization of environment texture
  46162. * stored in a BabylonJS env file.
  46163. * Those files are usually stored as .env files.
  46164. */
  46165. export class EnvironmentTextureTools {
  46166. /**
  46167. * Magic number identifying the env file.
  46168. */
  46169. private static _MagicBytes;
  46170. /**
  46171. * Gets the environment info from an env file.
  46172. * @param data The array buffer containing the .env bytes.
  46173. * @returns the environment file info (the json header) if successfully parsed.
  46174. */
  46175. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46176. /**
  46177. * Creates an environment texture from a loaded cube texture.
  46178. * @param texture defines the cube texture to convert in env file
  46179. * @return a promise containing the environment data if succesfull.
  46180. */
  46181. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46182. /**
  46183. * Creates a JSON representation of the spherical data.
  46184. * @param texture defines the texture containing the polynomials
  46185. * @return the JSON representation of the spherical info
  46186. */
  46187. private static _CreateEnvTextureIrradiance;
  46188. /**
  46189. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46190. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46191. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46192. * @return the views described by info providing access to the underlying buffer
  46193. */
  46194. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46195. /**
  46196. * Uploads the texture info contained in the env file to the GPU.
  46197. * @param texture defines the internal texture to upload to
  46198. * @param arrayBuffer defines the buffer cotaining the data to load
  46199. * @param info defines the texture info retrieved through the GetEnvInfo method
  46200. * @returns a promise
  46201. */
  46202. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46203. /**
  46204. * Uploads the levels of image data to the GPU.
  46205. * @param texture defines the internal texture to upload to
  46206. * @param imageData defines the array buffer views of image data [mipmap][face]
  46207. * @returns a promise
  46208. */
  46209. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46210. /**
  46211. * Uploads spherical polynomials information to the texture.
  46212. * @param texture defines the texture we are trying to upload the information to
  46213. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46214. */
  46215. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46216. /** @hidden */
  46217. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46218. }
  46219. }
  46220. declare module "babylonjs/Maths/math.vertexFormat" {
  46221. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46222. /**
  46223. * Contains position and normal vectors for a vertex
  46224. */
  46225. export class PositionNormalVertex {
  46226. /** the position of the vertex (defaut: 0,0,0) */
  46227. position: Vector3;
  46228. /** the normal of the vertex (defaut: 0,1,0) */
  46229. normal: Vector3;
  46230. /**
  46231. * Creates a PositionNormalVertex
  46232. * @param position the position of the vertex (defaut: 0,0,0)
  46233. * @param normal the normal of the vertex (defaut: 0,1,0)
  46234. */
  46235. constructor(
  46236. /** the position of the vertex (defaut: 0,0,0) */
  46237. position?: Vector3,
  46238. /** the normal of the vertex (defaut: 0,1,0) */
  46239. normal?: Vector3);
  46240. /**
  46241. * Clones the PositionNormalVertex
  46242. * @returns the cloned PositionNormalVertex
  46243. */
  46244. clone(): PositionNormalVertex;
  46245. }
  46246. /**
  46247. * Contains position, normal and uv vectors for a vertex
  46248. */
  46249. export class PositionNormalTextureVertex {
  46250. /** the position of the vertex (defaut: 0,0,0) */
  46251. position: Vector3;
  46252. /** the normal of the vertex (defaut: 0,1,0) */
  46253. normal: Vector3;
  46254. /** the uv of the vertex (default: 0,0) */
  46255. uv: Vector2;
  46256. /**
  46257. * Creates a PositionNormalTextureVertex
  46258. * @param position the position of the vertex (defaut: 0,0,0)
  46259. * @param normal the normal of the vertex (defaut: 0,1,0)
  46260. * @param uv the uv of the vertex (default: 0,0)
  46261. */
  46262. constructor(
  46263. /** the position of the vertex (defaut: 0,0,0) */
  46264. position?: Vector3,
  46265. /** the normal of the vertex (defaut: 0,1,0) */
  46266. normal?: Vector3,
  46267. /** the uv of the vertex (default: 0,0) */
  46268. uv?: Vector2);
  46269. /**
  46270. * Clones the PositionNormalTextureVertex
  46271. * @returns the cloned PositionNormalTextureVertex
  46272. */
  46273. clone(): PositionNormalTextureVertex;
  46274. }
  46275. }
  46276. declare module "babylonjs/Maths/math" {
  46277. export * from "babylonjs/Maths/math.axis";
  46278. export * from "babylonjs/Maths/math.color";
  46279. export * from "babylonjs/Maths/math.constants";
  46280. export * from "babylonjs/Maths/math.frustum";
  46281. export * from "babylonjs/Maths/math.path";
  46282. export * from "babylonjs/Maths/math.plane";
  46283. export * from "babylonjs/Maths/math.size";
  46284. export * from "babylonjs/Maths/math.vector";
  46285. export * from "babylonjs/Maths/math.vertexFormat";
  46286. export * from "babylonjs/Maths/math.viewport";
  46287. }
  46288. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46289. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46290. /** @hidden */
  46291. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46292. private _genericAttributeLocation;
  46293. private _varyingLocationCount;
  46294. private _varyingLocationMap;
  46295. private _replacements;
  46296. private _textureCount;
  46297. private _uniforms;
  46298. lineProcessor(line: string): string;
  46299. attributeProcessor(attribute: string): string;
  46300. varyingProcessor(varying: string, isFragment: boolean): string;
  46301. uniformProcessor(uniform: string): string;
  46302. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46303. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46304. }
  46305. }
  46306. declare module "babylonjs/Engines/nativeEngine" {
  46307. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46308. import { Engine } from "babylonjs/Engines/engine";
  46309. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46312. import { Effect } from "babylonjs/Materials/effect";
  46313. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46314. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46315. import { Scene } from "babylonjs/scene";
  46316. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46317. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46318. /**
  46319. * Container for accessors for natively-stored mesh data buffers.
  46320. */
  46321. class NativeDataBuffer extends DataBuffer {
  46322. /**
  46323. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46324. */
  46325. nativeIndexBuffer?: any;
  46326. /**
  46327. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46328. */
  46329. nativeVertexBuffer?: any;
  46330. }
  46331. /** @hidden */
  46332. export class NativeEngine extends Engine {
  46333. private readonly _native;
  46334. getHardwareScalingLevel(): number;
  46335. constructor();
  46336. /**
  46337. * Can be used to override the current requestAnimationFrame requester.
  46338. * @hidden
  46339. */
  46340. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46341. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46342. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46343. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46344. recordVertexArrayObject(vertexBuffers: {
  46345. [key: string]: VertexBuffer;
  46346. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46347. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46348. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46349. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46350. /**
  46351. * Draw a list of indexed primitives
  46352. * @param fillMode defines the primitive to use
  46353. * @param indexStart defines the starting index
  46354. * @param indexCount defines the number of index to draw
  46355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46356. */
  46357. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46358. /**
  46359. * Draw a list of unindexed primitives
  46360. * @param fillMode defines the primitive to use
  46361. * @param verticesStart defines the index of first vertex to draw
  46362. * @param verticesCount defines the count of vertices to draw
  46363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46364. */
  46365. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46366. createPipelineContext(): IPipelineContext;
  46367. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46368. /** @hidden */
  46369. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46370. /** @hidden */
  46371. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46372. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46373. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46374. protected _setProgram(program: WebGLProgram): void;
  46375. _releaseEffect(effect: Effect): void;
  46376. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46377. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46378. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46379. bindSamplers(effect: Effect): void;
  46380. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46381. getRenderWidth(useScreen?: boolean): number;
  46382. getRenderHeight(useScreen?: boolean): number;
  46383. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46384. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46385. /**
  46386. * Set the z offset to apply to current rendering
  46387. * @param value defines the offset to apply
  46388. */
  46389. setZOffset(value: number): void;
  46390. /**
  46391. * Gets the current value of the zOffset
  46392. * @returns the current zOffset state
  46393. */
  46394. getZOffset(): number;
  46395. /**
  46396. * Enable or disable depth buffering
  46397. * @param enable defines the state to set
  46398. */
  46399. setDepthBuffer(enable: boolean): void;
  46400. /**
  46401. * Gets a boolean indicating if depth writing is enabled
  46402. * @returns the current depth writing state
  46403. */
  46404. getDepthWrite(): boolean;
  46405. /**
  46406. * Enable or disable depth writing
  46407. * @param enable defines the state to set
  46408. */
  46409. setDepthWrite(enable: boolean): void;
  46410. /**
  46411. * Enable or disable color writing
  46412. * @param enable defines the state to set
  46413. */
  46414. setColorWrite(enable: boolean): void;
  46415. /**
  46416. * Gets a boolean indicating if color writing is enabled
  46417. * @returns the current color writing state
  46418. */
  46419. getColorWrite(): boolean;
  46420. /**
  46421. * Sets alpha constants used by some alpha blending modes
  46422. * @param r defines the red component
  46423. * @param g defines the green component
  46424. * @param b defines the blue component
  46425. * @param a defines the alpha component
  46426. */
  46427. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46428. /**
  46429. * Sets the current alpha mode
  46430. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46431. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46432. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46433. */
  46434. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46435. /**
  46436. * Gets the current alpha mode
  46437. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46438. * @returns the current alpha mode
  46439. */
  46440. getAlphaMode(): number;
  46441. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46442. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46443. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46444. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46445. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46446. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46447. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46448. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46449. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46450. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46451. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46452. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46453. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46454. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46455. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46456. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46457. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46458. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46459. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46460. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46461. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46462. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46463. wipeCaches(bruteForce?: boolean): void;
  46464. _createTexture(): WebGLTexture;
  46465. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46466. /**
  46467. * Usually called from BABYLON.Texture.ts.
  46468. * Passed information to create a WebGLTexture
  46469. * @param urlArg defines a value which contains one of the following:
  46470. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46471. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46472. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46473. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46474. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46475. * @param scene needed for loading to the correct scene
  46476. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46477. * @param onLoad optional callback to be called upon successful completion
  46478. * @param onError optional callback to be called upon failure
  46479. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46480. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46481. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46482. * @param forcedExtension defines the extension to use to pick the right loader
  46483. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46484. */
  46485. 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;
  46486. /**
  46487. * Creates a cube texture
  46488. * @param rootUrl defines the url where the files to load is located
  46489. * @param scene defines the current scene
  46490. * @param files defines the list of files to load (1 per face)
  46491. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46492. * @param onLoad defines an optional callback raised when the texture is loaded
  46493. * @param onError defines an optional callback raised if there is an issue to load the texture
  46494. * @param format defines the format of the data
  46495. * @param forcedExtension defines the extension to use to pick the right loader
  46496. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46497. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46498. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46499. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46500. * @returns the cube texture as an InternalTexture
  46501. */
  46502. 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;
  46503. private _getSamplingFilter;
  46504. private static _GetNativeTextureFormat;
  46505. createRenderTargetTexture(size: number | {
  46506. width: number;
  46507. height: number;
  46508. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46509. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46510. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46511. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46512. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46513. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46514. /**
  46515. * Updates a dynamic vertex buffer.
  46516. * @param vertexBuffer the vertex buffer to update
  46517. * @param data the data used to update the vertex buffer
  46518. * @param byteOffset the byte offset of the data (optional)
  46519. * @param byteLength the byte length of the data (optional)
  46520. */
  46521. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46522. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46523. private _updateAnisotropicLevel;
  46524. private _getAddressMode;
  46525. /** @hidden */
  46526. _bindTexture(channel: number, texture: InternalTexture): void;
  46527. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46528. releaseEffects(): void;
  46529. /** @hidden */
  46530. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46531. /** @hidden */
  46532. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46533. /** @hidden */
  46534. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46535. /** @hidden */
  46536. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46537. }
  46538. }
  46539. declare module "babylonjs/Engines/index" {
  46540. export * from "babylonjs/Engines/constants";
  46541. export * from "babylonjs/Engines/engineCapabilities";
  46542. export * from "babylonjs/Engines/instancingAttributeInfo";
  46543. export * from "babylonjs/Engines/thinEngine";
  46544. export * from "babylonjs/Engines/engine";
  46545. export * from "babylonjs/Engines/engineStore";
  46546. export * from "babylonjs/Engines/nullEngine";
  46547. export * from "babylonjs/Engines/Extensions/index";
  46548. export * from "babylonjs/Engines/IPipelineContext";
  46549. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46550. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46551. export * from "babylonjs/Engines/nativeEngine";
  46552. }
  46553. declare module "babylonjs/Events/clipboardEvents" {
  46554. /**
  46555. * Gather the list of clipboard event types as constants.
  46556. */
  46557. export class ClipboardEventTypes {
  46558. /**
  46559. * The clipboard event is fired when a copy command is active (pressed).
  46560. */
  46561. static readonly COPY: number;
  46562. /**
  46563. * The clipboard event is fired when a cut command is active (pressed).
  46564. */
  46565. static readonly CUT: number;
  46566. /**
  46567. * The clipboard event is fired when a paste command is active (pressed).
  46568. */
  46569. static readonly PASTE: number;
  46570. }
  46571. /**
  46572. * This class is used to store clipboard related info for the onClipboardObservable event.
  46573. */
  46574. export class ClipboardInfo {
  46575. /**
  46576. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46577. */
  46578. type: number;
  46579. /**
  46580. * Defines the related dom event
  46581. */
  46582. event: ClipboardEvent;
  46583. /**
  46584. *Creates an instance of ClipboardInfo.
  46585. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46586. * @param event Defines the related dom event
  46587. */
  46588. constructor(
  46589. /**
  46590. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46591. */
  46592. type: number,
  46593. /**
  46594. * Defines the related dom event
  46595. */
  46596. event: ClipboardEvent);
  46597. /**
  46598. * Get the clipboard event's type from the keycode.
  46599. * @param keyCode Defines the keyCode for the current keyboard event.
  46600. * @return {number}
  46601. */
  46602. static GetTypeFromCharacter(keyCode: number): number;
  46603. }
  46604. }
  46605. declare module "babylonjs/Events/index" {
  46606. export * from "babylonjs/Events/keyboardEvents";
  46607. export * from "babylonjs/Events/pointerEvents";
  46608. export * from "babylonjs/Events/clipboardEvents";
  46609. }
  46610. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46611. import { Scene } from "babylonjs/scene";
  46612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46613. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46614. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46615. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46616. /**
  46617. * Google Daydream controller
  46618. */
  46619. export class DaydreamController extends WebVRController {
  46620. /**
  46621. * Base Url for the controller model.
  46622. */
  46623. static MODEL_BASE_URL: string;
  46624. /**
  46625. * File name for the controller model.
  46626. */
  46627. static MODEL_FILENAME: string;
  46628. /**
  46629. * Gamepad Id prefix used to identify Daydream Controller.
  46630. */
  46631. static readonly GAMEPAD_ID_PREFIX: string;
  46632. /**
  46633. * Creates a new DaydreamController from a gamepad
  46634. * @param vrGamepad the gamepad that the controller should be created from
  46635. */
  46636. constructor(vrGamepad: any);
  46637. /**
  46638. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46639. * @param scene scene in which to add meshes
  46640. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46641. */
  46642. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46643. /**
  46644. * Called once for each button that changed state since the last frame
  46645. * @param buttonIdx Which button index changed
  46646. * @param state New state of the button
  46647. * @param changes Which properties on the state changed since last frame
  46648. */
  46649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46650. }
  46651. }
  46652. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46653. import { Scene } from "babylonjs/scene";
  46654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46655. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46656. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46657. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46658. /**
  46659. * Gear VR Controller
  46660. */
  46661. export class GearVRController extends WebVRController {
  46662. /**
  46663. * Base Url for the controller model.
  46664. */
  46665. static MODEL_BASE_URL: string;
  46666. /**
  46667. * File name for the controller model.
  46668. */
  46669. static MODEL_FILENAME: string;
  46670. /**
  46671. * Gamepad Id prefix used to identify this controller.
  46672. */
  46673. static readonly GAMEPAD_ID_PREFIX: string;
  46674. private readonly _buttonIndexToObservableNameMap;
  46675. /**
  46676. * Creates a new GearVRController from a gamepad
  46677. * @param vrGamepad the gamepad that the controller should be created from
  46678. */
  46679. constructor(vrGamepad: any);
  46680. /**
  46681. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46682. * @param scene scene in which to add meshes
  46683. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46684. */
  46685. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46686. /**
  46687. * Called once for each button that changed state since the last frame
  46688. * @param buttonIdx Which button index changed
  46689. * @param state New state of the button
  46690. * @param changes Which properties on the state changed since last frame
  46691. */
  46692. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46693. }
  46694. }
  46695. declare module "babylonjs/Gamepads/Controllers/index" {
  46696. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46697. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46698. export * from "babylonjs/Gamepads/Controllers/genericController";
  46699. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46700. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46701. export * from "babylonjs/Gamepads/Controllers/viveController";
  46702. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46703. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46704. }
  46705. declare module "babylonjs/Gamepads/index" {
  46706. export * from "babylonjs/Gamepads/Controllers/index";
  46707. export * from "babylonjs/Gamepads/gamepad";
  46708. export * from "babylonjs/Gamepads/gamepadManager";
  46709. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46710. export * from "babylonjs/Gamepads/xboxGamepad";
  46711. export * from "babylonjs/Gamepads/dualShockGamepad";
  46712. }
  46713. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46714. import { Scene } from "babylonjs/scene";
  46715. import { Vector4 } from "babylonjs/Maths/math.vector";
  46716. import { Color4 } from "babylonjs/Maths/math.color";
  46717. import { Mesh } from "babylonjs/Meshes/mesh";
  46718. import { Nullable } from "babylonjs/types";
  46719. /**
  46720. * Class containing static functions to help procedurally build meshes
  46721. */
  46722. export class PolyhedronBuilder {
  46723. /**
  46724. * Creates a polyhedron mesh
  46725. * * 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
  46726. * * The parameter `size` (positive float, default 1) sets the polygon size
  46727. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46728. * * 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`
  46729. * * 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
  46730. * * 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)`)
  46731. * * 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
  46732. * * 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
  46733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46736. * @param name defines the name of the mesh
  46737. * @param options defines the options used to create the mesh
  46738. * @param scene defines the hosting scene
  46739. * @returns the polyhedron mesh
  46740. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46741. */
  46742. static CreatePolyhedron(name: string, options: {
  46743. type?: number;
  46744. size?: number;
  46745. sizeX?: number;
  46746. sizeY?: number;
  46747. sizeZ?: number;
  46748. custom?: any;
  46749. faceUV?: Vector4[];
  46750. faceColors?: Color4[];
  46751. flat?: boolean;
  46752. updatable?: boolean;
  46753. sideOrientation?: number;
  46754. frontUVs?: Vector4;
  46755. backUVs?: Vector4;
  46756. }, scene?: Nullable<Scene>): Mesh;
  46757. }
  46758. }
  46759. declare module "babylonjs/Gizmos/scaleGizmo" {
  46760. import { Observable } from "babylonjs/Misc/observable";
  46761. import { Nullable } from "babylonjs/types";
  46762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46763. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46764. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46765. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46766. /**
  46767. * Gizmo that enables scaling a mesh along 3 axis
  46768. */
  46769. export class ScaleGizmo extends Gizmo {
  46770. /**
  46771. * Internal gizmo used for interactions on the x axis
  46772. */
  46773. xGizmo: AxisScaleGizmo;
  46774. /**
  46775. * Internal gizmo used for interactions on the y axis
  46776. */
  46777. yGizmo: AxisScaleGizmo;
  46778. /**
  46779. * Internal gizmo used for interactions on the z axis
  46780. */
  46781. zGizmo: AxisScaleGizmo;
  46782. /**
  46783. * Internal gizmo used to scale all axis equally
  46784. */
  46785. uniformScaleGizmo: AxisScaleGizmo;
  46786. private _meshAttached;
  46787. private _updateGizmoRotationToMatchAttachedMesh;
  46788. private _snapDistance;
  46789. private _scaleRatio;
  46790. private _uniformScalingMesh;
  46791. private _octahedron;
  46792. /** Fires an event when any of it's sub gizmos are dragged */
  46793. onDragStartObservable: Observable<unknown>;
  46794. /** Fires an event when any of it's sub gizmos are released from dragging */
  46795. onDragEndObservable: Observable<unknown>;
  46796. attachedMesh: Nullable<AbstractMesh>;
  46797. /**
  46798. * Creates a ScaleGizmo
  46799. * @param gizmoLayer The utility layer the gizmo will be added to
  46800. */
  46801. constructor(gizmoLayer?: UtilityLayerRenderer);
  46802. updateGizmoRotationToMatchAttachedMesh: boolean;
  46803. /**
  46804. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46805. */
  46806. snapDistance: number;
  46807. /**
  46808. * Ratio for the scale of the gizmo (Default: 1)
  46809. */
  46810. scaleRatio: number;
  46811. /**
  46812. * Disposes of the gizmo
  46813. */
  46814. dispose(): void;
  46815. }
  46816. }
  46817. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46818. import { Observable } from "babylonjs/Misc/observable";
  46819. import { Nullable } from "babylonjs/types";
  46820. import { Vector3 } from "babylonjs/Maths/math.vector";
  46821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46822. import { Mesh } from "babylonjs/Meshes/mesh";
  46823. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46824. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46825. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46826. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46827. import { Color3 } from "babylonjs/Maths/math.color";
  46828. /**
  46829. * Single axis scale gizmo
  46830. */
  46831. export class AxisScaleGizmo extends Gizmo {
  46832. /**
  46833. * Drag behavior responsible for the gizmos dragging interactions
  46834. */
  46835. dragBehavior: PointerDragBehavior;
  46836. private _pointerObserver;
  46837. /**
  46838. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46839. */
  46840. snapDistance: number;
  46841. /**
  46842. * Event that fires each time the gizmo snaps to a new location.
  46843. * * snapDistance is the the change in distance
  46844. */
  46845. onSnapObservable: Observable<{
  46846. snapDistance: number;
  46847. }>;
  46848. /**
  46849. * If the scaling operation should be done on all axis (default: false)
  46850. */
  46851. uniformScaling: boolean;
  46852. private _isEnabled;
  46853. private _parent;
  46854. private _arrow;
  46855. private _coloredMaterial;
  46856. private _hoverMaterial;
  46857. /**
  46858. * Creates an AxisScaleGizmo
  46859. * @param gizmoLayer The utility layer the gizmo will be added to
  46860. * @param dragAxis The axis which the gizmo will be able to scale on
  46861. * @param color The color of the gizmo
  46862. */
  46863. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46864. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46865. /**
  46866. * If the gizmo is enabled
  46867. */
  46868. isEnabled: boolean;
  46869. /**
  46870. * Disposes of the gizmo
  46871. */
  46872. dispose(): void;
  46873. /**
  46874. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46875. * @param mesh The mesh to replace the default mesh of the gizmo
  46876. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46877. */
  46878. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46879. }
  46880. }
  46881. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46882. import { Observable } from "babylonjs/Misc/observable";
  46883. import { Nullable } from "babylonjs/types";
  46884. import { Vector3 } from "babylonjs/Maths/math.vector";
  46885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46886. import { Mesh } from "babylonjs/Meshes/mesh";
  46887. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46888. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46889. import { Color3 } from "babylonjs/Maths/math.color";
  46890. import "babylonjs/Meshes/Builders/boxBuilder";
  46891. /**
  46892. * Bounding box gizmo
  46893. */
  46894. export class BoundingBoxGizmo extends Gizmo {
  46895. private _lineBoundingBox;
  46896. private _rotateSpheresParent;
  46897. private _scaleBoxesParent;
  46898. private _boundingDimensions;
  46899. private _renderObserver;
  46900. private _pointerObserver;
  46901. private _scaleDragSpeed;
  46902. private _tmpQuaternion;
  46903. private _tmpVector;
  46904. private _tmpRotationMatrix;
  46905. /**
  46906. * 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)
  46907. */
  46908. ignoreChildren: boolean;
  46909. /**
  46910. * 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)
  46911. */
  46912. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46913. /**
  46914. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46915. */
  46916. rotationSphereSize: number;
  46917. /**
  46918. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46919. */
  46920. scaleBoxSize: number;
  46921. /**
  46922. * 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)
  46923. */
  46924. fixedDragMeshScreenSize: boolean;
  46925. /**
  46926. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46927. */
  46928. fixedDragMeshScreenSizeDistanceFactor: number;
  46929. /**
  46930. * Fired when a rotation sphere or scale box is dragged
  46931. */
  46932. onDragStartObservable: Observable<{}>;
  46933. /**
  46934. * Fired when a scale box is dragged
  46935. */
  46936. onScaleBoxDragObservable: Observable<{}>;
  46937. /**
  46938. * Fired when a scale box drag is ended
  46939. */
  46940. onScaleBoxDragEndObservable: Observable<{}>;
  46941. /**
  46942. * Fired when a rotation sphere is dragged
  46943. */
  46944. onRotationSphereDragObservable: Observable<{}>;
  46945. /**
  46946. * Fired when a rotation sphere drag is ended
  46947. */
  46948. onRotationSphereDragEndObservable: Observable<{}>;
  46949. /**
  46950. * 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)
  46951. */
  46952. scalePivot: Nullable<Vector3>;
  46953. /**
  46954. * Mesh used as a pivot to rotate the attached mesh
  46955. */
  46956. private _anchorMesh;
  46957. private _existingMeshScale;
  46958. private _dragMesh;
  46959. private pointerDragBehavior;
  46960. private coloredMaterial;
  46961. private hoverColoredMaterial;
  46962. /**
  46963. * Sets the color of the bounding box gizmo
  46964. * @param color the color to set
  46965. */
  46966. setColor(color: Color3): void;
  46967. /**
  46968. * Creates an BoundingBoxGizmo
  46969. * @param gizmoLayer The utility layer the gizmo will be added to
  46970. * @param color The color of the gizmo
  46971. */
  46972. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46973. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46974. private _selectNode;
  46975. /**
  46976. * Updates the bounding box information for the Gizmo
  46977. */
  46978. updateBoundingBox(): void;
  46979. private _updateRotationSpheres;
  46980. private _updateScaleBoxes;
  46981. /**
  46982. * Enables rotation on the specified axis and disables rotation on the others
  46983. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46984. */
  46985. setEnabledRotationAxis(axis: string): void;
  46986. /**
  46987. * Enables/disables scaling
  46988. * @param enable if scaling should be enabled
  46989. */
  46990. setEnabledScaling(enable: boolean): void;
  46991. private _updateDummy;
  46992. /**
  46993. * Enables a pointer drag behavior on the bounding box of the gizmo
  46994. */
  46995. enableDragBehavior(): void;
  46996. /**
  46997. * Disposes of the gizmo
  46998. */
  46999. dispose(): void;
  47000. /**
  47001. * 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)
  47002. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47003. * @returns the bounding box mesh with the passed in mesh as a child
  47004. */
  47005. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47006. /**
  47007. * CustomMeshes are not supported by this gizmo
  47008. * @param mesh The mesh to replace the default mesh of the gizmo
  47009. */
  47010. setCustomMesh(mesh: Mesh): void;
  47011. }
  47012. }
  47013. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47014. import { Observable } from "babylonjs/Misc/observable";
  47015. import { Nullable } from "babylonjs/types";
  47016. import { Vector3 } from "babylonjs/Maths/math.vector";
  47017. import { Color3 } from "babylonjs/Maths/math.color";
  47018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47019. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47020. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47021. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47022. import "babylonjs/Meshes/Builders/linesBuilder";
  47023. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47024. /**
  47025. * Single plane rotation gizmo
  47026. */
  47027. export class PlaneRotationGizmo extends Gizmo {
  47028. /**
  47029. * Drag behavior responsible for the gizmos dragging interactions
  47030. */
  47031. dragBehavior: PointerDragBehavior;
  47032. private _pointerObserver;
  47033. /**
  47034. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47035. */
  47036. snapDistance: number;
  47037. /**
  47038. * Event that fires each time the gizmo snaps to a new location.
  47039. * * snapDistance is the the change in distance
  47040. */
  47041. onSnapObservable: Observable<{
  47042. snapDistance: number;
  47043. }>;
  47044. private _isEnabled;
  47045. private _parent;
  47046. /**
  47047. * Creates a PlaneRotationGizmo
  47048. * @param gizmoLayer The utility layer the gizmo will be added to
  47049. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47050. * @param color The color of the gizmo
  47051. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47052. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47053. */
  47054. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47055. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47056. /**
  47057. * If the gizmo is enabled
  47058. */
  47059. isEnabled: boolean;
  47060. /**
  47061. * Disposes of the gizmo
  47062. */
  47063. dispose(): void;
  47064. }
  47065. }
  47066. declare module "babylonjs/Gizmos/rotationGizmo" {
  47067. import { Observable } from "babylonjs/Misc/observable";
  47068. import { Nullable } from "babylonjs/types";
  47069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47070. import { Mesh } from "babylonjs/Meshes/mesh";
  47071. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47072. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47073. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47074. /**
  47075. * Gizmo that enables rotating a mesh along 3 axis
  47076. */
  47077. export class RotationGizmo extends Gizmo {
  47078. /**
  47079. * Internal gizmo used for interactions on the x axis
  47080. */
  47081. xGizmo: PlaneRotationGizmo;
  47082. /**
  47083. * Internal gizmo used for interactions on the y axis
  47084. */
  47085. yGizmo: PlaneRotationGizmo;
  47086. /**
  47087. * Internal gizmo used for interactions on the z axis
  47088. */
  47089. zGizmo: PlaneRotationGizmo;
  47090. /** Fires an event when any of it's sub gizmos are dragged */
  47091. onDragStartObservable: Observable<unknown>;
  47092. /** Fires an event when any of it's sub gizmos are released from dragging */
  47093. onDragEndObservable: Observable<unknown>;
  47094. private _meshAttached;
  47095. attachedMesh: Nullable<AbstractMesh>;
  47096. /**
  47097. * Creates a RotationGizmo
  47098. * @param gizmoLayer The utility layer the gizmo will be added to
  47099. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47100. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47101. */
  47102. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47103. updateGizmoRotationToMatchAttachedMesh: boolean;
  47104. /**
  47105. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47106. */
  47107. snapDistance: number;
  47108. /**
  47109. * Ratio for the scale of the gizmo (Default: 1)
  47110. */
  47111. scaleRatio: number;
  47112. /**
  47113. * Disposes of the gizmo
  47114. */
  47115. dispose(): void;
  47116. /**
  47117. * CustomMeshes are not supported by this gizmo
  47118. * @param mesh The mesh to replace the default mesh of the gizmo
  47119. */
  47120. setCustomMesh(mesh: Mesh): void;
  47121. }
  47122. }
  47123. declare module "babylonjs/Gizmos/gizmoManager" {
  47124. import { Observable } from "babylonjs/Misc/observable";
  47125. import { Nullable } from "babylonjs/types";
  47126. import { Scene, IDisposable } from "babylonjs/scene";
  47127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47128. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47129. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47130. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47131. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47132. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47133. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47134. /**
  47135. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47136. */
  47137. export class GizmoManager implements IDisposable {
  47138. private scene;
  47139. /**
  47140. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47141. */
  47142. gizmos: {
  47143. positionGizmo: Nullable<PositionGizmo>;
  47144. rotationGizmo: Nullable<RotationGizmo>;
  47145. scaleGizmo: Nullable<ScaleGizmo>;
  47146. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47147. };
  47148. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47149. clearGizmoOnEmptyPointerEvent: boolean;
  47150. /** Fires an event when the manager is attached to a mesh */
  47151. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47152. private _gizmosEnabled;
  47153. private _pointerObserver;
  47154. private _attachedMesh;
  47155. private _boundingBoxColor;
  47156. private _defaultUtilityLayer;
  47157. private _defaultKeepDepthUtilityLayer;
  47158. /**
  47159. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47160. */
  47161. boundingBoxDragBehavior: SixDofDragBehavior;
  47162. /**
  47163. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47164. */
  47165. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47166. /**
  47167. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47168. */
  47169. usePointerToAttachGizmos: boolean;
  47170. /**
  47171. * Utility layer that the bounding box gizmo belongs to
  47172. */
  47173. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47174. /**
  47175. * Utility layer that all gizmos besides bounding box belong to
  47176. */
  47177. readonly utilityLayer: UtilityLayerRenderer;
  47178. /**
  47179. * Instatiates a gizmo manager
  47180. * @param scene the scene to overlay the gizmos on top of
  47181. */
  47182. constructor(scene: Scene);
  47183. /**
  47184. * Attaches a set of gizmos to the specified mesh
  47185. * @param mesh The mesh the gizmo's should be attached to
  47186. */
  47187. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47188. /**
  47189. * If the position gizmo is enabled
  47190. */
  47191. positionGizmoEnabled: boolean;
  47192. /**
  47193. * If the rotation gizmo is enabled
  47194. */
  47195. rotationGizmoEnabled: boolean;
  47196. /**
  47197. * If the scale gizmo is enabled
  47198. */
  47199. scaleGizmoEnabled: boolean;
  47200. /**
  47201. * If the boundingBox gizmo is enabled
  47202. */
  47203. boundingBoxGizmoEnabled: boolean;
  47204. /**
  47205. * Disposes of the gizmo manager
  47206. */
  47207. dispose(): void;
  47208. }
  47209. }
  47210. declare module "babylonjs/Lights/directionalLight" {
  47211. import { Camera } from "babylonjs/Cameras/camera";
  47212. import { Scene } from "babylonjs/scene";
  47213. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47215. import { Light } from "babylonjs/Lights/light";
  47216. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47217. import { Effect } from "babylonjs/Materials/effect";
  47218. /**
  47219. * A directional light is defined by a direction (what a surprise!).
  47220. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47221. * 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.
  47222. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47223. */
  47224. export class DirectionalLight extends ShadowLight {
  47225. private _shadowFrustumSize;
  47226. /**
  47227. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47228. */
  47229. /**
  47230. * Specifies a fix frustum size for the shadow generation.
  47231. */
  47232. shadowFrustumSize: number;
  47233. private _shadowOrthoScale;
  47234. /**
  47235. * Gets the shadow projection scale against the optimal computed one.
  47236. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47237. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47238. */
  47239. /**
  47240. * Sets the shadow projection scale against the optimal computed one.
  47241. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47242. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47243. */
  47244. shadowOrthoScale: number;
  47245. /**
  47246. * Automatically compute the projection matrix to best fit (including all the casters)
  47247. * on each frame.
  47248. */
  47249. autoUpdateExtends: boolean;
  47250. private _orthoLeft;
  47251. private _orthoRight;
  47252. private _orthoTop;
  47253. private _orthoBottom;
  47254. /**
  47255. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47256. * The directional light is emitted from everywhere in the given direction.
  47257. * It can cast shadows.
  47258. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47259. * @param name The friendly name of the light
  47260. * @param direction The direction of the light
  47261. * @param scene The scene the light belongs to
  47262. */
  47263. constructor(name: string, direction: Vector3, scene: Scene);
  47264. /**
  47265. * Returns the string "DirectionalLight".
  47266. * @return The class name
  47267. */
  47268. getClassName(): string;
  47269. /**
  47270. * Returns the integer 1.
  47271. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47272. */
  47273. getTypeID(): number;
  47274. /**
  47275. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47276. * Returns the DirectionalLight Shadow projection matrix.
  47277. */
  47278. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47279. /**
  47280. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47281. * Returns the DirectionalLight Shadow projection matrix.
  47282. */
  47283. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47284. /**
  47285. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47286. * Returns the DirectionalLight Shadow projection matrix.
  47287. */
  47288. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47289. protected _buildUniformLayout(): void;
  47290. /**
  47291. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47292. * @param effect The effect to update
  47293. * @param lightIndex The index of the light in the effect to update
  47294. * @returns The directional light
  47295. */
  47296. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47297. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47298. /**
  47299. * Gets the minZ used for shadow according to both the scene and the light.
  47300. *
  47301. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47302. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47303. * @param activeCamera The camera we are returning the min for
  47304. * @returns the depth min z
  47305. */
  47306. getDepthMinZ(activeCamera: Camera): number;
  47307. /**
  47308. * Gets the maxZ used for shadow according to both the scene and the light.
  47309. *
  47310. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47311. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47312. * @param activeCamera The camera we are returning the max for
  47313. * @returns the depth max z
  47314. */
  47315. getDepthMaxZ(activeCamera: Camera): number;
  47316. /**
  47317. * Prepares the list of defines specific to the light type.
  47318. * @param defines the list of defines
  47319. * @param lightIndex defines the index of the light for the effect
  47320. */
  47321. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47322. }
  47323. }
  47324. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47325. import { Mesh } from "babylonjs/Meshes/mesh";
  47326. /**
  47327. * Class containing static functions to help procedurally build meshes
  47328. */
  47329. export class HemisphereBuilder {
  47330. /**
  47331. * Creates a hemisphere mesh
  47332. * @param name defines the name of the mesh
  47333. * @param options defines the options used to create the mesh
  47334. * @param scene defines the hosting scene
  47335. * @returns the hemisphere mesh
  47336. */
  47337. static CreateHemisphere(name: string, options: {
  47338. segments?: number;
  47339. diameter?: number;
  47340. sideOrientation?: number;
  47341. }, scene: any): Mesh;
  47342. }
  47343. }
  47344. declare module "babylonjs/Lights/spotLight" {
  47345. import { Nullable } from "babylonjs/types";
  47346. import { Scene } from "babylonjs/scene";
  47347. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47349. import { Effect } from "babylonjs/Materials/effect";
  47350. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47351. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47352. /**
  47353. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47354. * These values define a cone of light starting from the position, emitting toward the direction.
  47355. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47356. * and the exponent defines the speed of the decay of the light with distance (reach).
  47357. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47358. */
  47359. export class SpotLight extends ShadowLight {
  47360. private _angle;
  47361. private _innerAngle;
  47362. private _cosHalfAngle;
  47363. private _lightAngleScale;
  47364. private _lightAngleOffset;
  47365. /**
  47366. * Gets the cone angle of the spot light in Radians.
  47367. */
  47368. /**
  47369. * Sets the cone angle of the spot light in Radians.
  47370. */
  47371. angle: number;
  47372. /**
  47373. * Only used in gltf falloff mode, this defines the angle where
  47374. * the directional falloff will start before cutting at angle which could be seen
  47375. * as outer angle.
  47376. */
  47377. /**
  47378. * Only used in gltf falloff mode, this defines the angle where
  47379. * the directional falloff will start before cutting at angle which could be seen
  47380. * as outer angle.
  47381. */
  47382. innerAngle: number;
  47383. private _shadowAngleScale;
  47384. /**
  47385. * Allows scaling the angle of the light for shadow generation only.
  47386. */
  47387. /**
  47388. * Allows scaling the angle of the light for shadow generation only.
  47389. */
  47390. shadowAngleScale: number;
  47391. /**
  47392. * The light decay speed with the distance from the emission spot.
  47393. */
  47394. exponent: number;
  47395. private _projectionTextureMatrix;
  47396. /**
  47397. * Allows reading the projecton texture
  47398. */
  47399. readonly projectionTextureMatrix: Matrix;
  47400. protected _projectionTextureLightNear: number;
  47401. /**
  47402. * Gets the near clip of the Spotlight for texture projection.
  47403. */
  47404. /**
  47405. * Sets the near clip of the Spotlight for texture projection.
  47406. */
  47407. projectionTextureLightNear: number;
  47408. protected _projectionTextureLightFar: number;
  47409. /**
  47410. * Gets the far clip of the Spotlight for texture projection.
  47411. */
  47412. /**
  47413. * Sets the far clip of the Spotlight for texture projection.
  47414. */
  47415. projectionTextureLightFar: number;
  47416. protected _projectionTextureUpDirection: Vector3;
  47417. /**
  47418. * Gets the Up vector of the Spotlight for texture projection.
  47419. */
  47420. /**
  47421. * Sets the Up vector of the Spotlight for texture projection.
  47422. */
  47423. projectionTextureUpDirection: Vector3;
  47424. private _projectionTexture;
  47425. /**
  47426. * Gets the projection texture of the light.
  47427. */
  47428. /**
  47429. * Sets the projection texture of the light.
  47430. */
  47431. projectionTexture: Nullable<BaseTexture>;
  47432. private _projectionTextureViewLightDirty;
  47433. private _projectionTextureProjectionLightDirty;
  47434. private _projectionTextureDirty;
  47435. private _projectionTextureViewTargetVector;
  47436. private _projectionTextureViewLightMatrix;
  47437. private _projectionTextureProjectionLightMatrix;
  47438. private _projectionTextureScalingMatrix;
  47439. /**
  47440. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47441. * It can cast shadows.
  47442. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47443. * @param name The light friendly name
  47444. * @param position The position of the spot light in the scene
  47445. * @param direction The direction of the light in the scene
  47446. * @param angle The cone angle of the light in Radians
  47447. * @param exponent The light decay speed with the distance from the emission spot
  47448. * @param scene The scene the lights belongs to
  47449. */
  47450. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47451. /**
  47452. * Returns the string "SpotLight".
  47453. * @returns the class name
  47454. */
  47455. getClassName(): string;
  47456. /**
  47457. * Returns the integer 2.
  47458. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47459. */
  47460. getTypeID(): number;
  47461. /**
  47462. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47463. */
  47464. protected _setDirection(value: Vector3): void;
  47465. /**
  47466. * Overrides the position setter to recompute the projection texture view light Matrix.
  47467. */
  47468. protected _setPosition(value: Vector3): void;
  47469. /**
  47470. * 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.
  47471. * Returns the SpotLight.
  47472. */
  47473. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47474. protected _computeProjectionTextureViewLightMatrix(): void;
  47475. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47476. /**
  47477. * Main function for light texture projection matrix computing.
  47478. */
  47479. protected _computeProjectionTextureMatrix(): void;
  47480. protected _buildUniformLayout(): void;
  47481. private _computeAngleValues;
  47482. /**
  47483. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47484. * @param effect The effect to update
  47485. * @param lightIndex The index of the light in the effect to update
  47486. * @returns The spot light
  47487. */
  47488. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47489. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47490. /**
  47491. * Disposes the light and the associated resources.
  47492. */
  47493. dispose(): void;
  47494. /**
  47495. * Prepares the list of defines specific to the light type.
  47496. * @param defines the list of defines
  47497. * @param lightIndex defines the index of the light for the effect
  47498. */
  47499. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47500. }
  47501. }
  47502. declare module "babylonjs/Gizmos/lightGizmo" {
  47503. import { Nullable } from "babylonjs/types";
  47504. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47505. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47506. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47507. import { Light } from "babylonjs/Lights/light";
  47508. /**
  47509. * Gizmo that enables viewing a light
  47510. */
  47511. export class LightGizmo extends Gizmo {
  47512. private _lightMesh;
  47513. private _material;
  47514. private cachedPosition;
  47515. private cachedForward;
  47516. /**
  47517. * Creates a LightGizmo
  47518. * @param gizmoLayer The utility layer the gizmo will be added to
  47519. */
  47520. constructor(gizmoLayer?: UtilityLayerRenderer);
  47521. private _light;
  47522. /**
  47523. * The light that the gizmo is attached to
  47524. */
  47525. light: Nullable<Light>;
  47526. /**
  47527. * Gets the material used to render the light gizmo
  47528. */
  47529. readonly material: StandardMaterial;
  47530. /**
  47531. * @hidden
  47532. * Updates the gizmo to match the attached mesh's position/rotation
  47533. */
  47534. protected _update(): void;
  47535. private static _Scale;
  47536. /**
  47537. * Creates the lines for a light mesh
  47538. */
  47539. private static _createLightLines;
  47540. /**
  47541. * Disposes of the light gizmo
  47542. */
  47543. dispose(): void;
  47544. private static _CreateHemisphericLightMesh;
  47545. private static _CreatePointLightMesh;
  47546. private static _CreateSpotLightMesh;
  47547. private static _CreateDirectionalLightMesh;
  47548. }
  47549. }
  47550. declare module "babylonjs/Gizmos/index" {
  47551. export * from "babylonjs/Gizmos/axisDragGizmo";
  47552. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47553. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47554. export * from "babylonjs/Gizmos/gizmo";
  47555. export * from "babylonjs/Gizmos/gizmoManager";
  47556. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47557. export * from "babylonjs/Gizmos/positionGizmo";
  47558. export * from "babylonjs/Gizmos/rotationGizmo";
  47559. export * from "babylonjs/Gizmos/scaleGizmo";
  47560. export * from "babylonjs/Gizmos/lightGizmo";
  47561. export * from "babylonjs/Gizmos/planeDragGizmo";
  47562. }
  47563. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47564. /** @hidden */
  47565. export var backgroundFragmentDeclaration: {
  47566. name: string;
  47567. shader: string;
  47568. };
  47569. }
  47570. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47571. /** @hidden */
  47572. export var backgroundUboDeclaration: {
  47573. name: string;
  47574. shader: string;
  47575. };
  47576. }
  47577. declare module "babylonjs/Shaders/background.fragment" {
  47578. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47579. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47580. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47581. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47582. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47583. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47584. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47585. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47586. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47587. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47588. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47589. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47590. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47591. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47592. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47593. /** @hidden */
  47594. export var backgroundPixelShader: {
  47595. name: string;
  47596. shader: string;
  47597. };
  47598. }
  47599. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47600. /** @hidden */
  47601. export var backgroundVertexDeclaration: {
  47602. name: string;
  47603. shader: string;
  47604. };
  47605. }
  47606. declare module "babylonjs/Shaders/background.vertex" {
  47607. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47608. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47610. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47611. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47612. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47613. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47614. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47615. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47616. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47617. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47618. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47619. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47620. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47621. /** @hidden */
  47622. export var backgroundVertexShader: {
  47623. name: string;
  47624. shader: string;
  47625. };
  47626. }
  47627. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47628. import { Nullable, int, float } from "babylonjs/types";
  47629. import { Scene } from "babylonjs/scene";
  47630. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47631. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47633. import { Mesh } from "babylonjs/Meshes/mesh";
  47634. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47635. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47636. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47638. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47639. import { Color3 } from "babylonjs/Maths/math.color";
  47640. import "babylonjs/Shaders/background.fragment";
  47641. import "babylonjs/Shaders/background.vertex";
  47642. /**
  47643. * Background material used to create an efficient environement around your scene.
  47644. */
  47645. export class BackgroundMaterial extends PushMaterial {
  47646. /**
  47647. * Standard reflectance value at parallel view angle.
  47648. */
  47649. static StandardReflectance0: number;
  47650. /**
  47651. * Standard reflectance value at grazing angle.
  47652. */
  47653. static StandardReflectance90: number;
  47654. protected _primaryColor: Color3;
  47655. /**
  47656. * Key light Color (multiply against the environement texture)
  47657. */
  47658. primaryColor: Color3;
  47659. protected __perceptualColor: Nullable<Color3>;
  47660. /**
  47661. * Experimental Internal Use Only.
  47662. *
  47663. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47664. * This acts as a helper to set the primary color to a more "human friendly" value.
  47665. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47666. * output color as close as possible from the chosen value.
  47667. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47668. * part of lighting setup.)
  47669. */
  47670. _perceptualColor: Nullable<Color3>;
  47671. protected _primaryColorShadowLevel: float;
  47672. /**
  47673. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47674. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47675. */
  47676. primaryColorShadowLevel: float;
  47677. protected _primaryColorHighlightLevel: float;
  47678. /**
  47679. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47680. * The primary color is used at the level chosen to define what the white area would look.
  47681. */
  47682. primaryColorHighlightLevel: float;
  47683. protected _reflectionTexture: Nullable<BaseTexture>;
  47684. /**
  47685. * Reflection Texture used in the material.
  47686. * Should be author in a specific way for the best result (refer to the documentation).
  47687. */
  47688. reflectionTexture: Nullable<BaseTexture>;
  47689. protected _reflectionBlur: float;
  47690. /**
  47691. * Reflection Texture level of blur.
  47692. *
  47693. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47694. * texture twice.
  47695. */
  47696. reflectionBlur: float;
  47697. protected _diffuseTexture: Nullable<BaseTexture>;
  47698. /**
  47699. * Diffuse Texture used in the material.
  47700. * Should be author in a specific way for the best result (refer to the documentation).
  47701. */
  47702. diffuseTexture: Nullable<BaseTexture>;
  47703. protected _shadowLights: Nullable<IShadowLight[]>;
  47704. /**
  47705. * Specify the list of lights casting shadow on the material.
  47706. * All scene shadow lights will be included if null.
  47707. */
  47708. shadowLights: Nullable<IShadowLight[]>;
  47709. protected _shadowLevel: float;
  47710. /**
  47711. * Helps adjusting the shadow to a softer level if required.
  47712. * 0 means black shadows and 1 means no shadows.
  47713. */
  47714. shadowLevel: float;
  47715. protected _sceneCenter: Vector3;
  47716. /**
  47717. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47718. * It is usually zero but might be interesting to modify according to your setup.
  47719. */
  47720. sceneCenter: Vector3;
  47721. protected _opacityFresnel: boolean;
  47722. /**
  47723. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47724. * This helps ensuring a nice transition when the camera goes under the ground.
  47725. */
  47726. opacityFresnel: boolean;
  47727. protected _reflectionFresnel: boolean;
  47728. /**
  47729. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47730. * This helps adding a mirror texture on the ground.
  47731. */
  47732. reflectionFresnel: boolean;
  47733. protected _reflectionFalloffDistance: number;
  47734. /**
  47735. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47736. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47737. */
  47738. reflectionFalloffDistance: number;
  47739. protected _reflectionAmount: number;
  47740. /**
  47741. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47742. */
  47743. reflectionAmount: number;
  47744. protected _reflectionReflectance0: number;
  47745. /**
  47746. * This specifies the weight of the reflection at grazing angle.
  47747. */
  47748. reflectionReflectance0: number;
  47749. protected _reflectionReflectance90: number;
  47750. /**
  47751. * This specifies the weight of the reflection at a perpendicular point of view.
  47752. */
  47753. reflectionReflectance90: number;
  47754. /**
  47755. * Sets the reflection reflectance fresnel values according to the default standard
  47756. * empirically know to work well :-)
  47757. */
  47758. reflectionStandardFresnelWeight: number;
  47759. protected _useRGBColor: boolean;
  47760. /**
  47761. * Helps to directly use the maps channels instead of their level.
  47762. */
  47763. useRGBColor: boolean;
  47764. protected _enableNoise: boolean;
  47765. /**
  47766. * This helps reducing the banding effect that could occur on the background.
  47767. */
  47768. enableNoise: boolean;
  47769. /**
  47770. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47771. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47772. * Recommended to be keep at 1.0 except for special cases.
  47773. */
  47774. fovMultiplier: number;
  47775. private _fovMultiplier;
  47776. /**
  47777. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47778. */
  47779. useEquirectangularFOV: boolean;
  47780. private _maxSimultaneousLights;
  47781. /**
  47782. * Number of Simultaneous lights allowed on the material.
  47783. */
  47784. maxSimultaneousLights: int;
  47785. /**
  47786. * Default configuration related to image processing available in the Background Material.
  47787. */
  47788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47789. /**
  47790. * Keep track of the image processing observer to allow dispose and replace.
  47791. */
  47792. private _imageProcessingObserver;
  47793. /**
  47794. * Attaches a new image processing configuration to the PBR Material.
  47795. * @param configuration (if null the scene configuration will be use)
  47796. */
  47797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47798. /**
  47799. * Gets the image processing configuration used either in this material.
  47800. */
  47801. /**
  47802. * Sets the Default image processing configuration used either in the this material.
  47803. *
  47804. * If sets to null, the scene one is in use.
  47805. */
  47806. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47807. /**
  47808. * Gets wether the color curves effect is enabled.
  47809. */
  47810. /**
  47811. * Sets wether the color curves effect is enabled.
  47812. */
  47813. cameraColorCurvesEnabled: boolean;
  47814. /**
  47815. * Gets wether the color grading effect is enabled.
  47816. */
  47817. /**
  47818. * Gets wether the color grading effect is enabled.
  47819. */
  47820. cameraColorGradingEnabled: boolean;
  47821. /**
  47822. * Gets wether tonemapping is enabled or not.
  47823. */
  47824. /**
  47825. * Sets wether tonemapping is enabled or not
  47826. */
  47827. cameraToneMappingEnabled: boolean;
  47828. /**
  47829. * The camera exposure used on this material.
  47830. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47831. * This corresponds to a photographic exposure.
  47832. */
  47833. /**
  47834. * The camera exposure used on this material.
  47835. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47836. * This corresponds to a photographic exposure.
  47837. */
  47838. cameraExposure: float;
  47839. /**
  47840. * Gets The camera contrast used on this material.
  47841. */
  47842. /**
  47843. * Sets The camera contrast used on this material.
  47844. */
  47845. cameraContrast: float;
  47846. /**
  47847. * Gets the Color Grading 2D Lookup Texture.
  47848. */
  47849. /**
  47850. * Sets the Color Grading 2D Lookup Texture.
  47851. */
  47852. cameraColorGradingTexture: Nullable<BaseTexture>;
  47853. /**
  47854. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47855. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47856. * 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;
  47857. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47858. */
  47859. /**
  47860. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47861. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47862. * 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;
  47863. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47864. */
  47865. cameraColorCurves: Nullable<ColorCurves>;
  47866. /**
  47867. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47868. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47869. */
  47870. switchToBGR: boolean;
  47871. private _renderTargets;
  47872. private _reflectionControls;
  47873. private _white;
  47874. private _primaryShadowColor;
  47875. private _primaryHighlightColor;
  47876. /**
  47877. * Instantiates a Background Material in the given scene
  47878. * @param name The friendly name of the material
  47879. * @param scene The scene to add the material to
  47880. */
  47881. constructor(name: string, scene: Scene);
  47882. /**
  47883. * Gets a boolean indicating that current material needs to register RTT
  47884. */
  47885. readonly hasRenderTargetTextures: boolean;
  47886. /**
  47887. * The entire material has been created in order to prevent overdraw.
  47888. * @returns false
  47889. */
  47890. needAlphaTesting(): boolean;
  47891. /**
  47892. * The entire material has been created in order to prevent overdraw.
  47893. * @returns true if blending is enable
  47894. */
  47895. needAlphaBlending(): boolean;
  47896. /**
  47897. * Checks wether the material is ready to be rendered for a given mesh.
  47898. * @param mesh The mesh to render
  47899. * @param subMesh The submesh to check against
  47900. * @param useInstances Specify wether or not the material is used with instances
  47901. * @returns true if all the dependencies are ready (Textures, Effects...)
  47902. */
  47903. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47904. /**
  47905. * Compute the primary color according to the chosen perceptual color.
  47906. */
  47907. private _computePrimaryColorFromPerceptualColor;
  47908. /**
  47909. * Compute the highlights and shadow colors according to their chosen levels.
  47910. */
  47911. private _computePrimaryColors;
  47912. /**
  47913. * Build the uniform buffer used in the material.
  47914. */
  47915. buildUniformLayout(): void;
  47916. /**
  47917. * Unbind the material.
  47918. */
  47919. unbind(): void;
  47920. /**
  47921. * Bind only the world matrix to the material.
  47922. * @param world The world matrix to bind.
  47923. */
  47924. bindOnlyWorldMatrix(world: Matrix): void;
  47925. /**
  47926. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47927. * @param world The world matrix to bind.
  47928. * @param subMesh The submesh to bind for.
  47929. */
  47930. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47931. /**
  47932. * Checks to see if a texture is used in the material.
  47933. * @param texture - Base texture to use.
  47934. * @returns - Boolean specifying if a texture is used in the material.
  47935. */
  47936. hasTexture(texture: BaseTexture): boolean;
  47937. /**
  47938. * Dispose the material.
  47939. * @param forceDisposeEffect Force disposal of the associated effect.
  47940. * @param forceDisposeTextures Force disposal of the associated textures.
  47941. */
  47942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47943. /**
  47944. * Clones the material.
  47945. * @param name The cloned name.
  47946. * @returns The cloned material.
  47947. */
  47948. clone(name: string): BackgroundMaterial;
  47949. /**
  47950. * Serializes the current material to its JSON representation.
  47951. * @returns The JSON representation.
  47952. */
  47953. serialize(): any;
  47954. /**
  47955. * Gets the class name of the material
  47956. * @returns "BackgroundMaterial"
  47957. */
  47958. getClassName(): string;
  47959. /**
  47960. * Parse a JSON input to create back a background material.
  47961. * @param source The JSON data to parse
  47962. * @param scene The scene to create the parsed material in
  47963. * @param rootUrl The root url of the assets the material depends upon
  47964. * @returns the instantiated BackgroundMaterial.
  47965. */
  47966. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47967. }
  47968. }
  47969. declare module "babylonjs/Helpers/environmentHelper" {
  47970. import { Observable } from "babylonjs/Misc/observable";
  47971. import { Nullable } from "babylonjs/types";
  47972. import { Scene } from "babylonjs/scene";
  47973. import { Vector3 } from "babylonjs/Maths/math.vector";
  47974. import { Color3 } from "babylonjs/Maths/math.color";
  47975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47976. import { Mesh } from "babylonjs/Meshes/mesh";
  47977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47978. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47979. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47980. import "babylonjs/Meshes/Builders/planeBuilder";
  47981. import "babylonjs/Meshes/Builders/boxBuilder";
  47982. /**
  47983. * Represents the different options available during the creation of
  47984. * a Environment helper.
  47985. *
  47986. * This can control the default ground, skybox and image processing setup of your scene.
  47987. */
  47988. export interface IEnvironmentHelperOptions {
  47989. /**
  47990. * Specifies wether or not to create a ground.
  47991. * True by default.
  47992. */
  47993. createGround: boolean;
  47994. /**
  47995. * Specifies the ground size.
  47996. * 15 by default.
  47997. */
  47998. groundSize: number;
  47999. /**
  48000. * The texture used on the ground for the main color.
  48001. * Comes from the BabylonJS CDN by default.
  48002. *
  48003. * Remarks: Can be either a texture or a url.
  48004. */
  48005. groundTexture: string | BaseTexture;
  48006. /**
  48007. * The color mixed in the ground texture by default.
  48008. * BabylonJS clearColor by default.
  48009. */
  48010. groundColor: Color3;
  48011. /**
  48012. * Specifies the ground opacity.
  48013. * 1 by default.
  48014. */
  48015. groundOpacity: number;
  48016. /**
  48017. * Enables the ground to receive shadows.
  48018. * True by default.
  48019. */
  48020. enableGroundShadow: boolean;
  48021. /**
  48022. * Helps preventing the shadow to be fully black on the ground.
  48023. * 0.5 by default.
  48024. */
  48025. groundShadowLevel: number;
  48026. /**
  48027. * Creates a mirror texture attach to the ground.
  48028. * false by default.
  48029. */
  48030. enableGroundMirror: boolean;
  48031. /**
  48032. * Specifies the ground mirror size ratio.
  48033. * 0.3 by default as the default kernel is 64.
  48034. */
  48035. groundMirrorSizeRatio: number;
  48036. /**
  48037. * Specifies the ground mirror blur kernel size.
  48038. * 64 by default.
  48039. */
  48040. groundMirrorBlurKernel: number;
  48041. /**
  48042. * Specifies the ground mirror visibility amount.
  48043. * 1 by default
  48044. */
  48045. groundMirrorAmount: number;
  48046. /**
  48047. * Specifies the ground mirror reflectance weight.
  48048. * This uses the standard weight of the background material to setup the fresnel effect
  48049. * of the mirror.
  48050. * 1 by default.
  48051. */
  48052. groundMirrorFresnelWeight: number;
  48053. /**
  48054. * Specifies the ground mirror Falloff distance.
  48055. * This can helps reducing the size of the reflection.
  48056. * 0 by Default.
  48057. */
  48058. groundMirrorFallOffDistance: number;
  48059. /**
  48060. * Specifies the ground mirror texture type.
  48061. * Unsigned Int by Default.
  48062. */
  48063. groundMirrorTextureType: number;
  48064. /**
  48065. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48066. * the shown objects.
  48067. */
  48068. groundYBias: number;
  48069. /**
  48070. * Specifies wether or not to create a skybox.
  48071. * True by default.
  48072. */
  48073. createSkybox: boolean;
  48074. /**
  48075. * Specifies the skybox size.
  48076. * 20 by default.
  48077. */
  48078. skyboxSize: number;
  48079. /**
  48080. * The texture used on the skybox for the main color.
  48081. * Comes from the BabylonJS CDN by default.
  48082. *
  48083. * Remarks: Can be either a texture or a url.
  48084. */
  48085. skyboxTexture: string | BaseTexture;
  48086. /**
  48087. * The color mixed in the skybox texture by default.
  48088. * BabylonJS clearColor by default.
  48089. */
  48090. skyboxColor: Color3;
  48091. /**
  48092. * The background rotation around the Y axis of the scene.
  48093. * This helps aligning the key lights of your scene with the background.
  48094. * 0 by default.
  48095. */
  48096. backgroundYRotation: number;
  48097. /**
  48098. * Compute automatically the size of the elements to best fit with the scene.
  48099. */
  48100. sizeAuto: boolean;
  48101. /**
  48102. * Default position of the rootMesh if autoSize is not true.
  48103. */
  48104. rootPosition: Vector3;
  48105. /**
  48106. * Sets up the image processing in the scene.
  48107. * true by default.
  48108. */
  48109. setupImageProcessing: boolean;
  48110. /**
  48111. * The texture used as your environment texture in the scene.
  48112. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48113. *
  48114. * Remarks: Can be either a texture or a url.
  48115. */
  48116. environmentTexture: string | BaseTexture;
  48117. /**
  48118. * The value of the exposure to apply to the scene.
  48119. * 0.6 by default if setupImageProcessing is true.
  48120. */
  48121. cameraExposure: number;
  48122. /**
  48123. * The value of the contrast to apply to the scene.
  48124. * 1.6 by default if setupImageProcessing is true.
  48125. */
  48126. cameraContrast: number;
  48127. /**
  48128. * Specifies wether or not tonemapping should be enabled in the scene.
  48129. * true by default if setupImageProcessing is true.
  48130. */
  48131. toneMappingEnabled: boolean;
  48132. }
  48133. /**
  48134. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48135. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48136. * It also helps with the default setup of your imageProcessing configuration.
  48137. */
  48138. export class EnvironmentHelper {
  48139. /**
  48140. * Default ground texture URL.
  48141. */
  48142. private static _groundTextureCDNUrl;
  48143. /**
  48144. * Default skybox texture URL.
  48145. */
  48146. private static _skyboxTextureCDNUrl;
  48147. /**
  48148. * Default environment texture URL.
  48149. */
  48150. private static _environmentTextureCDNUrl;
  48151. /**
  48152. * Creates the default options for the helper.
  48153. */
  48154. private static _getDefaultOptions;
  48155. private _rootMesh;
  48156. /**
  48157. * Gets the root mesh created by the helper.
  48158. */
  48159. readonly rootMesh: Mesh;
  48160. private _skybox;
  48161. /**
  48162. * Gets the skybox created by the helper.
  48163. */
  48164. readonly skybox: Nullable<Mesh>;
  48165. private _skyboxTexture;
  48166. /**
  48167. * Gets the skybox texture created by the helper.
  48168. */
  48169. readonly skyboxTexture: Nullable<BaseTexture>;
  48170. private _skyboxMaterial;
  48171. /**
  48172. * Gets the skybox material created by the helper.
  48173. */
  48174. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48175. private _ground;
  48176. /**
  48177. * Gets the ground mesh created by the helper.
  48178. */
  48179. readonly ground: Nullable<Mesh>;
  48180. private _groundTexture;
  48181. /**
  48182. * Gets the ground texture created by the helper.
  48183. */
  48184. readonly groundTexture: Nullable<BaseTexture>;
  48185. private _groundMirror;
  48186. /**
  48187. * Gets the ground mirror created by the helper.
  48188. */
  48189. readonly groundMirror: Nullable<MirrorTexture>;
  48190. /**
  48191. * Gets the ground mirror render list to helps pushing the meshes
  48192. * you wish in the ground reflection.
  48193. */
  48194. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48195. private _groundMaterial;
  48196. /**
  48197. * Gets the ground material created by the helper.
  48198. */
  48199. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48200. /**
  48201. * Stores the creation options.
  48202. */
  48203. private readonly _scene;
  48204. private _options;
  48205. /**
  48206. * This observable will be notified with any error during the creation of the environment,
  48207. * mainly texture creation errors.
  48208. */
  48209. onErrorObservable: Observable<{
  48210. message?: string;
  48211. exception?: any;
  48212. }>;
  48213. /**
  48214. * constructor
  48215. * @param options Defines the options we want to customize the helper
  48216. * @param scene The scene to add the material to
  48217. */
  48218. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48219. /**
  48220. * Updates the background according to the new options
  48221. * @param options
  48222. */
  48223. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48224. /**
  48225. * Sets the primary color of all the available elements.
  48226. * @param color the main color to affect to the ground and the background
  48227. */
  48228. setMainColor(color: Color3): void;
  48229. /**
  48230. * Setup the image processing according to the specified options.
  48231. */
  48232. private _setupImageProcessing;
  48233. /**
  48234. * Setup the environment texture according to the specified options.
  48235. */
  48236. private _setupEnvironmentTexture;
  48237. /**
  48238. * Setup the background according to the specified options.
  48239. */
  48240. private _setupBackground;
  48241. /**
  48242. * Get the scene sizes according to the setup.
  48243. */
  48244. private _getSceneSize;
  48245. /**
  48246. * Setup the ground according to the specified options.
  48247. */
  48248. private _setupGround;
  48249. /**
  48250. * Setup the ground material according to the specified options.
  48251. */
  48252. private _setupGroundMaterial;
  48253. /**
  48254. * Setup the ground diffuse texture according to the specified options.
  48255. */
  48256. private _setupGroundDiffuseTexture;
  48257. /**
  48258. * Setup the ground mirror texture according to the specified options.
  48259. */
  48260. private _setupGroundMirrorTexture;
  48261. /**
  48262. * Setup the ground to receive the mirror texture.
  48263. */
  48264. private _setupMirrorInGroundMaterial;
  48265. /**
  48266. * Setup the skybox according to the specified options.
  48267. */
  48268. private _setupSkybox;
  48269. /**
  48270. * Setup the skybox material according to the specified options.
  48271. */
  48272. private _setupSkyboxMaterial;
  48273. /**
  48274. * Setup the skybox reflection texture according to the specified options.
  48275. */
  48276. private _setupSkyboxReflectionTexture;
  48277. private _errorHandler;
  48278. /**
  48279. * Dispose all the elements created by the Helper.
  48280. */
  48281. dispose(): void;
  48282. }
  48283. }
  48284. declare module "babylonjs/Helpers/photoDome" {
  48285. import { Observable } from "babylonjs/Misc/observable";
  48286. import { Nullable } from "babylonjs/types";
  48287. import { Scene } from "babylonjs/scene";
  48288. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48289. import { Mesh } from "babylonjs/Meshes/mesh";
  48290. import { Texture } from "babylonjs/Materials/Textures/texture";
  48291. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48292. import "babylonjs/Meshes/Builders/sphereBuilder";
  48293. /**
  48294. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48295. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48296. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48297. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48298. */
  48299. export class PhotoDome extends TransformNode {
  48300. /**
  48301. * Define the image as a Monoscopic panoramic 360 image.
  48302. */
  48303. static readonly MODE_MONOSCOPIC: number;
  48304. /**
  48305. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48306. */
  48307. static readonly MODE_TOPBOTTOM: number;
  48308. /**
  48309. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48310. */
  48311. static readonly MODE_SIDEBYSIDE: number;
  48312. private _useDirectMapping;
  48313. /**
  48314. * The texture being displayed on the sphere
  48315. */
  48316. protected _photoTexture: Texture;
  48317. /**
  48318. * Gets or sets the texture being displayed on the sphere
  48319. */
  48320. photoTexture: Texture;
  48321. /**
  48322. * Observable raised when an error occured while loading the 360 image
  48323. */
  48324. onLoadErrorObservable: Observable<string>;
  48325. /**
  48326. * The skybox material
  48327. */
  48328. protected _material: BackgroundMaterial;
  48329. /**
  48330. * The surface used for the skybox
  48331. */
  48332. protected _mesh: Mesh;
  48333. /**
  48334. * Gets the mesh used for the skybox.
  48335. */
  48336. readonly mesh: Mesh;
  48337. /**
  48338. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48339. * Also see the options.resolution property.
  48340. */
  48341. fovMultiplier: number;
  48342. private _imageMode;
  48343. /**
  48344. * Gets or set the current video mode for the video. It can be:
  48345. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48346. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48347. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48348. */
  48349. imageMode: number;
  48350. /**
  48351. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48352. * @param name Element's name, child elements will append suffixes for their own names.
  48353. * @param urlsOfPhoto defines the url of the photo to display
  48354. * @param options defines an object containing optional or exposed sub element properties
  48355. * @param onError defines a callback called when an error occured while loading the texture
  48356. */
  48357. constructor(name: string, urlOfPhoto: string, options: {
  48358. resolution?: number;
  48359. size?: number;
  48360. useDirectMapping?: boolean;
  48361. faceForward?: boolean;
  48362. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48363. private _onBeforeCameraRenderObserver;
  48364. private _changeImageMode;
  48365. /**
  48366. * Releases resources associated with this node.
  48367. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48368. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48369. */
  48370. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48371. }
  48372. }
  48373. declare module "babylonjs/Misc/rgbdTextureTools" {
  48374. import "babylonjs/Shaders/rgbdDecode.fragment";
  48375. import { Texture } from "babylonjs/Materials/Textures/texture";
  48376. /**
  48377. * Class used to host RGBD texture specific utilities
  48378. */
  48379. export class RGBDTextureTools {
  48380. /**
  48381. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48382. * @param texture the texture to expand.
  48383. */
  48384. static ExpandRGBDTexture(texture: Texture): void;
  48385. }
  48386. }
  48387. declare module "babylonjs/Misc/brdfTextureTools" {
  48388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48389. import { Scene } from "babylonjs/scene";
  48390. /**
  48391. * Class used to host texture specific utilities
  48392. */
  48393. export class BRDFTextureTools {
  48394. /**
  48395. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48396. * @param scene defines the hosting scene
  48397. * @returns the environment BRDF texture
  48398. */
  48399. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48400. private static _environmentBRDFBase64Texture;
  48401. }
  48402. }
  48403. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48404. import { Nullable } from "babylonjs/types";
  48405. import { Color3 } from "babylonjs/Maths/math.color";
  48406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48407. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48408. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48409. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48410. import { Engine } from "babylonjs/Engines/engine";
  48411. import { Scene } from "babylonjs/scene";
  48412. /**
  48413. * @hidden
  48414. */
  48415. export interface IMaterialClearCoatDefines {
  48416. CLEARCOAT: boolean;
  48417. CLEARCOAT_DEFAULTIOR: boolean;
  48418. CLEARCOAT_TEXTURE: boolean;
  48419. CLEARCOAT_TEXTUREDIRECTUV: number;
  48420. CLEARCOAT_BUMP: boolean;
  48421. CLEARCOAT_BUMPDIRECTUV: number;
  48422. CLEARCOAT_TINT: boolean;
  48423. CLEARCOAT_TINT_TEXTURE: boolean;
  48424. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48425. /** @hidden */
  48426. _areTexturesDirty: boolean;
  48427. }
  48428. /**
  48429. * Define the code related to the clear coat parameters of the pbr material.
  48430. */
  48431. export class PBRClearCoatConfiguration {
  48432. /**
  48433. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48434. * The default fits with a polyurethane material.
  48435. */
  48436. private static readonly _DefaultIndexOfRefraction;
  48437. private _isEnabled;
  48438. /**
  48439. * Defines if the clear coat is enabled in the material.
  48440. */
  48441. isEnabled: boolean;
  48442. /**
  48443. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48444. */
  48445. intensity: number;
  48446. /**
  48447. * Defines the clear coat layer roughness.
  48448. */
  48449. roughness: number;
  48450. private _indexOfRefraction;
  48451. /**
  48452. * Defines the index of refraction of the clear coat.
  48453. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48454. * The default fits with a polyurethane material.
  48455. * Changing the default value is more performance intensive.
  48456. */
  48457. indexOfRefraction: number;
  48458. private _texture;
  48459. /**
  48460. * Stores the clear coat values in a texture.
  48461. */
  48462. texture: Nullable<BaseTexture>;
  48463. private _bumpTexture;
  48464. /**
  48465. * Define the clear coat specific bump texture.
  48466. */
  48467. bumpTexture: Nullable<BaseTexture>;
  48468. private _isTintEnabled;
  48469. /**
  48470. * Defines if the clear coat tint is enabled in the material.
  48471. */
  48472. isTintEnabled: boolean;
  48473. /**
  48474. * Defines the clear coat tint of the material.
  48475. * This is only use if tint is enabled
  48476. */
  48477. tintColor: Color3;
  48478. /**
  48479. * Defines the distance at which the tint color should be found in the
  48480. * clear coat media.
  48481. * This is only use if tint is enabled
  48482. */
  48483. tintColorAtDistance: number;
  48484. /**
  48485. * Defines the clear coat layer thickness.
  48486. * This is only use if tint is enabled
  48487. */
  48488. tintThickness: number;
  48489. private _tintTexture;
  48490. /**
  48491. * Stores the clear tint values in a texture.
  48492. * rgb is tint
  48493. * a is a thickness factor
  48494. */
  48495. tintTexture: Nullable<BaseTexture>;
  48496. /** @hidden */
  48497. private _internalMarkAllSubMeshesAsTexturesDirty;
  48498. /** @hidden */
  48499. _markAllSubMeshesAsTexturesDirty(): void;
  48500. /**
  48501. * Instantiate a new istance of clear coat configuration.
  48502. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48503. */
  48504. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48505. /**
  48506. * Gets wehter the submesh is ready to be used or not.
  48507. * @param defines the list of "defines" to update.
  48508. * @param scene defines the scene the material belongs to.
  48509. * @param engine defines the engine the material belongs to.
  48510. * @param disableBumpMap defines wether the material disables bump or not.
  48511. * @returns - boolean indicating that the submesh is ready or not.
  48512. */
  48513. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48514. /**
  48515. * Checks to see if a texture is used in the material.
  48516. * @param defines the list of "defines" to update.
  48517. * @param scene defines the scene to the material belongs to.
  48518. */
  48519. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48520. /**
  48521. * Binds the material data.
  48522. * @param uniformBuffer defines the Uniform buffer to fill in.
  48523. * @param scene defines the scene the material belongs to.
  48524. * @param engine defines the engine the material belongs to.
  48525. * @param disableBumpMap defines wether the material disables bump or not.
  48526. * @param isFrozen defines wether the material is frozen or not.
  48527. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48528. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48529. */
  48530. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48531. /**
  48532. * Checks to see if a texture is used in the material.
  48533. * @param texture - Base texture to use.
  48534. * @returns - Boolean specifying if a texture is used in the material.
  48535. */
  48536. hasTexture(texture: BaseTexture): boolean;
  48537. /**
  48538. * Returns an array of the actively used textures.
  48539. * @param activeTextures Array of BaseTextures
  48540. */
  48541. getActiveTextures(activeTextures: BaseTexture[]): void;
  48542. /**
  48543. * Returns the animatable textures.
  48544. * @param animatables Array of animatable textures.
  48545. */
  48546. getAnimatables(animatables: IAnimatable[]): void;
  48547. /**
  48548. * Disposes the resources of the material.
  48549. * @param forceDisposeTextures - Forces the disposal of all textures.
  48550. */
  48551. dispose(forceDisposeTextures?: boolean): void;
  48552. /**
  48553. * Get the current class name of the texture useful for serialization or dynamic coding.
  48554. * @returns "PBRClearCoatConfiguration"
  48555. */
  48556. getClassName(): string;
  48557. /**
  48558. * Add fallbacks to the effect fallbacks list.
  48559. * @param defines defines the Base texture to use.
  48560. * @param fallbacks defines the current fallback list.
  48561. * @param currentRank defines the current fallback rank.
  48562. * @returns the new fallback rank.
  48563. */
  48564. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48565. /**
  48566. * Add the required uniforms to the current list.
  48567. * @param uniforms defines the current uniform list.
  48568. */
  48569. static AddUniforms(uniforms: string[]): void;
  48570. /**
  48571. * Add the required samplers to the current list.
  48572. * @param samplers defines the current sampler list.
  48573. */
  48574. static AddSamplers(samplers: string[]): void;
  48575. /**
  48576. * Add the required uniforms to the current buffer.
  48577. * @param uniformBuffer defines the current uniform buffer.
  48578. */
  48579. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48580. /**
  48581. * Makes a duplicate of the current configuration into another one.
  48582. * @param clearCoatConfiguration define the config where to copy the info
  48583. */
  48584. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48585. /**
  48586. * Serializes this clear coat configuration.
  48587. * @returns - An object with the serialized config.
  48588. */
  48589. serialize(): any;
  48590. /**
  48591. * Parses a anisotropy Configuration from a serialized object.
  48592. * @param source - Serialized object.
  48593. * @param scene Defines the scene we are parsing for
  48594. * @param rootUrl Defines the rootUrl to load from
  48595. */
  48596. parse(source: any, scene: Scene, rootUrl: string): void;
  48597. }
  48598. }
  48599. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48600. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48602. import { Vector2 } from "babylonjs/Maths/math.vector";
  48603. import { Scene } from "babylonjs/scene";
  48604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48605. import { Nullable } from "babylonjs/types";
  48606. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48607. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48608. /**
  48609. * @hidden
  48610. */
  48611. export interface IMaterialAnisotropicDefines {
  48612. ANISOTROPIC: boolean;
  48613. ANISOTROPIC_TEXTURE: boolean;
  48614. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48615. MAINUV1: boolean;
  48616. _areTexturesDirty: boolean;
  48617. _needUVs: boolean;
  48618. }
  48619. /**
  48620. * Define the code related to the anisotropic parameters of the pbr material.
  48621. */
  48622. export class PBRAnisotropicConfiguration {
  48623. private _isEnabled;
  48624. /**
  48625. * Defines if the anisotropy is enabled in the material.
  48626. */
  48627. isEnabled: boolean;
  48628. /**
  48629. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48630. */
  48631. intensity: number;
  48632. /**
  48633. * Defines if the effect is along the tangents, bitangents or in between.
  48634. * By default, the effect is "strectching" the highlights along the tangents.
  48635. */
  48636. direction: Vector2;
  48637. private _texture;
  48638. /**
  48639. * Stores the anisotropy values in a texture.
  48640. * rg is direction (like normal from -1 to 1)
  48641. * b is a intensity
  48642. */
  48643. texture: Nullable<BaseTexture>;
  48644. /** @hidden */
  48645. private _internalMarkAllSubMeshesAsTexturesDirty;
  48646. /** @hidden */
  48647. _markAllSubMeshesAsTexturesDirty(): void;
  48648. /**
  48649. * Instantiate a new istance of anisotropy configuration.
  48650. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48651. */
  48652. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48653. /**
  48654. * Specifies that the submesh is ready to be used.
  48655. * @param defines the list of "defines" to update.
  48656. * @param scene defines the scene the material belongs to.
  48657. * @returns - boolean indicating that the submesh is ready or not.
  48658. */
  48659. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48660. /**
  48661. * Checks to see if a texture is used in the material.
  48662. * @param defines the list of "defines" to update.
  48663. * @param mesh the mesh we are preparing the defines for.
  48664. * @param scene defines the scene the material belongs to.
  48665. */
  48666. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48667. /**
  48668. * Binds the material data.
  48669. * @param uniformBuffer defines the Uniform buffer to fill in.
  48670. * @param scene defines the scene the material belongs to.
  48671. * @param isFrozen defines wether the material is frozen or not.
  48672. */
  48673. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48674. /**
  48675. * Checks to see if a texture is used in the material.
  48676. * @param texture - Base texture to use.
  48677. * @returns - Boolean specifying if a texture is used in the material.
  48678. */
  48679. hasTexture(texture: BaseTexture): boolean;
  48680. /**
  48681. * Returns an array of the actively used textures.
  48682. * @param activeTextures Array of BaseTextures
  48683. */
  48684. getActiveTextures(activeTextures: BaseTexture[]): void;
  48685. /**
  48686. * Returns the animatable textures.
  48687. * @param animatables Array of animatable textures.
  48688. */
  48689. getAnimatables(animatables: IAnimatable[]): void;
  48690. /**
  48691. * Disposes the resources of the material.
  48692. * @param forceDisposeTextures - Forces the disposal of all textures.
  48693. */
  48694. dispose(forceDisposeTextures?: boolean): void;
  48695. /**
  48696. * Get the current class name of the texture useful for serialization or dynamic coding.
  48697. * @returns "PBRAnisotropicConfiguration"
  48698. */
  48699. getClassName(): string;
  48700. /**
  48701. * Add fallbacks to the effect fallbacks list.
  48702. * @param defines defines the Base texture to use.
  48703. * @param fallbacks defines the current fallback list.
  48704. * @param currentRank defines the current fallback rank.
  48705. * @returns the new fallback rank.
  48706. */
  48707. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48708. /**
  48709. * Add the required uniforms to the current list.
  48710. * @param uniforms defines the current uniform list.
  48711. */
  48712. static AddUniforms(uniforms: string[]): void;
  48713. /**
  48714. * Add the required uniforms to the current buffer.
  48715. * @param uniformBuffer defines the current uniform buffer.
  48716. */
  48717. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48718. /**
  48719. * Add the required samplers to the current list.
  48720. * @param samplers defines the current sampler list.
  48721. */
  48722. static AddSamplers(samplers: string[]): void;
  48723. /**
  48724. * Makes a duplicate of the current configuration into another one.
  48725. * @param anisotropicConfiguration define the config where to copy the info
  48726. */
  48727. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48728. /**
  48729. * Serializes this anisotropy configuration.
  48730. * @returns - An object with the serialized config.
  48731. */
  48732. serialize(): any;
  48733. /**
  48734. * Parses a anisotropy Configuration from a serialized object.
  48735. * @param source - Serialized object.
  48736. * @param scene Defines the scene we are parsing for
  48737. * @param rootUrl Defines the rootUrl to load from
  48738. */
  48739. parse(source: any, scene: Scene, rootUrl: string): void;
  48740. }
  48741. }
  48742. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48743. import { Scene } from "babylonjs/scene";
  48744. /**
  48745. * @hidden
  48746. */
  48747. export interface IMaterialBRDFDefines {
  48748. BRDF_V_HEIGHT_CORRELATED: boolean;
  48749. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48750. SPHERICAL_HARMONICS: boolean;
  48751. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48752. /** @hidden */
  48753. _areMiscDirty: boolean;
  48754. }
  48755. /**
  48756. * Define the code related to the BRDF parameters of the pbr material.
  48757. */
  48758. export class PBRBRDFConfiguration {
  48759. /**
  48760. * Default value used for the energy conservation.
  48761. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48762. */
  48763. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48764. /**
  48765. * Default value used for the Smith Visibility Height Correlated mode.
  48766. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48767. */
  48768. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48769. /**
  48770. * Default value used for the IBL diffuse part.
  48771. * This can help switching back to the polynomials mode globally which is a tiny bit
  48772. * less GPU intensive at the drawback of a lower quality.
  48773. */
  48774. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48775. /**
  48776. * Default value used for activating energy conservation for the specular workflow.
  48777. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48778. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48779. */
  48780. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48781. private _useEnergyConservation;
  48782. /**
  48783. * Defines if the material uses energy conservation.
  48784. */
  48785. useEnergyConservation: boolean;
  48786. private _useSmithVisibilityHeightCorrelated;
  48787. /**
  48788. * LEGACY Mode set to false
  48789. * Defines if the material uses height smith correlated visibility term.
  48790. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48791. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48792. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48793. * Not relying on height correlated will also disable energy conservation.
  48794. */
  48795. useSmithVisibilityHeightCorrelated: boolean;
  48796. private _useSphericalHarmonics;
  48797. /**
  48798. * LEGACY Mode set to false
  48799. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48800. * diffuse part of the IBL.
  48801. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48802. * to the ground truth.
  48803. */
  48804. useSphericalHarmonics: boolean;
  48805. private _useSpecularGlossinessInputEnergyConservation;
  48806. /**
  48807. * Defines if the material uses energy conservation, when the specular workflow is active.
  48808. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48809. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48810. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48811. */
  48812. useSpecularGlossinessInputEnergyConservation: boolean;
  48813. /** @hidden */
  48814. private _internalMarkAllSubMeshesAsMiscDirty;
  48815. /** @hidden */
  48816. _markAllSubMeshesAsMiscDirty(): void;
  48817. /**
  48818. * Instantiate a new istance of clear coat configuration.
  48819. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48820. */
  48821. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48822. /**
  48823. * Checks to see if a texture is used in the material.
  48824. * @param defines the list of "defines" to update.
  48825. */
  48826. prepareDefines(defines: IMaterialBRDFDefines): void;
  48827. /**
  48828. * Get the current class name of the texture useful for serialization or dynamic coding.
  48829. * @returns "PBRClearCoatConfiguration"
  48830. */
  48831. getClassName(): string;
  48832. /**
  48833. * Makes a duplicate of the current configuration into another one.
  48834. * @param brdfConfiguration define the config where to copy the info
  48835. */
  48836. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48837. /**
  48838. * Serializes this BRDF configuration.
  48839. * @returns - An object with the serialized config.
  48840. */
  48841. serialize(): any;
  48842. /**
  48843. * Parses a anisotropy Configuration from a serialized object.
  48844. * @param source - Serialized object.
  48845. * @param scene Defines the scene we are parsing for
  48846. * @param rootUrl Defines the rootUrl to load from
  48847. */
  48848. parse(source: any, scene: Scene, rootUrl: string): void;
  48849. }
  48850. }
  48851. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48852. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48853. import { Color3 } from "babylonjs/Maths/math.color";
  48854. import { Scene } from "babylonjs/scene";
  48855. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48856. import { Nullable } from "babylonjs/types";
  48857. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48858. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48859. /**
  48860. * @hidden
  48861. */
  48862. export interface IMaterialSheenDefines {
  48863. SHEEN: boolean;
  48864. SHEEN_TEXTURE: boolean;
  48865. SHEEN_TEXTUREDIRECTUV: number;
  48866. SHEEN_LINKWITHALBEDO: boolean;
  48867. /** @hidden */
  48868. _areTexturesDirty: boolean;
  48869. }
  48870. /**
  48871. * Define the code related to the Sheen parameters of the pbr material.
  48872. */
  48873. export class PBRSheenConfiguration {
  48874. private _isEnabled;
  48875. /**
  48876. * Defines if the material uses sheen.
  48877. */
  48878. isEnabled: boolean;
  48879. private _linkSheenWithAlbedo;
  48880. /**
  48881. * Defines if the sheen is linked to the sheen color.
  48882. */
  48883. linkSheenWithAlbedo: boolean;
  48884. /**
  48885. * Defines the sheen intensity.
  48886. */
  48887. intensity: number;
  48888. /**
  48889. * Defines the sheen color.
  48890. */
  48891. color: Color3;
  48892. private _texture;
  48893. /**
  48894. * Stores the sheen tint values in a texture.
  48895. * rgb is tint
  48896. * a is a intensity
  48897. */
  48898. texture: Nullable<BaseTexture>;
  48899. /** @hidden */
  48900. private _internalMarkAllSubMeshesAsTexturesDirty;
  48901. /** @hidden */
  48902. _markAllSubMeshesAsTexturesDirty(): void;
  48903. /**
  48904. * Instantiate a new istance of clear coat configuration.
  48905. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48906. */
  48907. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48908. /**
  48909. * Specifies that the submesh is ready to be used.
  48910. * @param defines the list of "defines" to update.
  48911. * @param scene defines the scene the material belongs to.
  48912. * @returns - boolean indicating that the submesh is ready or not.
  48913. */
  48914. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48915. /**
  48916. * Checks to see if a texture is used in the material.
  48917. * @param defines the list of "defines" to update.
  48918. * @param scene defines the scene the material belongs to.
  48919. */
  48920. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48921. /**
  48922. * Binds the material data.
  48923. * @param uniformBuffer defines the Uniform buffer to fill in.
  48924. * @param scene defines the scene the material belongs to.
  48925. * @param isFrozen defines wether the material is frozen or not.
  48926. */
  48927. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48928. /**
  48929. * Checks to see if a texture is used in the material.
  48930. * @param texture - Base texture to use.
  48931. * @returns - Boolean specifying if a texture is used in the material.
  48932. */
  48933. hasTexture(texture: BaseTexture): boolean;
  48934. /**
  48935. * Returns an array of the actively used textures.
  48936. * @param activeTextures Array of BaseTextures
  48937. */
  48938. getActiveTextures(activeTextures: BaseTexture[]): void;
  48939. /**
  48940. * Returns the animatable textures.
  48941. * @param animatables Array of animatable textures.
  48942. */
  48943. getAnimatables(animatables: IAnimatable[]): void;
  48944. /**
  48945. * Disposes the resources of the material.
  48946. * @param forceDisposeTextures - Forces the disposal of all textures.
  48947. */
  48948. dispose(forceDisposeTextures?: boolean): void;
  48949. /**
  48950. * Get the current class name of the texture useful for serialization or dynamic coding.
  48951. * @returns "PBRSheenConfiguration"
  48952. */
  48953. getClassName(): string;
  48954. /**
  48955. * Add fallbacks to the effect fallbacks list.
  48956. * @param defines defines the Base texture to use.
  48957. * @param fallbacks defines the current fallback list.
  48958. * @param currentRank defines the current fallback rank.
  48959. * @returns the new fallback rank.
  48960. */
  48961. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48962. /**
  48963. * Add the required uniforms to the current list.
  48964. * @param uniforms defines the current uniform list.
  48965. */
  48966. static AddUniforms(uniforms: string[]): void;
  48967. /**
  48968. * Add the required uniforms to the current buffer.
  48969. * @param uniformBuffer defines the current uniform buffer.
  48970. */
  48971. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48972. /**
  48973. * Add the required samplers to the current list.
  48974. * @param samplers defines the current sampler list.
  48975. */
  48976. static AddSamplers(samplers: string[]): void;
  48977. /**
  48978. * Makes a duplicate of the current configuration into another one.
  48979. * @param sheenConfiguration define the config where to copy the info
  48980. */
  48981. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48982. /**
  48983. * Serializes this BRDF configuration.
  48984. * @returns - An object with the serialized config.
  48985. */
  48986. serialize(): any;
  48987. /**
  48988. * Parses a anisotropy Configuration from a serialized object.
  48989. * @param source - Serialized object.
  48990. * @param scene Defines the scene we are parsing for
  48991. * @param rootUrl Defines the rootUrl to load from
  48992. */
  48993. parse(source: any, scene: Scene, rootUrl: string): void;
  48994. }
  48995. }
  48996. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48997. import { Nullable } from "babylonjs/types";
  48998. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48999. import { Color3 } from "babylonjs/Maths/math.color";
  49000. import { SmartArray } from "babylonjs/Misc/smartArray";
  49001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49002. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49003. import { Effect } from "babylonjs/Materials/effect";
  49004. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49005. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49006. import { Engine } from "babylonjs/Engines/engine";
  49007. import { Scene } from "babylonjs/scene";
  49008. /**
  49009. * @hidden
  49010. */
  49011. export interface IMaterialSubSurfaceDefines {
  49012. SUBSURFACE: boolean;
  49013. SS_REFRACTION: boolean;
  49014. SS_TRANSLUCENCY: boolean;
  49015. SS_SCATERRING: boolean;
  49016. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49017. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49018. SS_REFRACTIONMAP_3D: boolean;
  49019. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49020. SS_LODINREFRACTIONALPHA: boolean;
  49021. SS_GAMMAREFRACTION: boolean;
  49022. SS_RGBDREFRACTION: boolean;
  49023. SS_LINEARSPECULARREFRACTION: boolean;
  49024. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49025. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49026. /** @hidden */
  49027. _areTexturesDirty: boolean;
  49028. }
  49029. /**
  49030. * Define the code related to the sub surface parameters of the pbr material.
  49031. */
  49032. export class PBRSubSurfaceConfiguration {
  49033. private _isRefractionEnabled;
  49034. /**
  49035. * Defines if the refraction is enabled in the material.
  49036. */
  49037. isRefractionEnabled: boolean;
  49038. private _isTranslucencyEnabled;
  49039. /**
  49040. * Defines if the translucency is enabled in the material.
  49041. */
  49042. isTranslucencyEnabled: boolean;
  49043. private _isScatteringEnabled;
  49044. /**
  49045. * Defines the refraction intensity of the material.
  49046. * The refraction when enabled replaces the Diffuse part of the material.
  49047. * The intensity helps transitionning between diffuse and refraction.
  49048. */
  49049. refractionIntensity: number;
  49050. /**
  49051. * Defines the translucency intensity of the material.
  49052. * When translucency has been enabled, this defines how much of the "translucency"
  49053. * is addded to the diffuse part of the material.
  49054. */
  49055. translucencyIntensity: number;
  49056. /**
  49057. * Defines the scattering intensity of the material.
  49058. * When scattering has been enabled, this defines how much of the "scattered light"
  49059. * is addded to the diffuse part of the material.
  49060. */
  49061. scatteringIntensity: number;
  49062. private _thicknessTexture;
  49063. /**
  49064. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49065. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49066. * 0 would mean minimumThickness
  49067. * 1 would mean maximumThickness
  49068. * The other channels might be use as a mask to vary the different effects intensity.
  49069. */
  49070. thicknessTexture: Nullable<BaseTexture>;
  49071. private _refractionTexture;
  49072. /**
  49073. * Defines the texture to use for refraction.
  49074. */
  49075. refractionTexture: Nullable<BaseTexture>;
  49076. private _indexOfRefraction;
  49077. /**
  49078. * Defines the index of refraction used in the material.
  49079. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49080. */
  49081. indexOfRefraction: number;
  49082. private _invertRefractionY;
  49083. /**
  49084. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49085. */
  49086. invertRefractionY: boolean;
  49087. private _linkRefractionWithTransparency;
  49088. /**
  49089. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49090. * Materials half opaque for instance using refraction could benefit from this control.
  49091. */
  49092. linkRefractionWithTransparency: boolean;
  49093. /**
  49094. * Defines the minimum thickness stored in the thickness map.
  49095. * If no thickness map is defined, this value will be used to simulate thickness.
  49096. */
  49097. minimumThickness: number;
  49098. /**
  49099. * Defines the maximum thickness stored in the thickness map.
  49100. */
  49101. maximumThickness: number;
  49102. /**
  49103. * Defines the volume tint of the material.
  49104. * This is used for both translucency and scattering.
  49105. */
  49106. tintColor: Color3;
  49107. /**
  49108. * Defines the distance at which the tint color should be found in the media.
  49109. * This is used for refraction only.
  49110. */
  49111. tintColorAtDistance: number;
  49112. /**
  49113. * Defines how far each channel transmit through the media.
  49114. * It is defined as a color to simplify it selection.
  49115. */
  49116. diffusionDistance: Color3;
  49117. private _useMaskFromThicknessTexture;
  49118. /**
  49119. * Stores the intensity of the different subsurface effects in the thickness texture.
  49120. * * the green channel is the translucency intensity.
  49121. * * the blue channel is the scattering intensity.
  49122. * * the alpha channel is the refraction intensity.
  49123. */
  49124. useMaskFromThicknessTexture: boolean;
  49125. /** @hidden */
  49126. private _internalMarkAllSubMeshesAsTexturesDirty;
  49127. /** @hidden */
  49128. _markAllSubMeshesAsTexturesDirty(): void;
  49129. /**
  49130. * Instantiate a new istance of sub surface configuration.
  49131. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49132. */
  49133. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49134. /**
  49135. * Gets wehter the submesh is ready to be used or not.
  49136. * @param defines the list of "defines" to update.
  49137. * @param scene defines the scene the material belongs to.
  49138. * @returns - boolean indicating that the submesh is ready or not.
  49139. */
  49140. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49141. /**
  49142. * Checks to see if a texture is used in the material.
  49143. * @param defines the list of "defines" to update.
  49144. * @param scene defines the scene to the material belongs to.
  49145. */
  49146. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49147. /**
  49148. * Binds the material data.
  49149. * @param uniformBuffer defines the Uniform buffer to fill in.
  49150. * @param scene defines the scene the material belongs to.
  49151. * @param engine defines the engine the material belongs to.
  49152. * @param isFrozen defines wether the material is frozen or not.
  49153. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49154. */
  49155. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49156. /**
  49157. * Unbinds the material from the mesh.
  49158. * @param activeEffect defines the effect that should be unbound from.
  49159. * @returns true if unbound, otherwise false
  49160. */
  49161. unbind(activeEffect: Effect): boolean;
  49162. /**
  49163. * Returns the texture used for refraction or null if none is used.
  49164. * @param scene defines the scene the material belongs to.
  49165. * @returns - Refraction texture if present. If no refraction texture and refraction
  49166. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49167. */
  49168. private _getRefractionTexture;
  49169. /**
  49170. * Returns true if alpha blending should be disabled.
  49171. */
  49172. readonly disableAlphaBlending: boolean;
  49173. /**
  49174. * Fills the list of render target textures.
  49175. * @param renderTargets the list of render targets to update
  49176. */
  49177. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49178. /**
  49179. * Checks to see if a texture is used in the material.
  49180. * @param texture - Base texture to use.
  49181. * @returns - Boolean specifying if a texture is used in the material.
  49182. */
  49183. hasTexture(texture: BaseTexture): boolean;
  49184. /**
  49185. * Gets a boolean indicating that current material needs to register RTT
  49186. * @returns true if this uses a render target otherwise false.
  49187. */
  49188. hasRenderTargetTextures(): boolean;
  49189. /**
  49190. * Returns an array of the actively used textures.
  49191. * @param activeTextures Array of BaseTextures
  49192. */
  49193. getActiveTextures(activeTextures: BaseTexture[]): void;
  49194. /**
  49195. * Returns the animatable textures.
  49196. * @param animatables Array of animatable textures.
  49197. */
  49198. getAnimatables(animatables: IAnimatable[]): void;
  49199. /**
  49200. * Disposes the resources of the material.
  49201. * @param forceDisposeTextures - Forces the disposal of all textures.
  49202. */
  49203. dispose(forceDisposeTextures?: boolean): void;
  49204. /**
  49205. * Get the current class name of the texture useful for serialization or dynamic coding.
  49206. * @returns "PBRSubSurfaceConfiguration"
  49207. */
  49208. getClassName(): string;
  49209. /**
  49210. * Add fallbacks to the effect fallbacks list.
  49211. * @param defines defines the Base texture to use.
  49212. * @param fallbacks defines the current fallback list.
  49213. * @param currentRank defines the current fallback rank.
  49214. * @returns the new fallback rank.
  49215. */
  49216. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49217. /**
  49218. * Add the required uniforms to the current list.
  49219. * @param uniforms defines the current uniform list.
  49220. */
  49221. static AddUniforms(uniforms: string[]): void;
  49222. /**
  49223. * Add the required samplers to the current list.
  49224. * @param samplers defines the current sampler list.
  49225. */
  49226. static AddSamplers(samplers: string[]): void;
  49227. /**
  49228. * Add the required uniforms to the current buffer.
  49229. * @param uniformBuffer defines the current uniform buffer.
  49230. */
  49231. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49232. /**
  49233. * Makes a duplicate of the current configuration into another one.
  49234. * @param configuration define the config where to copy the info
  49235. */
  49236. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49237. /**
  49238. * Serializes this Sub Surface configuration.
  49239. * @returns - An object with the serialized config.
  49240. */
  49241. serialize(): any;
  49242. /**
  49243. * Parses a anisotropy Configuration from a serialized object.
  49244. * @param source - Serialized object.
  49245. * @param scene Defines the scene we are parsing for
  49246. * @param rootUrl Defines the rootUrl to load from
  49247. */
  49248. parse(source: any, scene: Scene, rootUrl: string): void;
  49249. }
  49250. }
  49251. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49252. /** @hidden */
  49253. export var pbrFragmentDeclaration: {
  49254. name: string;
  49255. shader: string;
  49256. };
  49257. }
  49258. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49259. /** @hidden */
  49260. export var pbrUboDeclaration: {
  49261. name: string;
  49262. shader: string;
  49263. };
  49264. }
  49265. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49266. /** @hidden */
  49267. export var pbrFragmentExtraDeclaration: {
  49268. name: string;
  49269. shader: string;
  49270. };
  49271. }
  49272. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49273. /** @hidden */
  49274. export var pbrFragmentSamplersDeclaration: {
  49275. name: string;
  49276. shader: string;
  49277. };
  49278. }
  49279. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49280. /** @hidden */
  49281. export var pbrHelperFunctions: {
  49282. name: string;
  49283. shader: string;
  49284. };
  49285. }
  49286. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49287. /** @hidden */
  49288. export var harmonicsFunctions: {
  49289. name: string;
  49290. shader: string;
  49291. };
  49292. }
  49293. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49294. /** @hidden */
  49295. export var pbrDirectLightingSetupFunctions: {
  49296. name: string;
  49297. shader: string;
  49298. };
  49299. }
  49300. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49301. /** @hidden */
  49302. export var pbrDirectLightingFalloffFunctions: {
  49303. name: string;
  49304. shader: string;
  49305. };
  49306. }
  49307. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49308. /** @hidden */
  49309. export var pbrBRDFFunctions: {
  49310. name: string;
  49311. shader: string;
  49312. };
  49313. }
  49314. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49315. /** @hidden */
  49316. export var pbrDirectLightingFunctions: {
  49317. name: string;
  49318. shader: string;
  49319. };
  49320. }
  49321. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49322. /** @hidden */
  49323. export var pbrIBLFunctions: {
  49324. name: string;
  49325. shader: string;
  49326. };
  49327. }
  49328. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49329. /** @hidden */
  49330. export var pbrDebug: {
  49331. name: string;
  49332. shader: string;
  49333. };
  49334. }
  49335. declare module "babylonjs/Shaders/pbr.fragment" {
  49336. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49337. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49338. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49339. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49340. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49341. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49342. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49343. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49344. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49345. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49346. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49347. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49348. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49349. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49350. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49351. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49352. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49353. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49354. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49355. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49356. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49357. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49359. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49360. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49361. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49362. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49363. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49364. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49365. /** @hidden */
  49366. export var pbrPixelShader: {
  49367. name: string;
  49368. shader: string;
  49369. };
  49370. }
  49371. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49372. /** @hidden */
  49373. export var pbrVertexDeclaration: {
  49374. name: string;
  49375. shader: string;
  49376. };
  49377. }
  49378. declare module "babylonjs/Shaders/pbr.vertex" {
  49379. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49380. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49381. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49382. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49383. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49384. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49385. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49387. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49388. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49389. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49390. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49392. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49394. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49395. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49396. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49397. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49398. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49399. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49400. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49401. /** @hidden */
  49402. export var pbrVertexShader: {
  49403. name: string;
  49404. shader: string;
  49405. };
  49406. }
  49407. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49408. import { Nullable } from "babylonjs/types";
  49409. import { Scene } from "babylonjs/scene";
  49410. import { Matrix } from "babylonjs/Maths/math.vector";
  49411. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49413. import { Mesh } from "babylonjs/Meshes/mesh";
  49414. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49415. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49416. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49417. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49418. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49419. import { Color3 } from "babylonjs/Maths/math.color";
  49420. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49421. import { Material } from "babylonjs/Materials/material";
  49422. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49423. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49425. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49426. import "babylonjs/Shaders/pbr.fragment";
  49427. import "babylonjs/Shaders/pbr.vertex";
  49428. /**
  49429. * Manages the defines for the PBR Material.
  49430. * @hidden
  49431. */
  49432. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49433. PBR: boolean;
  49434. MAINUV1: boolean;
  49435. MAINUV2: boolean;
  49436. UV1: boolean;
  49437. UV2: boolean;
  49438. ALBEDO: boolean;
  49439. ALBEDODIRECTUV: number;
  49440. VERTEXCOLOR: boolean;
  49441. AMBIENT: boolean;
  49442. AMBIENTDIRECTUV: number;
  49443. AMBIENTINGRAYSCALE: boolean;
  49444. OPACITY: boolean;
  49445. VERTEXALPHA: boolean;
  49446. OPACITYDIRECTUV: number;
  49447. OPACITYRGB: boolean;
  49448. ALPHATEST: boolean;
  49449. DEPTHPREPASS: boolean;
  49450. ALPHABLEND: boolean;
  49451. ALPHAFROMALBEDO: boolean;
  49452. ALPHATESTVALUE: string;
  49453. SPECULAROVERALPHA: boolean;
  49454. RADIANCEOVERALPHA: boolean;
  49455. ALPHAFRESNEL: boolean;
  49456. LINEARALPHAFRESNEL: boolean;
  49457. PREMULTIPLYALPHA: boolean;
  49458. EMISSIVE: boolean;
  49459. EMISSIVEDIRECTUV: number;
  49460. REFLECTIVITY: boolean;
  49461. REFLECTIVITYDIRECTUV: number;
  49462. SPECULARTERM: boolean;
  49463. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49464. MICROSURFACEAUTOMATIC: boolean;
  49465. LODBASEDMICROSFURACE: boolean;
  49466. MICROSURFACEMAP: boolean;
  49467. MICROSURFACEMAPDIRECTUV: number;
  49468. METALLICWORKFLOW: boolean;
  49469. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49470. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49471. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49472. AOSTOREINMETALMAPRED: boolean;
  49473. ENVIRONMENTBRDF: boolean;
  49474. ENVIRONMENTBRDF_RGBD: boolean;
  49475. NORMAL: boolean;
  49476. TANGENT: boolean;
  49477. BUMP: boolean;
  49478. BUMPDIRECTUV: number;
  49479. OBJECTSPACE_NORMALMAP: boolean;
  49480. PARALLAX: boolean;
  49481. PARALLAXOCCLUSION: boolean;
  49482. NORMALXYSCALE: boolean;
  49483. LIGHTMAP: boolean;
  49484. LIGHTMAPDIRECTUV: number;
  49485. USELIGHTMAPASSHADOWMAP: boolean;
  49486. GAMMALIGHTMAP: boolean;
  49487. RGBDLIGHTMAP: boolean;
  49488. REFLECTION: boolean;
  49489. REFLECTIONMAP_3D: boolean;
  49490. REFLECTIONMAP_SPHERICAL: boolean;
  49491. REFLECTIONMAP_PLANAR: boolean;
  49492. REFLECTIONMAP_CUBIC: boolean;
  49493. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49494. REFLECTIONMAP_PROJECTION: boolean;
  49495. REFLECTIONMAP_SKYBOX: boolean;
  49496. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49497. REFLECTIONMAP_EXPLICIT: boolean;
  49498. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49499. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49500. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49501. INVERTCUBICMAP: boolean;
  49502. USESPHERICALFROMREFLECTIONMAP: boolean;
  49503. USEIRRADIANCEMAP: boolean;
  49504. SPHERICAL_HARMONICS: boolean;
  49505. USESPHERICALINVERTEX: boolean;
  49506. REFLECTIONMAP_OPPOSITEZ: boolean;
  49507. LODINREFLECTIONALPHA: boolean;
  49508. GAMMAREFLECTION: boolean;
  49509. RGBDREFLECTION: boolean;
  49510. LINEARSPECULARREFLECTION: boolean;
  49511. RADIANCEOCCLUSION: boolean;
  49512. HORIZONOCCLUSION: boolean;
  49513. INSTANCES: boolean;
  49514. NUM_BONE_INFLUENCERS: number;
  49515. BonesPerMesh: number;
  49516. BONETEXTURE: boolean;
  49517. NONUNIFORMSCALING: boolean;
  49518. MORPHTARGETS: boolean;
  49519. MORPHTARGETS_NORMAL: boolean;
  49520. MORPHTARGETS_TANGENT: boolean;
  49521. MORPHTARGETS_UV: boolean;
  49522. NUM_MORPH_INFLUENCERS: number;
  49523. IMAGEPROCESSING: boolean;
  49524. VIGNETTE: boolean;
  49525. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49526. VIGNETTEBLENDMODEOPAQUE: boolean;
  49527. TONEMAPPING: boolean;
  49528. TONEMAPPING_ACES: boolean;
  49529. CONTRAST: boolean;
  49530. COLORCURVES: boolean;
  49531. COLORGRADING: boolean;
  49532. COLORGRADING3D: boolean;
  49533. SAMPLER3DGREENDEPTH: boolean;
  49534. SAMPLER3DBGRMAP: boolean;
  49535. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49536. EXPOSURE: boolean;
  49537. MULTIVIEW: boolean;
  49538. USEPHYSICALLIGHTFALLOFF: boolean;
  49539. USEGLTFLIGHTFALLOFF: boolean;
  49540. TWOSIDEDLIGHTING: boolean;
  49541. SHADOWFLOAT: boolean;
  49542. CLIPPLANE: boolean;
  49543. CLIPPLANE2: boolean;
  49544. CLIPPLANE3: boolean;
  49545. CLIPPLANE4: boolean;
  49546. POINTSIZE: boolean;
  49547. FOG: boolean;
  49548. LOGARITHMICDEPTH: boolean;
  49549. FORCENORMALFORWARD: boolean;
  49550. SPECULARAA: boolean;
  49551. CLEARCOAT: boolean;
  49552. CLEARCOAT_DEFAULTIOR: boolean;
  49553. CLEARCOAT_TEXTURE: boolean;
  49554. CLEARCOAT_TEXTUREDIRECTUV: number;
  49555. CLEARCOAT_BUMP: boolean;
  49556. CLEARCOAT_BUMPDIRECTUV: number;
  49557. CLEARCOAT_TINT: boolean;
  49558. CLEARCOAT_TINT_TEXTURE: boolean;
  49559. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49560. ANISOTROPIC: boolean;
  49561. ANISOTROPIC_TEXTURE: boolean;
  49562. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49563. BRDF_V_HEIGHT_CORRELATED: boolean;
  49564. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49565. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49566. SHEEN: boolean;
  49567. SHEEN_TEXTURE: boolean;
  49568. SHEEN_TEXTUREDIRECTUV: number;
  49569. SHEEN_LINKWITHALBEDO: boolean;
  49570. SUBSURFACE: boolean;
  49571. SS_REFRACTION: boolean;
  49572. SS_TRANSLUCENCY: boolean;
  49573. SS_SCATERRING: boolean;
  49574. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49575. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49576. SS_REFRACTIONMAP_3D: boolean;
  49577. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49578. SS_LODINREFRACTIONALPHA: boolean;
  49579. SS_GAMMAREFRACTION: boolean;
  49580. SS_RGBDREFRACTION: boolean;
  49581. SS_LINEARSPECULARREFRACTION: boolean;
  49582. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49583. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49584. UNLIT: boolean;
  49585. DEBUGMODE: number;
  49586. /**
  49587. * Initializes the PBR Material defines.
  49588. */
  49589. constructor();
  49590. /**
  49591. * Resets the PBR Material defines.
  49592. */
  49593. reset(): void;
  49594. }
  49595. /**
  49596. * The Physically based material base class of BJS.
  49597. *
  49598. * This offers the main features of a standard PBR material.
  49599. * For more information, please refer to the documentation :
  49600. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49601. */
  49602. export abstract class PBRBaseMaterial extends PushMaterial {
  49603. /**
  49604. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49605. */
  49606. static readonly PBRMATERIAL_OPAQUE: number;
  49607. /**
  49608. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49609. */
  49610. static readonly PBRMATERIAL_ALPHATEST: number;
  49611. /**
  49612. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49613. */
  49614. static readonly PBRMATERIAL_ALPHABLEND: number;
  49615. /**
  49616. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49617. * They are also discarded below the alpha cutoff threshold to improve performances.
  49618. */
  49619. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49620. /**
  49621. * Defines the default value of how much AO map is occluding the analytical lights
  49622. * (point spot...).
  49623. */
  49624. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49625. /**
  49626. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49627. */
  49628. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49629. /**
  49630. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49631. * to enhance interoperability with other engines.
  49632. */
  49633. static readonly LIGHTFALLOFF_GLTF: number;
  49634. /**
  49635. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49636. * to enhance interoperability with other materials.
  49637. */
  49638. static readonly LIGHTFALLOFF_STANDARD: number;
  49639. /**
  49640. * Intensity of the direct lights e.g. the four lights available in your scene.
  49641. * This impacts both the direct diffuse and specular highlights.
  49642. */
  49643. protected _directIntensity: number;
  49644. /**
  49645. * Intensity of the emissive part of the material.
  49646. * This helps controlling the emissive effect without modifying the emissive color.
  49647. */
  49648. protected _emissiveIntensity: number;
  49649. /**
  49650. * Intensity of the environment e.g. how much the environment will light the object
  49651. * either through harmonics for rough material or through the refelction for shiny ones.
  49652. */
  49653. protected _environmentIntensity: number;
  49654. /**
  49655. * This is a special control allowing the reduction of the specular highlights coming from the
  49656. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49657. */
  49658. protected _specularIntensity: number;
  49659. /**
  49660. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49661. */
  49662. private _lightingInfos;
  49663. /**
  49664. * Debug Control allowing disabling the bump map on this material.
  49665. */
  49666. protected _disableBumpMap: boolean;
  49667. /**
  49668. * AKA Diffuse Texture in standard nomenclature.
  49669. */
  49670. protected _albedoTexture: Nullable<BaseTexture>;
  49671. /**
  49672. * AKA Occlusion Texture in other nomenclature.
  49673. */
  49674. protected _ambientTexture: Nullable<BaseTexture>;
  49675. /**
  49676. * AKA Occlusion Texture Intensity in other nomenclature.
  49677. */
  49678. protected _ambientTextureStrength: number;
  49679. /**
  49680. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49681. * 1 means it completely occludes it
  49682. * 0 mean it has no impact
  49683. */
  49684. protected _ambientTextureImpactOnAnalyticalLights: number;
  49685. /**
  49686. * Stores the alpha values in a texture.
  49687. */
  49688. protected _opacityTexture: Nullable<BaseTexture>;
  49689. /**
  49690. * Stores the reflection values in a texture.
  49691. */
  49692. protected _reflectionTexture: Nullable<BaseTexture>;
  49693. /**
  49694. * Stores the emissive values in a texture.
  49695. */
  49696. protected _emissiveTexture: Nullable<BaseTexture>;
  49697. /**
  49698. * AKA Specular texture in other nomenclature.
  49699. */
  49700. protected _reflectivityTexture: Nullable<BaseTexture>;
  49701. /**
  49702. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49703. */
  49704. protected _metallicTexture: Nullable<BaseTexture>;
  49705. /**
  49706. * Specifies the metallic scalar of the metallic/roughness workflow.
  49707. * Can also be used to scale the metalness values of the metallic texture.
  49708. */
  49709. protected _metallic: Nullable<number>;
  49710. /**
  49711. * Specifies the roughness scalar of the metallic/roughness workflow.
  49712. * Can also be used to scale the roughness values of the metallic texture.
  49713. */
  49714. protected _roughness: Nullable<number>;
  49715. /**
  49716. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49717. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49718. */
  49719. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49720. /**
  49721. * Stores surface normal data used to displace a mesh in a texture.
  49722. */
  49723. protected _bumpTexture: Nullable<BaseTexture>;
  49724. /**
  49725. * Stores the pre-calculated light information of a mesh in a texture.
  49726. */
  49727. protected _lightmapTexture: Nullable<BaseTexture>;
  49728. /**
  49729. * The color of a material in ambient lighting.
  49730. */
  49731. protected _ambientColor: Color3;
  49732. /**
  49733. * AKA Diffuse Color in other nomenclature.
  49734. */
  49735. protected _albedoColor: Color3;
  49736. /**
  49737. * AKA Specular Color in other nomenclature.
  49738. */
  49739. protected _reflectivityColor: Color3;
  49740. /**
  49741. * The color applied when light is reflected from a material.
  49742. */
  49743. protected _reflectionColor: Color3;
  49744. /**
  49745. * The color applied when light is emitted from a material.
  49746. */
  49747. protected _emissiveColor: Color3;
  49748. /**
  49749. * AKA Glossiness in other nomenclature.
  49750. */
  49751. protected _microSurface: number;
  49752. /**
  49753. * Specifies that the material will use the light map as a show map.
  49754. */
  49755. protected _useLightmapAsShadowmap: boolean;
  49756. /**
  49757. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49758. * makes the reflect vector face the model (under horizon).
  49759. */
  49760. protected _useHorizonOcclusion: boolean;
  49761. /**
  49762. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49763. * too much the area relying on ambient texture to define their ambient occlusion.
  49764. */
  49765. protected _useRadianceOcclusion: boolean;
  49766. /**
  49767. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49768. */
  49769. protected _useAlphaFromAlbedoTexture: boolean;
  49770. /**
  49771. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49772. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49773. */
  49774. protected _useSpecularOverAlpha: boolean;
  49775. /**
  49776. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49777. */
  49778. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49779. /**
  49780. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49781. */
  49782. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49783. /**
  49784. * Specifies if the metallic texture contains the roughness information in its green channel.
  49785. */
  49786. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49787. /**
  49788. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49789. */
  49790. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49791. /**
  49792. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49793. */
  49794. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49795. /**
  49796. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49797. */
  49798. protected _useAmbientInGrayScale: boolean;
  49799. /**
  49800. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49801. * The material will try to infer what glossiness each pixel should be.
  49802. */
  49803. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49804. /**
  49805. * Defines the falloff type used in this material.
  49806. * It by default is Physical.
  49807. */
  49808. protected _lightFalloff: number;
  49809. /**
  49810. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49811. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49812. */
  49813. protected _useRadianceOverAlpha: boolean;
  49814. /**
  49815. * Allows using an object space normal map (instead of tangent space).
  49816. */
  49817. protected _useObjectSpaceNormalMap: boolean;
  49818. /**
  49819. * Allows using the bump map in parallax mode.
  49820. */
  49821. protected _useParallax: boolean;
  49822. /**
  49823. * Allows using the bump map in parallax occlusion mode.
  49824. */
  49825. protected _useParallaxOcclusion: boolean;
  49826. /**
  49827. * Controls the scale bias of the parallax mode.
  49828. */
  49829. protected _parallaxScaleBias: number;
  49830. /**
  49831. * If sets to true, disables all the lights affecting the material.
  49832. */
  49833. protected _disableLighting: boolean;
  49834. /**
  49835. * Number of Simultaneous lights allowed on the material.
  49836. */
  49837. protected _maxSimultaneousLights: number;
  49838. /**
  49839. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49840. */
  49841. protected _invertNormalMapX: boolean;
  49842. /**
  49843. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49844. */
  49845. protected _invertNormalMapY: boolean;
  49846. /**
  49847. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49848. */
  49849. protected _twoSidedLighting: boolean;
  49850. /**
  49851. * Defines the alpha limits in alpha test mode.
  49852. */
  49853. protected _alphaCutOff: number;
  49854. /**
  49855. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49856. */
  49857. protected _forceAlphaTest: boolean;
  49858. /**
  49859. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49860. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49861. */
  49862. protected _useAlphaFresnel: boolean;
  49863. /**
  49864. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49865. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49866. */
  49867. protected _useLinearAlphaFresnel: boolean;
  49868. /**
  49869. * The transparency mode of the material.
  49870. */
  49871. protected _transparencyMode: Nullable<number>;
  49872. /**
  49873. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49874. * from cos thetav and roughness:
  49875. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49876. */
  49877. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49878. /**
  49879. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49880. */
  49881. protected _forceIrradianceInFragment: boolean;
  49882. /**
  49883. * Force normal to face away from face.
  49884. */
  49885. protected _forceNormalForward: boolean;
  49886. /**
  49887. * Enables specular anti aliasing in the PBR shader.
  49888. * It will both interacts on the Geometry for analytical and IBL lighting.
  49889. * It also prefilter the roughness map based on the bump values.
  49890. */
  49891. protected _enableSpecularAntiAliasing: boolean;
  49892. /**
  49893. * Default configuration related to image processing available in the PBR Material.
  49894. */
  49895. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49896. /**
  49897. * Keep track of the image processing observer to allow dispose and replace.
  49898. */
  49899. private _imageProcessingObserver;
  49900. /**
  49901. * Attaches a new image processing configuration to the PBR Material.
  49902. * @param configuration
  49903. */
  49904. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49905. /**
  49906. * Stores the available render targets.
  49907. */
  49908. private _renderTargets;
  49909. /**
  49910. * Sets the global ambient color for the material used in lighting calculations.
  49911. */
  49912. private _globalAmbientColor;
  49913. /**
  49914. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49915. */
  49916. private _useLogarithmicDepth;
  49917. /**
  49918. * If set to true, no lighting calculations will be applied.
  49919. */
  49920. private _unlit;
  49921. private _debugMode;
  49922. /**
  49923. * @hidden
  49924. * This is reserved for the inspector.
  49925. * Defines the material debug mode.
  49926. * It helps seeing only some components of the material while troubleshooting.
  49927. */
  49928. debugMode: number;
  49929. /**
  49930. * @hidden
  49931. * This is reserved for the inspector.
  49932. * Specify from where on screen the debug mode should start.
  49933. * The value goes from -1 (full screen) to 1 (not visible)
  49934. * It helps with side by side comparison against the final render
  49935. * This defaults to -1
  49936. */
  49937. private debugLimit;
  49938. /**
  49939. * @hidden
  49940. * This is reserved for the inspector.
  49941. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49942. * You can use the factor to better multiply the final value.
  49943. */
  49944. private debugFactor;
  49945. /**
  49946. * Defines the clear coat layer parameters for the material.
  49947. */
  49948. readonly clearCoat: PBRClearCoatConfiguration;
  49949. /**
  49950. * Defines the anisotropic parameters for the material.
  49951. */
  49952. readonly anisotropy: PBRAnisotropicConfiguration;
  49953. /**
  49954. * Defines the BRDF parameters for the material.
  49955. */
  49956. readonly brdf: PBRBRDFConfiguration;
  49957. /**
  49958. * Defines the Sheen parameters for the material.
  49959. */
  49960. readonly sheen: PBRSheenConfiguration;
  49961. /**
  49962. * Defines the SubSurface parameters for the material.
  49963. */
  49964. readonly subSurface: PBRSubSurfaceConfiguration;
  49965. /**
  49966. * Custom callback helping to override the default shader used in the material.
  49967. */
  49968. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49969. protected _rebuildInParallel: boolean;
  49970. /**
  49971. * Instantiates a new PBRMaterial instance.
  49972. *
  49973. * @param name The material name
  49974. * @param scene The scene the material will be use in.
  49975. */
  49976. constructor(name: string, scene: Scene);
  49977. /**
  49978. * Gets a boolean indicating that current material needs to register RTT
  49979. */
  49980. readonly hasRenderTargetTextures: boolean;
  49981. /**
  49982. * Gets the name of the material class.
  49983. */
  49984. getClassName(): string;
  49985. /**
  49986. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49987. */
  49988. /**
  49989. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49990. */
  49991. useLogarithmicDepth: boolean;
  49992. /**
  49993. * Gets the current transparency mode.
  49994. */
  49995. /**
  49996. * Sets the transparency mode of the material.
  49997. *
  49998. * | Value | Type | Description |
  49999. * | ----- | ----------------------------------- | ----------- |
  50000. * | 0 | OPAQUE | |
  50001. * | 1 | ALPHATEST | |
  50002. * | 2 | ALPHABLEND | |
  50003. * | 3 | ALPHATESTANDBLEND | |
  50004. *
  50005. */
  50006. transparencyMode: Nullable<number>;
  50007. /**
  50008. * Returns true if alpha blending should be disabled.
  50009. */
  50010. private readonly _disableAlphaBlending;
  50011. /**
  50012. * Specifies whether or not this material should be rendered in alpha blend mode.
  50013. */
  50014. needAlphaBlending(): boolean;
  50015. /**
  50016. * Specifies if the mesh will require alpha blending.
  50017. * @param mesh - BJS mesh.
  50018. */
  50019. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50020. /**
  50021. * Specifies whether or not this material should be rendered in alpha test mode.
  50022. */
  50023. needAlphaTesting(): boolean;
  50024. /**
  50025. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50026. */
  50027. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50028. /**
  50029. * Gets the texture used for the alpha test.
  50030. */
  50031. getAlphaTestTexture(): Nullable<BaseTexture>;
  50032. /**
  50033. * Specifies that the submesh is ready to be used.
  50034. * @param mesh - BJS mesh.
  50035. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50036. * @param useInstances - Specifies that instances should be used.
  50037. * @returns - boolean indicating that the submesh is ready or not.
  50038. */
  50039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50040. /**
  50041. * Specifies if the material uses metallic roughness workflow.
  50042. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50043. */
  50044. isMetallicWorkflow(): boolean;
  50045. private _prepareEffect;
  50046. private _prepareDefines;
  50047. /**
  50048. * Force shader compilation
  50049. */
  50050. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50051. clipPlane: boolean;
  50052. }>): void;
  50053. /**
  50054. * Initializes the uniform buffer layout for the shader.
  50055. */
  50056. buildUniformLayout(): void;
  50057. /**
  50058. * Unbinds the material from the mesh
  50059. */
  50060. unbind(): void;
  50061. /**
  50062. * Binds the submesh data.
  50063. * @param world - The world matrix.
  50064. * @param mesh - The BJS mesh.
  50065. * @param subMesh - A submesh of the BJS mesh.
  50066. */
  50067. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50068. /**
  50069. * Returns the animatable textures.
  50070. * @returns - Array of animatable textures.
  50071. */
  50072. getAnimatables(): IAnimatable[];
  50073. /**
  50074. * Returns the texture used for reflections.
  50075. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50076. */
  50077. private _getReflectionTexture;
  50078. /**
  50079. * Returns an array of the actively used textures.
  50080. * @returns - Array of BaseTextures
  50081. */
  50082. getActiveTextures(): BaseTexture[];
  50083. /**
  50084. * Checks to see if a texture is used in the material.
  50085. * @param texture - Base texture to use.
  50086. * @returns - Boolean specifying if a texture is used in the material.
  50087. */
  50088. hasTexture(texture: BaseTexture): boolean;
  50089. /**
  50090. * Disposes the resources of the material.
  50091. * @param forceDisposeEffect - Forces the disposal of effects.
  50092. * @param forceDisposeTextures - Forces the disposal of all textures.
  50093. */
  50094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50095. }
  50096. }
  50097. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50098. import { Nullable } from "babylonjs/types";
  50099. import { Scene } from "babylonjs/scene";
  50100. import { Color3 } from "babylonjs/Maths/math.color";
  50101. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50102. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50104. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50105. /**
  50106. * The Physically based material of BJS.
  50107. *
  50108. * This offers the main features of a standard PBR material.
  50109. * For more information, please refer to the documentation :
  50110. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50111. */
  50112. export class PBRMaterial extends PBRBaseMaterial {
  50113. /**
  50114. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50115. */
  50116. static readonly PBRMATERIAL_OPAQUE: number;
  50117. /**
  50118. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50119. */
  50120. static readonly PBRMATERIAL_ALPHATEST: number;
  50121. /**
  50122. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50123. */
  50124. static readonly PBRMATERIAL_ALPHABLEND: number;
  50125. /**
  50126. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50127. * They are also discarded below the alpha cutoff threshold to improve performances.
  50128. */
  50129. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50130. /**
  50131. * Defines the default value of how much AO map is occluding the analytical lights
  50132. * (point spot...).
  50133. */
  50134. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50135. /**
  50136. * Intensity of the direct lights e.g. the four lights available in your scene.
  50137. * This impacts both the direct diffuse and specular highlights.
  50138. */
  50139. directIntensity: number;
  50140. /**
  50141. * Intensity of the emissive part of the material.
  50142. * This helps controlling the emissive effect without modifying the emissive color.
  50143. */
  50144. emissiveIntensity: number;
  50145. /**
  50146. * Intensity of the environment e.g. how much the environment will light the object
  50147. * either through harmonics for rough material or through the refelction for shiny ones.
  50148. */
  50149. environmentIntensity: number;
  50150. /**
  50151. * This is a special control allowing the reduction of the specular highlights coming from the
  50152. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50153. */
  50154. specularIntensity: number;
  50155. /**
  50156. * Debug Control allowing disabling the bump map on this material.
  50157. */
  50158. disableBumpMap: boolean;
  50159. /**
  50160. * AKA Diffuse Texture in standard nomenclature.
  50161. */
  50162. albedoTexture: BaseTexture;
  50163. /**
  50164. * AKA Occlusion Texture in other nomenclature.
  50165. */
  50166. ambientTexture: BaseTexture;
  50167. /**
  50168. * AKA Occlusion Texture Intensity in other nomenclature.
  50169. */
  50170. ambientTextureStrength: number;
  50171. /**
  50172. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50173. * 1 means it completely occludes it
  50174. * 0 mean it has no impact
  50175. */
  50176. ambientTextureImpactOnAnalyticalLights: number;
  50177. /**
  50178. * Stores the alpha values in a texture.
  50179. */
  50180. opacityTexture: BaseTexture;
  50181. /**
  50182. * Stores the reflection values in a texture.
  50183. */
  50184. reflectionTexture: Nullable<BaseTexture>;
  50185. /**
  50186. * Stores the emissive values in a texture.
  50187. */
  50188. emissiveTexture: BaseTexture;
  50189. /**
  50190. * AKA Specular texture in other nomenclature.
  50191. */
  50192. reflectivityTexture: BaseTexture;
  50193. /**
  50194. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50195. */
  50196. metallicTexture: BaseTexture;
  50197. /**
  50198. * Specifies the metallic scalar of the metallic/roughness workflow.
  50199. * Can also be used to scale the metalness values of the metallic texture.
  50200. */
  50201. metallic: Nullable<number>;
  50202. /**
  50203. * Specifies the roughness scalar of the metallic/roughness workflow.
  50204. * Can also be used to scale the roughness values of the metallic texture.
  50205. */
  50206. roughness: Nullable<number>;
  50207. /**
  50208. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50209. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50210. */
  50211. microSurfaceTexture: BaseTexture;
  50212. /**
  50213. * Stores surface normal data used to displace a mesh in a texture.
  50214. */
  50215. bumpTexture: BaseTexture;
  50216. /**
  50217. * Stores the pre-calculated light information of a mesh in a texture.
  50218. */
  50219. lightmapTexture: BaseTexture;
  50220. /**
  50221. * Stores the refracted light information in a texture.
  50222. */
  50223. refractionTexture: Nullable<BaseTexture>;
  50224. /**
  50225. * The color of a material in ambient lighting.
  50226. */
  50227. ambientColor: Color3;
  50228. /**
  50229. * AKA Diffuse Color in other nomenclature.
  50230. */
  50231. albedoColor: Color3;
  50232. /**
  50233. * AKA Specular Color in other nomenclature.
  50234. */
  50235. reflectivityColor: Color3;
  50236. /**
  50237. * The color reflected from the material.
  50238. */
  50239. reflectionColor: Color3;
  50240. /**
  50241. * The color emitted from the material.
  50242. */
  50243. emissiveColor: Color3;
  50244. /**
  50245. * AKA Glossiness in other nomenclature.
  50246. */
  50247. microSurface: number;
  50248. /**
  50249. * source material index of refraction (IOR)' / 'destination material IOR.
  50250. */
  50251. indexOfRefraction: number;
  50252. /**
  50253. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50254. */
  50255. invertRefractionY: boolean;
  50256. /**
  50257. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50258. * Materials half opaque for instance using refraction could benefit from this control.
  50259. */
  50260. linkRefractionWithTransparency: boolean;
  50261. /**
  50262. * If true, the light map contains occlusion information instead of lighting info.
  50263. */
  50264. useLightmapAsShadowmap: boolean;
  50265. /**
  50266. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50267. */
  50268. useAlphaFromAlbedoTexture: boolean;
  50269. /**
  50270. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50271. */
  50272. forceAlphaTest: boolean;
  50273. /**
  50274. * Defines the alpha limits in alpha test mode.
  50275. */
  50276. alphaCutOff: number;
  50277. /**
  50278. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50279. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50280. */
  50281. useSpecularOverAlpha: boolean;
  50282. /**
  50283. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50284. */
  50285. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50286. /**
  50287. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50288. */
  50289. useRoughnessFromMetallicTextureAlpha: boolean;
  50290. /**
  50291. * Specifies if the metallic texture contains the roughness information in its green channel.
  50292. */
  50293. useRoughnessFromMetallicTextureGreen: boolean;
  50294. /**
  50295. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50296. */
  50297. useMetallnessFromMetallicTextureBlue: boolean;
  50298. /**
  50299. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50300. */
  50301. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50302. /**
  50303. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50304. */
  50305. useAmbientInGrayScale: boolean;
  50306. /**
  50307. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50308. * The material will try to infer what glossiness each pixel should be.
  50309. */
  50310. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50311. /**
  50312. * BJS is using an harcoded light falloff based on a manually sets up range.
  50313. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50314. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50315. */
  50316. /**
  50317. * BJS is using an harcoded light falloff based on a manually sets up range.
  50318. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50319. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50320. */
  50321. usePhysicalLightFalloff: boolean;
  50322. /**
  50323. * In order to support the falloff compatibility with gltf, a special mode has been added
  50324. * to reproduce the gltf light falloff.
  50325. */
  50326. /**
  50327. * In order to support the falloff compatibility with gltf, a special mode has been added
  50328. * to reproduce the gltf light falloff.
  50329. */
  50330. useGLTFLightFalloff: boolean;
  50331. /**
  50332. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50333. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50334. */
  50335. useRadianceOverAlpha: boolean;
  50336. /**
  50337. * Allows using an object space normal map (instead of tangent space).
  50338. */
  50339. useObjectSpaceNormalMap: boolean;
  50340. /**
  50341. * Allows using the bump map in parallax mode.
  50342. */
  50343. useParallax: boolean;
  50344. /**
  50345. * Allows using the bump map in parallax occlusion mode.
  50346. */
  50347. useParallaxOcclusion: boolean;
  50348. /**
  50349. * Controls the scale bias of the parallax mode.
  50350. */
  50351. parallaxScaleBias: number;
  50352. /**
  50353. * If sets to true, disables all the lights affecting the material.
  50354. */
  50355. disableLighting: boolean;
  50356. /**
  50357. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50358. */
  50359. forceIrradianceInFragment: boolean;
  50360. /**
  50361. * Number of Simultaneous lights allowed on the material.
  50362. */
  50363. maxSimultaneousLights: number;
  50364. /**
  50365. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50366. */
  50367. invertNormalMapX: boolean;
  50368. /**
  50369. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50370. */
  50371. invertNormalMapY: boolean;
  50372. /**
  50373. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50374. */
  50375. twoSidedLighting: boolean;
  50376. /**
  50377. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50378. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50379. */
  50380. useAlphaFresnel: boolean;
  50381. /**
  50382. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50383. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50384. */
  50385. useLinearAlphaFresnel: boolean;
  50386. /**
  50387. * Let user defines the brdf lookup texture used for IBL.
  50388. * A default 8bit version is embedded but you could point at :
  50389. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50390. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50391. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50392. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50393. */
  50394. environmentBRDFTexture: Nullable<BaseTexture>;
  50395. /**
  50396. * Force normal to face away from face.
  50397. */
  50398. forceNormalForward: boolean;
  50399. /**
  50400. * Enables specular anti aliasing in the PBR shader.
  50401. * It will both interacts on the Geometry for analytical and IBL lighting.
  50402. * It also prefilter the roughness map based on the bump values.
  50403. */
  50404. enableSpecularAntiAliasing: boolean;
  50405. /**
  50406. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50407. * makes the reflect vector face the model (under horizon).
  50408. */
  50409. useHorizonOcclusion: boolean;
  50410. /**
  50411. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50412. * too much the area relying on ambient texture to define their ambient occlusion.
  50413. */
  50414. useRadianceOcclusion: boolean;
  50415. /**
  50416. * If set to true, no lighting calculations will be applied.
  50417. */
  50418. unlit: boolean;
  50419. /**
  50420. * Gets the image processing configuration used either in this material.
  50421. */
  50422. /**
  50423. * Sets the Default image processing configuration used either in the this material.
  50424. *
  50425. * If sets to null, the scene one is in use.
  50426. */
  50427. imageProcessingConfiguration: ImageProcessingConfiguration;
  50428. /**
  50429. * Gets wether the color curves effect is enabled.
  50430. */
  50431. /**
  50432. * Sets wether the color curves effect is enabled.
  50433. */
  50434. cameraColorCurvesEnabled: boolean;
  50435. /**
  50436. * Gets wether the color grading effect is enabled.
  50437. */
  50438. /**
  50439. * Gets wether the color grading effect is enabled.
  50440. */
  50441. cameraColorGradingEnabled: boolean;
  50442. /**
  50443. * Gets wether tonemapping is enabled or not.
  50444. */
  50445. /**
  50446. * Sets wether tonemapping is enabled or not
  50447. */
  50448. cameraToneMappingEnabled: boolean;
  50449. /**
  50450. * The camera exposure used on this material.
  50451. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50452. * This corresponds to a photographic exposure.
  50453. */
  50454. /**
  50455. * The camera exposure used on this material.
  50456. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50457. * This corresponds to a photographic exposure.
  50458. */
  50459. cameraExposure: number;
  50460. /**
  50461. * Gets The camera contrast used on this material.
  50462. */
  50463. /**
  50464. * Sets The camera contrast used on this material.
  50465. */
  50466. cameraContrast: number;
  50467. /**
  50468. * Gets the Color Grading 2D Lookup Texture.
  50469. */
  50470. /**
  50471. * Sets the Color Grading 2D Lookup Texture.
  50472. */
  50473. cameraColorGradingTexture: Nullable<BaseTexture>;
  50474. /**
  50475. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50476. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50477. * 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;
  50478. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50479. */
  50480. /**
  50481. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50482. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50483. * 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;
  50484. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50485. */
  50486. cameraColorCurves: Nullable<ColorCurves>;
  50487. /**
  50488. * Instantiates a new PBRMaterial instance.
  50489. *
  50490. * @param name The material name
  50491. * @param scene The scene the material will be use in.
  50492. */
  50493. constructor(name: string, scene: Scene);
  50494. /**
  50495. * Returns the name of this material class.
  50496. */
  50497. getClassName(): string;
  50498. /**
  50499. * Makes a duplicate of the current material.
  50500. * @param name - name to use for the new material.
  50501. */
  50502. clone(name: string): PBRMaterial;
  50503. /**
  50504. * Serializes this PBR Material.
  50505. * @returns - An object with the serialized material.
  50506. */
  50507. serialize(): any;
  50508. /**
  50509. * Parses a PBR Material from a serialized object.
  50510. * @param source - Serialized object.
  50511. * @param scene - BJS scene instance.
  50512. * @param rootUrl - url for the scene object
  50513. * @returns - PBRMaterial
  50514. */
  50515. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50516. }
  50517. }
  50518. declare module "babylonjs/Misc/dds" {
  50519. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50521. import { Nullable } from "babylonjs/types";
  50522. import { Scene } from "babylonjs/scene";
  50523. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50524. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50525. /**
  50526. * Direct draw surface info
  50527. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50528. */
  50529. export interface DDSInfo {
  50530. /**
  50531. * Width of the texture
  50532. */
  50533. width: number;
  50534. /**
  50535. * Width of the texture
  50536. */
  50537. height: number;
  50538. /**
  50539. * Number of Mipmaps for the texture
  50540. * @see https://en.wikipedia.org/wiki/Mipmap
  50541. */
  50542. mipmapCount: number;
  50543. /**
  50544. * If the textures format is a known fourCC format
  50545. * @see https://www.fourcc.org/
  50546. */
  50547. isFourCC: boolean;
  50548. /**
  50549. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50550. */
  50551. isRGB: boolean;
  50552. /**
  50553. * If the texture is a lumincance format
  50554. */
  50555. isLuminance: boolean;
  50556. /**
  50557. * If this is a cube texture
  50558. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50559. */
  50560. isCube: boolean;
  50561. /**
  50562. * If the texture is a compressed format eg. FOURCC_DXT1
  50563. */
  50564. isCompressed: boolean;
  50565. /**
  50566. * The dxgiFormat of the texture
  50567. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50568. */
  50569. dxgiFormat: number;
  50570. /**
  50571. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50572. */
  50573. textureType: number;
  50574. /**
  50575. * Sphericle polynomial created for the dds texture
  50576. */
  50577. sphericalPolynomial?: SphericalPolynomial;
  50578. }
  50579. /**
  50580. * Class used to provide DDS decompression tools
  50581. */
  50582. export class DDSTools {
  50583. /**
  50584. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50585. */
  50586. static StoreLODInAlphaChannel: boolean;
  50587. /**
  50588. * Gets DDS information from an array buffer
  50589. * @param arrayBuffer defines the array buffer to read data from
  50590. * @returns the DDS information
  50591. */
  50592. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50593. private static _FloatView;
  50594. private static _Int32View;
  50595. private static _ToHalfFloat;
  50596. private static _FromHalfFloat;
  50597. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50598. private static _GetHalfFloatRGBAArrayBuffer;
  50599. private static _GetFloatRGBAArrayBuffer;
  50600. private static _GetFloatAsUIntRGBAArrayBuffer;
  50601. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50602. private static _GetRGBAArrayBuffer;
  50603. private static _ExtractLongWordOrder;
  50604. private static _GetRGBArrayBuffer;
  50605. private static _GetLuminanceArrayBuffer;
  50606. /**
  50607. * Uploads DDS Levels to a Babylon Texture
  50608. * @hidden
  50609. */
  50610. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50611. }
  50612. module "babylonjs/Engines/thinEngine" {
  50613. interface ThinEngine {
  50614. /**
  50615. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50616. * @param rootUrl defines the url where the file to load is located
  50617. * @param scene defines the current scene
  50618. * @param lodScale defines scale to apply to the mip map selection
  50619. * @param lodOffset defines offset to apply to the mip map selection
  50620. * @param onLoad defines an optional callback raised when the texture is loaded
  50621. * @param onError defines an optional callback raised if there is an issue to load the texture
  50622. * @param format defines the format of the data
  50623. * @param forcedExtension defines the extension to use to pick the right loader
  50624. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50625. * @returns the cube texture as an InternalTexture
  50626. */
  50627. 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;
  50628. }
  50629. }
  50630. }
  50631. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50632. import { Nullable } from "babylonjs/types";
  50633. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50634. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50635. /**
  50636. * Implementation of the DDS Texture Loader.
  50637. * @hidden
  50638. */
  50639. export class _DDSTextureLoader implements IInternalTextureLoader {
  50640. /**
  50641. * Defines wether the loader supports cascade loading the different faces.
  50642. */
  50643. readonly supportCascades: boolean;
  50644. /**
  50645. * This returns if the loader support the current file information.
  50646. * @param extension defines the file extension of the file being loaded
  50647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50648. * @param fallback defines the fallback internal texture if any
  50649. * @param isBase64 defines whether the texture is encoded as a base64
  50650. * @param isBuffer defines whether the texture data are stored as a buffer
  50651. * @returns true if the loader can load the specified file
  50652. */
  50653. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50654. /**
  50655. * Transform the url before loading if required.
  50656. * @param rootUrl the url of the texture
  50657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50658. * @returns the transformed texture
  50659. */
  50660. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50661. /**
  50662. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50663. * @param rootUrl the url of the texture
  50664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50665. * @returns the fallback texture
  50666. */
  50667. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50668. /**
  50669. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50670. * @param data contains the texture data
  50671. * @param texture defines the BabylonJS internal texture
  50672. * @param createPolynomials will be true if polynomials have been requested
  50673. * @param onLoad defines the callback to trigger once the texture is ready
  50674. * @param onError defines the callback to trigger in case of error
  50675. */
  50676. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50677. /**
  50678. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50679. * @param data contains the texture data
  50680. * @param texture defines the BabylonJS internal texture
  50681. * @param callback defines the method to call once ready to upload
  50682. */
  50683. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50684. }
  50685. }
  50686. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50687. import { Nullable } from "babylonjs/types";
  50688. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50689. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50690. /**
  50691. * Implementation of the ENV Texture Loader.
  50692. * @hidden
  50693. */
  50694. export class _ENVTextureLoader implements IInternalTextureLoader {
  50695. /**
  50696. * Defines wether the loader supports cascade loading the different faces.
  50697. */
  50698. readonly supportCascades: boolean;
  50699. /**
  50700. * This returns if the loader support the current file information.
  50701. * @param extension defines the file extension of the file being loaded
  50702. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50703. * @param fallback defines the fallback internal texture if any
  50704. * @param isBase64 defines whether the texture is encoded as a base64
  50705. * @param isBuffer defines whether the texture data are stored as a buffer
  50706. * @returns true if the loader can load the specified file
  50707. */
  50708. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50709. /**
  50710. * Transform the url before loading if required.
  50711. * @param rootUrl the url of the texture
  50712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50713. * @returns the transformed texture
  50714. */
  50715. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50716. /**
  50717. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50718. * @param rootUrl the url of the texture
  50719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50720. * @returns the fallback texture
  50721. */
  50722. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50723. /**
  50724. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50725. * @param data contains the texture data
  50726. * @param texture defines the BabylonJS internal texture
  50727. * @param createPolynomials will be true if polynomials have been requested
  50728. * @param onLoad defines the callback to trigger once the texture is ready
  50729. * @param onError defines the callback to trigger in case of error
  50730. */
  50731. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50732. /**
  50733. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50734. * @param data contains the texture data
  50735. * @param texture defines the BabylonJS internal texture
  50736. * @param callback defines the method to call once ready to upload
  50737. */
  50738. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50739. }
  50740. }
  50741. declare module "babylonjs/Misc/khronosTextureContainer" {
  50742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50743. /**
  50744. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50745. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50746. */
  50747. export class KhronosTextureContainer {
  50748. /** contents of the KTX container file */
  50749. arrayBuffer: any;
  50750. private static HEADER_LEN;
  50751. private static COMPRESSED_2D;
  50752. private static COMPRESSED_3D;
  50753. private static TEX_2D;
  50754. private static TEX_3D;
  50755. /**
  50756. * Gets the openGL type
  50757. */
  50758. glType: number;
  50759. /**
  50760. * Gets the openGL type size
  50761. */
  50762. glTypeSize: number;
  50763. /**
  50764. * Gets the openGL format
  50765. */
  50766. glFormat: number;
  50767. /**
  50768. * Gets the openGL internal format
  50769. */
  50770. glInternalFormat: number;
  50771. /**
  50772. * Gets the base internal format
  50773. */
  50774. glBaseInternalFormat: number;
  50775. /**
  50776. * Gets image width in pixel
  50777. */
  50778. pixelWidth: number;
  50779. /**
  50780. * Gets image height in pixel
  50781. */
  50782. pixelHeight: number;
  50783. /**
  50784. * Gets image depth in pixels
  50785. */
  50786. pixelDepth: number;
  50787. /**
  50788. * Gets the number of array elements
  50789. */
  50790. numberOfArrayElements: number;
  50791. /**
  50792. * Gets the number of faces
  50793. */
  50794. numberOfFaces: number;
  50795. /**
  50796. * Gets the number of mipmap levels
  50797. */
  50798. numberOfMipmapLevels: number;
  50799. /**
  50800. * Gets the bytes of key value data
  50801. */
  50802. bytesOfKeyValueData: number;
  50803. /**
  50804. * Gets the load type
  50805. */
  50806. loadType: number;
  50807. /**
  50808. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50809. */
  50810. isInvalid: boolean;
  50811. /**
  50812. * Creates a new KhronosTextureContainer
  50813. * @param arrayBuffer contents of the KTX container file
  50814. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50815. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50816. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50817. */
  50818. constructor(
  50819. /** contents of the KTX container file */
  50820. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50821. /**
  50822. * Uploads KTX content to a Babylon Texture.
  50823. * It is assumed that the texture has already been created & is currently bound
  50824. * @hidden
  50825. */
  50826. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50827. private _upload2DCompressedLevels;
  50828. }
  50829. }
  50830. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50831. import { Nullable } from "babylonjs/types";
  50832. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50833. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50834. /**
  50835. * Implementation of the KTX Texture Loader.
  50836. * @hidden
  50837. */
  50838. export class _KTXTextureLoader implements IInternalTextureLoader {
  50839. /**
  50840. * Defines wether the loader supports cascade loading the different faces.
  50841. */
  50842. readonly supportCascades: boolean;
  50843. /**
  50844. * This returns if the loader support the current file information.
  50845. * @param extension defines the file extension of the file being loaded
  50846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50847. * @param fallback defines the fallback internal texture if any
  50848. * @param isBase64 defines whether the texture is encoded as a base64
  50849. * @param isBuffer defines whether the texture data are stored as a buffer
  50850. * @returns true if the loader can load the specified file
  50851. */
  50852. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50853. /**
  50854. * Transform the url before loading if required.
  50855. * @param rootUrl the url of the texture
  50856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50857. * @returns the transformed texture
  50858. */
  50859. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50860. /**
  50861. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50862. * @param rootUrl the url of the texture
  50863. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50864. * @returns the fallback texture
  50865. */
  50866. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50867. /**
  50868. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50869. * @param data contains the texture data
  50870. * @param texture defines the BabylonJS internal texture
  50871. * @param createPolynomials will be true if polynomials have been requested
  50872. * @param onLoad defines the callback to trigger once the texture is ready
  50873. * @param onError defines the callback to trigger in case of error
  50874. */
  50875. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50876. /**
  50877. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50878. * @param data contains the texture data
  50879. * @param texture defines the BabylonJS internal texture
  50880. * @param callback defines the method to call once ready to upload
  50881. */
  50882. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50883. }
  50884. }
  50885. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50886. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50887. import { Scene } from "babylonjs/scene";
  50888. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50889. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50890. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50891. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50892. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50893. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50895. /**
  50896. * Options for the default xr helper
  50897. */
  50898. export class WebXRDefaultExperienceOptions {
  50899. /**
  50900. * Floor meshes that should be used for teleporting
  50901. */
  50902. floorMeshes: Array<AbstractMesh>;
  50903. }
  50904. /**
  50905. * Default experience which provides a similar setup to the previous webVRExperience
  50906. */
  50907. export class WebXRDefaultExperience {
  50908. /**
  50909. * Base experience
  50910. */
  50911. baseExperience: WebXRExperienceHelper;
  50912. /**
  50913. * Input experience extension
  50914. */
  50915. input: WebXRInput;
  50916. /**
  50917. * Loads the controller models
  50918. */
  50919. controllerModelLoader: WebXRControllerModelLoader;
  50920. /**
  50921. * Enables laser pointer and selection
  50922. */
  50923. pointerSelection: WebXRControllerPointerSelection;
  50924. /**
  50925. * Enables teleportation
  50926. */
  50927. teleportation: WebXRControllerTeleportation;
  50928. /**
  50929. * Enables ui for enetering/exiting xr
  50930. */
  50931. enterExitUI: WebXREnterExitUI;
  50932. /**
  50933. * Default output canvas xr should render to
  50934. */
  50935. outputCanvas: WebXRManagedOutputCanvas;
  50936. /**
  50937. * Creates the default xr experience
  50938. * @param scene scene
  50939. * @param options options for basic configuration
  50940. * @returns resulting WebXRDefaultExperience
  50941. */
  50942. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50943. private constructor();
  50944. /**
  50945. * DIsposes of the experience helper
  50946. */
  50947. dispose(): void;
  50948. }
  50949. }
  50950. declare module "babylonjs/Helpers/sceneHelpers" {
  50951. import { Nullable } from "babylonjs/types";
  50952. import { Mesh } from "babylonjs/Meshes/mesh";
  50953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50954. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50955. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50956. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50957. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50958. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50959. import "babylonjs/Meshes/Builders/boxBuilder";
  50960. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50961. /** @hidden */
  50962. export var _forceSceneHelpersToBundle: boolean;
  50963. module "babylonjs/scene" {
  50964. interface Scene {
  50965. /**
  50966. * Creates a default light for the scene.
  50967. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50968. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50969. */
  50970. createDefaultLight(replace?: boolean): void;
  50971. /**
  50972. * Creates a default camera for the scene.
  50973. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50974. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50975. * @param replace has default false, when true replaces the active camera in the scene
  50976. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50977. */
  50978. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50979. /**
  50980. * Creates a default camera and a default light.
  50981. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50982. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50983. * @param replace has the default false, when true replaces the active camera/light in the scene
  50984. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50985. */
  50986. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50987. /**
  50988. * Creates a new sky box
  50989. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50990. * @param environmentTexture defines the texture to use as environment texture
  50991. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50992. * @param scale defines the overall scale of the skybox
  50993. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50994. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50995. * @returns a new mesh holding the sky box
  50996. */
  50997. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50998. /**
  50999. * Creates a new environment
  51000. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51001. * @param options defines the options you can use to configure the environment
  51002. * @returns the new EnvironmentHelper
  51003. */
  51004. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51005. /**
  51006. * Creates a new VREXperienceHelper
  51007. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51008. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51009. * @returns a new VREXperienceHelper
  51010. */
  51011. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51012. /**
  51013. * Creates a new WebXRDefaultExperience
  51014. * @see http://doc.babylonjs.com/how_to/webxr
  51015. * @param options experience options
  51016. * @returns a promise for a new WebXRDefaultExperience
  51017. */
  51018. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51019. }
  51020. }
  51021. }
  51022. declare module "babylonjs/Helpers/videoDome" {
  51023. import { Scene } from "babylonjs/scene";
  51024. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51025. import { Mesh } from "babylonjs/Meshes/mesh";
  51026. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51027. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51028. import "babylonjs/Meshes/Builders/sphereBuilder";
  51029. /**
  51030. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51031. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51032. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51033. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51034. */
  51035. export class VideoDome extends TransformNode {
  51036. /**
  51037. * Define the video source as a Monoscopic panoramic 360 video.
  51038. */
  51039. static readonly MODE_MONOSCOPIC: number;
  51040. /**
  51041. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51042. */
  51043. static readonly MODE_TOPBOTTOM: number;
  51044. /**
  51045. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51046. */
  51047. static readonly MODE_SIDEBYSIDE: number;
  51048. private _halfDome;
  51049. private _useDirectMapping;
  51050. /**
  51051. * The video texture being displayed on the sphere
  51052. */
  51053. protected _videoTexture: VideoTexture;
  51054. /**
  51055. * Gets the video texture being displayed on the sphere
  51056. */
  51057. readonly videoTexture: VideoTexture;
  51058. /**
  51059. * The skybox material
  51060. */
  51061. protected _material: BackgroundMaterial;
  51062. /**
  51063. * The surface used for the skybox
  51064. */
  51065. protected _mesh: Mesh;
  51066. /**
  51067. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51068. */
  51069. private _halfDomeMask;
  51070. /**
  51071. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51072. * Also see the options.resolution property.
  51073. */
  51074. fovMultiplier: number;
  51075. private _videoMode;
  51076. /**
  51077. * Gets or set the current video mode for the video. It can be:
  51078. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51079. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51080. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51081. */
  51082. videoMode: number;
  51083. /**
  51084. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51085. *
  51086. */
  51087. /**
  51088. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51089. */
  51090. halfDome: boolean;
  51091. /**
  51092. * Oberserver used in Stereoscopic VR Mode.
  51093. */
  51094. private _onBeforeCameraRenderObserver;
  51095. /**
  51096. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51097. * @param name Element's name, child elements will append suffixes for their own names.
  51098. * @param urlsOrVideo defines the url(s) or the video element to use
  51099. * @param options An object containing optional or exposed sub element properties
  51100. */
  51101. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51102. resolution?: number;
  51103. clickToPlay?: boolean;
  51104. autoPlay?: boolean;
  51105. loop?: boolean;
  51106. size?: number;
  51107. poster?: string;
  51108. faceForward?: boolean;
  51109. useDirectMapping?: boolean;
  51110. halfDomeMode?: boolean;
  51111. }, scene: Scene);
  51112. private _changeVideoMode;
  51113. /**
  51114. * Releases resources associated with this node.
  51115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51117. */
  51118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51119. }
  51120. }
  51121. declare module "babylonjs/Helpers/index" {
  51122. export * from "babylonjs/Helpers/environmentHelper";
  51123. export * from "babylonjs/Helpers/photoDome";
  51124. export * from "babylonjs/Helpers/sceneHelpers";
  51125. export * from "babylonjs/Helpers/videoDome";
  51126. }
  51127. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51128. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51129. import { IDisposable } from "babylonjs/scene";
  51130. import { Engine } from "babylonjs/Engines/engine";
  51131. /**
  51132. * This class can be used to get instrumentation data from a Babylon engine
  51133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51134. */
  51135. export class EngineInstrumentation implements IDisposable {
  51136. /**
  51137. * Define the instrumented engine.
  51138. */
  51139. engine: Engine;
  51140. private _captureGPUFrameTime;
  51141. private _gpuFrameTimeToken;
  51142. private _gpuFrameTime;
  51143. private _captureShaderCompilationTime;
  51144. private _shaderCompilationTime;
  51145. private _onBeginFrameObserver;
  51146. private _onEndFrameObserver;
  51147. private _onBeforeShaderCompilationObserver;
  51148. private _onAfterShaderCompilationObserver;
  51149. /**
  51150. * Gets the perf counter used for GPU frame time
  51151. */
  51152. readonly gpuFrameTimeCounter: PerfCounter;
  51153. /**
  51154. * Gets the GPU frame time capture status
  51155. */
  51156. /**
  51157. * Enable or disable the GPU frame time capture
  51158. */
  51159. captureGPUFrameTime: boolean;
  51160. /**
  51161. * Gets the perf counter used for shader compilation time
  51162. */
  51163. readonly shaderCompilationTimeCounter: PerfCounter;
  51164. /**
  51165. * Gets the shader compilation time capture status
  51166. */
  51167. /**
  51168. * Enable or disable the shader compilation time capture
  51169. */
  51170. captureShaderCompilationTime: boolean;
  51171. /**
  51172. * Instantiates a new engine instrumentation.
  51173. * This class can be used to get instrumentation data from a Babylon engine
  51174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51175. * @param engine Defines the engine to instrument
  51176. */
  51177. constructor(
  51178. /**
  51179. * Define the instrumented engine.
  51180. */
  51181. engine: Engine);
  51182. /**
  51183. * Dispose and release associated resources.
  51184. */
  51185. dispose(): void;
  51186. }
  51187. }
  51188. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51189. import { Scene, IDisposable } from "babylonjs/scene";
  51190. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51191. /**
  51192. * This class can be used to get instrumentation data from a Babylon engine
  51193. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51194. */
  51195. export class SceneInstrumentation implements IDisposable {
  51196. /**
  51197. * Defines the scene to instrument
  51198. */
  51199. scene: Scene;
  51200. private _captureActiveMeshesEvaluationTime;
  51201. private _activeMeshesEvaluationTime;
  51202. private _captureRenderTargetsRenderTime;
  51203. private _renderTargetsRenderTime;
  51204. private _captureFrameTime;
  51205. private _frameTime;
  51206. private _captureRenderTime;
  51207. private _renderTime;
  51208. private _captureInterFrameTime;
  51209. private _interFrameTime;
  51210. private _captureParticlesRenderTime;
  51211. private _particlesRenderTime;
  51212. private _captureSpritesRenderTime;
  51213. private _spritesRenderTime;
  51214. private _capturePhysicsTime;
  51215. private _physicsTime;
  51216. private _captureAnimationsTime;
  51217. private _animationsTime;
  51218. private _captureCameraRenderTime;
  51219. private _cameraRenderTime;
  51220. private _onBeforeActiveMeshesEvaluationObserver;
  51221. private _onAfterActiveMeshesEvaluationObserver;
  51222. private _onBeforeRenderTargetsRenderObserver;
  51223. private _onAfterRenderTargetsRenderObserver;
  51224. private _onAfterRenderObserver;
  51225. private _onBeforeDrawPhaseObserver;
  51226. private _onAfterDrawPhaseObserver;
  51227. private _onBeforeAnimationsObserver;
  51228. private _onBeforeParticlesRenderingObserver;
  51229. private _onAfterParticlesRenderingObserver;
  51230. private _onBeforeSpritesRenderingObserver;
  51231. private _onAfterSpritesRenderingObserver;
  51232. private _onBeforePhysicsObserver;
  51233. private _onAfterPhysicsObserver;
  51234. private _onAfterAnimationsObserver;
  51235. private _onBeforeCameraRenderObserver;
  51236. private _onAfterCameraRenderObserver;
  51237. /**
  51238. * Gets the perf counter used for active meshes evaluation time
  51239. */
  51240. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51241. /**
  51242. * Gets the active meshes evaluation time capture status
  51243. */
  51244. /**
  51245. * Enable or disable the active meshes evaluation time capture
  51246. */
  51247. captureActiveMeshesEvaluationTime: boolean;
  51248. /**
  51249. * Gets the perf counter used for render targets render time
  51250. */
  51251. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51252. /**
  51253. * Gets the render targets render time capture status
  51254. */
  51255. /**
  51256. * Enable or disable the render targets render time capture
  51257. */
  51258. captureRenderTargetsRenderTime: boolean;
  51259. /**
  51260. * Gets the perf counter used for particles render time
  51261. */
  51262. readonly particlesRenderTimeCounter: PerfCounter;
  51263. /**
  51264. * Gets the particles render time capture status
  51265. */
  51266. /**
  51267. * Enable or disable the particles render time capture
  51268. */
  51269. captureParticlesRenderTime: boolean;
  51270. /**
  51271. * Gets the perf counter used for sprites render time
  51272. */
  51273. readonly spritesRenderTimeCounter: PerfCounter;
  51274. /**
  51275. * Gets the sprites render time capture status
  51276. */
  51277. /**
  51278. * Enable or disable the sprites render time capture
  51279. */
  51280. captureSpritesRenderTime: boolean;
  51281. /**
  51282. * Gets the perf counter used for physics time
  51283. */
  51284. readonly physicsTimeCounter: PerfCounter;
  51285. /**
  51286. * Gets the physics time capture status
  51287. */
  51288. /**
  51289. * Enable or disable the physics time capture
  51290. */
  51291. capturePhysicsTime: boolean;
  51292. /**
  51293. * Gets the perf counter used for animations time
  51294. */
  51295. readonly animationsTimeCounter: PerfCounter;
  51296. /**
  51297. * Gets the animations time capture status
  51298. */
  51299. /**
  51300. * Enable or disable the animations time capture
  51301. */
  51302. captureAnimationsTime: boolean;
  51303. /**
  51304. * Gets the perf counter used for frame time capture
  51305. */
  51306. readonly frameTimeCounter: PerfCounter;
  51307. /**
  51308. * Gets the frame time capture status
  51309. */
  51310. /**
  51311. * Enable or disable the frame time capture
  51312. */
  51313. captureFrameTime: boolean;
  51314. /**
  51315. * Gets the perf counter used for inter-frames time capture
  51316. */
  51317. readonly interFrameTimeCounter: PerfCounter;
  51318. /**
  51319. * Gets the inter-frames time capture status
  51320. */
  51321. /**
  51322. * Enable or disable the inter-frames time capture
  51323. */
  51324. captureInterFrameTime: boolean;
  51325. /**
  51326. * Gets the perf counter used for render time capture
  51327. */
  51328. readonly renderTimeCounter: PerfCounter;
  51329. /**
  51330. * Gets the render time capture status
  51331. */
  51332. /**
  51333. * Enable or disable the render time capture
  51334. */
  51335. captureRenderTime: boolean;
  51336. /**
  51337. * Gets the perf counter used for camera render time capture
  51338. */
  51339. readonly cameraRenderTimeCounter: PerfCounter;
  51340. /**
  51341. * Gets the camera render time capture status
  51342. */
  51343. /**
  51344. * Enable or disable the camera render time capture
  51345. */
  51346. captureCameraRenderTime: boolean;
  51347. /**
  51348. * Gets the perf counter used for draw calls
  51349. */
  51350. readonly drawCallsCounter: PerfCounter;
  51351. /**
  51352. * Instantiates a new scene instrumentation.
  51353. * This class can be used to get instrumentation data from a Babylon engine
  51354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51355. * @param scene Defines the scene to instrument
  51356. */
  51357. constructor(
  51358. /**
  51359. * Defines the scene to instrument
  51360. */
  51361. scene: Scene);
  51362. /**
  51363. * Dispose and release associated resources.
  51364. */
  51365. dispose(): void;
  51366. }
  51367. }
  51368. declare module "babylonjs/Instrumentation/index" {
  51369. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51370. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51371. export * from "babylonjs/Instrumentation/timeToken";
  51372. }
  51373. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51374. /** @hidden */
  51375. export var glowMapGenerationPixelShader: {
  51376. name: string;
  51377. shader: string;
  51378. };
  51379. }
  51380. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51381. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51382. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51383. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51384. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51386. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51387. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51388. /** @hidden */
  51389. export var glowMapGenerationVertexShader: {
  51390. name: string;
  51391. shader: string;
  51392. };
  51393. }
  51394. declare module "babylonjs/Layers/effectLayer" {
  51395. import { Observable } from "babylonjs/Misc/observable";
  51396. import { Nullable } from "babylonjs/types";
  51397. import { Camera } from "babylonjs/Cameras/camera";
  51398. import { Scene } from "babylonjs/scene";
  51399. import { ISize } from "babylonjs/Maths/math.size";
  51400. import { Color4 } from "babylonjs/Maths/math.color";
  51401. import { Engine } from "babylonjs/Engines/engine";
  51402. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51404. import { Mesh } from "babylonjs/Meshes/mesh";
  51405. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51407. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51408. import { Effect } from "babylonjs/Materials/effect";
  51409. import { Material } from "babylonjs/Materials/material";
  51410. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51411. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51412. /**
  51413. * Effect layer options. This helps customizing the behaviour
  51414. * of the effect layer.
  51415. */
  51416. export interface IEffectLayerOptions {
  51417. /**
  51418. * Multiplication factor apply to the canvas size to compute the render target size
  51419. * used to generated the objects (the smaller the faster).
  51420. */
  51421. mainTextureRatio: number;
  51422. /**
  51423. * Enforces a fixed size texture to ensure effect stability across devices.
  51424. */
  51425. mainTextureFixedSize?: number;
  51426. /**
  51427. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51428. */
  51429. alphaBlendingMode: number;
  51430. /**
  51431. * The camera attached to the layer.
  51432. */
  51433. camera: Nullable<Camera>;
  51434. /**
  51435. * The rendering group to draw the layer in.
  51436. */
  51437. renderingGroupId: number;
  51438. }
  51439. /**
  51440. * The effect layer Helps adding post process effect blended with the main pass.
  51441. *
  51442. * This can be for instance use to generate glow or higlight effects on the scene.
  51443. *
  51444. * The effect layer class can not be used directly and is intented to inherited from to be
  51445. * customized per effects.
  51446. */
  51447. export abstract class EffectLayer {
  51448. private _vertexBuffers;
  51449. private _indexBuffer;
  51450. private _cachedDefines;
  51451. private _effectLayerMapGenerationEffect;
  51452. private _effectLayerOptions;
  51453. private _mergeEffect;
  51454. protected _scene: Scene;
  51455. protected _engine: Engine;
  51456. protected _maxSize: number;
  51457. protected _mainTextureDesiredSize: ISize;
  51458. protected _mainTexture: RenderTargetTexture;
  51459. protected _shouldRender: boolean;
  51460. protected _postProcesses: PostProcess[];
  51461. protected _textures: BaseTexture[];
  51462. protected _emissiveTextureAndColor: {
  51463. texture: Nullable<BaseTexture>;
  51464. color: Color4;
  51465. };
  51466. /**
  51467. * The name of the layer
  51468. */
  51469. name: string;
  51470. /**
  51471. * The clear color of the texture used to generate the glow map.
  51472. */
  51473. neutralColor: Color4;
  51474. /**
  51475. * Specifies wether the highlight layer is enabled or not.
  51476. */
  51477. isEnabled: boolean;
  51478. /**
  51479. * Gets the camera attached to the layer.
  51480. */
  51481. readonly camera: Nullable<Camera>;
  51482. /**
  51483. * Gets the rendering group id the layer should render in.
  51484. */
  51485. renderingGroupId: number;
  51486. /**
  51487. * An event triggered when the effect layer has been disposed.
  51488. */
  51489. onDisposeObservable: Observable<EffectLayer>;
  51490. /**
  51491. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51492. */
  51493. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51494. /**
  51495. * An event triggered when the generated texture is being merged in the scene.
  51496. */
  51497. onBeforeComposeObservable: Observable<EffectLayer>;
  51498. /**
  51499. * An event triggered when the generated texture has been merged in the scene.
  51500. */
  51501. onAfterComposeObservable: Observable<EffectLayer>;
  51502. /**
  51503. * An event triggered when the efffect layer changes its size.
  51504. */
  51505. onSizeChangedObservable: Observable<EffectLayer>;
  51506. /** @hidden */
  51507. static _SceneComponentInitialization: (scene: Scene) => void;
  51508. /**
  51509. * Instantiates a new effect Layer and references it in the scene.
  51510. * @param name The name of the layer
  51511. * @param scene The scene to use the layer in
  51512. */
  51513. constructor(
  51514. /** The Friendly of the effect in the scene */
  51515. name: string, scene: Scene);
  51516. /**
  51517. * Get the effect name of the layer.
  51518. * @return The effect name
  51519. */
  51520. abstract getEffectName(): string;
  51521. /**
  51522. * Checks for the readiness of the element composing the layer.
  51523. * @param subMesh the mesh to check for
  51524. * @param useInstances specify wether or not to use instances to render the mesh
  51525. * @return true if ready otherwise, false
  51526. */
  51527. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51528. /**
  51529. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51530. * @returns true if the effect requires stencil during the main canvas render pass.
  51531. */
  51532. abstract needStencil(): boolean;
  51533. /**
  51534. * Create the merge effect. This is the shader use to blit the information back
  51535. * to the main canvas at the end of the scene rendering.
  51536. * @returns The effect containing the shader used to merge the effect on the main canvas
  51537. */
  51538. protected abstract _createMergeEffect(): Effect;
  51539. /**
  51540. * Creates the render target textures and post processes used in the effect layer.
  51541. */
  51542. protected abstract _createTextureAndPostProcesses(): void;
  51543. /**
  51544. * Implementation specific of rendering the generating effect on the main canvas.
  51545. * @param effect The effect used to render through
  51546. */
  51547. protected abstract _internalRender(effect: Effect): void;
  51548. /**
  51549. * Sets the required values for both the emissive texture and and the main color.
  51550. */
  51551. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51552. /**
  51553. * Free any resources and references associated to a mesh.
  51554. * Internal use
  51555. * @param mesh The mesh to free.
  51556. */
  51557. abstract _disposeMesh(mesh: Mesh): void;
  51558. /**
  51559. * Serializes this layer (Glow or Highlight for example)
  51560. * @returns a serialized layer object
  51561. */
  51562. abstract serialize?(): any;
  51563. /**
  51564. * Initializes the effect layer with the required options.
  51565. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51566. */
  51567. protected _init(options: Partial<IEffectLayerOptions>): void;
  51568. /**
  51569. * Generates the index buffer of the full screen quad blending to the main canvas.
  51570. */
  51571. private _generateIndexBuffer;
  51572. /**
  51573. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51574. */
  51575. private _generateVertexBuffer;
  51576. /**
  51577. * Sets the main texture desired size which is the closest power of two
  51578. * of the engine canvas size.
  51579. */
  51580. private _setMainTextureSize;
  51581. /**
  51582. * Creates the main texture for the effect layer.
  51583. */
  51584. protected _createMainTexture(): void;
  51585. /**
  51586. * Adds specific effects defines.
  51587. * @param defines The defines to add specifics to.
  51588. */
  51589. protected _addCustomEffectDefines(defines: string[]): void;
  51590. /**
  51591. * Checks for the readiness of the element composing the layer.
  51592. * @param subMesh the mesh to check for
  51593. * @param useInstances specify wether or not to use instances to render the mesh
  51594. * @param emissiveTexture the associated emissive texture used to generate the glow
  51595. * @return true if ready otherwise, false
  51596. */
  51597. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51598. /**
  51599. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51600. */
  51601. render(): void;
  51602. /**
  51603. * Determine if a given mesh will be used in the current effect.
  51604. * @param mesh mesh to test
  51605. * @returns true if the mesh will be used
  51606. */
  51607. hasMesh(mesh: AbstractMesh): boolean;
  51608. /**
  51609. * Returns true if the layer contains information to display, otherwise false.
  51610. * @returns true if the glow layer should be rendered
  51611. */
  51612. shouldRender(): boolean;
  51613. /**
  51614. * Returns true if the mesh should render, otherwise false.
  51615. * @param mesh The mesh to render
  51616. * @returns true if it should render otherwise false
  51617. */
  51618. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51619. /**
  51620. * Returns true if the mesh can be rendered, otherwise false.
  51621. * @param mesh The mesh to render
  51622. * @param material The material used on the mesh
  51623. * @returns true if it can be rendered otherwise false
  51624. */
  51625. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51626. /**
  51627. * Returns true if the mesh should render, otherwise false.
  51628. * @param mesh The mesh to render
  51629. * @returns true if it should render otherwise false
  51630. */
  51631. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51632. /**
  51633. * Renders the submesh passed in parameter to the generation map.
  51634. */
  51635. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51636. /**
  51637. * Rebuild the required buffers.
  51638. * @hidden Internal use only.
  51639. */
  51640. _rebuild(): void;
  51641. /**
  51642. * Dispose only the render target textures and post process.
  51643. */
  51644. private _disposeTextureAndPostProcesses;
  51645. /**
  51646. * Dispose the highlight layer and free resources.
  51647. */
  51648. dispose(): void;
  51649. /**
  51650. * Gets the class name of the effect layer
  51651. * @returns the string with the class name of the effect layer
  51652. */
  51653. getClassName(): string;
  51654. /**
  51655. * Creates an effect layer from parsed effect layer data
  51656. * @param parsedEffectLayer defines effect layer data
  51657. * @param scene defines the current scene
  51658. * @param rootUrl defines the root URL containing the effect layer information
  51659. * @returns a parsed effect Layer
  51660. */
  51661. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51662. }
  51663. }
  51664. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51665. import { Scene } from "babylonjs/scene";
  51666. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51667. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51668. import { AbstractScene } from "babylonjs/abstractScene";
  51669. module "babylonjs/abstractScene" {
  51670. interface AbstractScene {
  51671. /**
  51672. * The list of effect layers (highlights/glow) added to the scene
  51673. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51674. * @see http://doc.babylonjs.com/how_to/glow_layer
  51675. */
  51676. effectLayers: Array<EffectLayer>;
  51677. /**
  51678. * Removes the given effect layer from this scene.
  51679. * @param toRemove defines the effect layer to remove
  51680. * @returns the index of the removed effect layer
  51681. */
  51682. removeEffectLayer(toRemove: EffectLayer): number;
  51683. /**
  51684. * Adds the given effect layer to this scene
  51685. * @param newEffectLayer defines the effect layer to add
  51686. */
  51687. addEffectLayer(newEffectLayer: EffectLayer): void;
  51688. }
  51689. }
  51690. /**
  51691. * Defines the layer scene component responsible to manage any effect layers
  51692. * in a given scene.
  51693. */
  51694. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51695. /**
  51696. * The component name helpfull to identify the component in the list of scene components.
  51697. */
  51698. readonly name: string;
  51699. /**
  51700. * The scene the component belongs to.
  51701. */
  51702. scene: Scene;
  51703. private _engine;
  51704. private _renderEffects;
  51705. private _needStencil;
  51706. private _previousStencilState;
  51707. /**
  51708. * Creates a new instance of the component for the given scene
  51709. * @param scene Defines the scene to register the component in
  51710. */
  51711. constructor(scene: Scene);
  51712. /**
  51713. * Registers the component in a given scene
  51714. */
  51715. register(): void;
  51716. /**
  51717. * Rebuilds the elements related to this component in case of
  51718. * context lost for instance.
  51719. */
  51720. rebuild(): void;
  51721. /**
  51722. * Serializes the component data to the specified json object
  51723. * @param serializationObject The object to serialize to
  51724. */
  51725. serialize(serializationObject: any): void;
  51726. /**
  51727. * Adds all the elements from the container to the scene
  51728. * @param container the container holding the elements
  51729. */
  51730. addFromContainer(container: AbstractScene): void;
  51731. /**
  51732. * Removes all the elements in the container from the scene
  51733. * @param container contains the elements to remove
  51734. * @param dispose if the removed element should be disposed (default: false)
  51735. */
  51736. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51737. /**
  51738. * Disposes the component and the associated ressources.
  51739. */
  51740. dispose(): void;
  51741. private _isReadyForMesh;
  51742. private _renderMainTexture;
  51743. private _setStencil;
  51744. private _setStencilBack;
  51745. private _draw;
  51746. private _drawCamera;
  51747. private _drawRenderingGroup;
  51748. }
  51749. }
  51750. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51751. /** @hidden */
  51752. export var glowMapMergePixelShader: {
  51753. name: string;
  51754. shader: string;
  51755. };
  51756. }
  51757. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51758. /** @hidden */
  51759. export var glowMapMergeVertexShader: {
  51760. name: string;
  51761. shader: string;
  51762. };
  51763. }
  51764. declare module "babylonjs/Layers/glowLayer" {
  51765. import { Nullable } from "babylonjs/types";
  51766. import { Camera } from "babylonjs/Cameras/camera";
  51767. import { Scene } from "babylonjs/scene";
  51768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51770. import { Mesh } from "babylonjs/Meshes/mesh";
  51771. import { Texture } from "babylonjs/Materials/Textures/texture";
  51772. import { Effect } from "babylonjs/Materials/effect";
  51773. import { Material } from "babylonjs/Materials/material";
  51774. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51775. import { Color4 } from "babylonjs/Maths/math.color";
  51776. import "babylonjs/Shaders/glowMapMerge.fragment";
  51777. import "babylonjs/Shaders/glowMapMerge.vertex";
  51778. import "babylonjs/Layers/effectLayerSceneComponent";
  51779. module "babylonjs/abstractScene" {
  51780. interface AbstractScene {
  51781. /**
  51782. * Return a the first highlight layer of the scene with a given name.
  51783. * @param name The name of the highlight layer to look for.
  51784. * @return The highlight layer if found otherwise null.
  51785. */
  51786. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51787. }
  51788. }
  51789. /**
  51790. * Glow layer options. This helps customizing the behaviour
  51791. * of the glow layer.
  51792. */
  51793. export interface IGlowLayerOptions {
  51794. /**
  51795. * Multiplication factor apply to the canvas size to compute the render target size
  51796. * used to generated the glowing objects (the smaller the faster).
  51797. */
  51798. mainTextureRatio: number;
  51799. /**
  51800. * Enforces a fixed size texture to ensure resize independant blur.
  51801. */
  51802. mainTextureFixedSize?: number;
  51803. /**
  51804. * How big is the kernel of the blur texture.
  51805. */
  51806. blurKernelSize: number;
  51807. /**
  51808. * The camera attached to the layer.
  51809. */
  51810. camera: Nullable<Camera>;
  51811. /**
  51812. * Enable MSAA by chosing the number of samples.
  51813. */
  51814. mainTextureSamples?: number;
  51815. /**
  51816. * The rendering group to draw the layer in.
  51817. */
  51818. renderingGroupId: number;
  51819. }
  51820. /**
  51821. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51822. *
  51823. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51824. * glowy meshes to your scene.
  51825. *
  51826. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51827. */
  51828. export class GlowLayer extends EffectLayer {
  51829. /**
  51830. * Effect Name of the layer.
  51831. */
  51832. static readonly EffectName: string;
  51833. /**
  51834. * The default blur kernel size used for the glow.
  51835. */
  51836. static DefaultBlurKernelSize: number;
  51837. /**
  51838. * The default texture size ratio used for the glow.
  51839. */
  51840. static DefaultTextureRatio: number;
  51841. /**
  51842. * Sets the kernel size of the blur.
  51843. */
  51844. /**
  51845. * Gets the kernel size of the blur.
  51846. */
  51847. blurKernelSize: number;
  51848. /**
  51849. * Sets the glow intensity.
  51850. */
  51851. /**
  51852. * Gets the glow intensity.
  51853. */
  51854. intensity: number;
  51855. private _options;
  51856. private _intensity;
  51857. private _horizontalBlurPostprocess1;
  51858. private _verticalBlurPostprocess1;
  51859. private _horizontalBlurPostprocess2;
  51860. private _verticalBlurPostprocess2;
  51861. private _blurTexture1;
  51862. private _blurTexture2;
  51863. private _postProcesses1;
  51864. private _postProcesses2;
  51865. private _includedOnlyMeshes;
  51866. private _excludedMeshes;
  51867. /**
  51868. * Callback used to let the user override the color selection on a per mesh basis
  51869. */
  51870. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51871. /**
  51872. * Callback used to let the user override the texture selection on a per mesh basis
  51873. */
  51874. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51875. /**
  51876. * Instantiates a new glow Layer and references it to the scene.
  51877. * @param name The name of the layer
  51878. * @param scene The scene to use the layer in
  51879. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51880. */
  51881. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51882. /**
  51883. * Get the effect name of the layer.
  51884. * @return The effect name
  51885. */
  51886. getEffectName(): string;
  51887. /**
  51888. * Create the merge effect. This is the shader use to blit the information back
  51889. * to the main canvas at the end of the scene rendering.
  51890. */
  51891. protected _createMergeEffect(): Effect;
  51892. /**
  51893. * Creates the render target textures and post processes used in the glow layer.
  51894. */
  51895. protected _createTextureAndPostProcesses(): void;
  51896. /**
  51897. * Checks for the readiness of the element composing the layer.
  51898. * @param subMesh the mesh to check for
  51899. * @param useInstances specify wether or not to use instances to render the mesh
  51900. * @param emissiveTexture the associated emissive texture used to generate the glow
  51901. * @return true if ready otherwise, false
  51902. */
  51903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51904. /**
  51905. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51906. */
  51907. needStencil(): boolean;
  51908. /**
  51909. * Returns true if the mesh can be rendered, otherwise false.
  51910. * @param mesh The mesh to render
  51911. * @param material The material used on the mesh
  51912. * @returns true if it can be rendered otherwise false
  51913. */
  51914. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51915. /**
  51916. * Implementation specific of rendering the generating effect on the main canvas.
  51917. * @param effect The effect used to render through
  51918. */
  51919. protected _internalRender(effect: Effect): void;
  51920. /**
  51921. * Sets the required values for both the emissive texture and and the main color.
  51922. */
  51923. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51924. /**
  51925. * Returns true if the mesh should render, otherwise false.
  51926. * @param mesh The mesh to render
  51927. * @returns true if it should render otherwise false
  51928. */
  51929. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51930. /**
  51931. * Adds specific effects defines.
  51932. * @param defines The defines to add specifics to.
  51933. */
  51934. protected _addCustomEffectDefines(defines: string[]): void;
  51935. /**
  51936. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51937. * @param mesh The mesh to exclude from the glow layer
  51938. */
  51939. addExcludedMesh(mesh: Mesh): void;
  51940. /**
  51941. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51942. * @param mesh The mesh to remove
  51943. */
  51944. removeExcludedMesh(mesh: Mesh): void;
  51945. /**
  51946. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51947. * @param mesh The mesh to include in the glow layer
  51948. */
  51949. addIncludedOnlyMesh(mesh: Mesh): void;
  51950. /**
  51951. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51952. * @param mesh The mesh to remove
  51953. */
  51954. removeIncludedOnlyMesh(mesh: Mesh): void;
  51955. /**
  51956. * Determine if a given mesh will be used in the glow layer
  51957. * @param mesh The mesh to test
  51958. * @returns true if the mesh will be highlighted by the current glow layer
  51959. */
  51960. hasMesh(mesh: AbstractMesh): boolean;
  51961. /**
  51962. * Free any resources and references associated to a mesh.
  51963. * Internal use
  51964. * @param mesh The mesh to free.
  51965. * @hidden
  51966. */
  51967. _disposeMesh(mesh: Mesh): void;
  51968. /**
  51969. * Gets the class name of the effect layer
  51970. * @returns the string with the class name of the effect layer
  51971. */
  51972. getClassName(): string;
  51973. /**
  51974. * Serializes this glow layer
  51975. * @returns a serialized glow layer object
  51976. */
  51977. serialize(): any;
  51978. /**
  51979. * Creates a Glow Layer from parsed glow layer data
  51980. * @param parsedGlowLayer defines glow layer data
  51981. * @param scene defines the current scene
  51982. * @param rootUrl defines the root URL containing the glow layer information
  51983. * @returns a parsed Glow Layer
  51984. */
  51985. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51986. }
  51987. }
  51988. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51989. /** @hidden */
  51990. export var glowBlurPostProcessPixelShader: {
  51991. name: string;
  51992. shader: string;
  51993. };
  51994. }
  51995. declare module "babylonjs/Layers/highlightLayer" {
  51996. import { Observable } from "babylonjs/Misc/observable";
  51997. import { Nullable } from "babylonjs/types";
  51998. import { Camera } from "babylonjs/Cameras/camera";
  51999. import { Scene } from "babylonjs/scene";
  52000. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52002. import { Mesh } from "babylonjs/Meshes/mesh";
  52003. import { Effect } from "babylonjs/Materials/effect";
  52004. import { Material } from "babylonjs/Materials/material";
  52005. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52006. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52007. import "babylonjs/Shaders/glowMapMerge.fragment";
  52008. import "babylonjs/Shaders/glowMapMerge.vertex";
  52009. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52010. module "babylonjs/abstractScene" {
  52011. interface AbstractScene {
  52012. /**
  52013. * Return a the first highlight layer of the scene with a given name.
  52014. * @param name The name of the highlight layer to look for.
  52015. * @return The highlight layer if found otherwise null.
  52016. */
  52017. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52018. }
  52019. }
  52020. /**
  52021. * Highlight layer options. This helps customizing the behaviour
  52022. * of the highlight layer.
  52023. */
  52024. export interface IHighlightLayerOptions {
  52025. /**
  52026. * Multiplication factor apply to the canvas size to compute the render target size
  52027. * used to generated the glowing objects (the smaller the faster).
  52028. */
  52029. mainTextureRatio: number;
  52030. /**
  52031. * Enforces a fixed size texture to ensure resize independant blur.
  52032. */
  52033. mainTextureFixedSize?: number;
  52034. /**
  52035. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52036. * of the picture to blur (the smaller the faster).
  52037. */
  52038. blurTextureSizeRatio: number;
  52039. /**
  52040. * How big in texel of the blur texture is the vertical blur.
  52041. */
  52042. blurVerticalSize: number;
  52043. /**
  52044. * How big in texel of the blur texture is the horizontal blur.
  52045. */
  52046. blurHorizontalSize: number;
  52047. /**
  52048. * Alpha blending mode used to apply the blur. Default is combine.
  52049. */
  52050. alphaBlendingMode: number;
  52051. /**
  52052. * The camera attached to the layer.
  52053. */
  52054. camera: Nullable<Camera>;
  52055. /**
  52056. * Should we display highlight as a solid stroke?
  52057. */
  52058. isStroke?: boolean;
  52059. /**
  52060. * The rendering group to draw the layer in.
  52061. */
  52062. renderingGroupId: number;
  52063. }
  52064. /**
  52065. * The highlight layer Helps adding a glow effect around a mesh.
  52066. *
  52067. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52068. * glowy meshes to your scene.
  52069. *
  52070. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52071. */
  52072. export class HighlightLayer extends EffectLayer {
  52073. name: string;
  52074. /**
  52075. * Effect Name of the highlight layer.
  52076. */
  52077. static readonly EffectName: string;
  52078. /**
  52079. * The neutral color used during the preparation of the glow effect.
  52080. * This is black by default as the blend operation is a blend operation.
  52081. */
  52082. static NeutralColor: Color4;
  52083. /**
  52084. * Stencil value used for glowing meshes.
  52085. */
  52086. static GlowingMeshStencilReference: number;
  52087. /**
  52088. * Stencil value used for the other meshes in the scene.
  52089. */
  52090. static NormalMeshStencilReference: number;
  52091. /**
  52092. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52093. */
  52094. innerGlow: boolean;
  52095. /**
  52096. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52097. */
  52098. outerGlow: boolean;
  52099. /**
  52100. * Specifies the horizontal size of the blur.
  52101. */
  52102. /**
  52103. * Gets the horizontal size of the blur.
  52104. */
  52105. blurHorizontalSize: number;
  52106. /**
  52107. * Specifies the vertical size of the blur.
  52108. */
  52109. /**
  52110. * Gets the vertical size of the blur.
  52111. */
  52112. blurVerticalSize: number;
  52113. /**
  52114. * An event triggered when the highlight layer is being blurred.
  52115. */
  52116. onBeforeBlurObservable: Observable<HighlightLayer>;
  52117. /**
  52118. * An event triggered when the highlight layer has been blurred.
  52119. */
  52120. onAfterBlurObservable: Observable<HighlightLayer>;
  52121. private _instanceGlowingMeshStencilReference;
  52122. private _options;
  52123. private _downSamplePostprocess;
  52124. private _horizontalBlurPostprocess;
  52125. private _verticalBlurPostprocess;
  52126. private _blurTexture;
  52127. private _meshes;
  52128. private _excludedMeshes;
  52129. /**
  52130. * Instantiates a new highlight Layer and references it to the scene..
  52131. * @param name The name of the layer
  52132. * @param scene The scene to use the layer in
  52133. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52134. */
  52135. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52136. /**
  52137. * Get the effect name of the layer.
  52138. * @return The effect name
  52139. */
  52140. getEffectName(): string;
  52141. /**
  52142. * Create the merge effect. This is the shader use to blit the information back
  52143. * to the main canvas at the end of the scene rendering.
  52144. */
  52145. protected _createMergeEffect(): Effect;
  52146. /**
  52147. * Creates the render target textures and post processes used in the highlight layer.
  52148. */
  52149. protected _createTextureAndPostProcesses(): void;
  52150. /**
  52151. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52152. */
  52153. needStencil(): boolean;
  52154. /**
  52155. * Checks for the readiness of the element composing the layer.
  52156. * @param subMesh the mesh to check for
  52157. * @param useInstances specify wether or not to use instances to render the mesh
  52158. * @param emissiveTexture the associated emissive texture used to generate the glow
  52159. * @return true if ready otherwise, false
  52160. */
  52161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52162. /**
  52163. * Implementation specific of rendering the generating effect on the main canvas.
  52164. * @param effect The effect used to render through
  52165. */
  52166. protected _internalRender(effect: Effect): void;
  52167. /**
  52168. * Returns true if the layer contains information to display, otherwise false.
  52169. */
  52170. shouldRender(): boolean;
  52171. /**
  52172. * Returns true if the mesh should render, otherwise false.
  52173. * @param mesh The mesh to render
  52174. * @returns true if it should render otherwise false
  52175. */
  52176. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52177. /**
  52178. * Sets the required values for both the emissive texture and and the main color.
  52179. */
  52180. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52181. /**
  52182. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52183. * @param mesh The mesh to exclude from the highlight layer
  52184. */
  52185. addExcludedMesh(mesh: Mesh): void;
  52186. /**
  52187. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52188. * @param mesh The mesh to highlight
  52189. */
  52190. removeExcludedMesh(mesh: Mesh): void;
  52191. /**
  52192. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52193. * @param mesh mesh to test
  52194. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52195. */
  52196. hasMesh(mesh: AbstractMesh): boolean;
  52197. /**
  52198. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52199. * @param mesh The mesh to highlight
  52200. * @param color The color of the highlight
  52201. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52202. */
  52203. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52204. /**
  52205. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52206. * @param mesh The mesh to highlight
  52207. */
  52208. removeMesh(mesh: Mesh): void;
  52209. /**
  52210. * Force the stencil to the normal expected value for none glowing parts
  52211. */
  52212. private _defaultStencilReference;
  52213. /**
  52214. * Free any resources and references associated to a mesh.
  52215. * Internal use
  52216. * @param mesh The mesh to free.
  52217. * @hidden
  52218. */
  52219. _disposeMesh(mesh: Mesh): void;
  52220. /**
  52221. * Dispose the highlight layer and free resources.
  52222. */
  52223. dispose(): void;
  52224. /**
  52225. * Gets the class name of the effect layer
  52226. * @returns the string with the class name of the effect layer
  52227. */
  52228. getClassName(): string;
  52229. /**
  52230. * Serializes this Highlight layer
  52231. * @returns a serialized Highlight layer object
  52232. */
  52233. serialize(): any;
  52234. /**
  52235. * Creates a Highlight layer from parsed Highlight layer data
  52236. * @param parsedHightlightLayer defines the Highlight layer data
  52237. * @param scene defines the current scene
  52238. * @param rootUrl defines the root URL containing the Highlight layer information
  52239. * @returns a parsed Highlight layer
  52240. */
  52241. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52242. }
  52243. }
  52244. declare module "babylonjs/Layers/layerSceneComponent" {
  52245. import { Scene } from "babylonjs/scene";
  52246. import { ISceneComponent } from "babylonjs/sceneComponent";
  52247. import { Layer } from "babylonjs/Layers/layer";
  52248. import { AbstractScene } from "babylonjs/abstractScene";
  52249. module "babylonjs/abstractScene" {
  52250. interface AbstractScene {
  52251. /**
  52252. * The list of layers (background and foreground) of the scene
  52253. */
  52254. layers: Array<Layer>;
  52255. }
  52256. }
  52257. /**
  52258. * Defines the layer scene component responsible to manage any layers
  52259. * in a given scene.
  52260. */
  52261. export class LayerSceneComponent implements ISceneComponent {
  52262. /**
  52263. * The component name helpfull to identify the component in the list of scene components.
  52264. */
  52265. readonly name: string;
  52266. /**
  52267. * The scene the component belongs to.
  52268. */
  52269. scene: Scene;
  52270. private _engine;
  52271. /**
  52272. * Creates a new instance of the component for the given scene
  52273. * @param scene Defines the scene to register the component in
  52274. */
  52275. constructor(scene: Scene);
  52276. /**
  52277. * Registers the component in a given scene
  52278. */
  52279. register(): void;
  52280. /**
  52281. * Rebuilds the elements related to this component in case of
  52282. * context lost for instance.
  52283. */
  52284. rebuild(): void;
  52285. /**
  52286. * Disposes the component and the associated ressources.
  52287. */
  52288. dispose(): void;
  52289. private _draw;
  52290. private _drawCameraPredicate;
  52291. private _drawCameraBackground;
  52292. private _drawCameraForeground;
  52293. private _drawRenderTargetPredicate;
  52294. private _drawRenderTargetBackground;
  52295. private _drawRenderTargetForeground;
  52296. /**
  52297. * Adds all the elements from the container to the scene
  52298. * @param container the container holding the elements
  52299. */
  52300. addFromContainer(container: AbstractScene): void;
  52301. /**
  52302. * Removes all the elements in the container from the scene
  52303. * @param container contains the elements to remove
  52304. * @param dispose if the removed element should be disposed (default: false)
  52305. */
  52306. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52307. }
  52308. }
  52309. declare module "babylonjs/Shaders/layer.fragment" {
  52310. /** @hidden */
  52311. export var layerPixelShader: {
  52312. name: string;
  52313. shader: string;
  52314. };
  52315. }
  52316. declare module "babylonjs/Shaders/layer.vertex" {
  52317. /** @hidden */
  52318. export var layerVertexShader: {
  52319. name: string;
  52320. shader: string;
  52321. };
  52322. }
  52323. declare module "babylonjs/Layers/layer" {
  52324. import { Observable } from "babylonjs/Misc/observable";
  52325. import { Nullable } from "babylonjs/types";
  52326. import { Scene } from "babylonjs/scene";
  52327. import { Vector2 } from "babylonjs/Maths/math.vector";
  52328. import { Color4 } from "babylonjs/Maths/math.color";
  52329. import { Texture } from "babylonjs/Materials/Textures/texture";
  52330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52331. import "babylonjs/Shaders/layer.fragment";
  52332. import "babylonjs/Shaders/layer.vertex";
  52333. /**
  52334. * This represents a full screen 2d layer.
  52335. * This can be useful to display a picture in the background of your scene for instance.
  52336. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52337. */
  52338. export class Layer {
  52339. /**
  52340. * Define the name of the layer.
  52341. */
  52342. name: string;
  52343. /**
  52344. * Define the texture the layer should display.
  52345. */
  52346. texture: Nullable<Texture>;
  52347. /**
  52348. * Is the layer in background or foreground.
  52349. */
  52350. isBackground: boolean;
  52351. /**
  52352. * Define the color of the layer (instead of texture).
  52353. */
  52354. color: Color4;
  52355. /**
  52356. * Define the scale of the layer in order to zoom in out of the texture.
  52357. */
  52358. scale: Vector2;
  52359. /**
  52360. * Define an offset for the layer in order to shift the texture.
  52361. */
  52362. offset: Vector2;
  52363. /**
  52364. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52365. */
  52366. alphaBlendingMode: number;
  52367. /**
  52368. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52369. * Alpha test will not mix with the background color in case of transparency.
  52370. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52371. */
  52372. alphaTest: boolean;
  52373. /**
  52374. * Define a mask to restrict the layer to only some of the scene cameras.
  52375. */
  52376. layerMask: number;
  52377. /**
  52378. * Define the list of render target the layer is visible into.
  52379. */
  52380. renderTargetTextures: RenderTargetTexture[];
  52381. /**
  52382. * Define if the layer is only used in renderTarget or if it also
  52383. * renders in the main frame buffer of the canvas.
  52384. */
  52385. renderOnlyInRenderTargetTextures: boolean;
  52386. private _scene;
  52387. private _vertexBuffers;
  52388. private _indexBuffer;
  52389. private _effect;
  52390. private _alphaTestEffect;
  52391. /**
  52392. * An event triggered when the layer is disposed.
  52393. */
  52394. onDisposeObservable: Observable<Layer>;
  52395. private _onDisposeObserver;
  52396. /**
  52397. * Back compatibility with callback before the onDisposeObservable existed.
  52398. * The set callback will be triggered when the layer has been disposed.
  52399. */
  52400. onDispose: () => void;
  52401. /**
  52402. * An event triggered before rendering the scene
  52403. */
  52404. onBeforeRenderObservable: Observable<Layer>;
  52405. private _onBeforeRenderObserver;
  52406. /**
  52407. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52408. * The set callback will be triggered just before rendering the layer.
  52409. */
  52410. onBeforeRender: () => void;
  52411. /**
  52412. * An event triggered after rendering the scene
  52413. */
  52414. onAfterRenderObservable: Observable<Layer>;
  52415. private _onAfterRenderObserver;
  52416. /**
  52417. * Back compatibility with callback before the onAfterRenderObservable existed.
  52418. * The set callback will be triggered just after rendering the layer.
  52419. */
  52420. onAfterRender: () => void;
  52421. /**
  52422. * Instantiates a new layer.
  52423. * This represents a full screen 2d layer.
  52424. * This can be useful to display a picture in the background of your scene for instance.
  52425. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52426. * @param name Define the name of the layer in the scene
  52427. * @param imgUrl Define the url of the texture to display in the layer
  52428. * @param scene Define the scene the layer belongs to
  52429. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52430. * @param color Defines a color for the layer
  52431. */
  52432. constructor(
  52433. /**
  52434. * Define the name of the layer.
  52435. */
  52436. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52437. private _createIndexBuffer;
  52438. /** @hidden */
  52439. _rebuild(): void;
  52440. /**
  52441. * Renders the layer in the scene.
  52442. */
  52443. render(): void;
  52444. /**
  52445. * Disposes and releases the associated ressources.
  52446. */
  52447. dispose(): void;
  52448. }
  52449. }
  52450. declare module "babylonjs/Layers/index" {
  52451. export * from "babylonjs/Layers/effectLayer";
  52452. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52453. export * from "babylonjs/Layers/glowLayer";
  52454. export * from "babylonjs/Layers/highlightLayer";
  52455. export * from "babylonjs/Layers/layer";
  52456. export * from "babylonjs/Layers/layerSceneComponent";
  52457. }
  52458. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52459. /** @hidden */
  52460. export var lensFlarePixelShader: {
  52461. name: string;
  52462. shader: string;
  52463. };
  52464. }
  52465. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52466. /** @hidden */
  52467. export var lensFlareVertexShader: {
  52468. name: string;
  52469. shader: string;
  52470. };
  52471. }
  52472. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52473. import { Scene } from "babylonjs/scene";
  52474. import { Vector3 } from "babylonjs/Maths/math.vector";
  52475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52476. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52477. import "babylonjs/Shaders/lensFlare.fragment";
  52478. import "babylonjs/Shaders/lensFlare.vertex";
  52479. import { Viewport } from "babylonjs/Maths/math.viewport";
  52480. /**
  52481. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52482. * It is usually composed of several `lensFlare`.
  52483. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52484. */
  52485. export class LensFlareSystem {
  52486. /**
  52487. * Define the name of the lens flare system
  52488. */
  52489. name: string;
  52490. /**
  52491. * List of lens flares used in this system.
  52492. */
  52493. lensFlares: LensFlare[];
  52494. /**
  52495. * Define a limit from the border the lens flare can be visible.
  52496. */
  52497. borderLimit: number;
  52498. /**
  52499. * Define a viewport border we do not want to see the lens flare in.
  52500. */
  52501. viewportBorder: number;
  52502. /**
  52503. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52504. */
  52505. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52506. /**
  52507. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52508. */
  52509. layerMask: number;
  52510. /**
  52511. * Define the id of the lens flare system in the scene.
  52512. * (equal to name by default)
  52513. */
  52514. id: string;
  52515. private _scene;
  52516. private _emitter;
  52517. private _vertexBuffers;
  52518. private _indexBuffer;
  52519. private _effect;
  52520. private _positionX;
  52521. private _positionY;
  52522. private _isEnabled;
  52523. /** @hidden */
  52524. static _SceneComponentInitialization: (scene: Scene) => void;
  52525. /**
  52526. * Instantiates a lens flare system.
  52527. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52528. * It is usually composed of several `lensFlare`.
  52529. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52530. * @param name Define the name of the lens flare system in the scene
  52531. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52532. * @param scene Define the scene the lens flare system belongs to
  52533. */
  52534. constructor(
  52535. /**
  52536. * Define the name of the lens flare system
  52537. */
  52538. name: string, emitter: any, scene: Scene);
  52539. /**
  52540. * Define if the lens flare system is enabled.
  52541. */
  52542. isEnabled: boolean;
  52543. /**
  52544. * Get the scene the effects belongs to.
  52545. * @returns the scene holding the lens flare system
  52546. */
  52547. getScene(): Scene;
  52548. /**
  52549. * Get the emitter of the lens flare system.
  52550. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52551. * @returns the emitter of the lens flare system
  52552. */
  52553. getEmitter(): any;
  52554. /**
  52555. * Set the emitter of the lens flare system.
  52556. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52557. * @param newEmitter Define the new emitter of the system
  52558. */
  52559. setEmitter(newEmitter: any): void;
  52560. /**
  52561. * Get the lens flare system emitter position.
  52562. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52563. * @returns the position
  52564. */
  52565. getEmitterPosition(): Vector3;
  52566. /**
  52567. * @hidden
  52568. */
  52569. computeEffectivePosition(globalViewport: Viewport): boolean;
  52570. /** @hidden */
  52571. _isVisible(): boolean;
  52572. /**
  52573. * @hidden
  52574. */
  52575. render(): boolean;
  52576. /**
  52577. * Dispose and release the lens flare with its associated resources.
  52578. */
  52579. dispose(): void;
  52580. /**
  52581. * Parse a lens flare system from a JSON repressentation
  52582. * @param parsedLensFlareSystem Define the JSON to parse
  52583. * @param scene Define the scene the parsed system should be instantiated in
  52584. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52585. * @returns the parsed system
  52586. */
  52587. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52588. /**
  52589. * Serialize the current Lens Flare System into a JSON representation.
  52590. * @returns the serialized JSON
  52591. */
  52592. serialize(): any;
  52593. }
  52594. }
  52595. declare module "babylonjs/LensFlares/lensFlare" {
  52596. import { Nullable } from "babylonjs/types";
  52597. import { Color3 } from "babylonjs/Maths/math.color";
  52598. import { Texture } from "babylonjs/Materials/Textures/texture";
  52599. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52600. /**
  52601. * This represents one of the lens effect in a `lensFlareSystem`.
  52602. * It controls one of the indiviual texture used in the effect.
  52603. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52604. */
  52605. export class LensFlare {
  52606. /**
  52607. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52608. */
  52609. size: number;
  52610. /**
  52611. * 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.
  52612. */
  52613. position: number;
  52614. /**
  52615. * Define the lens color.
  52616. */
  52617. color: Color3;
  52618. /**
  52619. * Define the lens texture.
  52620. */
  52621. texture: Nullable<Texture>;
  52622. /**
  52623. * Define the alpha mode to render this particular lens.
  52624. */
  52625. alphaMode: number;
  52626. private _system;
  52627. /**
  52628. * Creates a new Lens Flare.
  52629. * This represents one of the lens effect in a `lensFlareSystem`.
  52630. * It controls one of the indiviual texture used in the effect.
  52631. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52632. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52633. * @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.
  52634. * @param color Define the lens color
  52635. * @param imgUrl Define the lens texture url
  52636. * @param system Define the `lensFlareSystem` this flare is part of
  52637. * @returns The newly created Lens Flare
  52638. */
  52639. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52640. /**
  52641. * Instantiates a new Lens Flare.
  52642. * This represents one of the lens effect in a `lensFlareSystem`.
  52643. * It controls one of the indiviual texture used in the effect.
  52644. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52645. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52646. * @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.
  52647. * @param color Define the lens color
  52648. * @param imgUrl Define the lens texture url
  52649. * @param system Define the `lensFlareSystem` this flare is part of
  52650. */
  52651. constructor(
  52652. /**
  52653. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52654. */
  52655. size: number,
  52656. /**
  52657. * 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.
  52658. */
  52659. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52660. /**
  52661. * Dispose and release the lens flare with its associated resources.
  52662. */
  52663. dispose(): void;
  52664. }
  52665. }
  52666. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52667. import { Nullable } from "babylonjs/types";
  52668. import { Scene } from "babylonjs/scene";
  52669. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52670. import { AbstractScene } from "babylonjs/abstractScene";
  52671. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52672. module "babylonjs/abstractScene" {
  52673. interface AbstractScene {
  52674. /**
  52675. * The list of lens flare system added to the scene
  52676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52677. */
  52678. lensFlareSystems: Array<LensFlareSystem>;
  52679. /**
  52680. * Removes the given lens flare system from this scene.
  52681. * @param toRemove The lens flare system to remove
  52682. * @returns The index of the removed lens flare system
  52683. */
  52684. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52685. /**
  52686. * Adds the given lens flare system to this scene
  52687. * @param newLensFlareSystem The lens flare system to add
  52688. */
  52689. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52690. /**
  52691. * Gets a lens flare system using its name
  52692. * @param name defines the name to look for
  52693. * @returns the lens flare system or null if not found
  52694. */
  52695. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52696. /**
  52697. * Gets a lens flare system using its id
  52698. * @param id defines the id to look for
  52699. * @returns the lens flare system or null if not found
  52700. */
  52701. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52702. }
  52703. }
  52704. /**
  52705. * Defines the lens flare scene component responsible to manage any lens flares
  52706. * in a given scene.
  52707. */
  52708. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52709. /**
  52710. * The component name helpfull to identify the component in the list of scene components.
  52711. */
  52712. readonly name: string;
  52713. /**
  52714. * The scene the component belongs to.
  52715. */
  52716. scene: Scene;
  52717. /**
  52718. * Creates a new instance of the component for the given scene
  52719. * @param scene Defines the scene to register the component in
  52720. */
  52721. constructor(scene: Scene);
  52722. /**
  52723. * Registers the component in a given scene
  52724. */
  52725. register(): void;
  52726. /**
  52727. * Rebuilds the elements related to this component in case of
  52728. * context lost for instance.
  52729. */
  52730. rebuild(): void;
  52731. /**
  52732. * Adds all the elements from the container to the scene
  52733. * @param container the container holding the elements
  52734. */
  52735. addFromContainer(container: AbstractScene): void;
  52736. /**
  52737. * Removes all the elements in the container from the scene
  52738. * @param container contains the elements to remove
  52739. * @param dispose if the removed element should be disposed (default: false)
  52740. */
  52741. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52742. /**
  52743. * Serializes the component data to the specified json object
  52744. * @param serializationObject The object to serialize to
  52745. */
  52746. serialize(serializationObject: any): void;
  52747. /**
  52748. * Disposes the component and the associated ressources.
  52749. */
  52750. dispose(): void;
  52751. private _draw;
  52752. }
  52753. }
  52754. declare module "babylonjs/LensFlares/index" {
  52755. export * from "babylonjs/LensFlares/lensFlare";
  52756. export * from "babylonjs/LensFlares/lensFlareSystem";
  52757. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52758. }
  52759. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52760. import { Scene } from "babylonjs/scene";
  52761. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52762. import { AbstractScene } from "babylonjs/abstractScene";
  52763. /**
  52764. * Defines the shadow generator component responsible to manage any shadow generators
  52765. * in a given scene.
  52766. */
  52767. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52768. /**
  52769. * The component name helpfull to identify the component in the list of scene components.
  52770. */
  52771. readonly name: string;
  52772. /**
  52773. * The scene the component belongs to.
  52774. */
  52775. scene: Scene;
  52776. /**
  52777. * Creates a new instance of the component for the given scene
  52778. * @param scene Defines the scene to register the component in
  52779. */
  52780. constructor(scene: Scene);
  52781. /**
  52782. * Registers the component in a given scene
  52783. */
  52784. register(): void;
  52785. /**
  52786. * Rebuilds the elements related to this component in case of
  52787. * context lost for instance.
  52788. */
  52789. rebuild(): void;
  52790. /**
  52791. * Serializes the component data to the specified json object
  52792. * @param serializationObject The object to serialize to
  52793. */
  52794. serialize(serializationObject: any): void;
  52795. /**
  52796. * Adds all the elements from the container to the scene
  52797. * @param container the container holding the elements
  52798. */
  52799. addFromContainer(container: AbstractScene): void;
  52800. /**
  52801. * Removes all the elements in the container from the scene
  52802. * @param container contains the elements to remove
  52803. * @param dispose if the removed element should be disposed (default: false)
  52804. */
  52805. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52806. /**
  52807. * Rebuilds the elements related to this component in case of
  52808. * context lost for instance.
  52809. */
  52810. dispose(): void;
  52811. private _gatherRenderTargets;
  52812. }
  52813. }
  52814. declare module "babylonjs/Lights/Shadows/index" {
  52815. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52816. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52817. }
  52818. declare module "babylonjs/Lights/pointLight" {
  52819. import { Scene } from "babylonjs/scene";
  52820. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52822. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52823. import { Effect } from "babylonjs/Materials/effect";
  52824. /**
  52825. * A point light is a light defined by an unique point in world space.
  52826. * The light is emitted in every direction from this point.
  52827. * A good example of a point light is a standard light bulb.
  52828. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52829. */
  52830. export class PointLight extends ShadowLight {
  52831. private _shadowAngle;
  52832. /**
  52833. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52834. * This specifies what angle the shadow will use to be created.
  52835. *
  52836. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52837. */
  52838. /**
  52839. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52840. * This specifies what angle the shadow will use to be created.
  52841. *
  52842. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52843. */
  52844. shadowAngle: number;
  52845. /**
  52846. * Gets the direction if it has been set.
  52847. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52848. */
  52849. /**
  52850. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52851. */
  52852. direction: Vector3;
  52853. /**
  52854. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52855. * A PointLight emits the light in every direction.
  52856. * It can cast shadows.
  52857. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52858. * ```javascript
  52859. * var pointLight = new PointLight("pl", camera.position, scene);
  52860. * ```
  52861. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52862. * @param name The light friendly name
  52863. * @param position The position of the point light in the scene
  52864. * @param scene The scene the lights belongs to
  52865. */
  52866. constructor(name: string, position: Vector3, scene: Scene);
  52867. /**
  52868. * Returns the string "PointLight"
  52869. * @returns the class name
  52870. */
  52871. getClassName(): string;
  52872. /**
  52873. * Returns the integer 0.
  52874. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52875. */
  52876. getTypeID(): number;
  52877. /**
  52878. * Specifies wether or not the shadowmap should be a cube texture.
  52879. * @returns true if the shadowmap needs to be a cube texture.
  52880. */
  52881. needCube(): boolean;
  52882. /**
  52883. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52884. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52885. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52886. */
  52887. getShadowDirection(faceIndex?: number): Vector3;
  52888. /**
  52889. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52890. * - fov = PI / 2
  52891. * - aspect ratio : 1.0
  52892. * - z-near and far equal to the active camera minZ and maxZ.
  52893. * Returns the PointLight.
  52894. */
  52895. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52896. protected _buildUniformLayout(): void;
  52897. /**
  52898. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52899. * @param effect The effect to update
  52900. * @param lightIndex The index of the light in the effect to update
  52901. * @returns The point light
  52902. */
  52903. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52904. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52905. /**
  52906. * Prepares the list of defines specific to the light type.
  52907. * @param defines the list of defines
  52908. * @param lightIndex defines the index of the light for the effect
  52909. */
  52910. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52911. }
  52912. }
  52913. declare module "babylonjs/Lights/index" {
  52914. export * from "babylonjs/Lights/light";
  52915. export * from "babylonjs/Lights/shadowLight";
  52916. export * from "babylonjs/Lights/Shadows/index";
  52917. export * from "babylonjs/Lights/directionalLight";
  52918. export * from "babylonjs/Lights/hemisphericLight";
  52919. export * from "babylonjs/Lights/pointLight";
  52920. export * from "babylonjs/Lights/spotLight";
  52921. }
  52922. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52923. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52924. /**
  52925. * Header information of HDR texture files.
  52926. */
  52927. export interface HDRInfo {
  52928. /**
  52929. * The height of the texture in pixels.
  52930. */
  52931. height: number;
  52932. /**
  52933. * The width of the texture in pixels.
  52934. */
  52935. width: number;
  52936. /**
  52937. * The index of the beginning of the data in the binary file.
  52938. */
  52939. dataPosition: number;
  52940. }
  52941. /**
  52942. * This groups tools to convert HDR texture to native colors array.
  52943. */
  52944. export class HDRTools {
  52945. private static Ldexp;
  52946. private static Rgbe2float;
  52947. private static readStringLine;
  52948. /**
  52949. * Reads header information from an RGBE texture stored in a native array.
  52950. * More information on this format are available here:
  52951. * https://en.wikipedia.org/wiki/RGBE_image_format
  52952. *
  52953. * @param uint8array The binary file stored in native array.
  52954. * @return The header information.
  52955. */
  52956. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52957. /**
  52958. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52959. * This RGBE texture needs to store the information as a panorama.
  52960. *
  52961. * More information on this format are available here:
  52962. * https://en.wikipedia.org/wiki/RGBE_image_format
  52963. *
  52964. * @param buffer The binary file stored in an array buffer.
  52965. * @param size The expected size of the extracted cubemap.
  52966. * @return The Cube Map information.
  52967. */
  52968. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52969. /**
  52970. * Returns the pixels data extracted from an RGBE texture.
  52971. * This pixels will be stored left to right up to down in the R G B order in one array.
  52972. *
  52973. * More information on this format are available here:
  52974. * https://en.wikipedia.org/wiki/RGBE_image_format
  52975. *
  52976. * @param uint8array The binary file stored in an array buffer.
  52977. * @param hdrInfo The header information of the file.
  52978. * @return The pixels data in RGB right to left up to down order.
  52979. */
  52980. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52981. private static RGBE_ReadPixels_RLE;
  52982. }
  52983. }
  52984. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52985. import { Nullable } from "babylonjs/types";
  52986. import { Scene } from "babylonjs/scene";
  52987. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52989. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52990. /**
  52991. * This represents a texture coming from an HDR input.
  52992. *
  52993. * The only supported format is currently panorama picture stored in RGBE format.
  52994. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52995. */
  52996. export class HDRCubeTexture extends BaseTexture {
  52997. private static _facesMapping;
  52998. private _generateHarmonics;
  52999. private _noMipmap;
  53000. private _textureMatrix;
  53001. private _size;
  53002. private _onLoad;
  53003. private _onError;
  53004. /**
  53005. * The texture URL.
  53006. */
  53007. url: string;
  53008. /**
  53009. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53010. */
  53011. coordinatesMode: number;
  53012. protected _isBlocking: boolean;
  53013. /**
  53014. * Sets wether or not the texture is blocking during loading.
  53015. */
  53016. /**
  53017. * Gets wether or not the texture is blocking during loading.
  53018. */
  53019. isBlocking: boolean;
  53020. protected _rotationY: number;
  53021. /**
  53022. * Sets texture matrix rotation angle around Y axis in radians.
  53023. */
  53024. /**
  53025. * Gets texture matrix rotation angle around Y axis radians.
  53026. */
  53027. rotationY: number;
  53028. /**
  53029. * Gets or sets the center of the bounding box associated with the cube texture
  53030. * It must define where the camera used to render the texture was set
  53031. */
  53032. boundingBoxPosition: Vector3;
  53033. private _boundingBoxSize;
  53034. /**
  53035. * Gets or sets the size of the bounding box associated with the cube texture
  53036. * When defined, the cubemap will switch to local mode
  53037. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53038. * @example https://www.babylonjs-playground.com/#RNASML
  53039. */
  53040. boundingBoxSize: Vector3;
  53041. /**
  53042. * Instantiates an HDRTexture from the following parameters.
  53043. *
  53044. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53045. * @param scene The scene the texture will be used in
  53046. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53047. * @param noMipmap Forces to not generate the mipmap if true
  53048. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53049. * @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)
  53050. * @param reserved Reserved flag for internal use.
  53051. */
  53052. 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>);
  53053. /**
  53054. * Get the current class name of the texture useful for serialization or dynamic coding.
  53055. * @returns "HDRCubeTexture"
  53056. */
  53057. getClassName(): string;
  53058. /**
  53059. * Occurs when the file is raw .hdr file.
  53060. */
  53061. private loadTexture;
  53062. clone(): HDRCubeTexture;
  53063. delayLoad(): void;
  53064. /**
  53065. * Get the texture reflection matrix used to rotate/transform the reflection.
  53066. * @returns the reflection matrix
  53067. */
  53068. getReflectionTextureMatrix(): Matrix;
  53069. /**
  53070. * Set the texture reflection matrix used to rotate/transform the reflection.
  53071. * @param value Define the reflection matrix to set
  53072. */
  53073. setReflectionTextureMatrix(value: Matrix): void;
  53074. /**
  53075. * Parses a JSON representation of an HDR Texture in order to create the texture
  53076. * @param parsedTexture Define the JSON representation
  53077. * @param scene Define the scene the texture should be created in
  53078. * @param rootUrl Define the root url in case we need to load relative dependencies
  53079. * @returns the newly created texture after parsing
  53080. */
  53081. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53082. serialize(): any;
  53083. }
  53084. }
  53085. declare module "babylonjs/Physics/physicsEngine" {
  53086. import { Nullable } from "babylonjs/types";
  53087. import { Vector3 } from "babylonjs/Maths/math.vector";
  53088. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53089. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53090. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53091. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53092. /**
  53093. * Class used to control physics engine
  53094. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53095. */
  53096. export class PhysicsEngine implements IPhysicsEngine {
  53097. private _physicsPlugin;
  53098. /**
  53099. * Global value used to control the smallest number supported by the simulation
  53100. */
  53101. static Epsilon: number;
  53102. private _impostors;
  53103. private _joints;
  53104. /**
  53105. * Gets the gravity vector used by the simulation
  53106. */
  53107. gravity: Vector3;
  53108. /**
  53109. * Factory used to create the default physics plugin.
  53110. * @returns The default physics plugin
  53111. */
  53112. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53113. /**
  53114. * Creates a new Physics Engine
  53115. * @param gravity defines the gravity vector used by the simulation
  53116. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53117. */
  53118. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53119. /**
  53120. * Sets the gravity vector used by the simulation
  53121. * @param gravity defines the gravity vector to use
  53122. */
  53123. setGravity(gravity: Vector3): void;
  53124. /**
  53125. * Set the time step of the physics engine.
  53126. * Default is 1/60.
  53127. * To slow it down, enter 1/600 for example.
  53128. * To speed it up, 1/30
  53129. * @param newTimeStep defines the new timestep to apply to this world.
  53130. */
  53131. setTimeStep(newTimeStep?: number): void;
  53132. /**
  53133. * Get the time step of the physics engine.
  53134. * @returns the current time step
  53135. */
  53136. getTimeStep(): number;
  53137. /**
  53138. * Release all resources
  53139. */
  53140. dispose(): void;
  53141. /**
  53142. * Gets the name of the current physics plugin
  53143. * @returns the name of the plugin
  53144. */
  53145. getPhysicsPluginName(): string;
  53146. /**
  53147. * Adding a new impostor for the impostor tracking.
  53148. * This will be done by the impostor itself.
  53149. * @param impostor the impostor to add
  53150. */
  53151. addImpostor(impostor: PhysicsImpostor): void;
  53152. /**
  53153. * Remove an impostor from the engine.
  53154. * This impostor and its mesh will not longer be updated by the physics engine.
  53155. * @param impostor the impostor to remove
  53156. */
  53157. removeImpostor(impostor: PhysicsImpostor): void;
  53158. /**
  53159. * Add a joint to the physics engine
  53160. * @param mainImpostor defines the main impostor to which the joint is added.
  53161. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53162. * @param joint defines the joint that will connect both impostors.
  53163. */
  53164. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53165. /**
  53166. * Removes a joint from the simulation
  53167. * @param mainImpostor defines the impostor used with the joint
  53168. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53169. * @param joint defines the joint to remove
  53170. */
  53171. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53172. /**
  53173. * Called by the scene. No need to call it.
  53174. * @param delta defines the timespam between frames
  53175. */
  53176. _step(delta: number): void;
  53177. /**
  53178. * Gets the current plugin used to run the simulation
  53179. * @returns current plugin
  53180. */
  53181. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53182. /**
  53183. * Gets the list of physic impostors
  53184. * @returns an array of PhysicsImpostor
  53185. */
  53186. getImpostors(): Array<PhysicsImpostor>;
  53187. /**
  53188. * Gets the impostor for a physics enabled object
  53189. * @param object defines the object impersonated by the impostor
  53190. * @returns the PhysicsImpostor or null if not found
  53191. */
  53192. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53193. /**
  53194. * Gets the impostor for a physics body object
  53195. * @param body defines physics body used by the impostor
  53196. * @returns the PhysicsImpostor or null if not found
  53197. */
  53198. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53199. /**
  53200. * Does a raycast in the physics world
  53201. * @param from when should the ray start?
  53202. * @param to when should the ray end?
  53203. * @returns PhysicsRaycastResult
  53204. */
  53205. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53206. }
  53207. }
  53208. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53209. import { Nullable } from "babylonjs/types";
  53210. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53212. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53213. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53214. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53215. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53216. /** @hidden */
  53217. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53218. private _useDeltaForWorldStep;
  53219. world: any;
  53220. name: string;
  53221. private _physicsMaterials;
  53222. private _fixedTimeStep;
  53223. private _cannonRaycastResult;
  53224. private _raycastResult;
  53225. private _physicsBodysToRemoveAfterStep;
  53226. BJSCANNON: any;
  53227. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53228. setGravity(gravity: Vector3): void;
  53229. setTimeStep(timeStep: number): void;
  53230. getTimeStep(): number;
  53231. executeStep(delta: number): void;
  53232. private _removeMarkedPhysicsBodiesFromWorld;
  53233. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53234. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53235. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53236. private _processChildMeshes;
  53237. removePhysicsBody(impostor: PhysicsImpostor): void;
  53238. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53239. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53240. private _addMaterial;
  53241. private _checkWithEpsilon;
  53242. private _createShape;
  53243. private _createHeightmap;
  53244. private _minus90X;
  53245. private _plus90X;
  53246. private _tmpPosition;
  53247. private _tmpDeltaPosition;
  53248. private _tmpUnityRotation;
  53249. private _updatePhysicsBodyTransformation;
  53250. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53251. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53252. isSupported(): boolean;
  53253. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53254. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53255. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53256. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53257. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53258. getBodyMass(impostor: PhysicsImpostor): number;
  53259. getBodyFriction(impostor: PhysicsImpostor): number;
  53260. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53261. getBodyRestitution(impostor: PhysicsImpostor): number;
  53262. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53263. sleepBody(impostor: PhysicsImpostor): void;
  53264. wakeUpBody(impostor: PhysicsImpostor): void;
  53265. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53266. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53267. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53268. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53269. getRadius(impostor: PhysicsImpostor): number;
  53270. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53271. dispose(): void;
  53272. private _extendNamespace;
  53273. /**
  53274. * Does a raycast in the physics world
  53275. * @param from when should the ray start?
  53276. * @param to when should the ray end?
  53277. * @returns PhysicsRaycastResult
  53278. */
  53279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53280. }
  53281. }
  53282. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53283. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53284. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53285. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53287. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53288. import { Nullable } from "babylonjs/types";
  53289. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53290. /** @hidden */
  53291. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53292. world: any;
  53293. name: string;
  53294. BJSOIMO: any;
  53295. private _raycastResult;
  53296. constructor(iterations?: number, oimoInjection?: any);
  53297. setGravity(gravity: Vector3): void;
  53298. setTimeStep(timeStep: number): void;
  53299. getTimeStep(): number;
  53300. private _tmpImpostorsArray;
  53301. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53302. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53303. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53304. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53305. private _tmpPositionVector;
  53306. removePhysicsBody(impostor: PhysicsImpostor): void;
  53307. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53308. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53309. isSupported(): boolean;
  53310. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53311. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53312. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53313. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53314. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53315. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53316. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53317. getBodyMass(impostor: PhysicsImpostor): number;
  53318. getBodyFriction(impostor: PhysicsImpostor): number;
  53319. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53320. getBodyRestitution(impostor: PhysicsImpostor): number;
  53321. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53322. sleepBody(impostor: PhysicsImpostor): void;
  53323. wakeUpBody(impostor: PhysicsImpostor): void;
  53324. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53325. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53326. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53327. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53328. getRadius(impostor: PhysicsImpostor): number;
  53329. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53330. dispose(): void;
  53331. /**
  53332. * Does a raycast in the physics world
  53333. * @param from when should the ray start?
  53334. * @param to when should the ray end?
  53335. * @returns PhysicsRaycastResult
  53336. */
  53337. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53338. }
  53339. }
  53340. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53341. import { Nullable } from "babylonjs/types";
  53342. import { Scene } from "babylonjs/scene";
  53343. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53344. import { Color4 } from "babylonjs/Maths/math.color";
  53345. import { Mesh } from "babylonjs/Meshes/mesh";
  53346. /**
  53347. * Class containing static functions to help procedurally build meshes
  53348. */
  53349. export class RibbonBuilder {
  53350. /**
  53351. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53352. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53353. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53354. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53355. * * 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
  53356. * * 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
  53357. * * 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
  53358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53361. * * 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
  53362. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53363. * * 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
  53364. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53366. * @param name defines the name of the mesh
  53367. * @param options defines the options used to create the mesh
  53368. * @param scene defines the hosting scene
  53369. * @returns the ribbon mesh
  53370. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53372. */
  53373. static CreateRibbon(name: string, options: {
  53374. pathArray: Vector3[][];
  53375. closeArray?: boolean;
  53376. closePath?: boolean;
  53377. offset?: number;
  53378. updatable?: boolean;
  53379. sideOrientation?: number;
  53380. frontUVs?: Vector4;
  53381. backUVs?: Vector4;
  53382. instance?: Mesh;
  53383. invertUV?: boolean;
  53384. uvs?: Vector2[];
  53385. colors?: Color4[];
  53386. }, scene?: Nullable<Scene>): Mesh;
  53387. }
  53388. }
  53389. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53390. import { Nullable } from "babylonjs/types";
  53391. import { Scene } from "babylonjs/scene";
  53392. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53393. import { Mesh } from "babylonjs/Meshes/mesh";
  53394. /**
  53395. * Class containing static functions to help procedurally build meshes
  53396. */
  53397. export class ShapeBuilder {
  53398. /**
  53399. * 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.
  53400. * * 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.
  53401. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53402. * * 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.
  53403. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53404. * * 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
  53405. * * 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
  53406. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53411. * @param name defines the name of the mesh
  53412. * @param options defines the options used to create the mesh
  53413. * @param scene defines the hosting scene
  53414. * @returns the extruded shape mesh
  53415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53417. */
  53418. static ExtrudeShape(name: string, options: {
  53419. shape: Vector3[];
  53420. path: Vector3[];
  53421. scale?: number;
  53422. rotation?: number;
  53423. cap?: number;
  53424. updatable?: boolean;
  53425. sideOrientation?: number;
  53426. frontUVs?: Vector4;
  53427. backUVs?: Vector4;
  53428. instance?: Mesh;
  53429. invertUV?: boolean;
  53430. }, scene?: Nullable<Scene>): Mesh;
  53431. /**
  53432. * Creates an custom extruded shape mesh.
  53433. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53434. * * 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.
  53435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53436. * * 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
  53437. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53438. * * 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
  53439. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53440. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53441. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53442. * * 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
  53443. * * 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
  53444. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53449. * @param name defines the name of the mesh
  53450. * @param options defines the options used to create the mesh
  53451. * @param scene defines the hosting scene
  53452. * @returns the custom extruded shape mesh
  53453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53454. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53456. */
  53457. static ExtrudeShapeCustom(name: string, options: {
  53458. shape: Vector3[];
  53459. path: Vector3[];
  53460. scaleFunction?: any;
  53461. rotationFunction?: any;
  53462. ribbonCloseArray?: boolean;
  53463. ribbonClosePath?: boolean;
  53464. cap?: number;
  53465. updatable?: boolean;
  53466. sideOrientation?: number;
  53467. frontUVs?: Vector4;
  53468. backUVs?: Vector4;
  53469. instance?: Mesh;
  53470. invertUV?: boolean;
  53471. }, scene?: Nullable<Scene>): Mesh;
  53472. private static _ExtrudeShapeGeneric;
  53473. }
  53474. }
  53475. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53476. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53477. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53478. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53479. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53480. import { Nullable } from "babylonjs/types";
  53481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53482. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53483. /**
  53484. * AmmoJS Physics plugin
  53485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53486. * @see https://github.com/kripken/ammo.js/
  53487. */
  53488. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53489. private _useDeltaForWorldStep;
  53490. /**
  53491. * Reference to the Ammo library
  53492. */
  53493. bjsAMMO: any;
  53494. /**
  53495. * Created ammoJS world which physics bodies are added to
  53496. */
  53497. world: any;
  53498. /**
  53499. * Name of the plugin
  53500. */
  53501. name: string;
  53502. private _timeStep;
  53503. private _fixedTimeStep;
  53504. private _maxSteps;
  53505. private _tmpQuaternion;
  53506. private _tmpAmmoTransform;
  53507. private _tmpAmmoQuaternion;
  53508. private _tmpAmmoConcreteContactResultCallback;
  53509. private _collisionConfiguration;
  53510. private _dispatcher;
  53511. private _overlappingPairCache;
  53512. private _solver;
  53513. private _softBodySolver;
  53514. private _tmpAmmoVectorA;
  53515. private _tmpAmmoVectorB;
  53516. private _tmpAmmoVectorC;
  53517. private _tmpAmmoVectorD;
  53518. private _tmpContactCallbackResult;
  53519. private _tmpAmmoVectorRCA;
  53520. private _tmpAmmoVectorRCB;
  53521. private _raycastResult;
  53522. private static readonly DISABLE_COLLISION_FLAG;
  53523. private static readonly KINEMATIC_FLAG;
  53524. private static readonly DISABLE_DEACTIVATION_FLAG;
  53525. /**
  53526. * Initializes the ammoJS plugin
  53527. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53528. * @param ammoInjection can be used to inject your own ammo reference
  53529. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53530. */
  53531. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53532. /**
  53533. * Sets the gravity of the physics world (m/(s^2))
  53534. * @param gravity Gravity to set
  53535. */
  53536. setGravity(gravity: Vector3): void;
  53537. /**
  53538. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53539. * @param timeStep timestep to use in seconds
  53540. */
  53541. setTimeStep(timeStep: number): void;
  53542. /**
  53543. * 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)
  53544. * @param fixedTimeStep fixedTimeStep to use in seconds
  53545. */
  53546. setFixedTimeStep(fixedTimeStep: number): void;
  53547. /**
  53548. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53549. * @param maxSteps the maximum number of steps by the physics engine per frame
  53550. */
  53551. setMaxSteps(maxSteps: number): void;
  53552. /**
  53553. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53554. * @returns the current timestep in seconds
  53555. */
  53556. getTimeStep(): number;
  53557. private _isImpostorInContact;
  53558. private _isImpostorPairInContact;
  53559. private _stepSimulation;
  53560. /**
  53561. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53562. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53563. * After the step the babylon meshes are set to the position of the physics imposters
  53564. * @param delta amount of time to step forward
  53565. * @param impostors array of imposters to update before/after the step
  53566. */
  53567. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53568. /**
  53569. * Update babylon mesh to match physics world object
  53570. * @param impostor imposter to match
  53571. */
  53572. private _afterSoftStep;
  53573. /**
  53574. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53575. * @param impostor imposter to match
  53576. */
  53577. private _ropeStep;
  53578. /**
  53579. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53580. * @param impostor imposter to match
  53581. */
  53582. private _softbodyOrClothStep;
  53583. private _tmpVector;
  53584. private _tmpMatrix;
  53585. /**
  53586. * Applies an impulse on the imposter
  53587. * @param impostor imposter to apply impulse to
  53588. * @param force amount of force to be applied to the imposter
  53589. * @param contactPoint the location to apply the impulse on the imposter
  53590. */
  53591. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53592. /**
  53593. * Applies a force on the imposter
  53594. * @param impostor imposter to apply force
  53595. * @param force amount of force to be applied to the imposter
  53596. * @param contactPoint the location to apply the force on the imposter
  53597. */
  53598. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53599. /**
  53600. * Creates a physics body using the plugin
  53601. * @param impostor the imposter to create the physics body on
  53602. */
  53603. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53604. /**
  53605. * Removes the physics body from the imposter and disposes of the body's memory
  53606. * @param impostor imposter to remove the physics body from
  53607. */
  53608. removePhysicsBody(impostor: PhysicsImpostor): void;
  53609. /**
  53610. * Generates a joint
  53611. * @param impostorJoint the imposter joint to create the joint with
  53612. */
  53613. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53614. /**
  53615. * Removes a joint
  53616. * @param impostorJoint the imposter joint to remove the joint from
  53617. */
  53618. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53619. private _addMeshVerts;
  53620. /**
  53621. * Initialise the soft body vertices to match its object's (mesh) vertices
  53622. * Softbody vertices (nodes) are in world space and to match this
  53623. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53624. * @param impostor to create the softbody for
  53625. */
  53626. private _softVertexData;
  53627. /**
  53628. * Create an impostor's soft body
  53629. * @param impostor to create the softbody for
  53630. */
  53631. private _createSoftbody;
  53632. /**
  53633. * Create cloth for an impostor
  53634. * @param impostor to create the softbody for
  53635. */
  53636. private _createCloth;
  53637. /**
  53638. * Create rope for an impostor
  53639. * @param impostor to create the softbody for
  53640. */
  53641. private _createRope;
  53642. private _addHullVerts;
  53643. private _createShape;
  53644. /**
  53645. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53646. * @param impostor imposter containing the physics body and babylon object
  53647. */
  53648. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53649. /**
  53650. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53651. * @param impostor imposter containing the physics body and babylon object
  53652. * @param newPosition new position
  53653. * @param newRotation new rotation
  53654. */
  53655. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53656. /**
  53657. * If this plugin is supported
  53658. * @returns true if its supported
  53659. */
  53660. isSupported(): boolean;
  53661. /**
  53662. * Sets the linear velocity of the physics body
  53663. * @param impostor imposter to set the velocity on
  53664. * @param velocity velocity to set
  53665. */
  53666. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53667. /**
  53668. * Sets the angular velocity of the physics body
  53669. * @param impostor imposter to set the velocity on
  53670. * @param velocity velocity to set
  53671. */
  53672. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53673. /**
  53674. * gets the linear velocity
  53675. * @param impostor imposter to get linear velocity from
  53676. * @returns linear velocity
  53677. */
  53678. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53679. /**
  53680. * gets the angular velocity
  53681. * @param impostor imposter to get angular velocity from
  53682. * @returns angular velocity
  53683. */
  53684. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53685. /**
  53686. * Sets the mass of physics body
  53687. * @param impostor imposter to set the mass on
  53688. * @param mass mass to set
  53689. */
  53690. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53691. /**
  53692. * Gets the mass of the physics body
  53693. * @param impostor imposter to get the mass from
  53694. * @returns mass
  53695. */
  53696. getBodyMass(impostor: PhysicsImpostor): number;
  53697. /**
  53698. * Gets friction of the impostor
  53699. * @param impostor impostor to get friction from
  53700. * @returns friction value
  53701. */
  53702. getBodyFriction(impostor: PhysicsImpostor): number;
  53703. /**
  53704. * Sets friction of the impostor
  53705. * @param impostor impostor to set friction on
  53706. * @param friction friction value
  53707. */
  53708. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53709. /**
  53710. * Gets restitution of the impostor
  53711. * @param impostor impostor to get restitution from
  53712. * @returns restitution value
  53713. */
  53714. getBodyRestitution(impostor: PhysicsImpostor): number;
  53715. /**
  53716. * Sets resitution of the impostor
  53717. * @param impostor impostor to set resitution on
  53718. * @param restitution resitution value
  53719. */
  53720. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53721. /**
  53722. * Gets pressure inside the impostor
  53723. * @param impostor impostor to get pressure from
  53724. * @returns pressure value
  53725. */
  53726. getBodyPressure(impostor: PhysicsImpostor): number;
  53727. /**
  53728. * Sets pressure inside a soft body impostor
  53729. * Cloth and rope must remain 0 pressure
  53730. * @param impostor impostor to set pressure on
  53731. * @param pressure pressure value
  53732. */
  53733. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53734. /**
  53735. * Gets stiffness of the impostor
  53736. * @param impostor impostor to get stiffness from
  53737. * @returns pressure value
  53738. */
  53739. getBodyStiffness(impostor: PhysicsImpostor): number;
  53740. /**
  53741. * Sets stiffness of the impostor
  53742. * @param impostor impostor to set stiffness on
  53743. * @param stiffness stiffness value from 0 to 1
  53744. */
  53745. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53746. /**
  53747. * Gets velocityIterations of the impostor
  53748. * @param impostor impostor to get velocity iterations from
  53749. * @returns velocityIterations value
  53750. */
  53751. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53752. /**
  53753. * Sets velocityIterations of the impostor
  53754. * @param impostor impostor to set velocity iterations on
  53755. * @param velocityIterations velocityIterations value
  53756. */
  53757. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53758. /**
  53759. * Gets positionIterations of the impostor
  53760. * @param impostor impostor to get position iterations from
  53761. * @returns positionIterations value
  53762. */
  53763. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53764. /**
  53765. * Sets positionIterations of the impostor
  53766. * @param impostor impostor to set position on
  53767. * @param positionIterations positionIterations value
  53768. */
  53769. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53770. /**
  53771. * Append an anchor to a cloth object
  53772. * @param impostor is the cloth impostor to add anchor to
  53773. * @param otherImpostor is the rigid impostor to anchor to
  53774. * @param width ratio across width from 0 to 1
  53775. * @param height ratio up height from 0 to 1
  53776. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53777. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53778. */
  53779. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53780. /**
  53781. * Append an hook to a rope object
  53782. * @param impostor is the rope impostor to add hook to
  53783. * @param otherImpostor is the rigid impostor to hook to
  53784. * @param length ratio along the rope from 0 to 1
  53785. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53786. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53787. */
  53788. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53789. /**
  53790. * Sleeps the physics body and stops it from being active
  53791. * @param impostor impostor to sleep
  53792. */
  53793. sleepBody(impostor: PhysicsImpostor): void;
  53794. /**
  53795. * Activates the physics body
  53796. * @param impostor impostor to activate
  53797. */
  53798. wakeUpBody(impostor: PhysicsImpostor): void;
  53799. /**
  53800. * Updates the distance parameters of the joint
  53801. * @param joint joint to update
  53802. * @param maxDistance maximum distance of the joint
  53803. * @param minDistance minimum distance of the joint
  53804. */
  53805. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53806. /**
  53807. * Sets a motor on the joint
  53808. * @param joint joint to set motor on
  53809. * @param speed speed of the motor
  53810. * @param maxForce maximum force of the motor
  53811. * @param motorIndex index of the motor
  53812. */
  53813. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53814. /**
  53815. * Sets the motors limit
  53816. * @param joint joint to set limit on
  53817. * @param upperLimit upper limit
  53818. * @param lowerLimit lower limit
  53819. */
  53820. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53821. /**
  53822. * Syncs the position and rotation of a mesh with the impostor
  53823. * @param mesh mesh to sync
  53824. * @param impostor impostor to update the mesh with
  53825. */
  53826. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53827. /**
  53828. * Gets the radius of the impostor
  53829. * @param impostor impostor to get radius from
  53830. * @returns the radius
  53831. */
  53832. getRadius(impostor: PhysicsImpostor): number;
  53833. /**
  53834. * Gets the box size of the impostor
  53835. * @param impostor impostor to get box size from
  53836. * @param result the resulting box size
  53837. */
  53838. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53839. /**
  53840. * Disposes of the impostor
  53841. */
  53842. dispose(): void;
  53843. /**
  53844. * Does a raycast in the physics world
  53845. * @param from when should the ray start?
  53846. * @param to when should the ray end?
  53847. * @returns PhysicsRaycastResult
  53848. */
  53849. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53850. }
  53851. }
  53852. declare module "babylonjs/Probes/reflectionProbe" {
  53853. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53854. import { Vector3 } from "babylonjs/Maths/math.vector";
  53855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53856. import { Nullable } from "babylonjs/types";
  53857. import { Scene } from "babylonjs/scene";
  53858. module "babylonjs/abstractScene" {
  53859. interface AbstractScene {
  53860. /**
  53861. * The list of reflection probes added to the scene
  53862. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53863. */
  53864. reflectionProbes: Array<ReflectionProbe>;
  53865. /**
  53866. * Removes the given reflection probe from this scene.
  53867. * @param toRemove The reflection probe to remove
  53868. * @returns The index of the removed reflection probe
  53869. */
  53870. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53871. /**
  53872. * Adds the given reflection probe to this scene.
  53873. * @param newReflectionProbe The reflection probe to add
  53874. */
  53875. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53876. }
  53877. }
  53878. /**
  53879. * Class used to generate realtime reflection / refraction cube textures
  53880. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53881. */
  53882. export class ReflectionProbe {
  53883. /** defines the name of the probe */
  53884. name: string;
  53885. private _scene;
  53886. private _renderTargetTexture;
  53887. private _projectionMatrix;
  53888. private _viewMatrix;
  53889. private _target;
  53890. private _add;
  53891. private _attachedMesh;
  53892. private _invertYAxis;
  53893. /** Gets or sets probe position (center of the cube map) */
  53894. position: Vector3;
  53895. /**
  53896. * Creates a new reflection probe
  53897. * @param name defines the name of the probe
  53898. * @param size defines the texture resolution (for each face)
  53899. * @param scene defines the hosting scene
  53900. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53901. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53902. */
  53903. constructor(
  53904. /** defines the name of the probe */
  53905. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53906. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53907. samples: number;
  53908. /** Gets or sets the refresh rate to use (on every frame by default) */
  53909. refreshRate: number;
  53910. /**
  53911. * Gets the hosting scene
  53912. * @returns a Scene
  53913. */
  53914. getScene(): Scene;
  53915. /** Gets the internal CubeTexture used to render to */
  53916. readonly cubeTexture: RenderTargetTexture;
  53917. /** Gets the list of meshes to render */
  53918. readonly renderList: Nullable<AbstractMesh[]>;
  53919. /**
  53920. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53921. * @param mesh defines the mesh to attach to
  53922. */
  53923. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53924. /**
  53925. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53926. * @param renderingGroupId The rendering group id corresponding to its index
  53927. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53928. */
  53929. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53930. /**
  53931. * Clean all associated resources
  53932. */
  53933. dispose(): void;
  53934. /**
  53935. * Converts the reflection probe information to a readable string for debug purpose.
  53936. * @param fullDetails Supports for multiple levels of logging within scene loading
  53937. * @returns the human readable reflection probe info
  53938. */
  53939. toString(fullDetails?: boolean): string;
  53940. /**
  53941. * Get the class name of the relfection probe.
  53942. * @returns "ReflectionProbe"
  53943. */
  53944. getClassName(): string;
  53945. /**
  53946. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53947. * @returns The JSON representation of the texture
  53948. */
  53949. serialize(): any;
  53950. /**
  53951. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53952. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53953. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53954. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53955. * @returns The parsed reflection probe if successful
  53956. */
  53957. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53958. }
  53959. }
  53960. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53961. /** @hidden */
  53962. export var _BabylonLoaderRegistered: boolean;
  53963. }
  53964. declare module "babylonjs/Loading/Plugins/index" {
  53965. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53966. }
  53967. declare module "babylonjs/Loading/index" {
  53968. export * from "babylonjs/Loading/loadingScreen";
  53969. export * from "babylonjs/Loading/Plugins/index";
  53970. export * from "babylonjs/Loading/sceneLoader";
  53971. export * from "babylonjs/Loading/sceneLoaderFlags";
  53972. }
  53973. declare module "babylonjs/Materials/Background/index" {
  53974. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53975. }
  53976. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53977. import { Scene } from "babylonjs/scene";
  53978. import { Color3 } from "babylonjs/Maths/math.color";
  53979. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53981. /**
  53982. * The Physically based simple base material of BJS.
  53983. *
  53984. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53985. * It is used as the base class for both the specGloss and metalRough conventions.
  53986. */
  53987. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53988. /**
  53989. * Number of Simultaneous lights allowed on the material.
  53990. */
  53991. maxSimultaneousLights: number;
  53992. /**
  53993. * If sets to true, disables all the lights affecting the material.
  53994. */
  53995. disableLighting: boolean;
  53996. /**
  53997. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53998. */
  53999. environmentTexture: BaseTexture;
  54000. /**
  54001. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54002. */
  54003. invertNormalMapX: boolean;
  54004. /**
  54005. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54006. */
  54007. invertNormalMapY: boolean;
  54008. /**
  54009. * Normal map used in the model.
  54010. */
  54011. normalTexture: BaseTexture;
  54012. /**
  54013. * Emissivie color used to self-illuminate the model.
  54014. */
  54015. emissiveColor: Color3;
  54016. /**
  54017. * Emissivie texture used to self-illuminate the model.
  54018. */
  54019. emissiveTexture: BaseTexture;
  54020. /**
  54021. * Occlusion Channel Strenght.
  54022. */
  54023. occlusionStrength: number;
  54024. /**
  54025. * Occlusion Texture of the material (adding extra occlusion effects).
  54026. */
  54027. occlusionTexture: BaseTexture;
  54028. /**
  54029. * Defines the alpha limits in alpha test mode.
  54030. */
  54031. alphaCutOff: number;
  54032. /**
  54033. * Gets the current double sided mode.
  54034. */
  54035. /**
  54036. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54037. */
  54038. doubleSided: boolean;
  54039. /**
  54040. * Stores the pre-calculated light information of a mesh in a texture.
  54041. */
  54042. lightmapTexture: BaseTexture;
  54043. /**
  54044. * If true, the light map contains occlusion information instead of lighting info.
  54045. */
  54046. useLightmapAsShadowmap: boolean;
  54047. /**
  54048. * Instantiates a new PBRMaterial instance.
  54049. *
  54050. * @param name The material name
  54051. * @param scene The scene the material will be use in.
  54052. */
  54053. constructor(name: string, scene: Scene);
  54054. getClassName(): string;
  54055. }
  54056. }
  54057. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54058. import { Scene } from "babylonjs/scene";
  54059. import { Color3 } from "babylonjs/Maths/math.color";
  54060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54061. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54062. /**
  54063. * The PBR material of BJS following the metal roughness convention.
  54064. *
  54065. * This fits to the PBR convention in the GLTF definition:
  54066. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54067. */
  54068. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54069. /**
  54070. * The base color has two different interpretations depending on the value of metalness.
  54071. * When the material is a metal, the base color is the specific measured reflectance value
  54072. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54073. * of the material.
  54074. */
  54075. baseColor: Color3;
  54076. /**
  54077. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54078. * well as opacity information in the alpha channel.
  54079. */
  54080. baseTexture: BaseTexture;
  54081. /**
  54082. * Specifies the metallic scalar value of the material.
  54083. * Can also be used to scale the metalness values of the metallic texture.
  54084. */
  54085. metallic: number;
  54086. /**
  54087. * Specifies the roughness scalar value of the material.
  54088. * Can also be used to scale the roughness values of the metallic texture.
  54089. */
  54090. roughness: number;
  54091. /**
  54092. * Texture containing both the metallic value in the B channel and the
  54093. * roughness value in the G channel to keep better precision.
  54094. */
  54095. metallicRoughnessTexture: BaseTexture;
  54096. /**
  54097. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54098. *
  54099. * @param name The material name
  54100. * @param scene The scene the material will be use in.
  54101. */
  54102. constructor(name: string, scene: Scene);
  54103. /**
  54104. * Return the currrent class name of the material.
  54105. */
  54106. getClassName(): string;
  54107. /**
  54108. * Makes a duplicate of the current material.
  54109. * @param name - name to use for the new material.
  54110. */
  54111. clone(name: string): PBRMetallicRoughnessMaterial;
  54112. /**
  54113. * Serialize the material to a parsable JSON object.
  54114. */
  54115. serialize(): any;
  54116. /**
  54117. * Parses a JSON object correponding to the serialize function.
  54118. */
  54119. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54120. }
  54121. }
  54122. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54123. import { Scene } from "babylonjs/scene";
  54124. import { Color3 } from "babylonjs/Maths/math.color";
  54125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54126. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54127. /**
  54128. * The PBR material of BJS following the specular glossiness convention.
  54129. *
  54130. * This fits to the PBR convention in the GLTF definition:
  54131. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54132. */
  54133. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54134. /**
  54135. * Specifies the diffuse color of the material.
  54136. */
  54137. diffuseColor: Color3;
  54138. /**
  54139. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54140. * channel.
  54141. */
  54142. diffuseTexture: BaseTexture;
  54143. /**
  54144. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54145. */
  54146. specularColor: Color3;
  54147. /**
  54148. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54149. */
  54150. glossiness: number;
  54151. /**
  54152. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54153. */
  54154. specularGlossinessTexture: BaseTexture;
  54155. /**
  54156. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54157. *
  54158. * @param name The material name
  54159. * @param scene The scene the material will be use in.
  54160. */
  54161. constructor(name: string, scene: Scene);
  54162. /**
  54163. * Return the currrent class name of the material.
  54164. */
  54165. getClassName(): string;
  54166. /**
  54167. * Makes a duplicate of the current material.
  54168. * @param name - name to use for the new material.
  54169. */
  54170. clone(name: string): PBRSpecularGlossinessMaterial;
  54171. /**
  54172. * Serialize the material to a parsable JSON object.
  54173. */
  54174. serialize(): any;
  54175. /**
  54176. * Parses a JSON object correponding to the serialize function.
  54177. */
  54178. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54179. }
  54180. }
  54181. declare module "babylonjs/Materials/PBR/index" {
  54182. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54183. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54184. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54185. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54186. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54187. }
  54188. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54189. import { Nullable } from "babylonjs/types";
  54190. import { Scene } from "babylonjs/scene";
  54191. import { Matrix } from "babylonjs/Maths/math.vector";
  54192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54193. /**
  54194. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54195. * It can help converting any input color in a desired output one. This can then be used to create effects
  54196. * from sepia, black and white to sixties or futuristic rendering...
  54197. *
  54198. * The only supported format is currently 3dl.
  54199. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54200. */
  54201. export class ColorGradingTexture extends BaseTexture {
  54202. /**
  54203. * The current texture matrix. (will always be identity in color grading texture)
  54204. */
  54205. private _textureMatrix;
  54206. /**
  54207. * The texture URL.
  54208. */
  54209. url: string;
  54210. /**
  54211. * Empty line regex stored for GC.
  54212. */
  54213. private static _noneEmptyLineRegex;
  54214. private _engine;
  54215. /**
  54216. * Instantiates a ColorGradingTexture from the following parameters.
  54217. *
  54218. * @param url The location of the color gradind data (currently only supporting 3dl)
  54219. * @param scene The scene the texture will be used in
  54220. */
  54221. constructor(url: string, scene: Scene);
  54222. /**
  54223. * Returns the texture matrix used in most of the material.
  54224. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54225. */
  54226. getTextureMatrix(): Matrix;
  54227. /**
  54228. * Occurs when the file being loaded is a .3dl LUT file.
  54229. */
  54230. private load3dlTexture;
  54231. /**
  54232. * Starts the loading process of the texture.
  54233. */
  54234. private loadTexture;
  54235. /**
  54236. * Clones the color gradind texture.
  54237. */
  54238. clone(): ColorGradingTexture;
  54239. /**
  54240. * Called during delayed load for textures.
  54241. */
  54242. delayLoad(): void;
  54243. /**
  54244. * Parses a color grading texture serialized by Babylon.
  54245. * @param parsedTexture The texture information being parsedTexture
  54246. * @param scene The scene to load the texture in
  54247. * @param rootUrl The root url of the data assets to load
  54248. * @return A color gradind texture
  54249. */
  54250. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54251. /**
  54252. * Serializes the LUT texture to json format.
  54253. */
  54254. serialize(): any;
  54255. }
  54256. }
  54257. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54259. import { Scene } from "babylonjs/scene";
  54260. import { Nullable } from "babylonjs/types";
  54261. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54262. /**
  54263. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54264. */
  54265. export class EquiRectangularCubeTexture extends BaseTexture {
  54266. /** The six faces of the cube. */
  54267. private static _FacesMapping;
  54268. private _noMipmap;
  54269. private _onLoad;
  54270. private _onError;
  54271. /** The size of the cubemap. */
  54272. private _size;
  54273. /** The buffer of the image. */
  54274. private _buffer;
  54275. /** The width of the input image. */
  54276. private _width;
  54277. /** The height of the input image. */
  54278. private _height;
  54279. /** The URL to the image. */
  54280. url: string;
  54281. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54282. coordinatesMode: number;
  54283. /**
  54284. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54285. * @param url The location of the image
  54286. * @param scene The scene the texture will be used in
  54287. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54288. * @param noMipmap Forces to not generate the mipmap if true
  54289. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54290. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54291. * @param onLoad — defines a callback called when texture is loaded
  54292. * @param onError — defines a callback called if there is an error
  54293. */
  54294. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54295. /**
  54296. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54297. */
  54298. private loadImage;
  54299. /**
  54300. * Convert the image buffer into a cubemap and create a CubeTexture.
  54301. */
  54302. private loadTexture;
  54303. /**
  54304. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54305. * @param buffer The ArrayBuffer that should be converted.
  54306. * @returns The buffer as Float32Array.
  54307. */
  54308. private getFloat32ArrayFromArrayBuffer;
  54309. /**
  54310. * Get the current class name of the texture useful for serialization or dynamic coding.
  54311. * @returns "EquiRectangularCubeTexture"
  54312. */
  54313. getClassName(): string;
  54314. /**
  54315. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54316. * @returns A clone of the current EquiRectangularCubeTexture.
  54317. */
  54318. clone(): EquiRectangularCubeTexture;
  54319. }
  54320. }
  54321. declare module "babylonjs/Misc/tga" {
  54322. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54323. /**
  54324. * Based on jsTGALoader - Javascript loader for TGA file
  54325. * By Vincent Thibault
  54326. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54327. */
  54328. export class TGATools {
  54329. private static _TYPE_INDEXED;
  54330. private static _TYPE_RGB;
  54331. private static _TYPE_GREY;
  54332. private static _TYPE_RLE_INDEXED;
  54333. private static _TYPE_RLE_RGB;
  54334. private static _TYPE_RLE_GREY;
  54335. private static _ORIGIN_MASK;
  54336. private static _ORIGIN_SHIFT;
  54337. private static _ORIGIN_BL;
  54338. private static _ORIGIN_BR;
  54339. private static _ORIGIN_UL;
  54340. private static _ORIGIN_UR;
  54341. /**
  54342. * Gets the header of a TGA file
  54343. * @param data defines the TGA data
  54344. * @returns the header
  54345. */
  54346. static GetTGAHeader(data: Uint8Array): any;
  54347. /**
  54348. * Uploads TGA content to a Babylon Texture
  54349. * @hidden
  54350. */
  54351. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54352. /** @hidden */
  54353. 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;
  54354. /** @hidden */
  54355. 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;
  54356. /** @hidden */
  54357. 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;
  54358. /** @hidden */
  54359. 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;
  54360. /** @hidden */
  54361. 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;
  54362. /** @hidden */
  54363. 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;
  54364. }
  54365. }
  54366. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54367. import { Nullable } from "babylonjs/types";
  54368. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54369. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54370. /**
  54371. * Implementation of the TGA Texture Loader.
  54372. * @hidden
  54373. */
  54374. export class _TGATextureLoader implements IInternalTextureLoader {
  54375. /**
  54376. * Defines wether the loader supports cascade loading the different faces.
  54377. */
  54378. readonly supportCascades: boolean;
  54379. /**
  54380. * This returns if the loader support the current file information.
  54381. * @param extension defines the file extension of the file being loaded
  54382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54383. * @param fallback defines the fallback internal texture if any
  54384. * @param isBase64 defines whether the texture is encoded as a base64
  54385. * @param isBuffer defines whether the texture data are stored as a buffer
  54386. * @returns true if the loader can load the specified file
  54387. */
  54388. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54389. /**
  54390. * Transform the url before loading if required.
  54391. * @param rootUrl the url of the texture
  54392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54393. * @returns the transformed texture
  54394. */
  54395. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54396. /**
  54397. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54398. * @param rootUrl the url of the texture
  54399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54400. * @returns the fallback texture
  54401. */
  54402. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54403. /**
  54404. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54405. * @param data contains the texture data
  54406. * @param texture defines the BabylonJS internal texture
  54407. * @param createPolynomials will be true if polynomials have been requested
  54408. * @param onLoad defines the callback to trigger once the texture is ready
  54409. * @param onError defines the callback to trigger in case of error
  54410. */
  54411. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54412. /**
  54413. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54414. * @param data contains the texture data
  54415. * @param texture defines the BabylonJS internal texture
  54416. * @param callback defines the method to call once ready to upload
  54417. */
  54418. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54419. }
  54420. }
  54421. declare module "babylonjs/Misc/basis" {
  54422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54423. /**
  54424. * Info about the .basis files
  54425. */
  54426. class BasisFileInfo {
  54427. /**
  54428. * If the file has alpha
  54429. */
  54430. hasAlpha: boolean;
  54431. /**
  54432. * Info about each image of the basis file
  54433. */
  54434. images: Array<{
  54435. levels: Array<{
  54436. width: number;
  54437. height: number;
  54438. transcodedPixels: ArrayBufferView;
  54439. }>;
  54440. }>;
  54441. }
  54442. /**
  54443. * Result of transcoding a basis file
  54444. */
  54445. class TranscodeResult {
  54446. /**
  54447. * Info about the .basis file
  54448. */
  54449. fileInfo: BasisFileInfo;
  54450. /**
  54451. * Format to use when loading the file
  54452. */
  54453. format: number;
  54454. }
  54455. /**
  54456. * Configuration options for the Basis transcoder
  54457. */
  54458. export class BasisTranscodeConfiguration {
  54459. /**
  54460. * Supported compression formats used to determine the supported output format of the transcoder
  54461. */
  54462. supportedCompressionFormats?: {
  54463. /**
  54464. * etc1 compression format
  54465. */
  54466. etc1?: boolean;
  54467. /**
  54468. * s3tc compression format
  54469. */
  54470. s3tc?: boolean;
  54471. /**
  54472. * pvrtc compression format
  54473. */
  54474. pvrtc?: boolean;
  54475. /**
  54476. * etc2 compression format
  54477. */
  54478. etc2?: boolean;
  54479. };
  54480. /**
  54481. * If mipmap levels should be loaded for transcoded images (Default: true)
  54482. */
  54483. loadMipmapLevels?: boolean;
  54484. /**
  54485. * Index of a single image to load (Default: all images)
  54486. */
  54487. loadSingleImage?: number;
  54488. }
  54489. /**
  54490. * Used to load .Basis files
  54491. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54492. */
  54493. export class BasisTools {
  54494. private static _IgnoreSupportedFormats;
  54495. /**
  54496. * URL to use when loading the basis transcoder
  54497. */
  54498. static JSModuleURL: string;
  54499. /**
  54500. * URL to use when loading the wasm module for the transcoder
  54501. */
  54502. static WasmModuleURL: string;
  54503. /**
  54504. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54505. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54506. * @returns internal format corresponding to the Basis format
  54507. */
  54508. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54509. private static _WorkerPromise;
  54510. private static _Worker;
  54511. private static _actionId;
  54512. private static _CreateWorkerAsync;
  54513. /**
  54514. * Transcodes a loaded image file to compressed pixel data
  54515. * @param imageData image data to transcode
  54516. * @param config configuration options for the transcoding
  54517. * @returns a promise resulting in the transcoded image
  54518. */
  54519. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54520. /**
  54521. * Loads a texture from the transcode result
  54522. * @param texture texture load to
  54523. * @param transcodeResult the result of transcoding the basis file to load from
  54524. */
  54525. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54526. }
  54527. }
  54528. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54529. import { Nullable } from "babylonjs/types";
  54530. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54531. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54532. /**
  54533. * Loader for .basis file format
  54534. */
  54535. export class _BasisTextureLoader implements IInternalTextureLoader {
  54536. /**
  54537. * Defines whether the loader supports cascade loading the different faces.
  54538. */
  54539. readonly supportCascades: boolean;
  54540. /**
  54541. * This returns if the loader support the current file information.
  54542. * @param extension defines the file extension of the file being loaded
  54543. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54544. * @param fallback defines the fallback internal texture if any
  54545. * @param isBase64 defines whether the texture is encoded as a base64
  54546. * @param isBuffer defines whether the texture data are stored as a buffer
  54547. * @returns true if the loader can load the specified file
  54548. */
  54549. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54550. /**
  54551. * Transform the url before loading if required.
  54552. * @param rootUrl the url of the texture
  54553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54554. * @returns the transformed texture
  54555. */
  54556. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54557. /**
  54558. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54559. * @param rootUrl the url of the texture
  54560. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54561. * @returns the fallback texture
  54562. */
  54563. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54564. /**
  54565. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54566. * @param data contains the texture data
  54567. * @param texture defines the BabylonJS internal texture
  54568. * @param createPolynomials will be true if polynomials have been requested
  54569. * @param onLoad defines the callback to trigger once the texture is ready
  54570. * @param onError defines the callback to trigger in case of error
  54571. */
  54572. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54573. /**
  54574. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54575. * @param data contains the texture data
  54576. * @param texture defines the BabylonJS internal texture
  54577. * @param callback defines the method to call once ready to upload
  54578. */
  54579. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54580. }
  54581. }
  54582. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54583. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54584. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54585. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54586. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54587. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54588. }
  54589. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54590. import { Scene } from "babylonjs/scene";
  54591. import { Texture } from "babylonjs/Materials/Textures/texture";
  54592. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54593. /**
  54594. * 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.
  54595. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54596. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54597. */
  54598. export class CustomProceduralTexture extends ProceduralTexture {
  54599. private _animate;
  54600. private _time;
  54601. private _config;
  54602. private _texturePath;
  54603. /**
  54604. * Instantiates a new Custom Procedural Texture.
  54605. * 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.
  54606. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54607. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54608. * @param name Define the name of the texture
  54609. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54610. * @param size Define the size of the texture to create
  54611. * @param scene Define the scene the texture belongs to
  54612. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54613. * @param generateMipMaps Define if the texture should creates mip maps or not
  54614. */
  54615. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54616. private _loadJson;
  54617. /**
  54618. * Is the texture ready to be used ? (rendered at least once)
  54619. * @returns true if ready, otherwise, false.
  54620. */
  54621. isReady(): boolean;
  54622. /**
  54623. * Render the texture to its associated render target.
  54624. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54625. */
  54626. render(useCameraPostProcess?: boolean): void;
  54627. /**
  54628. * Update the list of dependant textures samplers in the shader.
  54629. */
  54630. updateTextures(): void;
  54631. /**
  54632. * Update the uniform values of the procedural texture in the shader.
  54633. */
  54634. updateShaderUniforms(): void;
  54635. /**
  54636. * Define if the texture animates or not.
  54637. */
  54638. animate: boolean;
  54639. }
  54640. }
  54641. declare module "babylonjs/Shaders/noise.fragment" {
  54642. /** @hidden */
  54643. export var noisePixelShader: {
  54644. name: string;
  54645. shader: string;
  54646. };
  54647. }
  54648. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54649. import { Nullable } from "babylonjs/types";
  54650. import { Scene } from "babylonjs/scene";
  54651. import { Texture } from "babylonjs/Materials/Textures/texture";
  54652. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54653. import "babylonjs/Shaders/noise.fragment";
  54654. /**
  54655. * Class used to generate noise procedural textures
  54656. */
  54657. export class NoiseProceduralTexture extends ProceduralTexture {
  54658. private _time;
  54659. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54660. brightness: number;
  54661. /** Defines the number of octaves to process */
  54662. octaves: number;
  54663. /** Defines the level of persistence (0.8 by default) */
  54664. persistence: number;
  54665. /** Gets or sets animation speed factor (default is 1) */
  54666. animationSpeedFactor: number;
  54667. /**
  54668. * Creates a new NoiseProceduralTexture
  54669. * @param name defines the name fo the texture
  54670. * @param size defines the size of the texture (default is 256)
  54671. * @param scene defines the hosting scene
  54672. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54673. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54674. */
  54675. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54676. private _updateShaderUniforms;
  54677. protected _getDefines(): string;
  54678. /** Generate the current state of the procedural texture */
  54679. render(useCameraPostProcess?: boolean): void;
  54680. /**
  54681. * Serializes this noise procedural texture
  54682. * @returns a serialized noise procedural texture object
  54683. */
  54684. serialize(): any;
  54685. /**
  54686. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54687. * @param parsedTexture defines parsed texture data
  54688. * @param scene defines the current scene
  54689. * @param rootUrl defines the root URL containing noise procedural texture information
  54690. * @returns a parsed NoiseProceduralTexture
  54691. */
  54692. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54693. }
  54694. }
  54695. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54696. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54697. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54698. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54699. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54700. }
  54701. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54702. import { Nullable } from "babylonjs/types";
  54703. import { Scene } from "babylonjs/scene";
  54704. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54705. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54706. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54707. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54708. /**
  54709. * Raw cube texture where the raw buffers are passed in
  54710. */
  54711. export class RawCubeTexture extends CubeTexture {
  54712. /**
  54713. * Creates a cube texture where the raw buffers are passed in.
  54714. * @param scene defines the scene the texture is attached to
  54715. * @param data defines the array of data to use to create each face
  54716. * @param size defines the size of the textures
  54717. * @param format defines the format of the data
  54718. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54719. * @param generateMipMaps defines if the engine should generate the mip levels
  54720. * @param invertY defines if data must be stored with Y axis inverted
  54721. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54722. * @param compression defines the compression used (null by default)
  54723. */
  54724. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54725. /**
  54726. * Updates the raw cube texture.
  54727. * @param data defines the data to store
  54728. * @param format defines the data format
  54729. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54730. * @param invertY defines if data must be stored with Y axis inverted
  54731. * @param compression defines the compression used (null by default)
  54732. * @param level defines which level of the texture to update
  54733. */
  54734. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54735. /**
  54736. * Updates a raw cube texture with RGBD encoded data.
  54737. * @param data defines the array of data [mipmap][face] to use to create each face
  54738. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54739. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54740. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54741. * @returns a promsie that resolves when the operation is complete
  54742. */
  54743. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54744. /**
  54745. * Clones the raw cube texture.
  54746. * @return a new cube texture
  54747. */
  54748. clone(): CubeTexture;
  54749. /** @hidden */
  54750. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54751. }
  54752. }
  54753. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54754. import { Scene } from "babylonjs/scene";
  54755. import { Texture } from "babylonjs/Materials/Textures/texture";
  54756. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54757. /**
  54758. * Class used to store 3D textures containing user data
  54759. */
  54760. export class RawTexture3D extends Texture {
  54761. /** Gets or sets the texture format to use */
  54762. format: number;
  54763. private _engine;
  54764. /**
  54765. * Create a new RawTexture3D
  54766. * @param data defines the data of the texture
  54767. * @param width defines the width of the texture
  54768. * @param height defines the height of the texture
  54769. * @param depth defines the depth of the texture
  54770. * @param format defines the texture format to use
  54771. * @param scene defines the hosting scene
  54772. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54773. * @param invertY defines if texture must be stored with Y axis inverted
  54774. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54775. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54776. */
  54777. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54778. /** Gets or sets the texture format to use */
  54779. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54780. /**
  54781. * Update the texture with new data
  54782. * @param data defines the data to store in the texture
  54783. */
  54784. update(data: ArrayBufferView): void;
  54785. }
  54786. }
  54787. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54788. import { Scene } from "babylonjs/scene";
  54789. import { Plane } from "babylonjs/Maths/math.plane";
  54790. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54791. /**
  54792. * Creates a refraction texture used by refraction channel of the standard material.
  54793. * It is like a mirror but to see through a material.
  54794. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54795. */
  54796. export class RefractionTexture extends RenderTargetTexture {
  54797. /**
  54798. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54799. * 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.
  54800. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54801. */
  54802. refractionPlane: Plane;
  54803. /**
  54804. * Define how deep under the surface we should see.
  54805. */
  54806. depth: number;
  54807. /**
  54808. * Creates a refraction texture used by refraction channel of the standard material.
  54809. * It is like a mirror but to see through a material.
  54810. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54811. * @param name Define the texture name
  54812. * @param size Define the size of the underlying texture
  54813. * @param scene Define the scene the refraction belongs to
  54814. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54815. */
  54816. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54817. /**
  54818. * Clone the refraction texture.
  54819. * @returns the cloned texture
  54820. */
  54821. clone(): RefractionTexture;
  54822. /**
  54823. * Serialize the texture to a JSON representation you could use in Parse later on
  54824. * @returns the serialized JSON representation
  54825. */
  54826. serialize(): any;
  54827. }
  54828. }
  54829. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54830. import { Nullable } from "babylonjs/types";
  54831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54832. import { Matrix } from "babylonjs/Maths/math.vector";
  54833. import { Engine } from "babylonjs/Engines/engine";
  54834. import { Scene } from "babylonjs/scene";
  54835. /**
  54836. * Defines the options related to the creation of an HtmlElementTexture
  54837. */
  54838. export interface IHtmlElementTextureOptions {
  54839. /**
  54840. * Defines wether mip maps should be created or not.
  54841. */
  54842. generateMipMaps?: boolean;
  54843. /**
  54844. * Defines the sampling mode of the texture.
  54845. */
  54846. samplingMode?: number;
  54847. /**
  54848. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54849. */
  54850. engine: Nullable<Engine>;
  54851. /**
  54852. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54853. */
  54854. scene: Nullable<Scene>;
  54855. }
  54856. /**
  54857. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54858. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54859. * is automatically managed.
  54860. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54861. * in your application.
  54862. *
  54863. * As the update is not automatic, you need to call them manually.
  54864. */
  54865. export class HtmlElementTexture extends BaseTexture {
  54866. /**
  54867. * The texture URL.
  54868. */
  54869. element: HTMLVideoElement | HTMLCanvasElement;
  54870. private static readonly DefaultOptions;
  54871. private _textureMatrix;
  54872. private _engine;
  54873. private _isVideo;
  54874. private _generateMipMaps;
  54875. private _samplingMode;
  54876. /**
  54877. * Instantiates a HtmlElementTexture from the following parameters.
  54878. *
  54879. * @param name Defines the name of the texture
  54880. * @param element Defines the video or canvas the texture is filled with
  54881. * @param options Defines the other none mandatory texture creation options
  54882. */
  54883. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54884. private _createInternalTexture;
  54885. /**
  54886. * Returns the texture matrix used in most of the material.
  54887. */
  54888. getTextureMatrix(): Matrix;
  54889. /**
  54890. * Updates the content of the texture.
  54891. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54892. */
  54893. update(invertY?: Nullable<boolean>): void;
  54894. }
  54895. }
  54896. declare module "babylonjs/Materials/Textures/index" {
  54897. export * from "babylonjs/Materials/Textures/baseTexture";
  54898. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54899. export * from "babylonjs/Materials/Textures/cubeTexture";
  54900. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54901. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54902. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54903. export * from "babylonjs/Materials/Textures/internalTexture";
  54904. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54905. export * from "babylonjs/Materials/Textures/Loaders/index";
  54906. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54907. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54908. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54909. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54910. export * from "babylonjs/Materials/Textures/rawTexture";
  54911. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54912. export * from "babylonjs/Materials/Textures/refractionTexture";
  54913. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54914. export * from "babylonjs/Materials/Textures/texture";
  54915. export * from "babylonjs/Materials/Textures/videoTexture";
  54916. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54917. }
  54918. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54919. /**
  54920. * Enum used to define the target of a block
  54921. */
  54922. export enum NodeMaterialBlockTargets {
  54923. /** Vertex shader */
  54924. Vertex = 1,
  54925. /** Fragment shader */
  54926. Fragment = 2,
  54927. /** Neutral */
  54928. Neutral = 4,
  54929. /** Vertex and Fragment */
  54930. VertexAndFragment = 3
  54931. }
  54932. }
  54933. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54934. /**
  54935. * Defines the kind of connection point for node based material
  54936. */
  54937. export enum NodeMaterialBlockConnectionPointTypes {
  54938. /** Float */
  54939. Float = 1,
  54940. /** Int */
  54941. Int = 2,
  54942. /** Vector2 */
  54943. Vector2 = 4,
  54944. /** Vector3 */
  54945. Vector3 = 8,
  54946. /** Vector4 */
  54947. Vector4 = 16,
  54948. /** Color3 */
  54949. Color3 = 32,
  54950. /** Color4 */
  54951. Color4 = 64,
  54952. /** Matrix */
  54953. Matrix = 128,
  54954. /** Detect type based on connection */
  54955. AutoDetect = 1024,
  54956. /** Output type that will be defined by input type */
  54957. BasedOnInput = 2048
  54958. }
  54959. }
  54960. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54961. /**
  54962. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54963. */
  54964. export enum NodeMaterialBlockConnectionPointMode {
  54965. /** Value is an uniform */
  54966. Uniform = 0,
  54967. /** Value is a mesh attribute */
  54968. Attribute = 1,
  54969. /** Value is a varying between vertex and fragment shaders */
  54970. Varying = 2,
  54971. /** Mode is undefined */
  54972. Undefined = 3
  54973. }
  54974. }
  54975. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54976. /**
  54977. * Enum used to define system values e.g. values automatically provided by the system
  54978. */
  54979. export enum NodeMaterialSystemValues {
  54980. /** World */
  54981. World = 1,
  54982. /** View */
  54983. View = 2,
  54984. /** Projection */
  54985. Projection = 3,
  54986. /** ViewProjection */
  54987. ViewProjection = 4,
  54988. /** WorldView */
  54989. WorldView = 5,
  54990. /** WorldViewProjection */
  54991. WorldViewProjection = 6,
  54992. /** CameraPosition */
  54993. CameraPosition = 7,
  54994. /** Fog Color */
  54995. FogColor = 8,
  54996. /** Delta time */
  54997. DeltaTime = 9
  54998. }
  54999. }
  55000. declare module "babylonjs/Materials/Node/Enums/index" {
  55001. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55002. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55003. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55004. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55005. }
  55006. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55008. /**
  55009. * Root class for all node material optimizers
  55010. */
  55011. export class NodeMaterialOptimizer {
  55012. /**
  55013. * Function used to optimize a NodeMaterial graph
  55014. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55015. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55016. */
  55017. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55018. }
  55019. }
  55020. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55024. import { Scene } from "babylonjs/scene";
  55025. /**
  55026. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55027. */
  55028. export class TransformBlock extends NodeMaterialBlock {
  55029. /**
  55030. * Defines the value to use to complement W value to transform it to a Vector4
  55031. */
  55032. complementW: number;
  55033. /**
  55034. * Defines the value to use to complement z value to transform it to a Vector4
  55035. */
  55036. complementZ: number;
  55037. /**
  55038. * Creates a new TransformBlock
  55039. * @param name defines the block name
  55040. */
  55041. constructor(name: string);
  55042. /**
  55043. * Gets the current class name
  55044. * @returns the class name
  55045. */
  55046. getClassName(): string;
  55047. /**
  55048. * Gets the vector input
  55049. */
  55050. readonly vector: NodeMaterialConnectionPoint;
  55051. /**
  55052. * Gets the output component
  55053. */
  55054. readonly output: NodeMaterialConnectionPoint;
  55055. /**
  55056. * Gets the matrix transform input
  55057. */
  55058. readonly transform: NodeMaterialConnectionPoint;
  55059. protected _buildBlock(state: NodeMaterialBuildState): this;
  55060. serialize(): any;
  55061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55062. protected _dumpPropertiesCode(): string;
  55063. }
  55064. }
  55065. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55069. /**
  55070. * Block used to output the vertex position
  55071. */
  55072. export class VertexOutputBlock extends NodeMaterialBlock {
  55073. /**
  55074. * Creates a new VertexOutputBlock
  55075. * @param name defines the block name
  55076. */
  55077. constructor(name: string);
  55078. /**
  55079. * Gets the current class name
  55080. * @returns the class name
  55081. */
  55082. getClassName(): string;
  55083. /**
  55084. * Gets the vector input component
  55085. */
  55086. readonly vector: NodeMaterialConnectionPoint;
  55087. protected _buildBlock(state: NodeMaterialBuildState): this;
  55088. }
  55089. }
  55090. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55094. /**
  55095. * Block used to output the final color
  55096. */
  55097. export class FragmentOutputBlock extends NodeMaterialBlock {
  55098. /**
  55099. * Create a new FragmentOutputBlock
  55100. * @param name defines the block name
  55101. */
  55102. constructor(name: string);
  55103. /**
  55104. * Gets the current class name
  55105. * @returns the class name
  55106. */
  55107. getClassName(): string;
  55108. /**
  55109. * Gets the rgba input component
  55110. */
  55111. readonly rgba: NodeMaterialConnectionPoint;
  55112. /**
  55113. * Gets the rgb input component
  55114. */
  55115. readonly rgb: NodeMaterialConnectionPoint;
  55116. /**
  55117. * Gets the a input component
  55118. */
  55119. readonly a: NodeMaterialConnectionPoint;
  55120. protected _buildBlock(state: NodeMaterialBuildState): this;
  55121. }
  55122. }
  55123. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55129. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55130. import { Effect } from "babylonjs/Materials/effect";
  55131. import { Mesh } from "babylonjs/Meshes/mesh";
  55132. import { Nullable } from "babylonjs/types";
  55133. import { Scene } from "babylonjs/scene";
  55134. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55135. /**
  55136. * Block used to read a reflection texture from a sampler
  55137. */
  55138. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55139. private _define3DName;
  55140. private _defineCubicName;
  55141. private _defineExplicitName;
  55142. private _defineProjectionName;
  55143. private _defineLocalCubicName;
  55144. private _defineSphericalName;
  55145. private _definePlanarName;
  55146. private _defineEquirectangularName;
  55147. private _defineMirroredEquirectangularFixedName;
  55148. private _defineEquirectangularFixedName;
  55149. private _defineSkyboxName;
  55150. private _cubeSamplerName;
  55151. private _2DSamplerName;
  55152. private _positionUVWName;
  55153. private _directionWName;
  55154. private _reflectionCoordsName;
  55155. private _reflection2DCoordsName;
  55156. private _reflectionColorName;
  55157. private _reflectionMatrixName;
  55158. /**
  55159. * Gets or sets the texture associated with the node
  55160. */
  55161. texture: Nullable<BaseTexture>;
  55162. /**
  55163. * Create a new TextureBlock
  55164. * @param name defines the block name
  55165. */
  55166. constructor(name: string);
  55167. /**
  55168. * Gets the current class name
  55169. * @returns the class name
  55170. */
  55171. getClassName(): string;
  55172. /**
  55173. * Gets the world position input component
  55174. */
  55175. readonly position: NodeMaterialConnectionPoint;
  55176. /**
  55177. * Gets the world position input component
  55178. */
  55179. readonly worldPosition: NodeMaterialConnectionPoint;
  55180. /**
  55181. * Gets the world normal input component
  55182. */
  55183. readonly worldNormal: NodeMaterialConnectionPoint;
  55184. /**
  55185. * Gets the world input component
  55186. */
  55187. readonly world: NodeMaterialConnectionPoint;
  55188. /**
  55189. * Gets the camera (or eye) position component
  55190. */
  55191. readonly cameraPosition: NodeMaterialConnectionPoint;
  55192. /**
  55193. * Gets the view input component
  55194. */
  55195. readonly view: NodeMaterialConnectionPoint;
  55196. /**
  55197. * Gets the rgb output component
  55198. */
  55199. readonly rgb: NodeMaterialConnectionPoint;
  55200. /**
  55201. * Gets the r output component
  55202. */
  55203. readonly r: NodeMaterialConnectionPoint;
  55204. /**
  55205. * Gets the g output component
  55206. */
  55207. readonly g: NodeMaterialConnectionPoint;
  55208. /**
  55209. * Gets the b output component
  55210. */
  55211. readonly b: NodeMaterialConnectionPoint;
  55212. autoConfigure(material: NodeMaterial): void;
  55213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55214. isReady(): boolean;
  55215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55216. private _injectVertexCode;
  55217. private _writeOutput;
  55218. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55219. serialize(): any;
  55220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55221. }
  55222. }
  55223. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55225. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55226. import { Scene } from "babylonjs/scene";
  55227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55228. import { Matrix } from "babylonjs/Maths/math.vector";
  55229. import { Mesh } from "babylonjs/Meshes/mesh";
  55230. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55231. import { Observable } from "babylonjs/Misc/observable";
  55232. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55233. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55234. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55235. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55236. import { Nullable } from "babylonjs/types";
  55237. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55238. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55239. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55240. /**
  55241. * Interface used to configure the node material editor
  55242. */
  55243. export interface INodeMaterialEditorOptions {
  55244. /** Define the URl to load node editor script */
  55245. editorURL?: string;
  55246. }
  55247. /** @hidden */
  55248. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55249. /** BONES */
  55250. NUM_BONE_INFLUENCERS: number;
  55251. BonesPerMesh: number;
  55252. BONETEXTURE: boolean;
  55253. /** MORPH TARGETS */
  55254. MORPHTARGETS: boolean;
  55255. MORPHTARGETS_NORMAL: boolean;
  55256. MORPHTARGETS_TANGENT: boolean;
  55257. MORPHTARGETS_UV: boolean;
  55258. NUM_MORPH_INFLUENCERS: number;
  55259. /** IMAGE PROCESSING */
  55260. IMAGEPROCESSING: boolean;
  55261. VIGNETTE: boolean;
  55262. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55263. VIGNETTEBLENDMODEOPAQUE: boolean;
  55264. TONEMAPPING: boolean;
  55265. TONEMAPPING_ACES: boolean;
  55266. CONTRAST: boolean;
  55267. EXPOSURE: boolean;
  55268. COLORCURVES: boolean;
  55269. COLORGRADING: boolean;
  55270. COLORGRADING3D: boolean;
  55271. SAMPLER3DGREENDEPTH: boolean;
  55272. SAMPLER3DBGRMAP: boolean;
  55273. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55274. /** MISC. */
  55275. BUMPDIRECTUV: number;
  55276. constructor();
  55277. setValue(name: string, value: boolean): void;
  55278. }
  55279. /**
  55280. * Class used to configure NodeMaterial
  55281. */
  55282. export interface INodeMaterialOptions {
  55283. /**
  55284. * Defines if blocks should emit comments
  55285. */
  55286. emitComments: boolean;
  55287. }
  55288. /**
  55289. * Class used to create a node based material built by assembling shader blocks
  55290. */
  55291. export class NodeMaterial extends PushMaterial {
  55292. private static _BuildIdGenerator;
  55293. private _options;
  55294. private _vertexCompilationState;
  55295. private _fragmentCompilationState;
  55296. private _sharedData;
  55297. private _buildId;
  55298. private _buildWasSuccessful;
  55299. private _cachedWorldViewMatrix;
  55300. private _cachedWorldViewProjectionMatrix;
  55301. private _optimizers;
  55302. private _animationFrame;
  55303. /** Define the URl to load node editor script */
  55304. static EditorURL: string;
  55305. private BJSNODEMATERIALEDITOR;
  55306. /** Get the inspector from bundle or global */
  55307. private _getGlobalNodeMaterialEditor;
  55308. /**
  55309. * 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)
  55310. */
  55311. ignoreAlpha: boolean;
  55312. /**
  55313. * Defines the maximum number of lights that can be used in the material
  55314. */
  55315. maxSimultaneousLights: number;
  55316. /**
  55317. * Observable raised when the material is built
  55318. */
  55319. onBuildObservable: Observable<NodeMaterial>;
  55320. /**
  55321. * Gets or sets the root nodes of the material vertex shader
  55322. */
  55323. _vertexOutputNodes: NodeMaterialBlock[];
  55324. /**
  55325. * Gets or sets the root nodes of the material fragment (pixel) shader
  55326. */
  55327. _fragmentOutputNodes: NodeMaterialBlock[];
  55328. /** Gets or sets options to control the node material overall behavior */
  55329. options: INodeMaterialOptions;
  55330. /**
  55331. * Default configuration related to image processing available in the standard Material.
  55332. */
  55333. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55334. /**
  55335. * Gets the image processing configuration used either in this material.
  55336. */
  55337. /**
  55338. * Sets the Default image processing configuration used either in the this material.
  55339. *
  55340. * If sets to null, the scene one is in use.
  55341. */
  55342. imageProcessingConfiguration: ImageProcessingConfiguration;
  55343. /**
  55344. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55345. */
  55346. attachedBlocks: NodeMaterialBlock[];
  55347. /**
  55348. * Create a new node based material
  55349. * @param name defines the material name
  55350. * @param scene defines the hosting scene
  55351. * @param options defines creation option
  55352. */
  55353. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55354. /**
  55355. * Gets the current class name of the material e.g. "NodeMaterial"
  55356. * @returns the class name
  55357. */
  55358. getClassName(): string;
  55359. /**
  55360. * Keep track of the image processing observer to allow dispose and replace.
  55361. */
  55362. private _imageProcessingObserver;
  55363. /**
  55364. * Attaches a new image processing configuration to the Standard Material.
  55365. * @param configuration
  55366. */
  55367. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55368. /**
  55369. * Get a block by its name
  55370. * @param name defines the name of the block to retrieve
  55371. * @returns the required block or null if not found
  55372. */
  55373. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55374. /**
  55375. * Get a block by its name
  55376. * @param predicate defines the predicate used to find the good candidate
  55377. * @returns the required block or null if not found
  55378. */
  55379. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55380. /**
  55381. * Get an input block by its name
  55382. * @param predicate defines the predicate used to find the good candidate
  55383. * @returns the required input block or null if not found
  55384. */
  55385. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55386. /**
  55387. * Gets the list of input blocks attached to this material
  55388. * @returns an array of InputBlocks
  55389. */
  55390. getInputBlocks(): InputBlock[];
  55391. /**
  55392. * Adds a new optimizer to the list of optimizers
  55393. * @param optimizer defines the optimizers to add
  55394. * @returns the current material
  55395. */
  55396. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55397. /**
  55398. * Remove an optimizer from the list of optimizers
  55399. * @param optimizer defines the optimizers to remove
  55400. * @returns the current material
  55401. */
  55402. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55403. /**
  55404. * Add a new block to the list of output nodes
  55405. * @param node defines the node to add
  55406. * @returns the current material
  55407. */
  55408. addOutputNode(node: NodeMaterialBlock): this;
  55409. /**
  55410. * Remove a block from the list of root nodes
  55411. * @param node defines the node to remove
  55412. * @returns the current material
  55413. */
  55414. removeOutputNode(node: NodeMaterialBlock): this;
  55415. private _addVertexOutputNode;
  55416. private _removeVertexOutputNode;
  55417. private _addFragmentOutputNode;
  55418. private _removeFragmentOutputNode;
  55419. /**
  55420. * Specifies if the material will require alpha blending
  55421. * @returns a boolean specifying if alpha blending is needed
  55422. */
  55423. needAlphaBlending(): boolean;
  55424. /**
  55425. * Specifies if this material should be rendered in alpha test mode
  55426. * @returns a boolean specifying if an alpha test is needed.
  55427. */
  55428. needAlphaTesting(): boolean;
  55429. private _initializeBlock;
  55430. private _resetDualBlocks;
  55431. /**
  55432. * Build the material and generates the inner effect
  55433. * @param verbose defines if the build should log activity
  55434. */
  55435. build(verbose?: boolean): void;
  55436. /**
  55437. * Runs an otpimization phase to try to improve the shader code
  55438. */
  55439. optimize(): void;
  55440. private _prepareDefinesForAttributes;
  55441. /**
  55442. * Get if the submesh is ready to be used and all its information available.
  55443. * Child classes can use it to update shaders
  55444. * @param mesh defines the mesh to check
  55445. * @param subMesh defines which submesh to check
  55446. * @param useInstances specifies that instances should be used
  55447. * @returns a boolean indicating that the submesh is ready or not
  55448. */
  55449. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55450. /**
  55451. * Get a string representing the shaders built by the current node graph
  55452. */
  55453. readonly compiledShaders: string;
  55454. /**
  55455. * Binds the world matrix to the material
  55456. * @param world defines the world transformation matrix
  55457. */
  55458. bindOnlyWorldMatrix(world: Matrix): void;
  55459. /**
  55460. * Binds the submesh to this material by preparing the effect and shader to draw
  55461. * @param world defines the world transformation matrix
  55462. * @param mesh defines the mesh containing the submesh
  55463. * @param subMesh defines the submesh to bind the material to
  55464. */
  55465. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55466. /**
  55467. * Gets the active textures from the material
  55468. * @returns an array of textures
  55469. */
  55470. getActiveTextures(): BaseTexture[];
  55471. /**
  55472. * Gets the list of texture blocks
  55473. * @returns an array of texture blocks
  55474. */
  55475. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55476. /**
  55477. * Specifies if the material uses a texture
  55478. * @param texture defines the texture to check against the material
  55479. * @returns a boolean specifying if the material uses the texture
  55480. */
  55481. hasTexture(texture: BaseTexture): boolean;
  55482. /**
  55483. * Disposes the material
  55484. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55485. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55486. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55487. */
  55488. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55489. /** Creates the node editor window. */
  55490. private _createNodeEditor;
  55491. /**
  55492. * Launch the node material editor
  55493. * @param config Define the configuration of the editor
  55494. * @return a promise fulfilled when the node editor is visible
  55495. */
  55496. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55497. /**
  55498. * Clear the current material
  55499. */
  55500. clear(): void;
  55501. /**
  55502. * Clear the current material and set it to a default state
  55503. */
  55504. setToDefault(): void;
  55505. /**
  55506. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55507. * @param url defines the url to load from
  55508. * @returns a promise that will fullfil when the material is fully loaded
  55509. */
  55510. loadAsync(url: string): Promise<unknown>;
  55511. private _gatherBlocks;
  55512. /**
  55513. * Generate a string containing the code declaration required to create an equivalent of this material
  55514. * @returns a string
  55515. */
  55516. generateCode(): string;
  55517. /**
  55518. * Serializes this material in a JSON representation
  55519. * @returns the serialized material object
  55520. */
  55521. serialize(): any;
  55522. private _restoreConnections;
  55523. /**
  55524. * Clear the current graph and load a new one from a serialization object
  55525. * @param source defines the JSON representation of the material
  55526. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55527. */
  55528. loadFromSerialization(source: any, rootUrl?: string): void;
  55529. /**
  55530. * Creates a node material from parsed material data
  55531. * @param source defines the JSON representation of the material
  55532. * @param scene defines the hosting scene
  55533. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55534. * @returns a new node material
  55535. */
  55536. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55537. /**
  55538. * Creates a new node material set to default basic configuration
  55539. * @param name defines the name of the material
  55540. * @param scene defines the hosting scene
  55541. * @returns a new NodeMaterial
  55542. */
  55543. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55544. }
  55545. }
  55546. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55549. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55552. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55553. import { Effect } from "babylonjs/Materials/effect";
  55554. import { Mesh } from "babylonjs/Meshes/mesh";
  55555. import { Nullable } from "babylonjs/types";
  55556. import { Texture } from "babylonjs/Materials/Textures/texture";
  55557. import { Scene } from "babylonjs/scene";
  55558. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55559. /**
  55560. * Block used to read a texture from a sampler
  55561. */
  55562. export class TextureBlock extends NodeMaterialBlock {
  55563. private _defineName;
  55564. private _linearDefineName;
  55565. private _samplerName;
  55566. private _transformedUVName;
  55567. private _textureTransformName;
  55568. private _textureInfoName;
  55569. private _mainUVName;
  55570. private _mainUVDefineName;
  55571. /**
  55572. * Gets or sets the texture associated with the node
  55573. */
  55574. texture: Nullable<Texture>;
  55575. /**
  55576. * Create a new TextureBlock
  55577. * @param name defines the block name
  55578. */
  55579. constructor(name: string);
  55580. /**
  55581. * Gets the current class name
  55582. * @returns the class name
  55583. */
  55584. getClassName(): string;
  55585. /**
  55586. * Gets the uv input component
  55587. */
  55588. readonly uv: NodeMaterialConnectionPoint;
  55589. /**
  55590. * Gets the rgba output component
  55591. */
  55592. readonly rgba: NodeMaterialConnectionPoint;
  55593. /**
  55594. * Gets the rgb output component
  55595. */
  55596. readonly rgb: NodeMaterialConnectionPoint;
  55597. /**
  55598. * Gets the r output component
  55599. */
  55600. readonly r: NodeMaterialConnectionPoint;
  55601. /**
  55602. * Gets the g output component
  55603. */
  55604. readonly g: NodeMaterialConnectionPoint;
  55605. /**
  55606. * Gets the b output component
  55607. */
  55608. readonly b: NodeMaterialConnectionPoint;
  55609. /**
  55610. * Gets the a output component
  55611. */
  55612. readonly a: NodeMaterialConnectionPoint;
  55613. readonly target: NodeMaterialBlockTargets;
  55614. autoConfigure(material: NodeMaterial): void;
  55615. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55616. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55617. isReady(): boolean;
  55618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55619. private readonly _isMixed;
  55620. private _injectVertexCode;
  55621. private _writeOutput;
  55622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55623. protected _dumpPropertiesCode(): string;
  55624. serialize(): any;
  55625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55626. }
  55627. }
  55628. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55631. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55632. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55633. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55634. import { Scene } from "babylonjs/scene";
  55635. /**
  55636. * Class used to store shared data between 2 NodeMaterialBuildState
  55637. */
  55638. export class NodeMaterialBuildStateSharedData {
  55639. /**
  55640. * Gets the list of emitted varyings
  55641. */
  55642. temps: string[];
  55643. /**
  55644. * Gets the list of emitted varyings
  55645. */
  55646. varyings: string[];
  55647. /**
  55648. * Gets the varying declaration string
  55649. */
  55650. varyingDeclaration: string;
  55651. /**
  55652. * Input blocks
  55653. */
  55654. inputBlocks: InputBlock[];
  55655. /**
  55656. * Input blocks
  55657. */
  55658. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55659. /**
  55660. * Bindable blocks (Blocks that need to set data to the effect)
  55661. */
  55662. bindableBlocks: NodeMaterialBlock[];
  55663. /**
  55664. * List of blocks that can provide a compilation fallback
  55665. */
  55666. blocksWithFallbacks: NodeMaterialBlock[];
  55667. /**
  55668. * List of blocks that can provide a define update
  55669. */
  55670. blocksWithDefines: NodeMaterialBlock[];
  55671. /**
  55672. * List of blocks that can provide a repeatable content
  55673. */
  55674. repeatableContentBlocks: NodeMaterialBlock[];
  55675. /**
  55676. * List of blocks that can provide a dynamic list of uniforms
  55677. */
  55678. dynamicUniformBlocks: NodeMaterialBlock[];
  55679. /**
  55680. * List of blocks that can block the isReady function for the material
  55681. */
  55682. blockingBlocks: NodeMaterialBlock[];
  55683. /**
  55684. * Gets the list of animated inputs
  55685. */
  55686. animatedInputs: InputBlock[];
  55687. /**
  55688. * Build Id used to avoid multiple recompilations
  55689. */
  55690. buildId: number;
  55691. /** List of emitted variables */
  55692. variableNames: {
  55693. [key: string]: number;
  55694. };
  55695. /** List of emitted defines */
  55696. defineNames: {
  55697. [key: string]: number;
  55698. };
  55699. /** Should emit comments? */
  55700. emitComments: boolean;
  55701. /** Emit build activity */
  55702. verbose: boolean;
  55703. /** Gets or sets the hosting scene */
  55704. scene: Scene;
  55705. /**
  55706. * Gets the compilation hints emitted at compilation time
  55707. */
  55708. hints: {
  55709. needWorldViewMatrix: boolean;
  55710. needWorldViewProjectionMatrix: boolean;
  55711. needAlphaBlending: boolean;
  55712. needAlphaTesting: boolean;
  55713. };
  55714. /**
  55715. * List of compilation checks
  55716. */
  55717. checks: {
  55718. emitVertex: boolean;
  55719. emitFragment: boolean;
  55720. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55721. };
  55722. /** Creates a new shared data */
  55723. constructor();
  55724. /**
  55725. * Emits console errors and exceptions if there is a failing check
  55726. */
  55727. emitErrors(): void;
  55728. }
  55729. }
  55730. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55731. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55732. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55733. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55734. /**
  55735. * Class used to store node based material build state
  55736. */
  55737. export class NodeMaterialBuildState {
  55738. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55739. supportUniformBuffers: boolean;
  55740. /**
  55741. * Gets the list of emitted attributes
  55742. */
  55743. attributes: string[];
  55744. /**
  55745. * Gets the list of emitted uniforms
  55746. */
  55747. uniforms: string[];
  55748. /**
  55749. * Gets the list of emitted constants
  55750. */
  55751. constants: string[];
  55752. /**
  55753. * Gets the list of emitted uniform buffers
  55754. */
  55755. uniformBuffers: string[];
  55756. /**
  55757. * Gets the list of emitted samplers
  55758. */
  55759. samplers: string[];
  55760. /**
  55761. * Gets the list of emitted functions
  55762. */
  55763. functions: {
  55764. [key: string]: string;
  55765. };
  55766. /**
  55767. * Gets the list of emitted extensions
  55768. */
  55769. extensions: {
  55770. [key: string]: string;
  55771. };
  55772. /**
  55773. * Gets the target of the compilation state
  55774. */
  55775. target: NodeMaterialBlockTargets;
  55776. /**
  55777. * Gets the list of emitted counters
  55778. */
  55779. counters: {
  55780. [key: string]: number;
  55781. };
  55782. /**
  55783. * Shared data between multiple NodeMaterialBuildState instances
  55784. */
  55785. sharedData: NodeMaterialBuildStateSharedData;
  55786. /** @hidden */
  55787. _vertexState: NodeMaterialBuildState;
  55788. /** @hidden */
  55789. _attributeDeclaration: string;
  55790. /** @hidden */
  55791. _uniformDeclaration: string;
  55792. /** @hidden */
  55793. _constantDeclaration: string;
  55794. /** @hidden */
  55795. _samplerDeclaration: string;
  55796. /** @hidden */
  55797. _varyingTransfer: string;
  55798. private _repeatableContentAnchorIndex;
  55799. /** @hidden */
  55800. _builtCompilationString: string;
  55801. /**
  55802. * Gets the emitted compilation strings
  55803. */
  55804. compilationString: string;
  55805. /**
  55806. * Finalize the compilation strings
  55807. * @param state defines the current compilation state
  55808. */
  55809. finalize(state: NodeMaterialBuildState): void;
  55810. /** @hidden */
  55811. readonly _repeatableContentAnchor: string;
  55812. /** @hidden */
  55813. _getFreeVariableName(prefix: string): string;
  55814. /** @hidden */
  55815. _getFreeDefineName(prefix: string): string;
  55816. /** @hidden */
  55817. _excludeVariableName(name: string): void;
  55818. /** @hidden */
  55819. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55820. /** @hidden */
  55821. _emitExtension(name: string, extension: string): void;
  55822. /** @hidden */
  55823. _emitFunction(name: string, code: string, comments: string): void;
  55824. /** @hidden */
  55825. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55826. replaceStrings?: {
  55827. search: RegExp;
  55828. replace: string;
  55829. }[];
  55830. repeatKey?: string;
  55831. }): string;
  55832. /** @hidden */
  55833. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55834. repeatKey?: string;
  55835. removeAttributes?: boolean;
  55836. removeUniforms?: boolean;
  55837. removeVaryings?: boolean;
  55838. removeIfDef?: boolean;
  55839. replaceStrings?: {
  55840. search: RegExp;
  55841. replace: string;
  55842. }[];
  55843. }, storeKey?: string): void;
  55844. /** @hidden */
  55845. _registerTempVariable(name: string): boolean;
  55846. /** @hidden */
  55847. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55848. /** @hidden */
  55849. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55850. }
  55851. }
  55852. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55853. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55855. import { Nullable } from "babylonjs/types";
  55856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55857. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55858. import { Effect } from "babylonjs/Materials/effect";
  55859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55860. import { Mesh } from "babylonjs/Meshes/mesh";
  55861. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55862. import { Scene } from "babylonjs/scene";
  55863. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55864. /**
  55865. * Defines a block that can be used inside a node based material
  55866. */
  55867. export class NodeMaterialBlock {
  55868. private _buildId;
  55869. private _buildTarget;
  55870. private _target;
  55871. private _isFinalMerger;
  55872. private _isInput;
  55873. /** @hidden */
  55874. _codeVariableName: string;
  55875. /** @hidden */
  55876. _inputs: NodeMaterialConnectionPoint[];
  55877. /** @hidden */
  55878. _outputs: NodeMaterialConnectionPoint[];
  55879. /** @hidden */
  55880. _preparationId: number;
  55881. /**
  55882. * Gets or sets the name of the block
  55883. */
  55884. name: string;
  55885. /**
  55886. * Gets or sets the unique id of the node
  55887. */
  55888. uniqueId: number;
  55889. /**
  55890. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55891. */
  55892. readonly isFinalMerger: boolean;
  55893. /**
  55894. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55895. */
  55896. readonly isInput: boolean;
  55897. /**
  55898. * Gets or sets the build Id
  55899. */
  55900. buildId: number;
  55901. /**
  55902. * Gets or sets the target of the block
  55903. */
  55904. target: NodeMaterialBlockTargets;
  55905. /**
  55906. * Gets the list of input points
  55907. */
  55908. readonly inputs: NodeMaterialConnectionPoint[];
  55909. /** Gets the list of output points */
  55910. readonly outputs: NodeMaterialConnectionPoint[];
  55911. /**
  55912. * Find an input by its name
  55913. * @param name defines the name of the input to look for
  55914. * @returns the input or null if not found
  55915. */
  55916. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55917. /**
  55918. * Find an output by its name
  55919. * @param name defines the name of the outputto look for
  55920. * @returns the output or null if not found
  55921. */
  55922. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55923. /**
  55924. * Creates a new NodeMaterialBlock
  55925. * @param name defines the block name
  55926. * @param target defines the target of that block (Vertex by default)
  55927. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55928. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55929. */
  55930. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55931. /**
  55932. * Initialize the block and prepare the context for build
  55933. * @param state defines the state that will be used for the build
  55934. */
  55935. initialize(state: NodeMaterialBuildState): void;
  55936. /**
  55937. * Bind data to effect. Will only be called for blocks with isBindable === true
  55938. * @param effect defines the effect to bind data to
  55939. * @param nodeMaterial defines the hosting NodeMaterial
  55940. * @param mesh defines the mesh that will be rendered
  55941. */
  55942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55943. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55944. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55945. protected _writeFloat(value: number): string;
  55946. /**
  55947. * Gets the current class name e.g. "NodeMaterialBlock"
  55948. * @returns the class name
  55949. */
  55950. getClassName(): string;
  55951. /**
  55952. * Register a new input. Must be called inside a block constructor
  55953. * @param name defines the connection point name
  55954. * @param type defines the connection point type
  55955. * @param isOptional defines a boolean indicating that this input can be omitted
  55956. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55957. * @returns the current block
  55958. */
  55959. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55960. /**
  55961. * Register a new output. Must be called inside a block constructor
  55962. * @param name defines the connection point name
  55963. * @param type defines the connection point type
  55964. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55965. * @returns the current block
  55966. */
  55967. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55968. /**
  55969. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55970. * @param forOutput defines an optional connection point to check compatibility with
  55971. * @returns the first available input or null
  55972. */
  55973. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55974. /**
  55975. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55976. * @param forBlock defines an optional block to check compatibility with
  55977. * @returns the first available input or null
  55978. */
  55979. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55980. /**
  55981. * Gets the sibling of the given output
  55982. * @param current defines the current output
  55983. * @returns the next output in the list or null
  55984. */
  55985. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55986. /**
  55987. * Connect current block with another block
  55988. * @param other defines the block to connect with
  55989. * @param options define the various options to help pick the right connections
  55990. * @returns the current block
  55991. */
  55992. connectTo(other: NodeMaterialBlock, options?: {
  55993. input?: string;
  55994. output?: string;
  55995. outputSwizzle?: string;
  55996. }): this | undefined;
  55997. protected _buildBlock(state: NodeMaterialBuildState): void;
  55998. /**
  55999. * Add uniforms, samplers and uniform buffers at compilation time
  56000. * @param state defines the state to update
  56001. * @param nodeMaterial defines the node material requesting the update
  56002. * @param defines defines the material defines to update
  56003. */
  56004. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56005. /**
  56006. * Add potential fallbacks if shader compilation fails
  56007. * @param mesh defines the mesh to be rendered
  56008. * @param fallbacks defines the current prioritized list of fallbacks
  56009. */
  56010. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56011. /**
  56012. * Initialize defines for shader compilation
  56013. * @param mesh defines the mesh to be rendered
  56014. * @param nodeMaterial defines the node material requesting the update
  56015. * @param defines defines the material defines to update
  56016. * @param useInstances specifies that instances should be used
  56017. */
  56018. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56019. /**
  56020. * Update defines for shader compilation
  56021. * @param mesh defines the mesh to be rendered
  56022. * @param nodeMaterial defines the node material requesting the update
  56023. * @param defines defines the material defines to update
  56024. * @param useInstances specifies that instances should be used
  56025. */
  56026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56027. /**
  56028. * Lets the block try to connect some inputs automatically
  56029. * @param material defines the hosting NodeMaterial
  56030. */
  56031. autoConfigure(material: NodeMaterial): void;
  56032. /**
  56033. * Function called when a block is declared as repeatable content generator
  56034. * @param vertexShaderState defines the current compilation state for the vertex shader
  56035. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56036. * @param mesh defines the mesh to be rendered
  56037. * @param defines defines the material defines to update
  56038. */
  56039. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56040. /**
  56041. * Checks if the block is ready
  56042. * @param mesh defines the mesh to be rendered
  56043. * @param nodeMaterial defines the node material requesting the update
  56044. * @param defines defines the material defines to update
  56045. * @param useInstances specifies that instances should be used
  56046. * @returns true if the block is ready
  56047. */
  56048. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56049. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56050. private _processBuild;
  56051. /**
  56052. * Compile the current node and generate the shader code
  56053. * @param state defines the current compilation state (uniforms, samplers, current string)
  56054. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56055. * @returns true if already built
  56056. */
  56057. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56058. protected _inputRename(name: string): string;
  56059. protected _outputRename(name: string): string;
  56060. protected _dumpPropertiesCode(): string;
  56061. /** @hidden */
  56062. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56063. /**
  56064. * Clone the current block to a new identical block
  56065. * @param scene defines the hosting scene
  56066. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56067. * @returns a copy of the current block
  56068. */
  56069. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56070. /**
  56071. * Serializes this block in a JSON representation
  56072. * @returns the serialized block object
  56073. */
  56074. serialize(): any;
  56075. /** @hidden */
  56076. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56077. }
  56078. }
  56079. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56080. /**
  56081. * Enum defining the type of animations supported by InputBlock
  56082. */
  56083. export enum AnimatedInputBlockTypes {
  56084. /** No animation */
  56085. None = 0,
  56086. /** Time based animation. Will only work for floats */
  56087. Time = 1
  56088. }
  56089. }
  56090. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56092. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56093. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56094. import { Nullable } from "babylonjs/types";
  56095. import { Effect } from "babylonjs/Materials/effect";
  56096. import { Matrix } from "babylonjs/Maths/math.vector";
  56097. import { Scene } from "babylonjs/scene";
  56098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56100. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56101. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56102. /**
  56103. * Block used to expose an input value
  56104. */
  56105. export class InputBlock extends NodeMaterialBlock {
  56106. private _mode;
  56107. private _associatedVariableName;
  56108. private _storedValue;
  56109. private _valueCallback;
  56110. private _type;
  56111. private _animationType;
  56112. /** Gets or set a value used to limit the range of float values */
  56113. min: number;
  56114. /** Gets or set a value used to limit the range of float values */
  56115. max: number;
  56116. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56117. matrixMode: number;
  56118. /** @hidden */
  56119. _systemValue: Nullable<NodeMaterialSystemValues>;
  56120. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56121. visibleInInspector: boolean;
  56122. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56123. isConstant: boolean;
  56124. /**
  56125. * Gets or sets the connection point type (default is float)
  56126. */
  56127. readonly type: NodeMaterialBlockConnectionPointTypes;
  56128. /**
  56129. * Creates a new InputBlock
  56130. * @param name defines the block name
  56131. * @param target defines the target of that block (Vertex by default)
  56132. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56133. */
  56134. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56135. /**
  56136. * Gets the output component
  56137. */
  56138. readonly output: NodeMaterialConnectionPoint;
  56139. /**
  56140. * Set the source of this connection point to a vertex attribute
  56141. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56142. * @returns the current connection point
  56143. */
  56144. setAsAttribute(attributeName?: string): InputBlock;
  56145. /**
  56146. * Set the source of this connection point to a system value
  56147. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56148. * @returns the current connection point
  56149. */
  56150. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56151. /**
  56152. * Gets or sets the value of that point.
  56153. * Please note that this value will be ignored if valueCallback is defined
  56154. */
  56155. value: any;
  56156. /**
  56157. * Gets or sets a callback used to get the value of that point.
  56158. * Please note that setting this value will force the connection point to ignore the value property
  56159. */
  56160. valueCallback: () => any;
  56161. /**
  56162. * Gets or sets the associated variable name in the shader
  56163. */
  56164. associatedVariableName: string;
  56165. /** Gets or sets the type of animation applied to the input */
  56166. animationType: AnimatedInputBlockTypes;
  56167. /**
  56168. * Gets a boolean indicating that this connection point not defined yet
  56169. */
  56170. readonly isUndefined: boolean;
  56171. /**
  56172. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56173. * In this case the connection point name must be the name of the uniform to use.
  56174. * Can only be set on inputs
  56175. */
  56176. isUniform: boolean;
  56177. /**
  56178. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56179. * In this case the connection point name must be the name of the attribute to use
  56180. * Can only be set on inputs
  56181. */
  56182. isAttribute: boolean;
  56183. /**
  56184. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56185. * Can only be set on exit points
  56186. */
  56187. isVarying: boolean;
  56188. /**
  56189. * Gets a boolean indicating that the current connection point is a system value
  56190. */
  56191. readonly isSystemValue: boolean;
  56192. /**
  56193. * Gets or sets the current well known value or null if not defined as a system value
  56194. */
  56195. systemValue: Nullable<NodeMaterialSystemValues>;
  56196. /**
  56197. * Gets the current class name
  56198. * @returns the class name
  56199. */
  56200. getClassName(): string;
  56201. /**
  56202. * Animate the input if animationType !== None
  56203. * @param scene defines the rendering scene
  56204. */
  56205. animate(scene: Scene): void;
  56206. private _emitDefine;
  56207. initialize(state: NodeMaterialBuildState): void;
  56208. /**
  56209. * Set the input block to its default value (based on its type)
  56210. */
  56211. setDefaultValue(): void;
  56212. private _emitConstant;
  56213. private _emit;
  56214. /** @hidden */
  56215. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56216. /** @hidden */
  56217. _transmit(effect: Effect, scene: Scene): void;
  56218. protected _buildBlock(state: NodeMaterialBuildState): void;
  56219. protected _dumpPropertiesCode(): string;
  56220. serialize(): any;
  56221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56222. }
  56223. }
  56224. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56225. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56226. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56227. import { Nullable } from "babylonjs/types";
  56228. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56230. /**
  56231. * Defines a connection point for a block
  56232. */
  56233. export class NodeMaterialConnectionPoint {
  56234. /** @hidden */
  56235. _ownerBlock: NodeMaterialBlock;
  56236. /** @hidden */
  56237. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56238. private _endpoints;
  56239. private _associatedVariableName;
  56240. /** @hidden */
  56241. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56242. /** @hidden */
  56243. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56244. private _type;
  56245. /** @hidden */
  56246. _enforceAssociatedVariableName: boolean;
  56247. /**
  56248. * Gets or sets the additional types supported by this connection point
  56249. */
  56250. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56251. /**
  56252. * Gets or sets the additional types excluded by this connection point
  56253. */
  56254. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56255. /**
  56256. * Gets or sets the associated variable name in the shader
  56257. */
  56258. associatedVariableName: string;
  56259. /**
  56260. * Gets or sets the connection point type (default is float)
  56261. */
  56262. type: NodeMaterialBlockConnectionPointTypes;
  56263. /**
  56264. * Gets or sets the connection point name
  56265. */
  56266. name: string;
  56267. /**
  56268. * Gets or sets a boolean indicating that this connection point can be omitted
  56269. */
  56270. isOptional: boolean;
  56271. /**
  56272. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56273. */
  56274. define: string;
  56275. /** Gets or sets the target of that connection point */
  56276. target: NodeMaterialBlockTargets;
  56277. /**
  56278. * Gets a boolean indicating that the current point is connected
  56279. */
  56280. readonly isConnected: boolean;
  56281. /**
  56282. * Gets a boolean indicating that the current point is connected to an input block
  56283. */
  56284. readonly isConnectedToInputBlock: boolean;
  56285. /**
  56286. * Gets a the connected input block (if any)
  56287. */
  56288. readonly connectInputBlock: Nullable<InputBlock>;
  56289. /** Get the other side of the connection (if any) */
  56290. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56291. /** Get the block that owns this connection point */
  56292. readonly ownerBlock: NodeMaterialBlock;
  56293. /** Get the block connected on the other side of this connection (if any) */
  56294. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56295. /** Get the block connected on the endpoints of this connection (if any) */
  56296. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56297. /** Gets the list of connected endpoints */
  56298. readonly endpoints: NodeMaterialConnectionPoint[];
  56299. /** Gets a boolean indicating if that output point is connected to at least one input */
  56300. readonly hasEndpoints: boolean;
  56301. /**
  56302. * Creates a new connection point
  56303. * @param name defines the connection point name
  56304. * @param ownerBlock defines the block hosting this connection point
  56305. */
  56306. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56307. /**
  56308. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56309. * @returns the class name
  56310. */
  56311. getClassName(): string;
  56312. /**
  56313. * Gets an boolean indicating if the current point can be connected to another point
  56314. * @param connectionPoint defines the other connection point
  56315. * @returns true if the connection is possible
  56316. */
  56317. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56318. /**
  56319. * Connect this point to another connection point
  56320. * @param connectionPoint defines the other connection point
  56321. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56322. * @returns the current connection point
  56323. */
  56324. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56325. /**
  56326. * Disconnect this point from one of his endpoint
  56327. * @param endpoint defines the other connection point
  56328. * @returns the current connection point
  56329. */
  56330. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56331. /**
  56332. * Serializes this point in a JSON representation
  56333. * @returns the serialized point object
  56334. */
  56335. serialize(): any;
  56336. }
  56337. }
  56338. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56339. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56340. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56342. import { Mesh } from "babylonjs/Meshes/mesh";
  56343. import { Effect } from "babylonjs/Materials/effect";
  56344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56345. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56346. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56347. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56348. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56349. /**
  56350. * Block used to add support for vertex skinning (bones)
  56351. */
  56352. export class BonesBlock extends NodeMaterialBlock {
  56353. /**
  56354. * Creates a new BonesBlock
  56355. * @param name defines the block name
  56356. */
  56357. constructor(name: string);
  56358. /**
  56359. * Initialize the block and prepare the context for build
  56360. * @param state defines the state that will be used for the build
  56361. */
  56362. initialize(state: NodeMaterialBuildState): void;
  56363. /**
  56364. * Gets the current class name
  56365. * @returns the class name
  56366. */
  56367. getClassName(): string;
  56368. /**
  56369. * Gets the matrix indices input component
  56370. */
  56371. readonly matricesIndices: NodeMaterialConnectionPoint;
  56372. /**
  56373. * Gets the matrix weights input component
  56374. */
  56375. readonly matricesWeights: NodeMaterialConnectionPoint;
  56376. /**
  56377. * Gets the extra matrix indices input component
  56378. */
  56379. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56380. /**
  56381. * Gets the extra matrix weights input component
  56382. */
  56383. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56384. /**
  56385. * Gets the world input component
  56386. */
  56387. readonly world: NodeMaterialConnectionPoint;
  56388. /**
  56389. * Gets the output component
  56390. */
  56391. readonly output: NodeMaterialConnectionPoint;
  56392. autoConfigure(material: NodeMaterial): void;
  56393. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56394. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56396. protected _buildBlock(state: NodeMaterialBuildState): this;
  56397. }
  56398. }
  56399. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56404. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56405. /**
  56406. * Block used to add support for instances
  56407. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56408. */
  56409. export class InstancesBlock extends NodeMaterialBlock {
  56410. /**
  56411. * Creates a new InstancesBlock
  56412. * @param name defines the block name
  56413. */
  56414. constructor(name: string);
  56415. /**
  56416. * Gets the current class name
  56417. * @returns the class name
  56418. */
  56419. getClassName(): string;
  56420. /**
  56421. * Gets the first world row input component
  56422. */
  56423. readonly world0: NodeMaterialConnectionPoint;
  56424. /**
  56425. * Gets the second world row input component
  56426. */
  56427. readonly world1: NodeMaterialConnectionPoint;
  56428. /**
  56429. * Gets the third world row input component
  56430. */
  56431. readonly world2: NodeMaterialConnectionPoint;
  56432. /**
  56433. * Gets the forth world row input component
  56434. */
  56435. readonly world3: NodeMaterialConnectionPoint;
  56436. /**
  56437. * Gets the world input component
  56438. */
  56439. readonly world: NodeMaterialConnectionPoint;
  56440. /**
  56441. * Gets the output component
  56442. */
  56443. readonly output: NodeMaterialConnectionPoint;
  56444. autoConfigure(material: NodeMaterial): void;
  56445. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56446. protected _buildBlock(state: NodeMaterialBuildState): this;
  56447. }
  56448. }
  56449. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56454. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56455. import { Effect } from "babylonjs/Materials/effect";
  56456. import { Mesh } from "babylonjs/Meshes/mesh";
  56457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56458. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56459. /**
  56460. * Block used to add morph targets support to vertex shader
  56461. */
  56462. export class MorphTargetsBlock extends NodeMaterialBlock {
  56463. private _repeatableContentAnchor;
  56464. private _repeatebleContentGenerated;
  56465. /**
  56466. * Create a new MorphTargetsBlock
  56467. * @param name defines the block name
  56468. */
  56469. constructor(name: string);
  56470. /**
  56471. * Gets the current class name
  56472. * @returns the class name
  56473. */
  56474. getClassName(): string;
  56475. /**
  56476. * Gets the position input component
  56477. */
  56478. readonly position: NodeMaterialConnectionPoint;
  56479. /**
  56480. * Gets the normal input component
  56481. */
  56482. readonly normal: NodeMaterialConnectionPoint;
  56483. /**
  56484. * Gets the tangent input component
  56485. */
  56486. readonly tangent: NodeMaterialConnectionPoint;
  56487. /**
  56488. * Gets the tangent input component
  56489. */
  56490. readonly uv: NodeMaterialConnectionPoint;
  56491. /**
  56492. * Gets the position output component
  56493. */
  56494. readonly positionOutput: NodeMaterialConnectionPoint;
  56495. /**
  56496. * Gets the normal output component
  56497. */
  56498. readonly normalOutput: NodeMaterialConnectionPoint;
  56499. /**
  56500. * Gets the tangent output component
  56501. */
  56502. readonly tangentOutput: NodeMaterialConnectionPoint;
  56503. /**
  56504. * Gets the tangent output component
  56505. */
  56506. readonly uvOutput: NodeMaterialConnectionPoint;
  56507. initialize(state: NodeMaterialBuildState): void;
  56508. autoConfigure(material: NodeMaterial): void;
  56509. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56510. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56511. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56512. protected _buildBlock(state: NodeMaterialBuildState): this;
  56513. }
  56514. }
  56515. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56519. import { Nullable } from "babylonjs/types";
  56520. import { Scene } from "babylonjs/scene";
  56521. import { Effect } from "babylonjs/Materials/effect";
  56522. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56523. import { Mesh } from "babylonjs/Meshes/mesh";
  56524. import { Light } from "babylonjs/Lights/light";
  56525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56526. /**
  56527. * Block used to get data information from a light
  56528. */
  56529. export class LightInformationBlock extends NodeMaterialBlock {
  56530. private _lightDataUniformName;
  56531. private _lightColorUniformName;
  56532. private _lightTypeDefineName;
  56533. /**
  56534. * Gets or sets the light associated with this block
  56535. */
  56536. light: Nullable<Light>;
  56537. /**
  56538. * Creates a new LightInformationBlock
  56539. * @param name defines the block name
  56540. */
  56541. constructor(name: string);
  56542. /**
  56543. * Gets the current class name
  56544. * @returns the class name
  56545. */
  56546. getClassName(): string;
  56547. /**
  56548. * Gets the world position input component
  56549. */
  56550. readonly worldPosition: NodeMaterialConnectionPoint;
  56551. /**
  56552. * Gets the direction output component
  56553. */
  56554. readonly direction: NodeMaterialConnectionPoint;
  56555. /**
  56556. * Gets the direction output component
  56557. */
  56558. readonly color: NodeMaterialConnectionPoint;
  56559. /**
  56560. * Gets the direction output component
  56561. */
  56562. readonly intensity: NodeMaterialConnectionPoint;
  56563. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56564. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56565. protected _buildBlock(state: NodeMaterialBuildState): this;
  56566. serialize(): any;
  56567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56568. }
  56569. }
  56570. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56571. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56572. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56573. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56574. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56575. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56576. }
  56577. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56582. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56583. import { Effect } from "babylonjs/Materials/effect";
  56584. import { Mesh } from "babylonjs/Meshes/mesh";
  56585. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56586. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56587. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56588. /**
  56589. * Block used to add image processing support to fragment shader
  56590. */
  56591. export class ImageProcessingBlock extends NodeMaterialBlock {
  56592. /**
  56593. * Create a new ImageProcessingBlock
  56594. * @param name defines the block name
  56595. */
  56596. constructor(name: string);
  56597. /**
  56598. * Gets the current class name
  56599. * @returns the class name
  56600. */
  56601. getClassName(): string;
  56602. /**
  56603. * Gets the color input component
  56604. */
  56605. readonly color: NodeMaterialConnectionPoint;
  56606. /**
  56607. * Gets the output component
  56608. */
  56609. readonly output: NodeMaterialConnectionPoint;
  56610. /**
  56611. * Initialize the block and prepare the context for build
  56612. * @param state defines the state that will be used for the build
  56613. */
  56614. initialize(state: NodeMaterialBuildState): void;
  56615. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56616. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56618. protected _buildBlock(state: NodeMaterialBuildState): this;
  56619. }
  56620. }
  56621. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56625. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56627. import { Effect } from "babylonjs/Materials/effect";
  56628. import { Mesh } from "babylonjs/Meshes/mesh";
  56629. import { Scene } from "babylonjs/scene";
  56630. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56631. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56632. /**
  56633. * Block used to pertub normals based on a normal map
  56634. */
  56635. export class PerturbNormalBlock extends NodeMaterialBlock {
  56636. private _tangentSpaceParameterName;
  56637. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56638. invertX: boolean;
  56639. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56640. invertY: boolean;
  56641. /**
  56642. * Create a new PerturbNormalBlock
  56643. * @param name defines the block name
  56644. */
  56645. constructor(name: string);
  56646. /**
  56647. * Gets the current class name
  56648. * @returns the class name
  56649. */
  56650. getClassName(): string;
  56651. /**
  56652. * Gets the world position input component
  56653. */
  56654. readonly worldPosition: NodeMaterialConnectionPoint;
  56655. /**
  56656. * Gets the world normal input component
  56657. */
  56658. readonly worldNormal: NodeMaterialConnectionPoint;
  56659. /**
  56660. * Gets the uv input component
  56661. */
  56662. readonly uv: NodeMaterialConnectionPoint;
  56663. /**
  56664. * Gets the normal map color input component
  56665. */
  56666. readonly normalMapColor: NodeMaterialConnectionPoint;
  56667. /**
  56668. * Gets the strength input component
  56669. */
  56670. readonly strength: NodeMaterialConnectionPoint;
  56671. /**
  56672. * Gets the output component
  56673. */
  56674. readonly output: NodeMaterialConnectionPoint;
  56675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56676. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56677. autoConfigure(material: NodeMaterial): void;
  56678. protected _buildBlock(state: NodeMaterialBuildState): this;
  56679. protected _dumpPropertiesCode(): string;
  56680. serialize(): any;
  56681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56682. }
  56683. }
  56684. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56688. /**
  56689. * Block used to discard a pixel if a value is smaller than a cutoff
  56690. */
  56691. export class DiscardBlock extends NodeMaterialBlock {
  56692. /**
  56693. * Create a new DiscardBlock
  56694. * @param name defines the block name
  56695. */
  56696. constructor(name: string);
  56697. /**
  56698. * Gets the current class name
  56699. * @returns the class name
  56700. */
  56701. getClassName(): string;
  56702. /**
  56703. * Gets the color input component
  56704. */
  56705. readonly value: NodeMaterialConnectionPoint;
  56706. /**
  56707. * Gets the cutoff input component
  56708. */
  56709. readonly cutoff: NodeMaterialConnectionPoint;
  56710. protected _buildBlock(state: NodeMaterialBuildState): this;
  56711. }
  56712. }
  56713. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56714. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56715. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56716. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56717. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56718. }
  56719. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56722. import { Mesh } from "babylonjs/Meshes/mesh";
  56723. import { Effect } from "babylonjs/Materials/effect";
  56724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56726. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56727. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56728. /**
  56729. * Block used to add support for scene fog
  56730. */
  56731. export class FogBlock extends NodeMaterialBlock {
  56732. private _fogDistanceName;
  56733. private _fogParameters;
  56734. /**
  56735. * Create a new FogBlock
  56736. * @param name defines the block name
  56737. */
  56738. constructor(name: string);
  56739. /**
  56740. * Gets the current class name
  56741. * @returns the class name
  56742. */
  56743. getClassName(): string;
  56744. /**
  56745. * Gets the world position input component
  56746. */
  56747. readonly worldPosition: NodeMaterialConnectionPoint;
  56748. /**
  56749. * Gets the view input component
  56750. */
  56751. readonly view: NodeMaterialConnectionPoint;
  56752. /**
  56753. * Gets the color input component
  56754. */
  56755. readonly input: NodeMaterialConnectionPoint;
  56756. /**
  56757. * Gets the fog color input component
  56758. */
  56759. readonly fogColor: NodeMaterialConnectionPoint;
  56760. /**
  56761. * Gets the output component
  56762. */
  56763. readonly output: NodeMaterialConnectionPoint;
  56764. autoConfigure(material: NodeMaterial): void;
  56765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56767. protected _buildBlock(state: NodeMaterialBuildState): this;
  56768. }
  56769. }
  56770. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56775. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56776. import { Effect } from "babylonjs/Materials/effect";
  56777. import { Mesh } from "babylonjs/Meshes/mesh";
  56778. import { Light } from "babylonjs/Lights/light";
  56779. import { Nullable } from "babylonjs/types";
  56780. import { Scene } from "babylonjs/scene";
  56781. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56782. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56783. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56785. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56786. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56787. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56788. /**
  56789. * Block used to add light in the fragment shader
  56790. */
  56791. export class LightBlock extends NodeMaterialBlock {
  56792. private _lightId;
  56793. /**
  56794. * Gets or sets the light associated with this block
  56795. */
  56796. light: Nullable<Light>;
  56797. /**
  56798. * Create a new LightBlock
  56799. * @param name defines the block name
  56800. */
  56801. constructor(name: string);
  56802. /**
  56803. * Gets the current class name
  56804. * @returns the class name
  56805. */
  56806. getClassName(): string;
  56807. /**
  56808. * Gets the world position input component
  56809. */
  56810. readonly worldPosition: NodeMaterialConnectionPoint;
  56811. /**
  56812. * Gets the world normal input component
  56813. */
  56814. readonly worldNormal: NodeMaterialConnectionPoint;
  56815. /**
  56816. * Gets the camera (or eye) position component
  56817. */
  56818. readonly cameraPosition: NodeMaterialConnectionPoint;
  56819. /**
  56820. * Gets the glossiness component
  56821. */
  56822. readonly glossiness: NodeMaterialConnectionPoint;
  56823. /**
  56824. * Gets the glossinness power component
  56825. */
  56826. readonly glossPower: NodeMaterialConnectionPoint;
  56827. /**
  56828. * Gets the diffuse color component
  56829. */
  56830. readonly diffuseColor: NodeMaterialConnectionPoint;
  56831. /**
  56832. * Gets the specular color component
  56833. */
  56834. readonly specularColor: NodeMaterialConnectionPoint;
  56835. /**
  56836. * Gets the diffuse output component
  56837. */
  56838. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56839. /**
  56840. * Gets the specular output component
  56841. */
  56842. readonly specularOutput: NodeMaterialConnectionPoint;
  56843. autoConfigure(material: NodeMaterial): void;
  56844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56845. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56846. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56847. private _injectVertexCode;
  56848. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56849. serialize(): any;
  56850. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56851. }
  56852. }
  56853. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56854. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56855. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56856. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56857. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56858. }
  56859. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56860. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56861. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56862. }
  56863. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56867. /**
  56868. * Block used to multiply 2 values
  56869. */
  56870. export class MultiplyBlock extends NodeMaterialBlock {
  56871. /**
  56872. * Creates a new MultiplyBlock
  56873. * @param name defines the block name
  56874. */
  56875. constructor(name: string);
  56876. /**
  56877. * Gets the current class name
  56878. * @returns the class name
  56879. */
  56880. getClassName(): string;
  56881. /**
  56882. * Gets the left operand input component
  56883. */
  56884. readonly left: NodeMaterialConnectionPoint;
  56885. /**
  56886. * Gets the right operand input component
  56887. */
  56888. readonly right: NodeMaterialConnectionPoint;
  56889. /**
  56890. * Gets the output component
  56891. */
  56892. readonly output: NodeMaterialConnectionPoint;
  56893. protected _buildBlock(state: NodeMaterialBuildState): this;
  56894. }
  56895. }
  56896. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56900. /**
  56901. * Block used to add 2 vectors
  56902. */
  56903. export class AddBlock extends NodeMaterialBlock {
  56904. /**
  56905. * Creates a new AddBlock
  56906. * @param name defines the block name
  56907. */
  56908. constructor(name: string);
  56909. /**
  56910. * Gets the current class name
  56911. * @returns the class name
  56912. */
  56913. getClassName(): string;
  56914. /**
  56915. * Gets the left operand input component
  56916. */
  56917. readonly left: NodeMaterialConnectionPoint;
  56918. /**
  56919. * Gets the right operand input component
  56920. */
  56921. readonly right: NodeMaterialConnectionPoint;
  56922. /**
  56923. * Gets the output component
  56924. */
  56925. readonly output: NodeMaterialConnectionPoint;
  56926. protected _buildBlock(state: NodeMaterialBuildState): this;
  56927. }
  56928. }
  56929. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56933. /**
  56934. * Block used to scale a vector by a float
  56935. */
  56936. export class ScaleBlock extends NodeMaterialBlock {
  56937. /**
  56938. * Creates a new ScaleBlock
  56939. * @param name defines the block name
  56940. */
  56941. constructor(name: string);
  56942. /**
  56943. * Gets the current class name
  56944. * @returns the class name
  56945. */
  56946. getClassName(): string;
  56947. /**
  56948. * Gets the input component
  56949. */
  56950. readonly input: NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the factor input component
  56953. */
  56954. readonly factor: NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the output component
  56957. */
  56958. readonly output: NodeMaterialConnectionPoint;
  56959. protected _buildBlock(state: NodeMaterialBuildState): this;
  56960. }
  56961. }
  56962. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56964. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56966. import { Scene } from "babylonjs/scene";
  56967. /**
  56968. * Block used to clamp a float
  56969. */
  56970. export class ClampBlock extends NodeMaterialBlock {
  56971. /** Gets or sets the minimum range */
  56972. minimum: number;
  56973. /** Gets or sets the maximum range */
  56974. maximum: number;
  56975. /**
  56976. * Creates a new ClampBlock
  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 value input component
  56987. */
  56988. readonly value: NodeMaterialConnectionPoint;
  56989. /**
  56990. * Gets the output component
  56991. */
  56992. readonly output: NodeMaterialConnectionPoint;
  56993. protected _buildBlock(state: NodeMaterialBuildState): this;
  56994. protected _dumpPropertiesCode(): string;
  56995. serialize(): any;
  56996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56997. }
  56998. }
  56999. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57003. /**
  57004. * Block used to apply a cross product between 2 vectors
  57005. */
  57006. export class CrossBlock extends NodeMaterialBlock {
  57007. /**
  57008. * Creates a new CrossBlock
  57009. * @param name defines the block name
  57010. */
  57011. constructor(name: string);
  57012. /**
  57013. * Gets the current class name
  57014. * @returns the class name
  57015. */
  57016. getClassName(): string;
  57017. /**
  57018. * Gets the left operand input component
  57019. */
  57020. readonly left: NodeMaterialConnectionPoint;
  57021. /**
  57022. * Gets the right operand input component
  57023. */
  57024. readonly right: NodeMaterialConnectionPoint;
  57025. /**
  57026. * Gets the output component
  57027. */
  57028. readonly output: NodeMaterialConnectionPoint;
  57029. protected _buildBlock(state: NodeMaterialBuildState): this;
  57030. }
  57031. }
  57032. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57036. /**
  57037. * Block used to apply a dot product between 2 vectors
  57038. */
  57039. export class DotBlock extends NodeMaterialBlock {
  57040. /**
  57041. * Creates a new DotBlock
  57042. * @param name defines the block name
  57043. */
  57044. constructor(name: string);
  57045. /**
  57046. * Gets the current class name
  57047. * @returns the class name
  57048. */
  57049. getClassName(): string;
  57050. /**
  57051. * Gets the left operand input component
  57052. */
  57053. readonly left: NodeMaterialConnectionPoint;
  57054. /**
  57055. * Gets the right operand input component
  57056. */
  57057. readonly right: NodeMaterialConnectionPoint;
  57058. /**
  57059. * Gets the output component
  57060. */
  57061. readonly output: NodeMaterialConnectionPoint;
  57062. protected _buildBlock(state: NodeMaterialBuildState): this;
  57063. }
  57064. }
  57065. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57069. import { Vector2 } from "babylonjs/Maths/math.vector";
  57070. import { Scene } from "babylonjs/scene";
  57071. /**
  57072. * Block used to remap a float from a range to a new one
  57073. */
  57074. export class RemapBlock extends NodeMaterialBlock {
  57075. /**
  57076. * Gets or sets the source range
  57077. */
  57078. sourceRange: Vector2;
  57079. /**
  57080. * Gets or sets the target range
  57081. */
  57082. targetRange: Vector2;
  57083. /**
  57084. * Creates a new RemapBlock
  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 input component
  57095. */
  57096. readonly input: NodeMaterialConnectionPoint;
  57097. /**
  57098. * Gets the source min input component
  57099. */
  57100. readonly sourceMin: NodeMaterialConnectionPoint;
  57101. /**
  57102. * Gets the source max input component
  57103. */
  57104. readonly sourceMax: NodeMaterialConnectionPoint;
  57105. /**
  57106. * Gets the target min input component
  57107. */
  57108. readonly targetMin: NodeMaterialConnectionPoint;
  57109. /**
  57110. * Gets the target max input component
  57111. */
  57112. readonly targetMax: NodeMaterialConnectionPoint;
  57113. /**
  57114. * Gets the output component
  57115. */
  57116. readonly output: NodeMaterialConnectionPoint;
  57117. protected _buildBlock(state: NodeMaterialBuildState): this;
  57118. protected _dumpPropertiesCode(): string;
  57119. serialize(): any;
  57120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57121. }
  57122. }
  57123. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57127. /**
  57128. * Block used to normalize a vector
  57129. */
  57130. export class NormalizeBlock extends NodeMaterialBlock {
  57131. /**
  57132. * Creates a new NormalizeBlock
  57133. * @param name defines the block name
  57134. */
  57135. constructor(name: string);
  57136. /**
  57137. * Gets the current class name
  57138. * @returns the class name
  57139. */
  57140. getClassName(): string;
  57141. /**
  57142. * Gets the input component
  57143. */
  57144. readonly input: NodeMaterialConnectionPoint;
  57145. /**
  57146. * Gets the output component
  57147. */
  57148. readonly output: NodeMaterialConnectionPoint;
  57149. protected _buildBlock(state: NodeMaterialBuildState): this;
  57150. }
  57151. }
  57152. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57153. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57154. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57155. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57156. import { Scene } from "babylonjs/scene";
  57157. /**
  57158. * Operations supported by the Trigonometry block
  57159. */
  57160. export enum TrigonometryBlockOperations {
  57161. /** Cos */
  57162. Cos = 0,
  57163. /** Sin */
  57164. Sin = 1,
  57165. /** Abs */
  57166. Abs = 2,
  57167. /** Exp */
  57168. Exp = 3,
  57169. /** Exp2 */
  57170. Exp2 = 4,
  57171. /** Round */
  57172. Round = 5,
  57173. /** Floor */
  57174. Floor = 6,
  57175. /** Ceiling */
  57176. Ceiling = 7,
  57177. /** Square root */
  57178. Sqrt = 8,
  57179. /** Log */
  57180. Log = 9,
  57181. /** Tangent */
  57182. Tan = 10,
  57183. /** Arc tangent */
  57184. ArcTan = 11,
  57185. /** Arc cosinus */
  57186. ArcCos = 12,
  57187. /** Arc sinus */
  57188. ArcSin = 13,
  57189. /** Fraction */
  57190. Fract = 14,
  57191. /** Sign */
  57192. Sign = 15,
  57193. /** To radians (from degrees) */
  57194. Radians = 16,
  57195. /** To degrees (from radians) */
  57196. Degrees = 17
  57197. }
  57198. /**
  57199. * Block used to apply trigonometry operation to floats
  57200. */
  57201. export class TrigonometryBlock extends NodeMaterialBlock {
  57202. /**
  57203. * Gets or sets the operation applied by the block
  57204. */
  57205. operation: TrigonometryBlockOperations;
  57206. /**
  57207. * Creates a new TrigonometryBlock
  57208. * @param name defines the block name
  57209. */
  57210. constructor(name: string);
  57211. /**
  57212. * Gets the current class name
  57213. * @returns the class name
  57214. */
  57215. getClassName(): string;
  57216. /**
  57217. * Gets the input component
  57218. */
  57219. readonly input: NodeMaterialConnectionPoint;
  57220. /**
  57221. * Gets the output component
  57222. */
  57223. readonly output: NodeMaterialConnectionPoint;
  57224. protected _buildBlock(state: NodeMaterialBuildState): this;
  57225. serialize(): any;
  57226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57227. }
  57228. }
  57229. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57233. /**
  57234. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57235. */
  57236. export class ColorMergerBlock extends NodeMaterialBlock {
  57237. /**
  57238. * Create a new ColorMergerBlock
  57239. * @param name defines the block name
  57240. */
  57241. constructor(name: string);
  57242. /**
  57243. * Gets the current class name
  57244. * @returns the class name
  57245. */
  57246. getClassName(): string;
  57247. /**
  57248. * Gets the r component (input)
  57249. */
  57250. readonly r: NodeMaterialConnectionPoint;
  57251. /**
  57252. * Gets the g component (input)
  57253. */
  57254. readonly g: NodeMaterialConnectionPoint;
  57255. /**
  57256. * Gets the b component (input)
  57257. */
  57258. readonly b: NodeMaterialConnectionPoint;
  57259. /**
  57260. * Gets the a component (input)
  57261. */
  57262. readonly a: NodeMaterialConnectionPoint;
  57263. /**
  57264. * Gets the rgba component (output)
  57265. */
  57266. readonly rgba: NodeMaterialConnectionPoint;
  57267. /**
  57268. * Gets the rgb component (output)
  57269. */
  57270. readonly rgb: NodeMaterialConnectionPoint;
  57271. protected _buildBlock(state: NodeMaterialBuildState): this;
  57272. }
  57273. }
  57274. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57278. /**
  57279. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57280. */
  57281. export class VectorMergerBlock extends NodeMaterialBlock {
  57282. /**
  57283. * Create a new VectorMergerBlock
  57284. * @param name defines the block name
  57285. */
  57286. constructor(name: string);
  57287. /**
  57288. * Gets the current class name
  57289. * @returns the class name
  57290. */
  57291. getClassName(): string;
  57292. /**
  57293. * Gets the x component (input)
  57294. */
  57295. readonly x: NodeMaterialConnectionPoint;
  57296. /**
  57297. * Gets the y component (input)
  57298. */
  57299. readonly y: NodeMaterialConnectionPoint;
  57300. /**
  57301. * Gets the z component (input)
  57302. */
  57303. readonly z: NodeMaterialConnectionPoint;
  57304. /**
  57305. * Gets the w component (input)
  57306. */
  57307. readonly w: NodeMaterialConnectionPoint;
  57308. /**
  57309. * Gets the xyzw component (output)
  57310. */
  57311. readonly xyzw: NodeMaterialConnectionPoint;
  57312. /**
  57313. * Gets the xyz component (output)
  57314. */
  57315. readonly xyz: NodeMaterialConnectionPoint;
  57316. /**
  57317. * Gets the xy component (output)
  57318. */
  57319. readonly xy: NodeMaterialConnectionPoint;
  57320. protected _buildBlock(state: NodeMaterialBuildState): this;
  57321. }
  57322. }
  57323. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57327. /**
  57328. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57329. */
  57330. export class ColorSplitterBlock extends NodeMaterialBlock {
  57331. /**
  57332. * Create a new ColorSplitterBlock
  57333. * @param name defines the block name
  57334. */
  57335. constructor(name: string);
  57336. /**
  57337. * Gets the current class name
  57338. * @returns the class name
  57339. */
  57340. getClassName(): string;
  57341. /**
  57342. * Gets the rgba component (input)
  57343. */
  57344. readonly rgba: NodeMaterialConnectionPoint;
  57345. /**
  57346. * Gets the rgb component (input)
  57347. */
  57348. readonly rgbIn: NodeMaterialConnectionPoint;
  57349. /**
  57350. * Gets the rgb component (output)
  57351. */
  57352. readonly rgbOut: NodeMaterialConnectionPoint;
  57353. /**
  57354. * Gets the r component (output)
  57355. */
  57356. readonly r: NodeMaterialConnectionPoint;
  57357. /**
  57358. * Gets the g component (output)
  57359. */
  57360. readonly g: NodeMaterialConnectionPoint;
  57361. /**
  57362. * Gets the b component (output)
  57363. */
  57364. readonly b: NodeMaterialConnectionPoint;
  57365. /**
  57366. * Gets the a component (output)
  57367. */
  57368. readonly a: NodeMaterialConnectionPoint;
  57369. protected _inputRename(name: string): string;
  57370. protected _outputRename(name: string): string;
  57371. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57372. }
  57373. }
  57374. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57378. /**
  57379. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57380. */
  57381. export class VectorSplitterBlock extends NodeMaterialBlock {
  57382. /**
  57383. * Create a new VectorSplitterBlock
  57384. * @param name defines the block name
  57385. */
  57386. constructor(name: string);
  57387. /**
  57388. * Gets the current class name
  57389. * @returns the class name
  57390. */
  57391. getClassName(): string;
  57392. /**
  57393. * Gets the xyzw component (input)
  57394. */
  57395. readonly xyzw: NodeMaterialConnectionPoint;
  57396. /**
  57397. * Gets the xyz component (input)
  57398. */
  57399. readonly xyzIn: NodeMaterialConnectionPoint;
  57400. /**
  57401. * Gets the xy component (input)
  57402. */
  57403. readonly xyIn: NodeMaterialConnectionPoint;
  57404. /**
  57405. * Gets the xyz component (output)
  57406. */
  57407. readonly xyzOut: NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the xy component (output)
  57410. */
  57411. readonly xyOut: NodeMaterialConnectionPoint;
  57412. /**
  57413. * Gets the x component (output)
  57414. */
  57415. readonly x: NodeMaterialConnectionPoint;
  57416. /**
  57417. * Gets the y component (output)
  57418. */
  57419. readonly y: NodeMaterialConnectionPoint;
  57420. /**
  57421. * Gets the z component (output)
  57422. */
  57423. readonly z: NodeMaterialConnectionPoint;
  57424. /**
  57425. * Gets the w component (output)
  57426. */
  57427. readonly w: NodeMaterialConnectionPoint;
  57428. protected _inputRename(name: string): string;
  57429. protected _outputRename(name: string): string;
  57430. protected _buildBlock(state: NodeMaterialBuildState): this;
  57431. }
  57432. }
  57433. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57437. /**
  57438. * Block used to lerp 2 values
  57439. */
  57440. export class LerpBlock extends NodeMaterialBlock {
  57441. /**
  57442. * Creates a new LerpBlock
  57443. * @param name defines the block name
  57444. */
  57445. constructor(name: string);
  57446. /**
  57447. * Gets the current class name
  57448. * @returns the class name
  57449. */
  57450. getClassName(): string;
  57451. /**
  57452. * Gets the left operand input component
  57453. */
  57454. readonly left: NodeMaterialConnectionPoint;
  57455. /**
  57456. * Gets the right operand input component
  57457. */
  57458. readonly right: NodeMaterialConnectionPoint;
  57459. /**
  57460. * Gets the gradient operand input component
  57461. */
  57462. readonly gradient: NodeMaterialConnectionPoint;
  57463. /**
  57464. * Gets the output component
  57465. */
  57466. readonly output: NodeMaterialConnectionPoint;
  57467. protected _buildBlock(state: NodeMaterialBuildState): this;
  57468. }
  57469. }
  57470. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57474. /**
  57475. * Block used to divide 2 vectors
  57476. */
  57477. export class DivideBlock extends NodeMaterialBlock {
  57478. /**
  57479. * Creates a new DivideBlock
  57480. * @param name defines the block name
  57481. */
  57482. constructor(name: string);
  57483. /**
  57484. * Gets the current class name
  57485. * @returns the class name
  57486. */
  57487. getClassName(): string;
  57488. /**
  57489. * Gets the left operand input component
  57490. */
  57491. readonly left: NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the right operand input component
  57494. */
  57495. readonly right: NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the output component
  57498. */
  57499. readonly output: NodeMaterialConnectionPoint;
  57500. protected _buildBlock(state: NodeMaterialBuildState): this;
  57501. }
  57502. }
  57503. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57507. /**
  57508. * Block used to subtract 2 vectors
  57509. */
  57510. export class SubtractBlock extends NodeMaterialBlock {
  57511. /**
  57512. * Creates a new SubtractBlock
  57513. * @param name defines the block name
  57514. */
  57515. constructor(name: string);
  57516. /**
  57517. * Gets the current class name
  57518. * @returns the class name
  57519. */
  57520. getClassName(): string;
  57521. /**
  57522. * Gets the left operand input component
  57523. */
  57524. readonly left: NodeMaterialConnectionPoint;
  57525. /**
  57526. * Gets the right operand input component
  57527. */
  57528. readonly right: NodeMaterialConnectionPoint;
  57529. /**
  57530. * Gets the output component
  57531. */
  57532. readonly output: NodeMaterialConnectionPoint;
  57533. protected _buildBlock(state: NodeMaterialBuildState): this;
  57534. }
  57535. }
  57536. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57540. /**
  57541. * Block used to step a value
  57542. */
  57543. export class StepBlock extends NodeMaterialBlock {
  57544. /**
  57545. * Creates a new StepBlock
  57546. * @param name defines the block name
  57547. */
  57548. constructor(name: string);
  57549. /**
  57550. * Gets the current class name
  57551. * @returns the class name
  57552. */
  57553. getClassName(): string;
  57554. /**
  57555. * Gets the value operand input component
  57556. */
  57557. readonly value: NodeMaterialConnectionPoint;
  57558. /**
  57559. * Gets the edge operand input component
  57560. */
  57561. readonly edge: NodeMaterialConnectionPoint;
  57562. /**
  57563. * Gets the output component
  57564. */
  57565. readonly output: NodeMaterialConnectionPoint;
  57566. protected _buildBlock(state: NodeMaterialBuildState): this;
  57567. }
  57568. }
  57569. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57572. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57573. /**
  57574. * Block used to get the opposite (1 - x) of a value
  57575. */
  57576. export class OneMinusBlock extends NodeMaterialBlock {
  57577. /**
  57578. * Creates a new OneMinusBlock
  57579. * @param name defines the block name
  57580. */
  57581. constructor(name: string);
  57582. /**
  57583. * Gets the current class name
  57584. * @returns the class name
  57585. */
  57586. getClassName(): string;
  57587. /**
  57588. * Gets the input component
  57589. */
  57590. readonly input: NodeMaterialConnectionPoint;
  57591. /**
  57592. * Gets the output component
  57593. */
  57594. readonly output: NodeMaterialConnectionPoint;
  57595. protected _buildBlock(state: NodeMaterialBuildState): this;
  57596. }
  57597. }
  57598. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57602. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57603. /**
  57604. * Block used to get the view direction
  57605. */
  57606. export class ViewDirectionBlock extends NodeMaterialBlock {
  57607. /**
  57608. * Creates a new ViewDirectionBlock
  57609. * @param name defines the block name
  57610. */
  57611. constructor(name: string);
  57612. /**
  57613. * Gets the current class name
  57614. * @returns the class name
  57615. */
  57616. getClassName(): string;
  57617. /**
  57618. * Gets the world position component
  57619. */
  57620. readonly worldPosition: NodeMaterialConnectionPoint;
  57621. /**
  57622. * Gets the camera position component
  57623. */
  57624. readonly cameraPosition: NodeMaterialConnectionPoint;
  57625. /**
  57626. * Gets the output component
  57627. */
  57628. readonly output: NodeMaterialConnectionPoint;
  57629. autoConfigure(material: NodeMaterial): void;
  57630. protected _buildBlock(state: NodeMaterialBuildState): this;
  57631. }
  57632. }
  57633. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57637. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57638. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57639. /**
  57640. * Block used to compute fresnel value
  57641. */
  57642. export class FresnelBlock extends NodeMaterialBlock {
  57643. /**
  57644. * Create a new FresnelBlock
  57645. * @param name defines the block name
  57646. */
  57647. constructor(name: string);
  57648. /**
  57649. * Gets the current class name
  57650. * @returns the class name
  57651. */
  57652. getClassName(): string;
  57653. /**
  57654. * Gets the world normal input component
  57655. */
  57656. readonly worldNormal: NodeMaterialConnectionPoint;
  57657. /**
  57658. * Gets the view direction input component
  57659. */
  57660. readonly viewDirection: NodeMaterialConnectionPoint;
  57661. /**
  57662. * Gets the bias input component
  57663. */
  57664. readonly bias: NodeMaterialConnectionPoint;
  57665. /**
  57666. * Gets the camera (or eye) position component
  57667. */
  57668. readonly power: NodeMaterialConnectionPoint;
  57669. /**
  57670. * Gets the fresnel output component
  57671. */
  57672. readonly fresnel: NodeMaterialConnectionPoint;
  57673. autoConfigure(material: NodeMaterial): void;
  57674. protected _buildBlock(state: NodeMaterialBuildState): this;
  57675. }
  57676. }
  57677. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57681. /**
  57682. * Block used to get the max of 2 values
  57683. */
  57684. export class MaxBlock extends NodeMaterialBlock {
  57685. /**
  57686. * Creates a new MaxBlock
  57687. * @param name defines the block name
  57688. */
  57689. constructor(name: string);
  57690. /**
  57691. * Gets the current class name
  57692. * @returns the class name
  57693. */
  57694. getClassName(): string;
  57695. /**
  57696. * Gets the left operand input component
  57697. */
  57698. readonly left: NodeMaterialConnectionPoint;
  57699. /**
  57700. * Gets the right operand input component
  57701. */
  57702. readonly right: NodeMaterialConnectionPoint;
  57703. /**
  57704. * Gets the output component
  57705. */
  57706. readonly output: NodeMaterialConnectionPoint;
  57707. protected _buildBlock(state: NodeMaterialBuildState): this;
  57708. }
  57709. }
  57710. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57714. /**
  57715. * Block used to get the min of 2 values
  57716. */
  57717. export class MinBlock extends NodeMaterialBlock {
  57718. /**
  57719. * Creates a new MinBlock
  57720. * @param name defines the block name
  57721. */
  57722. constructor(name: string);
  57723. /**
  57724. * Gets the current class name
  57725. * @returns the class name
  57726. */
  57727. getClassName(): string;
  57728. /**
  57729. * Gets the left operand input component
  57730. */
  57731. readonly left: NodeMaterialConnectionPoint;
  57732. /**
  57733. * Gets the right operand input component
  57734. */
  57735. readonly right: NodeMaterialConnectionPoint;
  57736. /**
  57737. * Gets the output component
  57738. */
  57739. readonly output: NodeMaterialConnectionPoint;
  57740. protected _buildBlock(state: NodeMaterialBuildState): this;
  57741. }
  57742. }
  57743. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57747. /**
  57748. * Block used to get the distance between 2 values
  57749. */
  57750. export class DistanceBlock extends NodeMaterialBlock {
  57751. /**
  57752. * Creates a new DistanceBlock
  57753. * @param name defines the block name
  57754. */
  57755. constructor(name: string);
  57756. /**
  57757. * Gets the current class name
  57758. * @returns the class name
  57759. */
  57760. getClassName(): string;
  57761. /**
  57762. * Gets the left operand input component
  57763. */
  57764. readonly left: NodeMaterialConnectionPoint;
  57765. /**
  57766. * Gets the right operand input component
  57767. */
  57768. readonly right: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the output component
  57771. */
  57772. readonly output: NodeMaterialConnectionPoint;
  57773. protected _buildBlock(state: NodeMaterialBuildState): this;
  57774. }
  57775. }
  57776. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57777. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57778. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57779. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57780. /**
  57781. * Block used to get the length of a vector
  57782. */
  57783. export class LengthBlock extends NodeMaterialBlock {
  57784. /**
  57785. * Creates a new LengthBlock
  57786. * @param name defines the block name
  57787. */
  57788. constructor(name: string);
  57789. /**
  57790. * Gets the current class name
  57791. * @returns the class name
  57792. */
  57793. getClassName(): string;
  57794. /**
  57795. * Gets the value input component
  57796. */
  57797. readonly value: NodeMaterialConnectionPoint;
  57798. /**
  57799. * Gets the output component
  57800. */
  57801. readonly output: NodeMaterialConnectionPoint;
  57802. protected _buildBlock(state: NodeMaterialBuildState): this;
  57803. }
  57804. }
  57805. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57809. /**
  57810. * Block used to get negative version of a value (i.e. x * -1)
  57811. */
  57812. export class NegateBlock extends NodeMaterialBlock {
  57813. /**
  57814. * Creates a new NegateBlock
  57815. * @param name defines the block name
  57816. */
  57817. constructor(name: string);
  57818. /**
  57819. * Gets the current class name
  57820. * @returns the class name
  57821. */
  57822. getClassName(): string;
  57823. /**
  57824. * Gets the value input component
  57825. */
  57826. readonly value: NodeMaterialConnectionPoint;
  57827. /**
  57828. * Gets the output component
  57829. */
  57830. readonly output: NodeMaterialConnectionPoint;
  57831. protected _buildBlock(state: NodeMaterialBuildState): this;
  57832. }
  57833. }
  57834. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57835. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57836. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57837. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57838. /**
  57839. * Block used to get the value of the first parameter raised to the power of the second
  57840. */
  57841. export class PowBlock extends NodeMaterialBlock {
  57842. /**
  57843. * Creates a new PowBlock
  57844. * @param name defines the block name
  57845. */
  57846. constructor(name: string);
  57847. /**
  57848. * Gets the current class name
  57849. * @returns the class name
  57850. */
  57851. getClassName(): string;
  57852. /**
  57853. * Gets the value operand input component
  57854. */
  57855. readonly value: NodeMaterialConnectionPoint;
  57856. /**
  57857. * Gets the power operand input component
  57858. */
  57859. readonly power: NodeMaterialConnectionPoint;
  57860. /**
  57861. * Gets the output component
  57862. */
  57863. readonly output: NodeMaterialConnectionPoint;
  57864. protected _buildBlock(state: NodeMaterialBuildState): this;
  57865. }
  57866. }
  57867. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57871. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57872. /**
  57873. * Block used to get a random number
  57874. */
  57875. export class RandomNumberBlock extends NodeMaterialBlock {
  57876. /**
  57877. * Creates a new RandomNumberBlock
  57878. * @param name defines the block name
  57879. */
  57880. constructor(name: string);
  57881. /**
  57882. * Gets the current class name
  57883. * @returns the class name
  57884. */
  57885. getClassName(): string;
  57886. /**
  57887. * Gets the seed input component
  57888. */
  57889. readonly seed: NodeMaterialConnectionPoint;
  57890. /**
  57891. * Gets the output component
  57892. */
  57893. readonly output: NodeMaterialConnectionPoint;
  57894. protected _buildBlock(state: NodeMaterialBuildState): this;
  57895. }
  57896. }
  57897. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57901. /**
  57902. * Block used to compute arc tangent of 2 values
  57903. */
  57904. export class ArcTan2Block extends NodeMaterialBlock {
  57905. /**
  57906. * Creates a new ArcTan2Block
  57907. * @param name defines the block name
  57908. */
  57909. constructor(name: string);
  57910. /**
  57911. * Gets the current class name
  57912. * @returns the class name
  57913. */
  57914. getClassName(): string;
  57915. /**
  57916. * Gets the x operand input component
  57917. */
  57918. readonly x: NodeMaterialConnectionPoint;
  57919. /**
  57920. * Gets the y operand input component
  57921. */
  57922. readonly y: NodeMaterialConnectionPoint;
  57923. /**
  57924. * Gets the output component
  57925. */
  57926. readonly output: NodeMaterialConnectionPoint;
  57927. protected _buildBlock(state: NodeMaterialBuildState): this;
  57928. }
  57929. }
  57930. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  57931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57934. /**
  57935. * Block used to smooth step a value
  57936. */
  57937. export class SmoothStepBlock extends NodeMaterialBlock {
  57938. /**
  57939. * Creates a new SmoothStepBlock
  57940. * @param name defines the block name
  57941. */
  57942. constructor(name: string);
  57943. /**
  57944. * Gets the current class name
  57945. * @returns the class name
  57946. */
  57947. getClassName(): string;
  57948. /**
  57949. * Gets the value operand input component
  57950. */
  57951. readonly value: NodeMaterialConnectionPoint;
  57952. /**
  57953. * Gets the first edge operand input component
  57954. */
  57955. readonly edge0: NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the second edge operand input component
  57958. */
  57959. readonly edge1: NodeMaterialConnectionPoint;
  57960. /**
  57961. * Gets the output component
  57962. */
  57963. readonly output: NodeMaterialConnectionPoint;
  57964. protected _buildBlock(state: NodeMaterialBuildState): this;
  57965. }
  57966. }
  57967. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  57968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57971. /**
  57972. * Block used to get the reciprocal (1 / x) of a value
  57973. */
  57974. export class ReciprocalBlock extends NodeMaterialBlock {
  57975. /**
  57976. * Creates a new ReciprocalBlock
  57977. * @param name defines the block name
  57978. */
  57979. constructor(name: string);
  57980. /**
  57981. * Gets the current class name
  57982. * @returns the class name
  57983. */
  57984. getClassName(): string;
  57985. /**
  57986. * Gets the input component
  57987. */
  57988. readonly input: NodeMaterialConnectionPoint;
  57989. /**
  57990. * Gets the output component
  57991. */
  57992. readonly output: NodeMaterialConnectionPoint;
  57993. protected _buildBlock(state: NodeMaterialBuildState): this;
  57994. }
  57995. }
  57996. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  57997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58000. /**
  58001. * Block used to replace a color by another one
  58002. */
  58003. export class ReplaceColorBlock extends NodeMaterialBlock {
  58004. /**
  58005. * Creates a new ReplaceColorBlock
  58006. * @param name defines the block name
  58007. */
  58008. constructor(name: string);
  58009. /**
  58010. * Gets the current class name
  58011. * @returns the class name
  58012. */
  58013. getClassName(): string;
  58014. /**
  58015. * Gets the value input component
  58016. */
  58017. readonly value: NodeMaterialConnectionPoint;
  58018. /**
  58019. * Gets the reference input component
  58020. */
  58021. readonly reference: NodeMaterialConnectionPoint;
  58022. /**
  58023. * Gets the distance input component
  58024. */
  58025. readonly distance: NodeMaterialConnectionPoint;
  58026. /**
  58027. * Gets the replacement input component
  58028. */
  58029. readonly replacement: NodeMaterialConnectionPoint;
  58030. /**
  58031. * Gets the output component
  58032. */
  58033. readonly output: NodeMaterialConnectionPoint;
  58034. protected _buildBlock(state: NodeMaterialBuildState): this;
  58035. }
  58036. }
  58037. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58041. /**
  58042. * Block used to posterize a value
  58043. * @see https://en.wikipedia.org/wiki/Posterization
  58044. */
  58045. export class PosterizeBlock extends NodeMaterialBlock {
  58046. /**
  58047. * Creates a new PosterizeBlock
  58048. * @param name defines the block name
  58049. */
  58050. constructor(name: string);
  58051. /**
  58052. * Gets the current class name
  58053. * @returns the class name
  58054. */
  58055. getClassName(): string;
  58056. /**
  58057. * Gets the value input component
  58058. */
  58059. readonly value: NodeMaterialConnectionPoint;
  58060. /**
  58061. * Gets the steps input component
  58062. */
  58063. readonly steps: NodeMaterialConnectionPoint;
  58064. /**
  58065. * Gets the output component
  58066. */
  58067. readonly output: NodeMaterialConnectionPoint;
  58068. protected _buildBlock(state: NodeMaterialBuildState): this;
  58069. }
  58070. }
  58071. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58075. import { Scene } from "babylonjs/scene";
  58076. /**
  58077. * Operations supported by the Wave block
  58078. */
  58079. export enum WaveBlockKind {
  58080. /** SawTooth */
  58081. SawTooth = 0,
  58082. /** Square */
  58083. Square = 1,
  58084. /** Triangle */
  58085. Triangle = 2
  58086. }
  58087. /**
  58088. * Block used to apply wave operation to floats
  58089. */
  58090. export class WaveBlock extends NodeMaterialBlock {
  58091. /**
  58092. * Gets or sets the kibnd of wave to be applied by the block
  58093. */
  58094. kind: WaveBlockKind;
  58095. /**
  58096. * Creates a new WaveBlock
  58097. * @param name defines the block name
  58098. */
  58099. constructor(name: string);
  58100. /**
  58101. * Gets the current class name
  58102. * @returns the class name
  58103. */
  58104. getClassName(): string;
  58105. /**
  58106. * Gets the input component
  58107. */
  58108. readonly input: NodeMaterialConnectionPoint;
  58109. /**
  58110. * Gets the output component
  58111. */
  58112. readonly output: NodeMaterialConnectionPoint;
  58113. protected _buildBlock(state: NodeMaterialBuildState): this;
  58114. serialize(): any;
  58115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58116. }
  58117. }
  58118. declare module "babylonjs/Materials/Node/Blocks/index" {
  58119. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58120. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58121. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58122. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58123. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58124. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58125. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58126. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58127. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58128. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58129. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58130. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58131. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58132. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58133. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58134. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58135. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58136. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58137. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58138. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58139. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58140. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58141. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58142. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58143. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58144. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58145. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58146. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58147. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58148. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58149. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58150. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58151. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58152. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58153. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58154. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58155. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58156. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58157. }
  58158. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58159. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58160. }
  58161. declare module "babylonjs/Materials/Node/index" {
  58162. export * from "babylonjs/Materials/Node/Enums/index";
  58163. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58164. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58165. export * from "babylonjs/Materials/Node/nodeMaterial";
  58166. export * from "babylonjs/Materials/Node/Blocks/index";
  58167. export * from "babylonjs/Materials/Node/Optimizers/index";
  58168. }
  58169. declare module "babylonjs/Materials/effectRenderer" {
  58170. import { Nullable } from "babylonjs/types";
  58171. import { Texture } from "babylonjs/Materials/Textures/texture";
  58172. import { Engine } from "babylonjs/Engines/engine";
  58173. import { Viewport } from "babylonjs/Maths/math.viewport";
  58174. import { Observable } from "babylonjs/Misc/observable";
  58175. import { Effect } from "babylonjs/Materials/effect";
  58176. import "babylonjs/Shaders/postprocess.vertex";
  58177. /**
  58178. * Effect Render Options
  58179. */
  58180. export interface IEffectRendererOptions {
  58181. /**
  58182. * Defines the vertices positions.
  58183. */
  58184. positions?: number[];
  58185. /**
  58186. * Defines the indices.
  58187. */
  58188. indices?: number[];
  58189. }
  58190. /**
  58191. * Helper class to render one or more effects
  58192. */
  58193. export class EffectRenderer {
  58194. private engine;
  58195. private static _DefaultOptions;
  58196. private _vertexBuffers;
  58197. private _indexBuffer;
  58198. private _ringBufferIndex;
  58199. private _ringScreenBuffer;
  58200. private _fullscreenViewport;
  58201. private _getNextFrameBuffer;
  58202. /**
  58203. * Creates an effect renderer
  58204. * @param engine the engine to use for rendering
  58205. * @param options defines the options of the effect renderer
  58206. */
  58207. constructor(engine: Engine, options?: IEffectRendererOptions);
  58208. /**
  58209. * Sets the current viewport in normalized coordinates 0-1
  58210. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58211. */
  58212. setViewport(viewport?: Viewport): void;
  58213. /**
  58214. * Binds the embedded attributes buffer to the effect.
  58215. * @param effect Defines the effect to bind the attributes for
  58216. */
  58217. bindBuffers(effect: Effect): void;
  58218. /**
  58219. * Sets the current effect wrapper to use during draw.
  58220. * The effect needs to be ready before calling this api.
  58221. * This also sets the default full screen position attribute.
  58222. * @param effectWrapper Defines the effect to draw with
  58223. */
  58224. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58225. /**
  58226. * Draws a full screen quad.
  58227. */
  58228. draw(): void;
  58229. /**
  58230. * renders one or more effects to a specified texture
  58231. * @param effectWrappers list of effects to renderer
  58232. * @param outputTexture texture to draw to, if null it will render to the screen
  58233. */
  58234. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58235. /**
  58236. * Disposes of the effect renderer
  58237. */
  58238. dispose(): void;
  58239. }
  58240. /**
  58241. * Options to create an EffectWrapper
  58242. */
  58243. interface EffectWrapperCreationOptions {
  58244. /**
  58245. * Engine to use to create the effect
  58246. */
  58247. engine: Engine;
  58248. /**
  58249. * Fragment shader for the effect
  58250. */
  58251. fragmentShader: string;
  58252. /**
  58253. * Vertex shader for the effect
  58254. */
  58255. vertexShader?: string;
  58256. /**
  58257. * Attributes to use in the shader
  58258. */
  58259. attributeNames?: Array<string>;
  58260. /**
  58261. * Uniforms to use in the shader
  58262. */
  58263. uniformNames?: Array<string>;
  58264. /**
  58265. * Texture sampler names to use in the shader
  58266. */
  58267. samplerNames?: Array<string>;
  58268. /**
  58269. * The friendly name of the effect displayed in Spector.
  58270. */
  58271. name?: string;
  58272. }
  58273. /**
  58274. * Wraps an effect to be used for rendering
  58275. */
  58276. export class EffectWrapper {
  58277. /**
  58278. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58279. */
  58280. onApplyObservable: Observable<{}>;
  58281. /**
  58282. * The underlying effect
  58283. */
  58284. effect: Effect;
  58285. /**
  58286. * Creates an effect to be renderer
  58287. * @param creationOptions options to create the effect
  58288. */
  58289. constructor(creationOptions: EffectWrapperCreationOptions);
  58290. /**
  58291. * Disposes of the effect wrapper
  58292. */
  58293. dispose(): void;
  58294. }
  58295. }
  58296. declare module "babylonjs/Materials/index" {
  58297. export * from "babylonjs/Materials/Background/index";
  58298. export * from "babylonjs/Materials/colorCurves";
  58299. export * from "babylonjs/Materials/iEffectFallbacks";
  58300. export * from "babylonjs/Materials/effectFallbacks";
  58301. export * from "babylonjs/Materials/effect";
  58302. export * from "babylonjs/Materials/fresnelParameters";
  58303. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58304. export * from "babylonjs/Materials/material";
  58305. export * from "babylonjs/Materials/materialDefines";
  58306. export * from "babylonjs/Materials/materialHelper";
  58307. export * from "babylonjs/Materials/multiMaterial";
  58308. export * from "babylonjs/Materials/PBR/index";
  58309. export * from "babylonjs/Materials/pushMaterial";
  58310. export * from "babylonjs/Materials/shaderMaterial";
  58311. export * from "babylonjs/Materials/standardMaterial";
  58312. export * from "babylonjs/Materials/Textures/index";
  58313. export * from "babylonjs/Materials/uniformBuffer";
  58314. export * from "babylonjs/Materials/materialFlags";
  58315. export * from "babylonjs/Materials/Node/index";
  58316. export * from "babylonjs/Materials/effectRenderer";
  58317. }
  58318. declare module "babylonjs/Maths/index" {
  58319. export * from "babylonjs/Maths/math.scalar";
  58320. export * from "babylonjs/Maths/math";
  58321. export * from "babylonjs/Maths/sphericalPolynomial";
  58322. }
  58323. declare module "babylonjs/Misc/workerPool" {
  58324. import { IDisposable } from "babylonjs/scene";
  58325. /**
  58326. * Helper class to push actions to a pool of workers.
  58327. */
  58328. export class WorkerPool implements IDisposable {
  58329. private _workerInfos;
  58330. private _pendingActions;
  58331. /**
  58332. * Constructor
  58333. * @param workers Array of workers to use for actions
  58334. */
  58335. constructor(workers: Array<Worker>);
  58336. /**
  58337. * Terminates all workers and clears any pending actions.
  58338. */
  58339. dispose(): void;
  58340. /**
  58341. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58342. * pended until a worker has completed its action.
  58343. * @param action The action to perform. Call onComplete when the action is complete.
  58344. */
  58345. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58346. private _execute;
  58347. }
  58348. }
  58349. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58350. import { IDisposable } from "babylonjs/scene";
  58351. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58352. /**
  58353. * Configuration for Draco compression
  58354. */
  58355. export interface IDracoCompressionConfiguration {
  58356. /**
  58357. * Configuration for the decoder.
  58358. */
  58359. decoder: {
  58360. /**
  58361. * The url to the WebAssembly module.
  58362. */
  58363. wasmUrl?: string;
  58364. /**
  58365. * The url to the WebAssembly binary.
  58366. */
  58367. wasmBinaryUrl?: string;
  58368. /**
  58369. * The url to the fallback JavaScript module.
  58370. */
  58371. fallbackUrl?: string;
  58372. };
  58373. }
  58374. /**
  58375. * Draco compression (https://google.github.io/draco/)
  58376. *
  58377. * This class wraps the Draco module.
  58378. *
  58379. * **Encoder**
  58380. *
  58381. * The encoder is not currently implemented.
  58382. *
  58383. * **Decoder**
  58384. *
  58385. * 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.
  58386. *
  58387. * To update the configuration, use the following code:
  58388. * ```javascript
  58389. * DracoCompression.Configuration = {
  58390. * decoder: {
  58391. * wasmUrl: "<url to the WebAssembly library>",
  58392. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58393. * fallbackUrl: "<url to the fallback JavaScript library>",
  58394. * }
  58395. * };
  58396. * ```
  58397. *
  58398. * 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.
  58399. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58400. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58401. *
  58402. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58403. * ```javascript
  58404. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58405. * ```
  58406. *
  58407. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58408. */
  58409. export class DracoCompression implements IDisposable {
  58410. private _workerPoolPromise?;
  58411. private _decoderModulePromise?;
  58412. /**
  58413. * The configuration. Defaults to the following urls:
  58414. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58415. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58416. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58417. */
  58418. static Configuration: IDracoCompressionConfiguration;
  58419. /**
  58420. * Returns true if the decoder configuration is available.
  58421. */
  58422. static readonly DecoderAvailable: boolean;
  58423. /**
  58424. * Default number of workers to create when creating the draco compression object.
  58425. */
  58426. static DefaultNumWorkers: number;
  58427. private static GetDefaultNumWorkers;
  58428. private static _Default;
  58429. /**
  58430. * Default instance for the draco compression object.
  58431. */
  58432. static readonly Default: DracoCompression;
  58433. /**
  58434. * Constructor
  58435. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58436. */
  58437. constructor(numWorkers?: number);
  58438. /**
  58439. * Stop all async operations and release resources.
  58440. */
  58441. dispose(): void;
  58442. /**
  58443. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58444. * @returns a promise that resolves when ready
  58445. */
  58446. whenReadyAsync(): Promise<void>;
  58447. /**
  58448. * Decode Draco compressed mesh data to vertex data.
  58449. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58450. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58451. * @returns A promise that resolves with the decoded vertex data
  58452. */
  58453. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58454. [kind: string]: number;
  58455. }): Promise<VertexData>;
  58456. }
  58457. }
  58458. declare module "babylonjs/Meshes/Compression/index" {
  58459. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58460. }
  58461. declare module "babylonjs/Meshes/csg" {
  58462. import { Nullable } from "babylonjs/types";
  58463. import { Scene } from "babylonjs/scene";
  58464. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58465. import { Mesh } from "babylonjs/Meshes/mesh";
  58466. import { Material } from "babylonjs/Materials/material";
  58467. /**
  58468. * Class for building Constructive Solid Geometry
  58469. */
  58470. export class CSG {
  58471. private polygons;
  58472. /**
  58473. * The world matrix
  58474. */
  58475. matrix: Matrix;
  58476. /**
  58477. * Stores the position
  58478. */
  58479. position: Vector3;
  58480. /**
  58481. * Stores the rotation
  58482. */
  58483. rotation: Vector3;
  58484. /**
  58485. * Stores the rotation quaternion
  58486. */
  58487. rotationQuaternion: Nullable<Quaternion>;
  58488. /**
  58489. * Stores the scaling vector
  58490. */
  58491. scaling: Vector3;
  58492. /**
  58493. * Convert the Mesh to CSG
  58494. * @param mesh The Mesh to convert to CSG
  58495. * @returns A new CSG from the Mesh
  58496. */
  58497. static FromMesh(mesh: Mesh): CSG;
  58498. /**
  58499. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58500. * @param polygons Polygons used to construct a CSG solid
  58501. */
  58502. private static FromPolygons;
  58503. /**
  58504. * Clones, or makes a deep copy, of the CSG
  58505. * @returns A new CSG
  58506. */
  58507. clone(): CSG;
  58508. /**
  58509. * Unions this CSG with another CSG
  58510. * @param csg The CSG to union against this CSG
  58511. * @returns The unioned CSG
  58512. */
  58513. union(csg: CSG): CSG;
  58514. /**
  58515. * Unions this CSG with another CSG in place
  58516. * @param csg The CSG to union against this CSG
  58517. */
  58518. unionInPlace(csg: CSG): void;
  58519. /**
  58520. * Subtracts this CSG with another CSG
  58521. * @param csg The CSG to subtract against this CSG
  58522. * @returns A new CSG
  58523. */
  58524. subtract(csg: CSG): CSG;
  58525. /**
  58526. * Subtracts this CSG with another CSG in place
  58527. * @param csg The CSG to subtact against this CSG
  58528. */
  58529. subtractInPlace(csg: CSG): void;
  58530. /**
  58531. * Intersect this CSG with another CSG
  58532. * @param csg The CSG to intersect against this CSG
  58533. * @returns A new CSG
  58534. */
  58535. intersect(csg: CSG): CSG;
  58536. /**
  58537. * Intersects this CSG with another CSG in place
  58538. * @param csg The CSG to intersect against this CSG
  58539. */
  58540. intersectInPlace(csg: CSG): void;
  58541. /**
  58542. * Return a new CSG solid with solid and empty space switched. This solid is
  58543. * not modified.
  58544. * @returns A new CSG solid with solid and empty space switched
  58545. */
  58546. inverse(): CSG;
  58547. /**
  58548. * Inverses the CSG in place
  58549. */
  58550. inverseInPlace(): void;
  58551. /**
  58552. * This is used to keep meshes transformations so they can be restored
  58553. * when we build back a Babylon Mesh
  58554. * NB : All CSG operations are performed in world coordinates
  58555. * @param csg The CSG to copy the transform attributes from
  58556. * @returns This CSG
  58557. */
  58558. copyTransformAttributes(csg: CSG): CSG;
  58559. /**
  58560. * Build Raw mesh from CSG
  58561. * Coordinates here are in world space
  58562. * @param name The name of the mesh geometry
  58563. * @param scene The Scene
  58564. * @param keepSubMeshes Specifies if the submeshes should be kept
  58565. * @returns A new Mesh
  58566. */
  58567. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58568. /**
  58569. * Build Mesh from CSG taking material and transforms into account
  58570. * @param name The name of the Mesh
  58571. * @param material The material of the Mesh
  58572. * @param scene The Scene
  58573. * @param keepSubMeshes Specifies if submeshes should be kept
  58574. * @returns The new Mesh
  58575. */
  58576. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58577. }
  58578. }
  58579. declare module "babylonjs/Meshes/trailMesh" {
  58580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58581. import { Mesh } from "babylonjs/Meshes/mesh";
  58582. import { Scene } from "babylonjs/scene";
  58583. /**
  58584. * Class used to create a trail following a mesh
  58585. */
  58586. export class TrailMesh extends Mesh {
  58587. private _generator;
  58588. private _autoStart;
  58589. private _running;
  58590. private _diameter;
  58591. private _length;
  58592. private _sectionPolygonPointsCount;
  58593. private _sectionVectors;
  58594. private _sectionNormalVectors;
  58595. private _beforeRenderObserver;
  58596. /**
  58597. * @constructor
  58598. * @param name The value used by scene.getMeshByName() to do a lookup.
  58599. * @param generator The mesh to generate a trail.
  58600. * @param scene The scene to add this mesh to.
  58601. * @param diameter Diameter of trailing mesh. Default is 1.
  58602. * @param length Length of trailing mesh. Default is 60.
  58603. * @param autoStart Automatically start trailing mesh. Default true.
  58604. */
  58605. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58606. /**
  58607. * "TrailMesh"
  58608. * @returns "TrailMesh"
  58609. */
  58610. getClassName(): string;
  58611. private _createMesh;
  58612. /**
  58613. * Start trailing mesh.
  58614. */
  58615. start(): void;
  58616. /**
  58617. * Stop trailing mesh.
  58618. */
  58619. stop(): void;
  58620. /**
  58621. * Update trailing mesh geometry.
  58622. */
  58623. update(): void;
  58624. /**
  58625. * Returns a new TrailMesh object.
  58626. * @param name is a string, the name given to the new mesh
  58627. * @param newGenerator use new generator object for cloned trail mesh
  58628. * @returns a new mesh
  58629. */
  58630. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58631. /**
  58632. * Serializes this trail mesh
  58633. * @param serializationObject object to write serialization to
  58634. */
  58635. serialize(serializationObject: any): void;
  58636. /**
  58637. * Parses a serialized trail mesh
  58638. * @param parsedMesh the serialized mesh
  58639. * @param scene the scene to create the trail mesh in
  58640. * @returns the created trail mesh
  58641. */
  58642. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58643. }
  58644. }
  58645. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58646. import { Nullable } from "babylonjs/types";
  58647. import { Scene } from "babylonjs/scene";
  58648. import { Vector4 } from "babylonjs/Maths/math.vector";
  58649. import { Color4 } from "babylonjs/Maths/math.color";
  58650. import { Mesh } from "babylonjs/Meshes/mesh";
  58651. /**
  58652. * Class containing static functions to help procedurally build meshes
  58653. */
  58654. export class TiledBoxBuilder {
  58655. /**
  58656. * Creates a box mesh
  58657. * 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)
  58658. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58662. * @param name defines the name of the mesh
  58663. * @param options defines the options used to create the mesh
  58664. * @param scene defines the hosting scene
  58665. * @returns the box mesh
  58666. */
  58667. static CreateTiledBox(name: string, options: {
  58668. pattern?: number;
  58669. width?: number;
  58670. height?: number;
  58671. depth?: number;
  58672. tileSize?: number;
  58673. tileWidth?: number;
  58674. tileHeight?: number;
  58675. alignHorizontal?: number;
  58676. alignVertical?: number;
  58677. faceUV?: Vector4[];
  58678. faceColors?: Color4[];
  58679. sideOrientation?: number;
  58680. updatable?: boolean;
  58681. }, scene?: Nullable<Scene>): Mesh;
  58682. }
  58683. }
  58684. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58685. import { Vector4 } from "babylonjs/Maths/math.vector";
  58686. import { Mesh } from "babylonjs/Meshes/mesh";
  58687. /**
  58688. * Class containing static functions to help procedurally build meshes
  58689. */
  58690. export class TorusKnotBuilder {
  58691. /**
  58692. * Creates a torus knot mesh
  58693. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58694. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58695. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58696. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58700. * @param name defines the name of the mesh
  58701. * @param options defines the options used to create the mesh
  58702. * @param scene defines the hosting scene
  58703. * @returns the torus knot mesh
  58704. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58705. */
  58706. static CreateTorusKnot(name: string, options: {
  58707. radius?: number;
  58708. tube?: number;
  58709. radialSegments?: number;
  58710. tubularSegments?: number;
  58711. p?: number;
  58712. q?: number;
  58713. updatable?: boolean;
  58714. sideOrientation?: number;
  58715. frontUVs?: Vector4;
  58716. backUVs?: Vector4;
  58717. }, scene: any): Mesh;
  58718. }
  58719. }
  58720. declare module "babylonjs/Meshes/polygonMesh" {
  58721. import { Scene } from "babylonjs/scene";
  58722. import { Vector2 } from "babylonjs/Maths/math.vector";
  58723. import { Mesh } from "babylonjs/Meshes/mesh";
  58724. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58725. import { Path2 } from "babylonjs/Maths/math.path";
  58726. /**
  58727. * Polygon
  58728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58729. */
  58730. export class Polygon {
  58731. /**
  58732. * Creates a rectangle
  58733. * @param xmin bottom X coord
  58734. * @param ymin bottom Y coord
  58735. * @param xmax top X coord
  58736. * @param ymax top Y coord
  58737. * @returns points that make the resulting rectation
  58738. */
  58739. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58740. /**
  58741. * Creates a circle
  58742. * @param radius radius of circle
  58743. * @param cx scale in x
  58744. * @param cy scale in y
  58745. * @param numberOfSides number of sides that make up the circle
  58746. * @returns points that make the resulting circle
  58747. */
  58748. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58749. /**
  58750. * Creates a polygon from input string
  58751. * @param input Input polygon data
  58752. * @returns the parsed points
  58753. */
  58754. static Parse(input: string): Vector2[];
  58755. /**
  58756. * Starts building a polygon from x and y coordinates
  58757. * @param x x coordinate
  58758. * @param y y coordinate
  58759. * @returns the started path2
  58760. */
  58761. static StartingAt(x: number, y: number): Path2;
  58762. }
  58763. /**
  58764. * Builds a polygon
  58765. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58766. */
  58767. export class PolygonMeshBuilder {
  58768. private _points;
  58769. private _outlinepoints;
  58770. private _holes;
  58771. private _name;
  58772. private _scene;
  58773. private _epoints;
  58774. private _eholes;
  58775. private _addToepoint;
  58776. /**
  58777. * Babylon reference to the earcut plugin.
  58778. */
  58779. bjsEarcut: any;
  58780. /**
  58781. * Creates a PolygonMeshBuilder
  58782. * @param name name of the builder
  58783. * @param contours Path of the polygon
  58784. * @param scene scene to add to when creating the mesh
  58785. * @param earcutInjection can be used to inject your own earcut reference
  58786. */
  58787. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58788. /**
  58789. * Adds a whole within the polygon
  58790. * @param hole Array of points defining the hole
  58791. * @returns this
  58792. */
  58793. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58794. /**
  58795. * Creates the polygon
  58796. * @param updatable If the mesh should be updatable
  58797. * @param depth The depth of the mesh created
  58798. * @returns the created mesh
  58799. */
  58800. build(updatable?: boolean, depth?: number): Mesh;
  58801. /**
  58802. * Creates the polygon
  58803. * @param depth The depth of the mesh created
  58804. * @returns the created VertexData
  58805. */
  58806. buildVertexData(depth?: number): VertexData;
  58807. /**
  58808. * Adds a side to the polygon
  58809. * @param positions points that make the polygon
  58810. * @param normals normals of the polygon
  58811. * @param uvs uvs of the polygon
  58812. * @param indices indices of the polygon
  58813. * @param bounds bounds of the polygon
  58814. * @param points points of the polygon
  58815. * @param depth depth of the polygon
  58816. * @param flip flip of the polygon
  58817. */
  58818. private addSide;
  58819. }
  58820. }
  58821. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58822. import { Scene } from "babylonjs/scene";
  58823. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58824. import { Color4 } from "babylonjs/Maths/math.color";
  58825. import { Mesh } from "babylonjs/Meshes/mesh";
  58826. import { Nullable } from "babylonjs/types";
  58827. /**
  58828. * Class containing static functions to help procedurally build meshes
  58829. */
  58830. export class PolygonBuilder {
  58831. /**
  58832. * Creates a polygon mesh
  58833. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58834. * * 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
  58835. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58838. * * Remember you can only change the shape positions, not their number when updating a polygon
  58839. * @param name defines the name of the mesh
  58840. * @param options defines the options used to create the mesh
  58841. * @param scene defines the hosting scene
  58842. * @param earcutInjection can be used to inject your own earcut reference
  58843. * @returns the polygon mesh
  58844. */
  58845. static CreatePolygon(name: string, options: {
  58846. shape: Vector3[];
  58847. holes?: Vector3[][];
  58848. depth?: number;
  58849. faceUV?: Vector4[];
  58850. faceColors?: Color4[];
  58851. updatable?: boolean;
  58852. sideOrientation?: number;
  58853. frontUVs?: Vector4;
  58854. backUVs?: Vector4;
  58855. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58856. /**
  58857. * Creates an extruded polygon mesh, with depth in the Y direction.
  58858. * * 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)
  58859. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58860. * @param name defines the name of the mesh
  58861. * @param options defines the options used to create the mesh
  58862. * @param scene defines the hosting scene
  58863. * @param earcutInjection can be used to inject your own earcut reference
  58864. * @returns the polygon mesh
  58865. */
  58866. static ExtrudePolygon(name: string, options: {
  58867. shape: Vector3[];
  58868. holes?: Vector3[][];
  58869. depth?: number;
  58870. faceUV?: Vector4[];
  58871. faceColors?: Color4[];
  58872. updatable?: boolean;
  58873. sideOrientation?: number;
  58874. frontUVs?: Vector4;
  58875. backUVs?: Vector4;
  58876. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58877. }
  58878. }
  58879. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58880. import { Scene } from "babylonjs/scene";
  58881. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58882. import { Mesh } from "babylonjs/Meshes/mesh";
  58883. import { Nullable } from "babylonjs/types";
  58884. /**
  58885. * Class containing static functions to help procedurally build meshes
  58886. */
  58887. export class LatheBuilder {
  58888. /**
  58889. * Creates lathe mesh.
  58890. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58891. * * 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
  58892. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58893. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58894. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58895. * * 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
  58896. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58897. * * 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
  58898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58902. * @param name defines the name of the mesh
  58903. * @param options defines the options used to create the mesh
  58904. * @param scene defines the hosting scene
  58905. * @returns the lathe mesh
  58906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58907. */
  58908. static CreateLathe(name: string, options: {
  58909. shape: Vector3[];
  58910. radius?: number;
  58911. tessellation?: number;
  58912. clip?: number;
  58913. arc?: number;
  58914. closed?: boolean;
  58915. updatable?: boolean;
  58916. sideOrientation?: number;
  58917. frontUVs?: Vector4;
  58918. backUVs?: Vector4;
  58919. cap?: number;
  58920. invertUV?: boolean;
  58921. }, scene?: Nullable<Scene>): Mesh;
  58922. }
  58923. }
  58924. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58925. import { Nullable } from "babylonjs/types";
  58926. import { Scene } from "babylonjs/scene";
  58927. import { Vector4 } from "babylonjs/Maths/math.vector";
  58928. import { Mesh } from "babylonjs/Meshes/mesh";
  58929. /**
  58930. * Class containing static functions to help procedurally build meshes
  58931. */
  58932. export class TiledPlaneBuilder {
  58933. /**
  58934. * Creates a tiled plane mesh
  58935. * * The parameter `pattern` will, depending on value, do nothing or
  58936. * * * flip (reflect about central vertical) alternate tiles across and up
  58937. * * * flip every tile on alternate rows
  58938. * * * rotate (180 degs) alternate tiles across and up
  58939. * * * rotate every tile on alternate rows
  58940. * * * flip and rotate alternate tiles across and up
  58941. * * * flip and rotate every tile on alternate rows
  58942. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58943. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58946. * * 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)
  58947. * * 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)
  58948. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58949. * @param name defines the name of the mesh
  58950. * @param options defines the options used to create the mesh
  58951. * @param scene defines the hosting scene
  58952. * @returns the box mesh
  58953. */
  58954. static CreateTiledPlane(name: string, options: {
  58955. pattern?: number;
  58956. tileSize?: number;
  58957. tileWidth?: number;
  58958. tileHeight?: number;
  58959. size?: number;
  58960. width?: number;
  58961. height?: number;
  58962. alignHorizontal?: number;
  58963. alignVertical?: number;
  58964. sideOrientation?: number;
  58965. frontUVs?: Vector4;
  58966. backUVs?: Vector4;
  58967. updatable?: boolean;
  58968. }, scene?: Nullable<Scene>): Mesh;
  58969. }
  58970. }
  58971. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58972. import { Nullable } from "babylonjs/types";
  58973. import { Scene } from "babylonjs/scene";
  58974. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58975. import { Mesh } from "babylonjs/Meshes/mesh";
  58976. /**
  58977. * Class containing static functions to help procedurally build meshes
  58978. */
  58979. export class TubeBuilder {
  58980. /**
  58981. * Creates a tube mesh.
  58982. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58983. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58984. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58985. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58986. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58987. * * 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)
  58988. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58989. * * 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
  58990. * * 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
  58991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58993. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58995. * @param name defines the name of the mesh
  58996. * @param options defines the options used to create the mesh
  58997. * @param scene defines the hosting scene
  58998. * @returns the tube mesh
  58999. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59000. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59001. */
  59002. static CreateTube(name: string, options: {
  59003. path: Vector3[];
  59004. radius?: number;
  59005. tessellation?: number;
  59006. radiusFunction?: {
  59007. (i: number, distance: number): number;
  59008. };
  59009. cap?: number;
  59010. arc?: number;
  59011. updatable?: boolean;
  59012. sideOrientation?: number;
  59013. frontUVs?: Vector4;
  59014. backUVs?: Vector4;
  59015. instance?: Mesh;
  59016. invertUV?: boolean;
  59017. }, scene?: Nullable<Scene>): Mesh;
  59018. }
  59019. }
  59020. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59021. import { Scene } from "babylonjs/scene";
  59022. import { Vector4 } from "babylonjs/Maths/math.vector";
  59023. import { Mesh } from "babylonjs/Meshes/mesh";
  59024. import { Nullable } from "babylonjs/types";
  59025. /**
  59026. * Class containing static functions to help procedurally build meshes
  59027. */
  59028. export class IcoSphereBuilder {
  59029. /**
  59030. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59031. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59032. * * 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`)
  59033. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59034. * * 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
  59035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59038. * @param name defines the name of the mesh
  59039. * @param options defines the options used to create the mesh
  59040. * @param scene defines the hosting scene
  59041. * @returns the icosahedron mesh
  59042. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59043. */
  59044. static CreateIcoSphere(name: string, options: {
  59045. radius?: number;
  59046. radiusX?: number;
  59047. radiusY?: number;
  59048. radiusZ?: number;
  59049. flat?: boolean;
  59050. subdivisions?: number;
  59051. sideOrientation?: number;
  59052. frontUVs?: Vector4;
  59053. backUVs?: Vector4;
  59054. updatable?: boolean;
  59055. }, scene?: Nullable<Scene>): Mesh;
  59056. }
  59057. }
  59058. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59059. import { Vector3 } from "babylonjs/Maths/math.vector";
  59060. import { Mesh } from "babylonjs/Meshes/mesh";
  59061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59062. /**
  59063. * Class containing static functions to help procedurally build meshes
  59064. */
  59065. export class DecalBuilder {
  59066. /**
  59067. * Creates a decal mesh.
  59068. * 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
  59069. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59070. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59071. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59072. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59073. * @param name defines the name of the mesh
  59074. * @param sourceMesh defines the mesh where the decal must be applied
  59075. * @param options defines the options used to create the mesh
  59076. * @param scene defines the hosting scene
  59077. * @returns the decal mesh
  59078. * @see https://doc.babylonjs.com/how_to/decals
  59079. */
  59080. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59081. position?: Vector3;
  59082. normal?: Vector3;
  59083. size?: Vector3;
  59084. angle?: number;
  59085. }): Mesh;
  59086. }
  59087. }
  59088. declare module "babylonjs/Meshes/meshBuilder" {
  59089. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59090. import { Nullable } from "babylonjs/types";
  59091. import { Scene } from "babylonjs/scene";
  59092. import { Mesh } from "babylonjs/Meshes/mesh";
  59093. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59094. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59096. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59097. import { Plane } from "babylonjs/Maths/math.plane";
  59098. /**
  59099. * Class containing static functions to help procedurally build meshes
  59100. */
  59101. export class MeshBuilder {
  59102. /**
  59103. * Creates a box mesh
  59104. * * The parameter `size` sets the size (float) of each box side (default 1)
  59105. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59106. * * 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)
  59107. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59111. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59112. * @param name defines the name of the mesh
  59113. * @param options defines the options used to create the mesh
  59114. * @param scene defines the hosting scene
  59115. * @returns the box mesh
  59116. */
  59117. static CreateBox(name: string, options: {
  59118. size?: number;
  59119. width?: number;
  59120. height?: number;
  59121. depth?: number;
  59122. faceUV?: Vector4[];
  59123. faceColors?: Color4[];
  59124. sideOrientation?: number;
  59125. frontUVs?: Vector4;
  59126. backUVs?: Vector4;
  59127. updatable?: boolean;
  59128. }, scene?: Nullable<Scene>): Mesh;
  59129. /**
  59130. * Creates a tiled box mesh
  59131. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59133. * @param name defines the name of the mesh
  59134. * @param options defines the options used to create the mesh
  59135. * @param scene defines the hosting scene
  59136. * @returns the tiled box mesh
  59137. */
  59138. static CreateTiledBox(name: string, options: {
  59139. pattern?: number;
  59140. size?: number;
  59141. width?: number;
  59142. height?: number;
  59143. depth: number;
  59144. tileSize?: number;
  59145. tileWidth?: number;
  59146. tileHeight?: number;
  59147. faceUV?: Vector4[];
  59148. faceColors?: Color4[];
  59149. alignHorizontal?: number;
  59150. alignVertical?: number;
  59151. sideOrientation?: number;
  59152. updatable?: boolean;
  59153. }, scene?: Nullable<Scene>): Mesh;
  59154. /**
  59155. * Creates a sphere mesh
  59156. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59157. * * 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`)
  59158. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59159. * * 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
  59160. * * 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)
  59161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59164. * @param name defines the name of the mesh
  59165. * @param options defines the options used to create the mesh
  59166. * @param scene defines the hosting scene
  59167. * @returns the sphere mesh
  59168. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59169. */
  59170. static CreateSphere(name: string, options: {
  59171. segments?: number;
  59172. diameter?: number;
  59173. diameterX?: number;
  59174. diameterY?: number;
  59175. diameterZ?: number;
  59176. arc?: number;
  59177. slice?: number;
  59178. sideOrientation?: number;
  59179. frontUVs?: Vector4;
  59180. backUVs?: Vector4;
  59181. updatable?: boolean;
  59182. }, scene?: Nullable<Scene>): Mesh;
  59183. /**
  59184. * Creates a plane polygonal mesh. By default, this is a disc
  59185. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59186. * * 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
  59187. * * 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
  59188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59191. * @param name defines the name of the mesh
  59192. * @param options defines the options used to create the mesh
  59193. * @param scene defines the hosting scene
  59194. * @returns the plane polygonal mesh
  59195. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59196. */
  59197. static CreateDisc(name: string, options: {
  59198. radius?: number;
  59199. tessellation?: number;
  59200. arc?: number;
  59201. updatable?: boolean;
  59202. sideOrientation?: number;
  59203. frontUVs?: Vector4;
  59204. backUVs?: Vector4;
  59205. }, scene?: Nullable<Scene>): Mesh;
  59206. /**
  59207. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59208. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59209. * * 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`)
  59210. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59211. * * 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
  59212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59215. * @param name defines the name of the mesh
  59216. * @param options defines the options used to create the mesh
  59217. * @param scene defines the hosting scene
  59218. * @returns the icosahedron mesh
  59219. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59220. */
  59221. static CreateIcoSphere(name: string, options: {
  59222. radius?: number;
  59223. radiusX?: number;
  59224. radiusY?: number;
  59225. radiusZ?: number;
  59226. flat?: boolean;
  59227. subdivisions?: number;
  59228. sideOrientation?: number;
  59229. frontUVs?: Vector4;
  59230. backUVs?: Vector4;
  59231. updatable?: boolean;
  59232. }, scene?: Nullable<Scene>): Mesh;
  59233. /**
  59234. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59235. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59236. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59237. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59238. * * 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
  59239. * * 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
  59240. * * 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
  59241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59244. * * 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
  59245. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59246. * * 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
  59247. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59249. * @param name defines the name of the mesh
  59250. * @param options defines the options used to create the mesh
  59251. * @param scene defines the hosting scene
  59252. * @returns the ribbon mesh
  59253. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59254. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59255. */
  59256. static CreateRibbon(name: string, options: {
  59257. pathArray: Vector3[][];
  59258. closeArray?: boolean;
  59259. closePath?: boolean;
  59260. offset?: number;
  59261. updatable?: boolean;
  59262. sideOrientation?: number;
  59263. frontUVs?: Vector4;
  59264. backUVs?: Vector4;
  59265. instance?: Mesh;
  59266. invertUV?: boolean;
  59267. uvs?: Vector2[];
  59268. colors?: Color4[];
  59269. }, scene?: Nullable<Scene>): Mesh;
  59270. /**
  59271. * Creates a cylinder or a cone mesh
  59272. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59273. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59274. * * 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.
  59275. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59276. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59277. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59278. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59279. * * 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).
  59280. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59281. * * 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).
  59282. * * 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
  59283. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59284. * * 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
  59285. * * 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.
  59286. * * If `enclose` is false, a ring surface is one element.
  59287. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59288. * * 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
  59289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59292. * @param name defines the name of the mesh
  59293. * @param options defines the options used to create the mesh
  59294. * @param scene defines the hosting scene
  59295. * @returns the cylinder mesh
  59296. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59297. */
  59298. static CreateCylinder(name: string, options: {
  59299. height?: number;
  59300. diameterTop?: number;
  59301. diameterBottom?: number;
  59302. diameter?: number;
  59303. tessellation?: number;
  59304. subdivisions?: number;
  59305. arc?: number;
  59306. faceColors?: Color4[];
  59307. faceUV?: Vector4[];
  59308. updatable?: boolean;
  59309. hasRings?: boolean;
  59310. enclose?: boolean;
  59311. cap?: number;
  59312. sideOrientation?: number;
  59313. frontUVs?: Vector4;
  59314. backUVs?: Vector4;
  59315. }, scene?: Nullable<Scene>): Mesh;
  59316. /**
  59317. * Creates a torus mesh
  59318. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59319. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59320. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59324. * @param name defines the name of the mesh
  59325. * @param options defines the options used to create the mesh
  59326. * @param scene defines the hosting scene
  59327. * @returns the torus mesh
  59328. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59329. */
  59330. static CreateTorus(name: string, options: {
  59331. diameter?: number;
  59332. thickness?: number;
  59333. tessellation?: number;
  59334. updatable?: boolean;
  59335. sideOrientation?: number;
  59336. frontUVs?: Vector4;
  59337. backUVs?: Vector4;
  59338. }, scene?: Nullable<Scene>): Mesh;
  59339. /**
  59340. * Creates a torus knot mesh
  59341. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59342. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59343. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59344. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59348. * @param name defines the name of the mesh
  59349. * @param options defines the options used to create the mesh
  59350. * @param scene defines the hosting scene
  59351. * @returns the torus knot mesh
  59352. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59353. */
  59354. static CreateTorusKnot(name: string, options: {
  59355. radius?: number;
  59356. tube?: number;
  59357. radialSegments?: number;
  59358. tubularSegments?: number;
  59359. p?: number;
  59360. q?: number;
  59361. updatable?: boolean;
  59362. sideOrientation?: number;
  59363. frontUVs?: Vector4;
  59364. backUVs?: Vector4;
  59365. }, scene?: Nullable<Scene>): Mesh;
  59366. /**
  59367. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59368. * * 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
  59369. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59370. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59371. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59372. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59373. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59374. * * 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
  59375. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59377. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59378. * @param name defines the name of the new line system
  59379. * @param options defines the options used to create the line system
  59380. * @param scene defines the hosting scene
  59381. * @returns a new line system mesh
  59382. */
  59383. static CreateLineSystem(name: string, options: {
  59384. lines: Vector3[][];
  59385. updatable?: boolean;
  59386. instance?: Nullable<LinesMesh>;
  59387. colors?: Nullable<Color4[][]>;
  59388. useVertexAlpha?: boolean;
  59389. }, scene: Nullable<Scene>): LinesMesh;
  59390. /**
  59391. * Creates a line mesh
  59392. * 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
  59393. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59394. * * The parameter `points` is an array successive Vector3
  59395. * * 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
  59396. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59397. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59398. * * When updating an instance, remember that only point positions can change, not the number of points
  59399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59401. * @param name defines the name of the new line system
  59402. * @param options defines the options used to create the line system
  59403. * @param scene defines the hosting scene
  59404. * @returns a new line mesh
  59405. */
  59406. static CreateLines(name: string, options: {
  59407. points: Vector3[];
  59408. updatable?: boolean;
  59409. instance?: Nullable<LinesMesh>;
  59410. colors?: Color4[];
  59411. useVertexAlpha?: boolean;
  59412. }, scene?: Nullable<Scene>): LinesMesh;
  59413. /**
  59414. * Creates a dashed line mesh
  59415. * * 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
  59416. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59417. * * The parameter `points` is an array successive Vector3
  59418. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59419. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59420. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59421. * * 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
  59422. * * When updating an instance, remember that only point positions can change, not the number of points
  59423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59424. * @param name defines the name of the mesh
  59425. * @param options defines the options used to create the mesh
  59426. * @param scene defines the hosting scene
  59427. * @returns the dashed line mesh
  59428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59429. */
  59430. static CreateDashedLines(name: string, options: {
  59431. points: Vector3[];
  59432. dashSize?: number;
  59433. gapSize?: number;
  59434. dashNb?: number;
  59435. updatable?: boolean;
  59436. instance?: LinesMesh;
  59437. }, scene?: Nullable<Scene>): LinesMesh;
  59438. /**
  59439. * 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.
  59440. * * 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.
  59441. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59442. * * 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.
  59443. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59444. * * 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
  59445. * * 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
  59446. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59451. * @param name defines the name of the mesh
  59452. * @param options defines the options used to create the mesh
  59453. * @param scene defines the hosting scene
  59454. * @returns the extruded shape mesh
  59455. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59457. */
  59458. static ExtrudeShape(name: string, options: {
  59459. shape: Vector3[];
  59460. path: Vector3[];
  59461. scale?: number;
  59462. rotation?: number;
  59463. cap?: number;
  59464. updatable?: boolean;
  59465. sideOrientation?: number;
  59466. frontUVs?: Vector4;
  59467. backUVs?: Vector4;
  59468. instance?: Mesh;
  59469. invertUV?: boolean;
  59470. }, scene?: Nullable<Scene>): Mesh;
  59471. /**
  59472. * Creates an custom extruded shape mesh.
  59473. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59474. * * 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.
  59475. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59476. * * 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
  59477. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59478. * * 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
  59479. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59480. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59481. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59482. * * 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
  59483. * * 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
  59484. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59489. * @param name defines the name of the mesh
  59490. * @param options defines the options used to create the mesh
  59491. * @param scene defines the hosting scene
  59492. * @returns the custom extruded shape mesh
  59493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59494. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59496. */
  59497. static ExtrudeShapeCustom(name: string, options: {
  59498. shape: Vector3[];
  59499. path: Vector3[];
  59500. scaleFunction?: any;
  59501. rotationFunction?: any;
  59502. ribbonCloseArray?: boolean;
  59503. ribbonClosePath?: boolean;
  59504. cap?: number;
  59505. updatable?: boolean;
  59506. sideOrientation?: number;
  59507. frontUVs?: Vector4;
  59508. backUVs?: Vector4;
  59509. instance?: Mesh;
  59510. invertUV?: boolean;
  59511. }, scene?: Nullable<Scene>): Mesh;
  59512. /**
  59513. * Creates lathe mesh.
  59514. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59515. * * 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
  59516. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59517. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59518. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59519. * * 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
  59520. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59521. * * 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
  59522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59524. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59526. * @param name defines the name of the mesh
  59527. * @param options defines the options used to create the mesh
  59528. * @param scene defines the hosting scene
  59529. * @returns the lathe mesh
  59530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59531. */
  59532. static CreateLathe(name: string, options: {
  59533. shape: Vector3[];
  59534. radius?: number;
  59535. tessellation?: number;
  59536. clip?: number;
  59537. arc?: number;
  59538. closed?: boolean;
  59539. updatable?: boolean;
  59540. sideOrientation?: number;
  59541. frontUVs?: Vector4;
  59542. backUVs?: Vector4;
  59543. cap?: number;
  59544. invertUV?: boolean;
  59545. }, scene?: Nullable<Scene>): Mesh;
  59546. /**
  59547. * Creates a tiled plane mesh
  59548. * * You can set a limited pattern arrangement with the tiles
  59549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59552. * @param name defines the name of the mesh
  59553. * @param options defines the options used to create the mesh
  59554. * @param scene defines the hosting scene
  59555. * @returns the plane mesh
  59556. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59557. */
  59558. static CreateTiledPlane(name: string, options: {
  59559. pattern?: number;
  59560. tileSize?: number;
  59561. tileWidth?: number;
  59562. tileHeight?: number;
  59563. size?: number;
  59564. width?: number;
  59565. height?: number;
  59566. alignHorizontal?: number;
  59567. alignVertical?: number;
  59568. sideOrientation?: number;
  59569. frontUVs?: Vector4;
  59570. backUVs?: Vector4;
  59571. updatable?: boolean;
  59572. }, scene?: Nullable<Scene>): Mesh;
  59573. /**
  59574. * Creates a plane mesh
  59575. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59576. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59577. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59581. * @param name defines the name of the mesh
  59582. * @param options defines the options used to create the mesh
  59583. * @param scene defines the hosting scene
  59584. * @returns the plane mesh
  59585. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59586. */
  59587. static CreatePlane(name: string, options: {
  59588. size?: number;
  59589. width?: number;
  59590. height?: number;
  59591. sideOrientation?: number;
  59592. frontUVs?: Vector4;
  59593. backUVs?: Vector4;
  59594. updatable?: boolean;
  59595. sourcePlane?: Plane;
  59596. }, scene?: Nullable<Scene>): Mesh;
  59597. /**
  59598. * Creates a ground mesh
  59599. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59600. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59602. * @param name defines the name of the mesh
  59603. * @param options defines the options used to create the mesh
  59604. * @param scene defines the hosting scene
  59605. * @returns the ground mesh
  59606. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59607. */
  59608. static CreateGround(name: string, options: {
  59609. width?: number;
  59610. height?: number;
  59611. subdivisions?: number;
  59612. subdivisionsX?: number;
  59613. subdivisionsY?: number;
  59614. updatable?: boolean;
  59615. }, scene?: Nullable<Scene>): Mesh;
  59616. /**
  59617. * Creates a tiled ground mesh
  59618. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59619. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59620. * * 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
  59621. * * 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
  59622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59623. * @param name defines the name of the mesh
  59624. * @param options defines the options used to create the mesh
  59625. * @param scene defines the hosting scene
  59626. * @returns the tiled ground mesh
  59627. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59628. */
  59629. static CreateTiledGround(name: string, options: {
  59630. xmin: number;
  59631. zmin: number;
  59632. xmax: number;
  59633. zmax: number;
  59634. subdivisions?: {
  59635. w: number;
  59636. h: number;
  59637. };
  59638. precision?: {
  59639. w: number;
  59640. h: number;
  59641. };
  59642. updatable?: boolean;
  59643. }, scene?: Nullable<Scene>): Mesh;
  59644. /**
  59645. * Creates a ground mesh from a height map
  59646. * * The parameter `url` sets the URL of the height map image resource.
  59647. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59648. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59649. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59650. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59651. * * 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.
  59652. * * 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).
  59653. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59655. * @param name defines the name of the mesh
  59656. * @param url defines the url to the height map
  59657. * @param options defines the options used to create the mesh
  59658. * @param scene defines the hosting scene
  59659. * @returns the ground mesh
  59660. * @see https://doc.babylonjs.com/babylon101/height_map
  59661. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59662. */
  59663. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59664. width?: number;
  59665. height?: number;
  59666. subdivisions?: number;
  59667. minHeight?: number;
  59668. maxHeight?: number;
  59669. colorFilter?: Color3;
  59670. alphaFilter?: number;
  59671. updatable?: boolean;
  59672. onReady?: (mesh: GroundMesh) => void;
  59673. }, scene?: Nullable<Scene>): GroundMesh;
  59674. /**
  59675. * Creates a polygon mesh
  59676. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59677. * * 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
  59678. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59681. * * Remember you can only change the shape positions, not their number when updating a polygon
  59682. * @param name defines the name of the mesh
  59683. * @param options defines the options used to create the mesh
  59684. * @param scene defines the hosting scene
  59685. * @param earcutInjection can be used to inject your own earcut reference
  59686. * @returns the polygon mesh
  59687. */
  59688. static CreatePolygon(name: string, options: {
  59689. shape: Vector3[];
  59690. holes?: Vector3[][];
  59691. depth?: number;
  59692. faceUV?: Vector4[];
  59693. faceColors?: Color4[];
  59694. updatable?: boolean;
  59695. sideOrientation?: number;
  59696. frontUVs?: Vector4;
  59697. backUVs?: Vector4;
  59698. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59699. /**
  59700. * Creates an extruded polygon mesh, with depth in the Y direction.
  59701. * * 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)
  59702. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59703. * @param name defines the name of the mesh
  59704. * @param options defines the options used to create the mesh
  59705. * @param scene defines the hosting scene
  59706. * @param earcutInjection can be used to inject your own earcut reference
  59707. * @returns the polygon mesh
  59708. */
  59709. static ExtrudePolygon(name: string, options: {
  59710. shape: Vector3[];
  59711. holes?: Vector3[][];
  59712. depth?: number;
  59713. faceUV?: Vector4[];
  59714. faceColors?: Color4[];
  59715. updatable?: boolean;
  59716. sideOrientation?: number;
  59717. frontUVs?: Vector4;
  59718. backUVs?: Vector4;
  59719. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59720. /**
  59721. * Creates a tube mesh.
  59722. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59723. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59724. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59725. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59726. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59727. * * 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)
  59728. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59729. * * 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
  59730. * * 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
  59731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59733. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59735. * @param name defines the name of the mesh
  59736. * @param options defines the options used to create the mesh
  59737. * @param scene defines the hosting scene
  59738. * @returns the tube mesh
  59739. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59740. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59741. */
  59742. static CreateTube(name: string, options: {
  59743. path: Vector3[];
  59744. radius?: number;
  59745. tessellation?: number;
  59746. radiusFunction?: {
  59747. (i: number, distance: number): number;
  59748. };
  59749. cap?: number;
  59750. arc?: number;
  59751. updatable?: boolean;
  59752. sideOrientation?: number;
  59753. frontUVs?: Vector4;
  59754. backUVs?: Vector4;
  59755. instance?: Mesh;
  59756. invertUV?: boolean;
  59757. }, scene?: Nullable<Scene>): Mesh;
  59758. /**
  59759. * Creates a polyhedron mesh
  59760. * * 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
  59761. * * The parameter `size` (positive float, default 1) sets the polygon size
  59762. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59763. * * 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`
  59764. * * 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
  59765. * * 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)`)
  59766. * * 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
  59767. * * 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
  59768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59771. * @param name defines the name of the mesh
  59772. * @param options defines the options used to create the mesh
  59773. * @param scene defines the hosting scene
  59774. * @returns the polyhedron mesh
  59775. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59776. */
  59777. static CreatePolyhedron(name: string, options: {
  59778. type?: number;
  59779. size?: number;
  59780. sizeX?: number;
  59781. sizeY?: number;
  59782. sizeZ?: number;
  59783. custom?: any;
  59784. faceUV?: Vector4[];
  59785. faceColors?: Color4[];
  59786. flat?: boolean;
  59787. updatable?: boolean;
  59788. sideOrientation?: number;
  59789. frontUVs?: Vector4;
  59790. backUVs?: Vector4;
  59791. }, scene?: Nullable<Scene>): Mesh;
  59792. /**
  59793. * Creates a decal mesh.
  59794. * 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
  59795. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59796. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59797. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59798. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59799. * @param name defines the name of the mesh
  59800. * @param sourceMesh defines the mesh where the decal must be applied
  59801. * @param options defines the options used to create the mesh
  59802. * @param scene defines the hosting scene
  59803. * @returns the decal mesh
  59804. * @see https://doc.babylonjs.com/how_to/decals
  59805. */
  59806. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59807. position?: Vector3;
  59808. normal?: Vector3;
  59809. size?: Vector3;
  59810. angle?: number;
  59811. }): Mesh;
  59812. }
  59813. }
  59814. declare module "babylonjs/Meshes/meshSimplification" {
  59815. import { Mesh } from "babylonjs/Meshes/mesh";
  59816. /**
  59817. * A simplifier interface for future simplification implementations
  59818. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59819. */
  59820. export interface ISimplifier {
  59821. /**
  59822. * Simplification of a given mesh according to the given settings.
  59823. * Since this requires computation, it is assumed that the function runs async.
  59824. * @param settings The settings of the simplification, including quality and distance
  59825. * @param successCallback A callback that will be called after the mesh was simplified.
  59826. * @param errorCallback in case of an error, this callback will be called. optional.
  59827. */
  59828. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59829. }
  59830. /**
  59831. * Expected simplification settings.
  59832. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59833. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59834. */
  59835. export interface ISimplificationSettings {
  59836. /**
  59837. * Gets or sets the expected quality
  59838. */
  59839. quality: number;
  59840. /**
  59841. * Gets or sets the distance when this optimized version should be used
  59842. */
  59843. distance: number;
  59844. /**
  59845. * Gets an already optimized mesh
  59846. */
  59847. optimizeMesh?: boolean;
  59848. }
  59849. /**
  59850. * Class used to specify simplification options
  59851. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59852. */
  59853. export class SimplificationSettings implements ISimplificationSettings {
  59854. /** expected quality */
  59855. quality: number;
  59856. /** distance when this optimized version should be used */
  59857. distance: number;
  59858. /** already optimized mesh */
  59859. optimizeMesh?: boolean | undefined;
  59860. /**
  59861. * Creates a SimplificationSettings
  59862. * @param quality expected quality
  59863. * @param distance distance when this optimized version should be used
  59864. * @param optimizeMesh already optimized mesh
  59865. */
  59866. constructor(
  59867. /** expected quality */
  59868. quality: number,
  59869. /** distance when this optimized version should be used */
  59870. distance: number,
  59871. /** already optimized mesh */
  59872. optimizeMesh?: boolean | undefined);
  59873. }
  59874. /**
  59875. * Interface used to define a simplification task
  59876. */
  59877. export interface ISimplificationTask {
  59878. /**
  59879. * Array of settings
  59880. */
  59881. settings: Array<ISimplificationSettings>;
  59882. /**
  59883. * Simplification type
  59884. */
  59885. simplificationType: SimplificationType;
  59886. /**
  59887. * Mesh to simplify
  59888. */
  59889. mesh: Mesh;
  59890. /**
  59891. * Callback called on success
  59892. */
  59893. successCallback?: () => void;
  59894. /**
  59895. * Defines if parallel processing can be used
  59896. */
  59897. parallelProcessing: boolean;
  59898. }
  59899. /**
  59900. * Queue used to order the simplification tasks
  59901. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59902. */
  59903. export class SimplificationQueue {
  59904. private _simplificationArray;
  59905. /**
  59906. * Gets a boolean indicating that the process is still running
  59907. */
  59908. running: boolean;
  59909. /**
  59910. * Creates a new queue
  59911. */
  59912. constructor();
  59913. /**
  59914. * Adds a new simplification task
  59915. * @param task defines a task to add
  59916. */
  59917. addTask(task: ISimplificationTask): void;
  59918. /**
  59919. * Execute next task
  59920. */
  59921. executeNext(): void;
  59922. /**
  59923. * Execute a simplification task
  59924. * @param task defines the task to run
  59925. */
  59926. runSimplification(task: ISimplificationTask): void;
  59927. private getSimplifier;
  59928. }
  59929. /**
  59930. * The implemented types of simplification
  59931. * At the moment only Quadratic Error Decimation is implemented
  59932. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59933. */
  59934. export enum SimplificationType {
  59935. /** Quadratic error decimation */
  59936. QUADRATIC = 0
  59937. }
  59938. }
  59939. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59940. import { Scene } from "babylonjs/scene";
  59941. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59942. import { ISceneComponent } from "babylonjs/sceneComponent";
  59943. module "babylonjs/scene" {
  59944. interface Scene {
  59945. /** @hidden (Backing field) */
  59946. _simplificationQueue: SimplificationQueue;
  59947. /**
  59948. * Gets or sets the simplification queue attached to the scene
  59949. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59950. */
  59951. simplificationQueue: SimplificationQueue;
  59952. }
  59953. }
  59954. module "babylonjs/Meshes/mesh" {
  59955. interface Mesh {
  59956. /**
  59957. * Simplify the mesh according to the given array of settings.
  59958. * Function will return immediately and will simplify async
  59959. * @param settings a collection of simplification settings
  59960. * @param parallelProcessing should all levels calculate parallel or one after the other
  59961. * @param simplificationType the type of simplification to run
  59962. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59963. * @returns the current mesh
  59964. */
  59965. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59966. }
  59967. }
  59968. /**
  59969. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59970. * created in a scene
  59971. */
  59972. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59973. /**
  59974. * The component name helpfull to identify the component in the list of scene components.
  59975. */
  59976. readonly name: string;
  59977. /**
  59978. * The scene the component belongs to.
  59979. */
  59980. scene: Scene;
  59981. /**
  59982. * Creates a new instance of the component for the given scene
  59983. * @param scene Defines the scene to register the component in
  59984. */
  59985. constructor(scene: Scene);
  59986. /**
  59987. * Registers the component in a given scene
  59988. */
  59989. register(): void;
  59990. /**
  59991. * Rebuilds the elements related to this component in case of
  59992. * context lost for instance.
  59993. */
  59994. rebuild(): void;
  59995. /**
  59996. * Disposes the component and the associated ressources
  59997. */
  59998. dispose(): void;
  59999. private _beforeCameraUpdate;
  60000. }
  60001. }
  60002. declare module "babylonjs/Meshes/Builders/index" {
  60003. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60004. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60005. export * from "babylonjs/Meshes/Builders/discBuilder";
  60006. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60007. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60008. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60009. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60010. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60011. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60012. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60013. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60014. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60015. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60016. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60017. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60018. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60019. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60020. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60021. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60022. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60023. }
  60024. declare module "babylonjs/Meshes/index" {
  60025. export * from "babylonjs/Meshes/abstractMesh";
  60026. export * from "babylonjs/Meshes/buffer";
  60027. export * from "babylonjs/Meshes/Compression/index";
  60028. export * from "babylonjs/Meshes/csg";
  60029. export * from "babylonjs/Meshes/geometry";
  60030. export * from "babylonjs/Meshes/groundMesh";
  60031. export * from "babylonjs/Meshes/trailMesh";
  60032. export * from "babylonjs/Meshes/instancedMesh";
  60033. export * from "babylonjs/Meshes/linesMesh";
  60034. export * from "babylonjs/Meshes/mesh";
  60035. export * from "babylonjs/Meshes/mesh.vertexData";
  60036. export * from "babylonjs/Meshes/meshBuilder";
  60037. export * from "babylonjs/Meshes/meshSimplification";
  60038. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60039. export * from "babylonjs/Meshes/polygonMesh";
  60040. export * from "babylonjs/Meshes/subMesh";
  60041. export * from "babylonjs/Meshes/meshLODLevel";
  60042. export * from "babylonjs/Meshes/transformNode";
  60043. export * from "babylonjs/Meshes/Builders/index";
  60044. export * from "babylonjs/Meshes/dataBuffer";
  60045. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60046. }
  60047. declare module "babylonjs/Morph/index" {
  60048. export * from "babylonjs/Morph/morphTarget";
  60049. export * from "babylonjs/Morph/morphTargetManager";
  60050. }
  60051. declare module "babylonjs/Navigation/INavigationEngine" {
  60052. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60053. import { Vector3 } from "babylonjs/Maths/math";
  60054. import { Mesh } from "babylonjs/Meshes/mesh";
  60055. import { Scene } from "babylonjs/scene";
  60056. /**
  60057. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60058. */
  60059. export interface INavigationEnginePlugin {
  60060. /**
  60061. * plugin name
  60062. */
  60063. name: string;
  60064. /**
  60065. * Creates a navigation mesh
  60066. * @param meshes array of all the geometry used to compute the navigatio mesh
  60067. * @param parameters bunch of parameters used to filter geometry
  60068. */
  60069. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60070. /**
  60071. * Create a navigation mesh debug mesh
  60072. * @param scene is where the mesh will be added
  60073. * @returns debug display mesh
  60074. */
  60075. createDebugNavMesh(scene: Scene): Mesh;
  60076. /**
  60077. * Get a navigation mesh constrained position, closest to the parameter position
  60078. * @param position world position
  60079. * @returns the closest point to position constrained by the navigation mesh
  60080. */
  60081. getClosestPoint(position: Vector3): Vector3;
  60082. /**
  60083. * Get a navigation mesh constrained position, within a particular radius
  60084. * @param position world position
  60085. * @param maxRadius the maximum distance to the constrained world position
  60086. * @returns the closest point to position constrained by the navigation mesh
  60087. */
  60088. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60089. /**
  60090. * Compute the final position from a segment made of destination-position
  60091. * @param position world position
  60092. * @param destination world position
  60093. * @returns the resulting point along the navmesh
  60094. */
  60095. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60096. /**
  60097. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60098. * @param start world position
  60099. * @param end world position
  60100. * @returns array containing world position composing the path
  60101. */
  60102. computePath(start: Vector3, end: Vector3): Vector3[];
  60103. /**
  60104. * If this plugin is supported
  60105. * @returns true if plugin is supported
  60106. */
  60107. isSupported(): boolean;
  60108. /**
  60109. * Create a new Crowd so you can add agents
  60110. * @param maxAgents the maximum agent count in the crowd
  60111. * @param maxAgentRadius the maximum radius an agent can have
  60112. * @param scene to attach the crowd to
  60113. * @returns the crowd you can add agents to
  60114. */
  60115. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60116. /**
  60117. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60118. * The queries will try to find a solution within those bounds
  60119. * default is (1,1,1)
  60120. * @param extent x,y,z value that define the extent around the queries point of reference
  60121. */
  60122. setDefaultQueryExtent(extent: Vector3): void;
  60123. /**
  60124. * Get the Bounding box extent specified by setDefaultQueryExtent
  60125. * @returns the box extent values
  60126. */
  60127. getDefaultQueryExtent(): Vector3;
  60128. /**
  60129. * Release all resources
  60130. */
  60131. dispose(): void;
  60132. }
  60133. /**
  60134. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60135. */
  60136. export interface ICrowd {
  60137. /**
  60138. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60139. * You can attach anything to that node. The node position is updated in the scene update tick.
  60140. * @param pos world position that will be constrained by the navigation mesh
  60141. * @param parameters agent parameters
  60142. * @param transform hooked to the agent that will be update by the scene
  60143. * @returns agent index
  60144. */
  60145. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60146. /**
  60147. * Returns the agent position in world space
  60148. * @param index agent index returned by addAgent
  60149. * @returns world space position
  60150. */
  60151. getAgentPosition(index: number): Vector3;
  60152. /**
  60153. * Gets the agent velocity in world space
  60154. * @param index agent index returned by addAgent
  60155. * @returns world space velocity
  60156. */
  60157. getAgentVelocity(index: number): Vector3;
  60158. /**
  60159. * remove a particular agent previously created
  60160. * @param index agent index returned by addAgent
  60161. */
  60162. removeAgent(index: number): void;
  60163. /**
  60164. * get the list of all agents attached to this crowd
  60165. * @returns list of agent indices
  60166. */
  60167. getAgents(): number[];
  60168. /**
  60169. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60170. * @param deltaTime in seconds
  60171. */
  60172. update(deltaTime: number): void;
  60173. /**
  60174. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60175. * @param index agent index returned by addAgent
  60176. * @param destination targeted world position
  60177. */
  60178. agentGoto(index: number, destination: Vector3): void;
  60179. /**
  60180. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60181. * The queries will try to find a solution within those bounds
  60182. * default is (1,1,1)
  60183. * @param extent x,y,z value that define the extent around the queries point of reference
  60184. */
  60185. setDefaultQueryExtent(extent: Vector3): void;
  60186. /**
  60187. * Get the Bounding box extent specified by setDefaultQueryExtent
  60188. * @returns the box extent values
  60189. */
  60190. getDefaultQueryExtent(): Vector3;
  60191. /**
  60192. * Release all resources
  60193. */
  60194. dispose(): void;
  60195. }
  60196. /**
  60197. * Configures an agent
  60198. */
  60199. export interface IAgentParameters {
  60200. /**
  60201. * Agent radius. [Limit: >= 0]
  60202. */
  60203. radius: number;
  60204. /**
  60205. * Agent height. [Limit: > 0]
  60206. */
  60207. height: number;
  60208. /**
  60209. * Maximum allowed acceleration. [Limit: >= 0]
  60210. */
  60211. maxAcceleration: number;
  60212. /**
  60213. * Maximum allowed speed. [Limit: >= 0]
  60214. */
  60215. maxSpeed: number;
  60216. /**
  60217. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60218. */
  60219. collisionQueryRange: number;
  60220. /**
  60221. * The path visibility optimization range. [Limit: > 0]
  60222. */
  60223. pathOptimizationRange: number;
  60224. /**
  60225. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60226. */
  60227. separationWeight: number;
  60228. }
  60229. /**
  60230. * Configures the navigation mesh creation
  60231. */
  60232. export interface INavMeshParameters {
  60233. /**
  60234. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60235. */
  60236. cs: number;
  60237. /**
  60238. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60239. */
  60240. ch: number;
  60241. /**
  60242. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60243. */
  60244. walkableSlopeAngle: number;
  60245. /**
  60246. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60247. * be considered walkable. [Limit: >= 3] [Units: vx]
  60248. */
  60249. walkableHeight: number;
  60250. /**
  60251. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60252. */
  60253. walkableClimb: number;
  60254. /**
  60255. * The distance to erode/shrink the walkable area of the heightfield away from
  60256. * obstructions. [Limit: >=0] [Units: vx]
  60257. */
  60258. walkableRadius: number;
  60259. /**
  60260. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60261. */
  60262. maxEdgeLen: number;
  60263. /**
  60264. * The maximum distance a simplfied contour's border edges should deviate
  60265. * the original raw contour. [Limit: >=0] [Units: vx]
  60266. */
  60267. maxSimplificationError: number;
  60268. /**
  60269. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60270. */
  60271. minRegionArea: number;
  60272. /**
  60273. * Any regions with a span count smaller than this value will, if possible,
  60274. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60275. */
  60276. mergeRegionArea: number;
  60277. /**
  60278. * The maximum number of vertices allowed for polygons generated during the
  60279. * contour to polygon conversion process. [Limit: >= 3]
  60280. */
  60281. maxVertsPerPoly: number;
  60282. /**
  60283. * Sets the sampling distance to use when generating the detail mesh.
  60284. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60285. */
  60286. detailSampleDist: number;
  60287. /**
  60288. * The maximum distance the detail mesh surface should deviate from heightfield
  60289. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60290. */
  60291. detailSampleMaxError: number;
  60292. }
  60293. }
  60294. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60295. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60296. import { Mesh } from "babylonjs/Meshes/mesh";
  60297. import { Scene } from "babylonjs/scene";
  60298. import { Vector3 } from "babylonjs/Maths/math";
  60299. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60300. /**
  60301. * RecastJS navigation plugin
  60302. */
  60303. export class RecastJSPlugin implements INavigationEnginePlugin {
  60304. /**
  60305. * Reference to the Recast library
  60306. */
  60307. bjsRECAST: any;
  60308. /**
  60309. * plugin name
  60310. */
  60311. name: string;
  60312. /**
  60313. * the first navmesh created. We might extend this to support multiple navmeshes
  60314. */
  60315. navMesh: any;
  60316. /**
  60317. * Initializes the recastJS plugin
  60318. * @param recastInjection can be used to inject your own recast reference
  60319. */
  60320. constructor(recastInjection?: any);
  60321. /**
  60322. * Creates a navigation mesh
  60323. * @param meshes array of all the geometry used to compute the navigatio mesh
  60324. * @param parameters bunch of parameters used to filter geometry
  60325. */
  60326. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60327. /**
  60328. * Create a navigation mesh debug mesh
  60329. * @param scene is where the mesh will be added
  60330. * @returns debug display mesh
  60331. */
  60332. createDebugNavMesh(scene: Scene): Mesh;
  60333. /**
  60334. * Get a navigation mesh constrained position, closest to the parameter position
  60335. * @param position world position
  60336. * @returns the closest point to position constrained by the navigation mesh
  60337. */
  60338. getClosestPoint(position: Vector3): Vector3;
  60339. /**
  60340. * Get a navigation mesh constrained position, within a particular radius
  60341. * @param position world position
  60342. * @param maxRadius the maximum distance to the constrained world position
  60343. * @returns the closest point to position constrained by the navigation mesh
  60344. */
  60345. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60346. /**
  60347. * Compute the final position from a segment made of destination-position
  60348. * @param position world position
  60349. * @param destination world position
  60350. * @returns the resulting point along the navmesh
  60351. */
  60352. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60353. /**
  60354. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60355. * @param start world position
  60356. * @param end world position
  60357. * @returns array containing world position composing the path
  60358. */
  60359. computePath(start: Vector3, end: Vector3): Vector3[];
  60360. /**
  60361. * Create a new Crowd so you can add agents
  60362. * @param maxAgents the maximum agent count in the crowd
  60363. * @param maxAgentRadius the maximum radius an agent can have
  60364. * @param scene to attach the crowd to
  60365. * @returns the crowd you can add agents to
  60366. */
  60367. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60368. /**
  60369. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60370. * The queries will try to find a solution within those bounds
  60371. * default is (1,1,1)
  60372. * @param extent x,y,z value that define the extent around the queries point of reference
  60373. */
  60374. setDefaultQueryExtent(extent: Vector3): void;
  60375. /**
  60376. * Get the Bounding box extent specified by setDefaultQueryExtent
  60377. * @returns the box extent values
  60378. */
  60379. getDefaultQueryExtent(): Vector3;
  60380. /**
  60381. * Disposes
  60382. */
  60383. dispose(): void;
  60384. /**
  60385. * If this plugin is supported
  60386. * @returns true if plugin is supported
  60387. */
  60388. isSupported(): boolean;
  60389. }
  60390. /**
  60391. * Recast detour crowd implementation
  60392. */
  60393. export class RecastJSCrowd implements ICrowd {
  60394. /**
  60395. * Recast/detour plugin
  60396. */
  60397. bjsRECASTPlugin: RecastJSPlugin;
  60398. /**
  60399. * Link to the detour crowd
  60400. */
  60401. recastCrowd: any;
  60402. /**
  60403. * One transform per agent
  60404. */
  60405. transforms: TransformNode[];
  60406. /**
  60407. * All agents created
  60408. */
  60409. agents: number[];
  60410. /**
  60411. * Link to the scene is kept to unregister the crowd from the scene
  60412. */
  60413. private _scene;
  60414. /**
  60415. * Observer for crowd updates
  60416. */
  60417. private _onBeforeAnimationsObserver;
  60418. /**
  60419. * Constructor
  60420. * @param plugin recastJS plugin
  60421. * @param maxAgents the maximum agent count in the crowd
  60422. * @param maxAgentRadius the maximum radius an agent can have
  60423. * @param scene to attach the crowd to
  60424. * @returns the crowd you can add agents to
  60425. */
  60426. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60427. /**
  60428. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60429. * You can attach anything to that node. The node position is updated in the scene update tick.
  60430. * @param pos world position that will be constrained by the navigation mesh
  60431. * @param parameters agent parameters
  60432. * @param transform hooked to the agent that will be update by the scene
  60433. * @returns agent index
  60434. */
  60435. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60436. /**
  60437. * Returns the agent position in world space
  60438. * @param index agent index returned by addAgent
  60439. * @returns world space position
  60440. */
  60441. getAgentPosition(index: number): Vector3;
  60442. /**
  60443. * Returns the agent velocity in world space
  60444. * @param index agent index returned by addAgent
  60445. * @returns world space velocity
  60446. */
  60447. getAgentVelocity(index: number): Vector3;
  60448. /**
  60449. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60450. * @param index agent index returned by addAgent
  60451. * @param destination targeted world position
  60452. */
  60453. agentGoto(index: number, destination: Vector3): void;
  60454. /**
  60455. * remove a particular agent previously created
  60456. * @param index agent index returned by addAgent
  60457. */
  60458. removeAgent(index: number): void;
  60459. /**
  60460. * get the list of all agents attached to this crowd
  60461. * @returns list of agent indices
  60462. */
  60463. getAgents(): number[];
  60464. /**
  60465. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60466. * @param deltaTime in seconds
  60467. */
  60468. update(deltaTime: number): void;
  60469. /**
  60470. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60471. * The queries will try to find a solution within those bounds
  60472. * default is (1,1,1)
  60473. * @param extent x,y,z value that define the extent around the queries point of reference
  60474. */
  60475. setDefaultQueryExtent(extent: Vector3): void;
  60476. /**
  60477. * Get the Bounding box extent specified by setDefaultQueryExtent
  60478. * @returns the box extent values
  60479. */
  60480. getDefaultQueryExtent(): Vector3;
  60481. /**
  60482. * Release all resources
  60483. */
  60484. dispose(): void;
  60485. }
  60486. }
  60487. declare module "babylonjs/Navigation/Plugins/index" {
  60488. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60489. }
  60490. declare module "babylonjs/Navigation/index" {
  60491. export * from "babylonjs/Navigation/INavigationEngine";
  60492. export * from "babylonjs/Navigation/Plugins/index";
  60493. }
  60494. declare module "babylonjs/Offline/database" {
  60495. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60496. /**
  60497. * Class used to enable access to IndexedDB
  60498. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60499. */
  60500. export class Database implements IOfflineProvider {
  60501. private _callbackManifestChecked;
  60502. private _currentSceneUrl;
  60503. private _db;
  60504. private _enableSceneOffline;
  60505. private _enableTexturesOffline;
  60506. private _manifestVersionFound;
  60507. private _mustUpdateRessources;
  60508. private _hasReachedQuota;
  60509. private _isSupported;
  60510. private _idbFactory;
  60511. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60512. private static IsUASupportingBlobStorage;
  60513. /**
  60514. * Gets a boolean indicating if Database storate is enabled (off by default)
  60515. */
  60516. static IDBStorageEnabled: boolean;
  60517. /**
  60518. * Gets a boolean indicating if scene must be saved in the database
  60519. */
  60520. readonly enableSceneOffline: boolean;
  60521. /**
  60522. * Gets a boolean indicating if textures must be saved in the database
  60523. */
  60524. readonly enableTexturesOffline: boolean;
  60525. /**
  60526. * Creates a new Database
  60527. * @param urlToScene defines the url to load the scene
  60528. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60529. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60530. */
  60531. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60532. private static _ParseURL;
  60533. private static _ReturnFullUrlLocation;
  60534. private _checkManifestFile;
  60535. /**
  60536. * Open the database and make it available
  60537. * @param successCallback defines the callback to call on success
  60538. * @param errorCallback defines the callback to call on error
  60539. */
  60540. open(successCallback: () => void, errorCallback: () => void): void;
  60541. /**
  60542. * Loads an image from the database
  60543. * @param url defines the url to load from
  60544. * @param image defines the target DOM image
  60545. */
  60546. loadImage(url: string, image: HTMLImageElement): void;
  60547. private _loadImageFromDBAsync;
  60548. private _saveImageIntoDBAsync;
  60549. private _checkVersionFromDB;
  60550. private _loadVersionFromDBAsync;
  60551. private _saveVersionIntoDBAsync;
  60552. /**
  60553. * Loads a file from database
  60554. * @param url defines the URL to load from
  60555. * @param sceneLoaded defines a callback to call on success
  60556. * @param progressCallBack defines a callback to call when progress changed
  60557. * @param errorCallback defines a callback to call on error
  60558. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60559. */
  60560. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60561. private _loadFileAsync;
  60562. private _saveFileAsync;
  60563. /**
  60564. * Validates if xhr data is correct
  60565. * @param xhr defines the request to validate
  60566. * @param dataType defines the expected data type
  60567. * @returns true if data is correct
  60568. */
  60569. private static _ValidateXHRData;
  60570. }
  60571. }
  60572. declare module "babylonjs/Offline/index" {
  60573. export * from "babylonjs/Offline/database";
  60574. export * from "babylonjs/Offline/IOfflineProvider";
  60575. }
  60576. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60577. /** @hidden */
  60578. export var gpuUpdateParticlesPixelShader: {
  60579. name: string;
  60580. shader: string;
  60581. };
  60582. }
  60583. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60584. /** @hidden */
  60585. export var gpuUpdateParticlesVertexShader: {
  60586. name: string;
  60587. shader: string;
  60588. };
  60589. }
  60590. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60591. /** @hidden */
  60592. export var clipPlaneFragmentDeclaration2: {
  60593. name: string;
  60594. shader: string;
  60595. };
  60596. }
  60597. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60598. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60599. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60600. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60601. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60602. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60603. /** @hidden */
  60604. export var gpuRenderParticlesPixelShader: {
  60605. name: string;
  60606. shader: string;
  60607. };
  60608. }
  60609. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60610. /** @hidden */
  60611. export var clipPlaneVertexDeclaration2: {
  60612. name: string;
  60613. shader: string;
  60614. };
  60615. }
  60616. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60617. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60618. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60619. /** @hidden */
  60620. export var gpuRenderParticlesVertexShader: {
  60621. name: string;
  60622. shader: string;
  60623. };
  60624. }
  60625. declare module "babylonjs/Particles/gpuParticleSystem" {
  60626. import { Nullable } from "babylonjs/types";
  60627. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60628. import { Observable } from "babylonjs/Misc/observable";
  60629. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60630. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60631. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60632. import { Scene, IDisposable } from "babylonjs/scene";
  60633. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60634. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60635. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60636. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60637. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60638. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60639. /**
  60640. * This represents a GPU particle system in Babylon
  60641. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60642. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60643. */
  60644. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60645. /**
  60646. * The layer mask we are rendering the particles through.
  60647. */
  60648. layerMask: number;
  60649. private _capacity;
  60650. private _activeCount;
  60651. private _currentActiveCount;
  60652. private _accumulatedCount;
  60653. private _renderEffect;
  60654. private _updateEffect;
  60655. private _buffer0;
  60656. private _buffer1;
  60657. private _spriteBuffer;
  60658. private _updateVAO;
  60659. private _renderVAO;
  60660. private _targetIndex;
  60661. private _sourceBuffer;
  60662. private _targetBuffer;
  60663. private _engine;
  60664. private _currentRenderId;
  60665. private _started;
  60666. private _stopped;
  60667. private _timeDelta;
  60668. private _randomTexture;
  60669. private _randomTexture2;
  60670. private _attributesStrideSize;
  60671. private _updateEffectOptions;
  60672. private _randomTextureSize;
  60673. private _actualFrame;
  60674. private readonly _rawTextureWidth;
  60675. /**
  60676. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60677. */
  60678. static readonly IsSupported: boolean;
  60679. /**
  60680. * An event triggered when the system is disposed.
  60681. */
  60682. onDisposeObservable: Observable<GPUParticleSystem>;
  60683. /**
  60684. * Gets the maximum number of particles active at the same time.
  60685. * @returns The max number of active particles.
  60686. */
  60687. getCapacity(): number;
  60688. /**
  60689. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60690. * to override the particles.
  60691. */
  60692. forceDepthWrite: boolean;
  60693. /**
  60694. * Gets or set the number of active particles
  60695. */
  60696. activeParticleCount: number;
  60697. private _preWarmDone;
  60698. /**
  60699. * Is this system ready to be used/rendered
  60700. * @return true if the system is ready
  60701. */
  60702. isReady(): boolean;
  60703. /**
  60704. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60705. * @returns True if it has been started, otherwise false.
  60706. */
  60707. isStarted(): boolean;
  60708. /**
  60709. * Starts the particle system and begins to emit
  60710. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60711. */
  60712. start(delay?: number): void;
  60713. /**
  60714. * Stops the particle system.
  60715. */
  60716. stop(): void;
  60717. /**
  60718. * Remove all active particles
  60719. */
  60720. reset(): void;
  60721. /**
  60722. * Returns the string "GPUParticleSystem"
  60723. * @returns a string containing the class name
  60724. */
  60725. getClassName(): string;
  60726. private _colorGradientsTexture;
  60727. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60728. /**
  60729. * Adds a new color gradient
  60730. * @param gradient defines the gradient to use (between 0 and 1)
  60731. * @param color1 defines the color to affect to the specified gradient
  60732. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60733. * @returns the current particle system
  60734. */
  60735. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60736. /**
  60737. * Remove a specific color gradient
  60738. * @param gradient defines the gradient to remove
  60739. * @returns the current particle system
  60740. */
  60741. removeColorGradient(gradient: number): GPUParticleSystem;
  60742. private _angularSpeedGradientsTexture;
  60743. private _sizeGradientsTexture;
  60744. private _velocityGradientsTexture;
  60745. private _limitVelocityGradientsTexture;
  60746. private _dragGradientsTexture;
  60747. private _addFactorGradient;
  60748. /**
  60749. * Adds a new size gradient
  60750. * @param gradient defines the gradient to use (between 0 and 1)
  60751. * @param factor defines the size factor to affect to the specified gradient
  60752. * @returns the current particle system
  60753. */
  60754. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60755. /**
  60756. * Remove a specific size gradient
  60757. * @param gradient defines the gradient to remove
  60758. * @returns the current particle system
  60759. */
  60760. removeSizeGradient(gradient: number): GPUParticleSystem;
  60761. /**
  60762. * Adds a new angular speed gradient
  60763. * @param gradient defines the gradient to use (between 0 and 1)
  60764. * @param factor defines the angular speed to affect to the specified gradient
  60765. * @returns the current particle system
  60766. */
  60767. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60768. /**
  60769. * Remove a specific angular speed gradient
  60770. * @param gradient defines the gradient to remove
  60771. * @returns the current particle system
  60772. */
  60773. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60774. /**
  60775. * Adds a new velocity gradient
  60776. * @param gradient defines the gradient to use (between 0 and 1)
  60777. * @param factor defines the velocity to affect to the specified gradient
  60778. * @returns the current particle system
  60779. */
  60780. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60781. /**
  60782. * Remove a specific velocity gradient
  60783. * @param gradient defines the gradient to remove
  60784. * @returns the current particle system
  60785. */
  60786. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60787. /**
  60788. * Adds a new limit velocity gradient
  60789. * @param gradient defines the gradient to use (between 0 and 1)
  60790. * @param factor defines the limit velocity value to affect to the specified gradient
  60791. * @returns the current particle system
  60792. */
  60793. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60794. /**
  60795. * Remove a specific limit velocity gradient
  60796. * @param gradient defines the gradient to remove
  60797. * @returns the current particle system
  60798. */
  60799. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60800. /**
  60801. * Adds a new drag gradient
  60802. * @param gradient defines the gradient to use (between 0 and 1)
  60803. * @param factor defines the drag value to affect to the specified gradient
  60804. * @returns the current particle system
  60805. */
  60806. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60807. /**
  60808. * Remove a specific drag gradient
  60809. * @param gradient defines the gradient to remove
  60810. * @returns the current particle system
  60811. */
  60812. removeDragGradient(gradient: number): GPUParticleSystem;
  60813. /**
  60814. * Not supported by GPUParticleSystem
  60815. * @param gradient defines the gradient to use (between 0 and 1)
  60816. * @param factor defines the emit rate value to affect to the specified gradient
  60817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60818. * @returns the current particle system
  60819. */
  60820. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60821. /**
  60822. * Not supported by GPUParticleSystem
  60823. * @param gradient defines the gradient to remove
  60824. * @returns the current particle system
  60825. */
  60826. removeEmitRateGradient(gradient: number): IParticleSystem;
  60827. /**
  60828. * Not supported by GPUParticleSystem
  60829. * @param gradient defines the gradient to use (between 0 and 1)
  60830. * @param factor defines the start size value to affect to the specified gradient
  60831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60832. * @returns the current particle system
  60833. */
  60834. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60835. /**
  60836. * Not supported by GPUParticleSystem
  60837. * @param gradient defines the gradient to remove
  60838. * @returns the current particle system
  60839. */
  60840. removeStartSizeGradient(gradient: number): IParticleSystem;
  60841. /**
  60842. * Not supported by GPUParticleSystem
  60843. * @param gradient defines the gradient to use (between 0 and 1)
  60844. * @param min defines the color remap minimal range
  60845. * @param max defines the color remap maximal range
  60846. * @returns the current particle system
  60847. */
  60848. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60849. /**
  60850. * Not supported by GPUParticleSystem
  60851. * @param gradient defines the gradient to remove
  60852. * @returns the current particle system
  60853. */
  60854. removeColorRemapGradient(): IParticleSystem;
  60855. /**
  60856. * Not supported by GPUParticleSystem
  60857. * @param gradient defines the gradient to use (between 0 and 1)
  60858. * @param min defines the alpha remap minimal range
  60859. * @param max defines the alpha remap maximal range
  60860. * @returns the current particle system
  60861. */
  60862. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60863. /**
  60864. * Not supported by GPUParticleSystem
  60865. * @param gradient defines the gradient to remove
  60866. * @returns the current particle system
  60867. */
  60868. removeAlphaRemapGradient(): IParticleSystem;
  60869. /**
  60870. * Not supported by GPUParticleSystem
  60871. * @param gradient defines the gradient to use (between 0 and 1)
  60872. * @param color defines the color to affect to the specified gradient
  60873. * @returns the current particle system
  60874. */
  60875. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60876. /**
  60877. * Not supported by GPUParticleSystem
  60878. * @param gradient defines the gradient to remove
  60879. * @returns the current particle system
  60880. */
  60881. removeRampGradient(): IParticleSystem;
  60882. /**
  60883. * Not supported by GPUParticleSystem
  60884. * @returns the list of ramp gradients
  60885. */
  60886. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60887. /**
  60888. * Not supported by GPUParticleSystem
  60889. * Gets or sets a boolean indicating that ramp gradients must be used
  60890. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60891. */
  60892. useRampGradients: boolean;
  60893. /**
  60894. * Not supported by GPUParticleSystem
  60895. * @param gradient defines the gradient to use (between 0 and 1)
  60896. * @param factor defines the life time factor to affect to the specified gradient
  60897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60898. * @returns the current particle system
  60899. */
  60900. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60901. /**
  60902. * Not supported by GPUParticleSystem
  60903. * @param gradient defines the gradient to remove
  60904. * @returns the current particle system
  60905. */
  60906. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60907. /**
  60908. * Instantiates a GPU particle system.
  60909. * 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.
  60910. * @param name The name of the particle system
  60911. * @param options The options used to create the system
  60912. * @param scene The scene the particle system belongs to
  60913. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60914. */
  60915. constructor(name: string, options: Partial<{
  60916. capacity: number;
  60917. randomTextureSize: number;
  60918. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60919. protected _reset(): void;
  60920. private _createUpdateVAO;
  60921. private _createRenderVAO;
  60922. private _initialize;
  60923. /** @hidden */
  60924. _recreateUpdateEffect(): void;
  60925. /** @hidden */
  60926. _recreateRenderEffect(): void;
  60927. /**
  60928. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60929. * @param preWarm defines if we are in the pre-warmimg phase
  60930. */
  60931. animate(preWarm?: boolean): void;
  60932. private _createFactorGradientTexture;
  60933. private _createSizeGradientTexture;
  60934. private _createAngularSpeedGradientTexture;
  60935. private _createVelocityGradientTexture;
  60936. private _createLimitVelocityGradientTexture;
  60937. private _createDragGradientTexture;
  60938. private _createColorGradientTexture;
  60939. /**
  60940. * Renders the particle system in its current state
  60941. * @param preWarm defines if the system should only update the particles but not render them
  60942. * @returns the current number of particles
  60943. */
  60944. render(preWarm?: boolean): number;
  60945. /**
  60946. * Rebuilds the particle system
  60947. */
  60948. rebuild(): void;
  60949. private _releaseBuffers;
  60950. private _releaseVAOs;
  60951. /**
  60952. * Disposes the particle system and free the associated resources
  60953. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60954. */
  60955. dispose(disposeTexture?: boolean): void;
  60956. /**
  60957. * Clones the particle system.
  60958. * @param name The name of the cloned object
  60959. * @param newEmitter The new emitter to use
  60960. * @returns the cloned particle system
  60961. */
  60962. clone(name: string, newEmitter: any): GPUParticleSystem;
  60963. /**
  60964. * Serializes the particle system to a JSON object.
  60965. * @returns the JSON object
  60966. */
  60967. serialize(): any;
  60968. /**
  60969. * Parses a JSON object to create a GPU particle system.
  60970. * @param parsedParticleSystem The JSON object to parse
  60971. * @param scene The scene to create the particle system in
  60972. * @param rootUrl The root url to use to load external dependencies like texture
  60973. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60974. * @returns the parsed GPU particle system
  60975. */
  60976. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60977. }
  60978. }
  60979. declare module "babylonjs/Particles/particleSystemSet" {
  60980. import { Nullable } from "babylonjs/types";
  60981. import { Color3 } from "babylonjs/Maths/math.color";
  60982. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60984. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60985. import { Scene, IDisposable } from "babylonjs/scene";
  60986. /**
  60987. * Represents a set of particle systems working together to create a specific effect
  60988. */
  60989. export class ParticleSystemSet implements IDisposable {
  60990. private _emitterCreationOptions;
  60991. private _emitterNode;
  60992. /**
  60993. * Gets the particle system list
  60994. */
  60995. systems: IParticleSystem[];
  60996. /**
  60997. * Gets the emitter node used with this set
  60998. */
  60999. readonly emitterNode: Nullable<TransformNode>;
  61000. /**
  61001. * Creates a new emitter mesh as a sphere
  61002. * @param options defines the options used to create the sphere
  61003. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61004. * @param scene defines the hosting scene
  61005. */
  61006. setEmitterAsSphere(options: {
  61007. diameter: number;
  61008. segments: number;
  61009. color: Color3;
  61010. }, renderingGroupId: number, scene: Scene): void;
  61011. /**
  61012. * Starts all particle systems of the set
  61013. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61014. */
  61015. start(emitter?: AbstractMesh): void;
  61016. /**
  61017. * Release all associated resources
  61018. */
  61019. dispose(): void;
  61020. /**
  61021. * Serialize the set into a JSON compatible object
  61022. * @returns a JSON compatible representation of the set
  61023. */
  61024. serialize(): any;
  61025. /**
  61026. * Parse a new ParticleSystemSet from a serialized source
  61027. * @param data defines a JSON compatible representation of the set
  61028. * @param scene defines the hosting scene
  61029. * @param gpu defines if we want GPU particles or CPU particles
  61030. * @returns a new ParticleSystemSet
  61031. */
  61032. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61033. }
  61034. }
  61035. declare module "babylonjs/Particles/particleHelper" {
  61036. import { Nullable } from "babylonjs/types";
  61037. import { Scene } from "babylonjs/scene";
  61038. import { Vector3 } from "babylonjs/Maths/math.vector";
  61039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61040. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61041. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61042. /**
  61043. * This class is made for on one-liner static method to help creating particle system set.
  61044. */
  61045. export class ParticleHelper {
  61046. /**
  61047. * Gets or sets base Assets URL
  61048. */
  61049. static BaseAssetsUrl: string;
  61050. /**
  61051. * Create a default particle system that you can tweak
  61052. * @param emitter defines the emitter to use
  61053. * @param capacity defines the system capacity (default is 500 particles)
  61054. * @param scene defines the hosting scene
  61055. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61056. * @returns the new Particle system
  61057. */
  61058. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61059. /**
  61060. * This is the main static method (one-liner) of this helper to create different particle systems
  61061. * @param type This string represents the type to the particle system to create
  61062. * @param scene The scene where the particle system should live
  61063. * @param gpu If the system will use gpu
  61064. * @returns the ParticleSystemSet created
  61065. */
  61066. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61067. /**
  61068. * Static function used to export a particle system to a ParticleSystemSet variable.
  61069. * Please note that the emitter shape is not exported
  61070. * @param systems defines the particle systems to export
  61071. * @returns the created particle system set
  61072. */
  61073. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61074. }
  61075. }
  61076. declare module "babylonjs/Particles/particleSystemComponent" {
  61077. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61078. import { Effect } from "babylonjs/Materials/effect";
  61079. import "babylonjs/Shaders/particles.vertex";
  61080. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61081. module "babylonjs/Engines/engine" {
  61082. interface Engine {
  61083. /**
  61084. * Create an effect to use with particle systems.
  61085. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61086. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61087. * @param uniformsNames defines a list of attribute names
  61088. * @param samplers defines an array of string used to represent textures
  61089. * @param defines defines the string containing the defines to use to compile the shaders
  61090. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61091. * @param onCompiled defines a function to call when the effect creation is successful
  61092. * @param onError defines a function to call when the effect creation has failed
  61093. * @returns the new Effect
  61094. */
  61095. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61096. }
  61097. }
  61098. module "babylonjs/Meshes/mesh" {
  61099. interface Mesh {
  61100. /**
  61101. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61102. * @returns an array of IParticleSystem
  61103. */
  61104. getEmittedParticleSystems(): IParticleSystem[];
  61105. /**
  61106. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61107. * @returns an array of IParticleSystem
  61108. */
  61109. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61110. }
  61111. }
  61112. /**
  61113. * @hidden
  61114. */
  61115. export var _IDoNeedToBeInTheBuild: number;
  61116. }
  61117. declare module "babylonjs/Particles/index" {
  61118. export * from "babylonjs/Particles/baseParticleSystem";
  61119. export * from "babylonjs/Particles/EmitterTypes/index";
  61120. export * from "babylonjs/Particles/gpuParticleSystem";
  61121. export * from "babylonjs/Particles/IParticleSystem";
  61122. export * from "babylonjs/Particles/particle";
  61123. export * from "babylonjs/Particles/particleHelper";
  61124. export * from "babylonjs/Particles/particleSystem";
  61125. export * from "babylonjs/Particles/particleSystemComponent";
  61126. export * from "babylonjs/Particles/particleSystemSet";
  61127. export * from "babylonjs/Particles/solidParticle";
  61128. export * from "babylonjs/Particles/solidParticleSystem";
  61129. export * from "babylonjs/Particles/subEmitter";
  61130. }
  61131. declare module "babylonjs/Physics/physicsEngineComponent" {
  61132. import { Nullable } from "babylonjs/types";
  61133. import { Observable, Observer } from "babylonjs/Misc/observable";
  61134. import { Vector3 } from "babylonjs/Maths/math.vector";
  61135. import { Mesh } from "babylonjs/Meshes/mesh";
  61136. import { ISceneComponent } from "babylonjs/sceneComponent";
  61137. import { Scene } from "babylonjs/scene";
  61138. import { Node } from "babylonjs/node";
  61139. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61140. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61141. module "babylonjs/scene" {
  61142. interface Scene {
  61143. /** @hidden (Backing field) */
  61144. _physicsEngine: Nullable<IPhysicsEngine>;
  61145. /**
  61146. * Gets the current physics engine
  61147. * @returns a IPhysicsEngine or null if none attached
  61148. */
  61149. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61150. /**
  61151. * Enables physics to the current scene
  61152. * @param gravity defines the scene's gravity for the physics engine
  61153. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61154. * @return a boolean indicating if the physics engine was initialized
  61155. */
  61156. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61157. /**
  61158. * Disables and disposes the physics engine associated with the scene
  61159. */
  61160. disablePhysicsEngine(): void;
  61161. /**
  61162. * Gets a boolean indicating if there is an active physics engine
  61163. * @returns a boolean indicating if there is an active physics engine
  61164. */
  61165. isPhysicsEnabled(): boolean;
  61166. /**
  61167. * Deletes a physics compound impostor
  61168. * @param compound defines the compound to delete
  61169. */
  61170. deleteCompoundImpostor(compound: any): void;
  61171. /**
  61172. * An event triggered when physic simulation is about to be run
  61173. */
  61174. onBeforePhysicsObservable: Observable<Scene>;
  61175. /**
  61176. * An event triggered when physic simulation has been done
  61177. */
  61178. onAfterPhysicsObservable: Observable<Scene>;
  61179. }
  61180. }
  61181. module "babylonjs/Meshes/abstractMesh" {
  61182. interface AbstractMesh {
  61183. /** @hidden */
  61184. _physicsImpostor: Nullable<PhysicsImpostor>;
  61185. /**
  61186. * Gets or sets impostor used for physic simulation
  61187. * @see http://doc.babylonjs.com/features/physics_engine
  61188. */
  61189. physicsImpostor: Nullable<PhysicsImpostor>;
  61190. /**
  61191. * Gets the current physics impostor
  61192. * @see http://doc.babylonjs.com/features/physics_engine
  61193. * @returns a physics impostor or null
  61194. */
  61195. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61196. /** Apply a physic impulse to the mesh
  61197. * @param force defines the force to apply
  61198. * @param contactPoint defines where to apply the force
  61199. * @returns the current mesh
  61200. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61201. */
  61202. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61203. /**
  61204. * Creates a physic joint between two meshes
  61205. * @param otherMesh defines the other mesh to use
  61206. * @param pivot1 defines the pivot to use on this mesh
  61207. * @param pivot2 defines the pivot to use on the other mesh
  61208. * @param options defines additional options (can be plugin dependent)
  61209. * @returns the current mesh
  61210. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61211. */
  61212. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61213. /** @hidden */
  61214. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61215. }
  61216. }
  61217. /**
  61218. * Defines the physics engine scene component responsible to manage a physics engine
  61219. */
  61220. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61221. /**
  61222. * The component name helpful to identify the component in the list of scene components.
  61223. */
  61224. readonly name: string;
  61225. /**
  61226. * The scene the component belongs to.
  61227. */
  61228. scene: Scene;
  61229. /**
  61230. * Creates a new instance of the component for the given scene
  61231. * @param scene Defines the scene to register the component in
  61232. */
  61233. constructor(scene: Scene);
  61234. /**
  61235. * Registers the component in a given scene
  61236. */
  61237. register(): void;
  61238. /**
  61239. * Rebuilds the elements related to this component in case of
  61240. * context lost for instance.
  61241. */
  61242. rebuild(): void;
  61243. /**
  61244. * Disposes the component and the associated ressources
  61245. */
  61246. dispose(): void;
  61247. }
  61248. }
  61249. declare module "babylonjs/Physics/physicsHelper" {
  61250. import { Nullable } from "babylonjs/types";
  61251. import { Vector3 } from "babylonjs/Maths/math.vector";
  61252. import { Mesh } from "babylonjs/Meshes/mesh";
  61253. import { Scene } from "babylonjs/scene";
  61254. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61255. /**
  61256. * A helper for physics simulations
  61257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61258. */
  61259. export class PhysicsHelper {
  61260. private _scene;
  61261. private _physicsEngine;
  61262. /**
  61263. * Initializes the Physics helper
  61264. * @param scene Babylon.js scene
  61265. */
  61266. constructor(scene: Scene);
  61267. /**
  61268. * Applies a radial explosion impulse
  61269. * @param origin the origin of the explosion
  61270. * @param radiusOrEventOptions the radius or the options of radial explosion
  61271. * @param strength the explosion strength
  61272. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61273. * @returns A physics radial explosion event, or null
  61274. */
  61275. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61276. /**
  61277. * Applies a radial explosion force
  61278. * @param origin the origin of the explosion
  61279. * @param radiusOrEventOptions the radius or the options of radial explosion
  61280. * @param strength the explosion strength
  61281. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61282. * @returns A physics radial explosion event, or null
  61283. */
  61284. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61285. /**
  61286. * Creates a gravitational field
  61287. * @param origin the origin of the explosion
  61288. * @param radiusOrEventOptions the radius or the options of radial explosion
  61289. * @param strength the explosion strength
  61290. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61291. * @returns A physics gravitational field event, or null
  61292. */
  61293. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61294. /**
  61295. * Creates a physics updraft event
  61296. * @param origin the origin of the updraft
  61297. * @param radiusOrEventOptions the radius or the options of the updraft
  61298. * @param strength the strength of the updraft
  61299. * @param height the height of the updraft
  61300. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61301. * @returns A physics updraft event, or null
  61302. */
  61303. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61304. /**
  61305. * Creates a physics vortex event
  61306. * @param origin the of the vortex
  61307. * @param radiusOrEventOptions the radius or the options of the vortex
  61308. * @param strength the strength of the vortex
  61309. * @param height the height of the vortex
  61310. * @returns a Physics vortex event, or null
  61311. * A physics vortex event or null
  61312. */
  61313. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61314. }
  61315. /**
  61316. * Represents a physics radial explosion event
  61317. */
  61318. class PhysicsRadialExplosionEvent {
  61319. private _scene;
  61320. private _options;
  61321. private _sphere;
  61322. private _dataFetched;
  61323. /**
  61324. * Initializes a radial explosioin event
  61325. * @param _scene BabylonJS scene
  61326. * @param _options The options for the vortex event
  61327. */
  61328. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61329. /**
  61330. * Returns the data related to the radial explosion event (sphere).
  61331. * @returns The radial explosion event data
  61332. */
  61333. getData(): PhysicsRadialExplosionEventData;
  61334. /**
  61335. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61336. * @param impostor A physics imposter
  61337. * @param origin the origin of the explosion
  61338. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61339. */
  61340. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61341. /**
  61342. * Triggers affecterd impostors callbacks
  61343. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61344. */
  61345. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61346. /**
  61347. * Disposes the sphere.
  61348. * @param force Specifies if the sphere should be disposed by force
  61349. */
  61350. dispose(force?: boolean): void;
  61351. /*** Helpers ***/
  61352. private _prepareSphere;
  61353. private _intersectsWithSphere;
  61354. }
  61355. /**
  61356. * Represents a gravitational field event
  61357. */
  61358. class PhysicsGravitationalFieldEvent {
  61359. private _physicsHelper;
  61360. private _scene;
  61361. private _origin;
  61362. private _options;
  61363. private _tickCallback;
  61364. private _sphere;
  61365. private _dataFetched;
  61366. /**
  61367. * Initializes the physics gravitational field event
  61368. * @param _physicsHelper A physics helper
  61369. * @param _scene BabylonJS scene
  61370. * @param _origin The origin position of the gravitational field event
  61371. * @param _options The options for the vortex event
  61372. */
  61373. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61374. /**
  61375. * Returns the data related to the gravitational field event (sphere).
  61376. * @returns A gravitational field event
  61377. */
  61378. getData(): PhysicsGravitationalFieldEventData;
  61379. /**
  61380. * Enables the gravitational field.
  61381. */
  61382. enable(): void;
  61383. /**
  61384. * Disables the gravitational field.
  61385. */
  61386. disable(): void;
  61387. /**
  61388. * Disposes the sphere.
  61389. * @param force The force to dispose from the gravitational field event
  61390. */
  61391. dispose(force?: boolean): void;
  61392. private _tick;
  61393. }
  61394. /**
  61395. * Represents a physics updraft event
  61396. */
  61397. class PhysicsUpdraftEvent {
  61398. private _scene;
  61399. private _origin;
  61400. private _options;
  61401. private _physicsEngine;
  61402. private _originTop;
  61403. private _originDirection;
  61404. private _tickCallback;
  61405. private _cylinder;
  61406. private _cylinderPosition;
  61407. private _dataFetched;
  61408. /**
  61409. * Initializes the physics updraft event
  61410. * @param _scene BabylonJS scene
  61411. * @param _origin The origin position of the updraft
  61412. * @param _options The options for the updraft event
  61413. */
  61414. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61415. /**
  61416. * Returns the data related to the updraft event (cylinder).
  61417. * @returns A physics updraft event
  61418. */
  61419. getData(): PhysicsUpdraftEventData;
  61420. /**
  61421. * Enables the updraft.
  61422. */
  61423. enable(): void;
  61424. /**
  61425. * Disables the updraft.
  61426. */
  61427. disable(): void;
  61428. /**
  61429. * Disposes the cylinder.
  61430. * @param force Specifies if the updraft should be disposed by force
  61431. */
  61432. dispose(force?: boolean): void;
  61433. private getImpostorHitData;
  61434. private _tick;
  61435. /*** Helpers ***/
  61436. private _prepareCylinder;
  61437. private _intersectsWithCylinder;
  61438. }
  61439. /**
  61440. * Represents a physics vortex event
  61441. */
  61442. class PhysicsVortexEvent {
  61443. private _scene;
  61444. private _origin;
  61445. private _options;
  61446. private _physicsEngine;
  61447. private _originTop;
  61448. private _tickCallback;
  61449. private _cylinder;
  61450. private _cylinderPosition;
  61451. private _dataFetched;
  61452. /**
  61453. * Initializes the physics vortex event
  61454. * @param _scene The BabylonJS scene
  61455. * @param _origin The origin position of the vortex
  61456. * @param _options The options for the vortex event
  61457. */
  61458. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61459. /**
  61460. * Returns the data related to the vortex event (cylinder).
  61461. * @returns The physics vortex event data
  61462. */
  61463. getData(): PhysicsVortexEventData;
  61464. /**
  61465. * Enables the vortex.
  61466. */
  61467. enable(): void;
  61468. /**
  61469. * Disables the cortex.
  61470. */
  61471. disable(): void;
  61472. /**
  61473. * Disposes the sphere.
  61474. * @param force
  61475. */
  61476. dispose(force?: boolean): void;
  61477. private getImpostorHitData;
  61478. private _tick;
  61479. /*** Helpers ***/
  61480. private _prepareCylinder;
  61481. private _intersectsWithCylinder;
  61482. }
  61483. /**
  61484. * Options fot the radial explosion event
  61485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61486. */
  61487. export class PhysicsRadialExplosionEventOptions {
  61488. /**
  61489. * The radius of the sphere for the radial explosion.
  61490. */
  61491. radius: number;
  61492. /**
  61493. * The strenth of the explosion.
  61494. */
  61495. strength: number;
  61496. /**
  61497. * The strenght of the force in correspondence to the distance of the affected object
  61498. */
  61499. falloff: PhysicsRadialImpulseFalloff;
  61500. /**
  61501. * Sphere options for the radial explosion.
  61502. */
  61503. sphere: {
  61504. segments: number;
  61505. diameter: number;
  61506. };
  61507. /**
  61508. * Sphere options for the radial explosion.
  61509. */
  61510. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61511. }
  61512. /**
  61513. * Options fot the updraft event
  61514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61515. */
  61516. export class PhysicsUpdraftEventOptions {
  61517. /**
  61518. * The radius of the cylinder for the vortex
  61519. */
  61520. radius: number;
  61521. /**
  61522. * The strenth of the updraft.
  61523. */
  61524. strength: number;
  61525. /**
  61526. * The height of the cylinder for the updraft.
  61527. */
  61528. height: number;
  61529. /**
  61530. * The mode for the the updraft.
  61531. */
  61532. updraftMode: PhysicsUpdraftMode;
  61533. }
  61534. /**
  61535. * Options fot the vortex event
  61536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61537. */
  61538. export class PhysicsVortexEventOptions {
  61539. /**
  61540. * The radius of the cylinder for the vortex
  61541. */
  61542. radius: number;
  61543. /**
  61544. * The strenth of the vortex.
  61545. */
  61546. strength: number;
  61547. /**
  61548. * The height of the cylinder for the vortex.
  61549. */
  61550. height: number;
  61551. /**
  61552. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61553. */
  61554. centripetalForceThreshold: number;
  61555. /**
  61556. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61557. */
  61558. centripetalForceMultiplier: number;
  61559. /**
  61560. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61561. */
  61562. centrifugalForceMultiplier: number;
  61563. /**
  61564. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61565. */
  61566. updraftForceMultiplier: number;
  61567. }
  61568. /**
  61569. * The strenght of the force in correspondence to the distance of the affected object
  61570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61571. */
  61572. export enum PhysicsRadialImpulseFalloff {
  61573. /** Defines that impulse is constant in strength across it's whole radius */
  61574. Constant = 0,
  61575. /** Defines that impulse gets weaker if it's further from the origin */
  61576. Linear = 1
  61577. }
  61578. /**
  61579. * The strength of the force in correspondence to the distance of the affected object
  61580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61581. */
  61582. export enum PhysicsUpdraftMode {
  61583. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61584. Center = 0,
  61585. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61586. Perpendicular = 1
  61587. }
  61588. /**
  61589. * Interface for a physics hit data
  61590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61591. */
  61592. export interface PhysicsHitData {
  61593. /**
  61594. * The force applied at the contact point
  61595. */
  61596. force: Vector3;
  61597. /**
  61598. * The contact point
  61599. */
  61600. contactPoint: Vector3;
  61601. /**
  61602. * The distance from the origin to the contact point
  61603. */
  61604. distanceFromOrigin: number;
  61605. }
  61606. /**
  61607. * Interface for radial explosion event data
  61608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61609. */
  61610. export interface PhysicsRadialExplosionEventData {
  61611. /**
  61612. * A sphere used for the radial explosion event
  61613. */
  61614. sphere: Mesh;
  61615. }
  61616. /**
  61617. * Interface for gravitational field event data
  61618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61619. */
  61620. export interface PhysicsGravitationalFieldEventData {
  61621. /**
  61622. * A sphere mesh used for the gravitational field event
  61623. */
  61624. sphere: Mesh;
  61625. }
  61626. /**
  61627. * Interface for updraft event data
  61628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61629. */
  61630. export interface PhysicsUpdraftEventData {
  61631. /**
  61632. * A cylinder used for the updraft event
  61633. */
  61634. cylinder: Mesh;
  61635. }
  61636. /**
  61637. * Interface for vortex event data
  61638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61639. */
  61640. export interface PhysicsVortexEventData {
  61641. /**
  61642. * A cylinder used for the vortex event
  61643. */
  61644. cylinder: Mesh;
  61645. }
  61646. /**
  61647. * Interface for an affected physics impostor
  61648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61649. */
  61650. export interface PhysicsAffectedImpostorWithData {
  61651. /**
  61652. * The impostor affected by the effect
  61653. */
  61654. impostor: PhysicsImpostor;
  61655. /**
  61656. * The data about the hit/horce from the explosion
  61657. */
  61658. hitData: PhysicsHitData;
  61659. }
  61660. }
  61661. declare module "babylonjs/Physics/Plugins/index" {
  61662. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61663. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61664. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61665. }
  61666. declare module "babylonjs/Physics/index" {
  61667. export * from "babylonjs/Physics/IPhysicsEngine";
  61668. export * from "babylonjs/Physics/physicsEngine";
  61669. export * from "babylonjs/Physics/physicsEngineComponent";
  61670. export * from "babylonjs/Physics/physicsHelper";
  61671. export * from "babylonjs/Physics/physicsImpostor";
  61672. export * from "babylonjs/Physics/physicsJoint";
  61673. export * from "babylonjs/Physics/Plugins/index";
  61674. }
  61675. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61676. /** @hidden */
  61677. export var blackAndWhitePixelShader: {
  61678. name: string;
  61679. shader: string;
  61680. };
  61681. }
  61682. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61683. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61684. import { Camera } from "babylonjs/Cameras/camera";
  61685. import { Engine } from "babylonjs/Engines/engine";
  61686. import "babylonjs/Shaders/blackAndWhite.fragment";
  61687. /**
  61688. * Post process used to render in black and white
  61689. */
  61690. export class BlackAndWhitePostProcess extends PostProcess {
  61691. /**
  61692. * Linear about to convert he result to black and white (default: 1)
  61693. */
  61694. degree: number;
  61695. /**
  61696. * Creates a black and white post process
  61697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61698. * @param name The name of the effect.
  61699. * @param options The required width/height ratio to downsize to before computing the render pass.
  61700. * @param camera The camera to apply the render pass to.
  61701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61702. * @param engine The engine which the post process will be applied. (default: current engine)
  61703. * @param reusable If the post process can be reused on the same frame. (default: false)
  61704. */
  61705. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61706. }
  61707. }
  61708. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61709. import { Nullable } from "babylonjs/types";
  61710. import { Camera } from "babylonjs/Cameras/camera";
  61711. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61712. import { Engine } from "babylonjs/Engines/engine";
  61713. /**
  61714. * This represents a set of one or more post processes in Babylon.
  61715. * A post process can be used to apply a shader to a texture after it is rendered.
  61716. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61717. */
  61718. export class PostProcessRenderEffect {
  61719. private _postProcesses;
  61720. private _getPostProcesses;
  61721. private _singleInstance;
  61722. private _cameras;
  61723. private _indicesForCamera;
  61724. /**
  61725. * Name of the effect
  61726. * @hidden
  61727. */
  61728. _name: string;
  61729. /**
  61730. * Instantiates a post process render effect.
  61731. * A post process can be used to apply a shader to a texture after it is rendered.
  61732. * @param engine The engine the effect is tied to
  61733. * @param name The name of the effect
  61734. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61735. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61736. */
  61737. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61738. /**
  61739. * Checks if all the post processes in the effect are supported.
  61740. */
  61741. readonly isSupported: boolean;
  61742. /**
  61743. * Updates the current state of the effect
  61744. * @hidden
  61745. */
  61746. _update(): void;
  61747. /**
  61748. * Attaches the effect on cameras
  61749. * @param cameras The camera to attach to.
  61750. * @hidden
  61751. */
  61752. _attachCameras(cameras: Camera): void;
  61753. /**
  61754. * Attaches the effect on cameras
  61755. * @param cameras The camera to attach to.
  61756. * @hidden
  61757. */
  61758. _attachCameras(cameras: Camera[]): void;
  61759. /**
  61760. * Detaches the effect on cameras
  61761. * @param cameras The camera to detatch from.
  61762. * @hidden
  61763. */
  61764. _detachCameras(cameras: Camera): void;
  61765. /**
  61766. * Detatches the effect on cameras
  61767. * @param cameras The camera to detatch from.
  61768. * @hidden
  61769. */
  61770. _detachCameras(cameras: Camera[]): void;
  61771. /**
  61772. * Enables the effect on given cameras
  61773. * @param cameras The camera to enable.
  61774. * @hidden
  61775. */
  61776. _enable(cameras: Camera): void;
  61777. /**
  61778. * Enables the effect on given cameras
  61779. * @param cameras The camera to enable.
  61780. * @hidden
  61781. */
  61782. _enable(cameras: Nullable<Camera[]>): void;
  61783. /**
  61784. * Disables the effect on the given cameras
  61785. * @param cameras The camera to disable.
  61786. * @hidden
  61787. */
  61788. _disable(cameras: Camera): void;
  61789. /**
  61790. * Disables the effect on the given cameras
  61791. * @param cameras The camera to disable.
  61792. * @hidden
  61793. */
  61794. _disable(cameras: Nullable<Camera[]>): void;
  61795. /**
  61796. * Gets a list of the post processes contained in the effect.
  61797. * @param camera The camera to get the post processes on.
  61798. * @returns The list of the post processes in the effect.
  61799. */
  61800. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61801. }
  61802. }
  61803. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61804. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61805. /** @hidden */
  61806. export var extractHighlightsPixelShader: {
  61807. name: string;
  61808. shader: string;
  61809. };
  61810. }
  61811. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61812. import { Nullable } from "babylonjs/types";
  61813. import { Camera } from "babylonjs/Cameras/camera";
  61814. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61815. import { Engine } from "babylonjs/Engines/engine";
  61816. import "babylonjs/Shaders/extractHighlights.fragment";
  61817. /**
  61818. * 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.
  61819. */
  61820. export class ExtractHighlightsPostProcess extends PostProcess {
  61821. /**
  61822. * The luminance threshold, pixels below this value will be set to black.
  61823. */
  61824. threshold: number;
  61825. /** @hidden */
  61826. _exposure: number;
  61827. /**
  61828. * Post process which has the input texture to be used when performing highlight extraction
  61829. * @hidden
  61830. */
  61831. _inputPostProcess: Nullable<PostProcess>;
  61832. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61833. }
  61834. }
  61835. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61836. /** @hidden */
  61837. export var bloomMergePixelShader: {
  61838. name: string;
  61839. shader: string;
  61840. };
  61841. }
  61842. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61843. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61844. import { Nullable } from "babylonjs/types";
  61845. import { Engine } from "babylonjs/Engines/engine";
  61846. import { Camera } from "babylonjs/Cameras/camera";
  61847. import "babylonjs/Shaders/bloomMerge.fragment";
  61848. /**
  61849. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61850. */
  61851. export class BloomMergePostProcess extends PostProcess {
  61852. /** Weight of the bloom to be added to the original input. */
  61853. weight: number;
  61854. /**
  61855. * Creates a new instance of @see BloomMergePostProcess
  61856. * @param name The name of the effect.
  61857. * @param originalFromInput Post process which's input will be used for the merge.
  61858. * @param blurred Blurred highlights post process which's output will be used.
  61859. * @param weight Weight of the bloom to be added to the original input.
  61860. * @param options The required width/height ratio to downsize to before computing the render pass.
  61861. * @param camera The camera to apply the render pass to.
  61862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61863. * @param engine The engine which the post process will be applied. (default: current engine)
  61864. * @param reusable If the post process can be reused on the same frame. (default: false)
  61865. * @param textureType Type of textures used when performing the post process. (default: 0)
  61866. * @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)
  61867. */
  61868. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61869. /** Weight of the bloom to be added to the original input. */
  61870. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61871. }
  61872. }
  61873. declare module "babylonjs/PostProcesses/bloomEffect" {
  61874. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61875. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61876. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61877. import { Camera } from "babylonjs/Cameras/camera";
  61878. import { Scene } from "babylonjs/scene";
  61879. /**
  61880. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61881. */
  61882. export class BloomEffect extends PostProcessRenderEffect {
  61883. private bloomScale;
  61884. /**
  61885. * @hidden Internal
  61886. */
  61887. _effects: Array<PostProcess>;
  61888. /**
  61889. * @hidden Internal
  61890. */
  61891. _downscale: ExtractHighlightsPostProcess;
  61892. private _blurX;
  61893. private _blurY;
  61894. private _merge;
  61895. /**
  61896. * The luminance threshold to find bright areas of the image to bloom.
  61897. */
  61898. threshold: number;
  61899. /**
  61900. * The strength of the bloom.
  61901. */
  61902. weight: number;
  61903. /**
  61904. * Specifies the size of the bloom blur kernel, relative to the final output size
  61905. */
  61906. kernel: number;
  61907. /**
  61908. * Creates a new instance of @see BloomEffect
  61909. * @param scene The scene the effect belongs to.
  61910. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61911. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61912. * @param bloomWeight The the strength of bloom.
  61913. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61914. * @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)
  61915. */
  61916. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61917. /**
  61918. * Disposes each of the internal effects for a given camera.
  61919. * @param camera The camera to dispose the effect on.
  61920. */
  61921. disposeEffects(camera: Camera): void;
  61922. /**
  61923. * @hidden Internal
  61924. */
  61925. _updateEffects(): void;
  61926. /**
  61927. * Internal
  61928. * @returns if all the contained post processes are ready.
  61929. * @hidden
  61930. */
  61931. _isReady(): boolean;
  61932. }
  61933. }
  61934. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61935. /** @hidden */
  61936. export var chromaticAberrationPixelShader: {
  61937. name: string;
  61938. shader: string;
  61939. };
  61940. }
  61941. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61942. import { Vector2 } from "babylonjs/Maths/math.vector";
  61943. import { Nullable } from "babylonjs/types";
  61944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61945. import { Camera } from "babylonjs/Cameras/camera";
  61946. import { Engine } from "babylonjs/Engines/engine";
  61947. import "babylonjs/Shaders/chromaticAberration.fragment";
  61948. /**
  61949. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61950. */
  61951. export class ChromaticAberrationPostProcess extends PostProcess {
  61952. /**
  61953. * The amount of seperation of rgb channels (default: 30)
  61954. */
  61955. aberrationAmount: number;
  61956. /**
  61957. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61958. */
  61959. radialIntensity: number;
  61960. /**
  61961. * 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))
  61962. */
  61963. direction: Vector2;
  61964. /**
  61965. * 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))
  61966. */
  61967. centerPosition: Vector2;
  61968. /**
  61969. * Creates a new instance ChromaticAberrationPostProcess
  61970. * @param name The name of the effect.
  61971. * @param screenWidth The width of the screen to apply the effect on.
  61972. * @param screenHeight The height of the screen to apply the effect on.
  61973. * @param options The required width/height ratio to downsize to before computing the render pass.
  61974. * @param camera The camera to apply the render pass to.
  61975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61976. * @param engine The engine which the post process will be applied. (default: current engine)
  61977. * @param reusable If the post process can be reused on the same frame. (default: false)
  61978. * @param textureType Type of textures used when performing the post process. (default: 0)
  61979. * @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)
  61980. */
  61981. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61982. }
  61983. }
  61984. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61985. /** @hidden */
  61986. export var circleOfConfusionPixelShader: {
  61987. name: string;
  61988. shader: string;
  61989. };
  61990. }
  61991. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61992. import { Nullable } from "babylonjs/types";
  61993. import { Engine } from "babylonjs/Engines/engine";
  61994. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61995. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61996. import { Camera } from "babylonjs/Cameras/camera";
  61997. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61998. /**
  61999. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62000. */
  62001. export class CircleOfConfusionPostProcess extends PostProcess {
  62002. /**
  62003. * 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.
  62004. */
  62005. lensSize: number;
  62006. /**
  62007. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62008. */
  62009. fStop: number;
  62010. /**
  62011. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62012. */
  62013. focusDistance: number;
  62014. /**
  62015. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62016. */
  62017. focalLength: number;
  62018. private _depthTexture;
  62019. /**
  62020. * Creates a new instance CircleOfConfusionPostProcess
  62021. * @param name The name of the effect.
  62022. * @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.
  62023. * @param options The required width/height ratio to downsize to before computing the render pass.
  62024. * @param camera The camera to apply the render pass to.
  62025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62026. * @param engine The engine which the post process will be applied. (default: current engine)
  62027. * @param reusable If the post process can be reused on the same frame. (default: false)
  62028. * @param textureType Type of textures used when performing the post process. (default: 0)
  62029. * @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)
  62030. */
  62031. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62032. /**
  62033. * 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.
  62034. */
  62035. depthTexture: RenderTargetTexture;
  62036. }
  62037. }
  62038. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62039. /** @hidden */
  62040. export var colorCorrectionPixelShader: {
  62041. name: string;
  62042. shader: string;
  62043. };
  62044. }
  62045. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62047. import { Engine } from "babylonjs/Engines/engine";
  62048. import { Camera } from "babylonjs/Cameras/camera";
  62049. import "babylonjs/Shaders/colorCorrection.fragment";
  62050. /**
  62051. *
  62052. * This post-process allows the modification of rendered colors by using
  62053. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62054. *
  62055. * The object needs to be provided an url to a texture containing the color
  62056. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62057. * Use an image editing software to tweak the LUT to match your needs.
  62058. *
  62059. * For an example of a color LUT, see here:
  62060. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62061. * For explanations on color grading, see here:
  62062. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62063. *
  62064. */
  62065. export class ColorCorrectionPostProcess extends PostProcess {
  62066. private _colorTableTexture;
  62067. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62068. }
  62069. }
  62070. declare module "babylonjs/Shaders/convolution.fragment" {
  62071. /** @hidden */
  62072. export var convolutionPixelShader: {
  62073. name: string;
  62074. shader: string;
  62075. };
  62076. }
  62077. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62078. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62079. import { Nullable } from "babylonjs/types";
  62080. import { Camera } from "babylonjs/Cameras/camera";
  62081. import { Engine } from "babylonjs/Engines/engine";
  62082. import "babylonjs/Shaders/convolution.fragment";
  62083. /**
  62084. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62085. * input texture to perform effects such as edge detection or sharpening
  62086. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62087. */
  62088. export class ConvolutionPostProcess extends PostProcess {
  62089. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62090. kernel: number[];
  62091. /**
  62092. * Creates a new instance ConvolutionPostProcess
  62093. * @param name The name of the effect.
  62094. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62095. * @param options The required width/height ratio to downsize to before computing the render pass.
  62096. * @param camera The camera to apply the render pass to.
  62097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62098. * @param engine The engine which the post process will be applied. (default: current engine)
  62099. * @param reusable If the post process can be reused on the same frame. (default: false)
  62100. * @param textureType Type of textures used when performing the post process. (default: 0)
  62101. */
  62102. constructor(name: string,
  62103. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62104. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62105. /**
  62106. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62107. */
  62108. static EdgeDetect0Kernel: number[];
  62109. /**
  62110. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62111. */
  62112. static EdgeDetect1Kernel: number[];
  62113. /**
  62114. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62115. */
  62116. static EdgeDetect2Kernel: number[];
  62117. /**
  62118. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62119. */
  62120. static SharpenKernel: number[];
  62121. /**
  62122. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62123. */
  62124. static EmbossKernel: number[];
  62125. /**
  62126. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62127. */
  62128. static GaussianKernel: number[];
  62129. }
  62130. }
  62131. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62132. import { Nullable } from "babylonjs/types";
  62133. import { Vector2 } from "babylonjs/Maths/math.vector";
  62134. import { Camera } from "babylonjs/Cameras/camera";
  62135. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62136. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62137. import { Engine } from "babylonjs/Engines/engine";
  62138. import { Scene } from "babylonjs/scene";
  62139. /**
  62140. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62141. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62142. * based on samples that have a large difference in distance than the center pixel.
  62143. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62144. */
  62145. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62146. direction: Vector2;
  62147. /**
  62148. * Creates a new instance CircleOfConfusionPostProcess
  62149. * @param name The name of the effect.
  62150. * @param scene The scene the effect belongs to.
  62151. * @param direction The direction the blur should be applied.
  62152. * @param kernel The size of the kernel used to blur.
  62153. * @param options The required width/height ratio to downsize to before computing the render pass.
  62154. * @param camera The camera to apply the render pass to.
  62155. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62156. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62158. * @param engine The engine which the post process will be applied. (default: current engine)
  62159. * @param reusable If the post process can be reused on the same frame. (default: false)
  62160. * @param textureType Type of textures used when performing the post process. (default: 0)
  62161. * @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)
  62162. */
  62163. 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);
  62164. }
  62165. }
  62166. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62167. /** @hidden */
  62168. export var depthOfFieldMergePixelShader: {
  62169. name: string;
  62170. shader: string;
  62171. };
  62172. }
  62173. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62174. import { Nullable } from "babylonjs/types";
  62175. import { Camera } from "babylonjs/Cameras/camera";
  62176. import { Effect } from "babylonjs/Materials/effect";
  62177. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62178. import { Engine } from "babylonjs/Engines/engine";
  62179. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62180. /**
  62181. * Options to be set when merging outputs from the default pipeline.
  62182. */
  62183. export class DepthOfFieldMergePostProcessOptions {
  62184. /**
  62185. * The original image to merge on top of
  62186. */
  62187. originalFromInput: PostProcess;
  62188. /**
  62189. * Parameters to perform the merge of the depth of field effect
  62190. */
  62191. depthOfField?: {
  62192. circleOfConfusion: PostProcess;
  62193. blurSteps: Array<PostProcess>;
  62194. };
  62195. /**
  62196. * Parameters to perform the merge of bloom effect
  62197. */
  62198. bloom?: {
  62199. blurred: PostProcess;
  62200. weight: number;
  62201. };
  62202. }
  62203. /**
  62204. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62205. */
  62206. export class DepthOfFieldMergePostProcess extends PostProcess {
  62207. private blurSteps;
  62208. /**
  62209. * Creates a new instance of DepthOfFieldMergePostProcess
  62210. * @param name The name of the effect.
  62211. * @param originalFromInput Post process which's input will be used for the merge.
  62212. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62213. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62214. * @param options The required width/height ratio to downsize to before computing the render pass.
  62215. * @param camera The camera to apply the render pass to.
  62216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62217. * @param engine The engine which the post process will be applied. (default: current engine)
  62218. * @param reusable If the post process can be reused on the same frame. (default: false)
  62219. * @param textureType Type of textures used when performing the post process. (default: 0)
  62220. * @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)
  62221. */
  62222. 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);
  62223. /**
  62224. * Updates the effect with the current post process compile time values and recompiles the shader.
  62225. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62226. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62227. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62228. * @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
  62229. * @param onCompiled Called when the shader has been compiled.
  62230. * @param onError Called if there is an error when compiling a shader.
  62231. */
  62232. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62233. }
  62234. }
  62235. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62236. import { Nullable } from "babylonjs/types";
  62237. import { Camera } from "babylonjs/Cameras/camera";
  62238. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62239. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62240. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62241. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62242. import { Scene } from "babylonjs/scene";
  62243. /**
  62244. * Specifies the level of max blur that should be applied when using the depth of field effect
  62245. */
  62246. export enum DepthOfFieldEffectBlurLevel {
  62247. /**
  62248. * Subtle blur
  62249. */
  62250. Low = 0,
  62251. /**
  62252. * Medium blur
  62253. */
  62254. Medium = 1,
  62255. /**
  62256. * Large blur
  62257. */
  62258. High = 2
  62259. }
  62260. /**
  62261. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62262. */
  62263. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62264. private _circleOfConfusion;
  62265. /**
  62266. * @hidden Internal, blurs from high to low
  62267. */
  62268. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62269. private _depthOfFieldBlurY;
  62270. private _dofMerge;
  62271. /**
  62272. * @hidden Internal post processes in depth of field effect
  62273. */
  62274. _effects: Array<PostProcess>;
  62275. /**
  62276. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62277. */
  62278. focalLength: number;
  62279. /**
  62280. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62281. */
  62282. fStop: number;
  62283. /**
  62284. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62285. */
  62286. focusDistance: number;
  62287. /**
  62288. * 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.
  62289. */
  62290. lensSize: number;
  62291. /**
  62292. * Creates a new instance DepthOfFieldEffect
  62293. * @param scene The scene the effect belongs to.
  62294. * @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.
  62295. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62296. * @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)
  62297. */
  62298. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62299. /**
  62300. * Get the current class name of the current effet
  62301. * @returns "DepthOfFieldEffect"
  62302. */
  62303. getClassName(): string;
  62304. /**
  62305. * 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.
  62306. */
  62307. depthTexture: RenderTargetTexture;
  62308. /**
  62309. * Disposes each of the internal effects for a given camera.
  62310. * @param camera The camera to dispose the effect on.
  62311. */
  62312. disposeEffects(camera: Camera): void;
  62313. /**
  62314. * @hidden Internal
  62315. */
  62316. _updateEffects(): void;
  62317. /**
  62318. * Internal
  62319. * @returns if all the contained post processes are ready.
  62320. * @hidden
  62321. */
  62322. _isReady(): boolean;
  62323. }
  62324. }
  62325. declare module "babylonjs/Shaders/displayPass.fragment" {
  62326. /** @hidden */
  62327. export var displayPassPixelShader: {
  62328. name: string;
  62329. shader: string;
  62330. };
  62331. }
  62332. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62333. import { Nullable } from "babylonjs/types";
  62334. import { Camera } from "babylonjs/Cameras/camera";
  62335. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62336. import { Engine } from "babylonjs/Engines/engine";
  62337. import "babylonjs/Shaders/displayPass.fragment";
  62338. /**
  62339. * DisplayPassPostProcess which produces an output the same as it's input
  62340. */
  62341. export class DisplayPassPostProcess extends PostProcess {
  62342. /**
  62343. * Creates the DisplayPassPostProcess
  62344. * @param name The name of the effect.
  62345. * @param options The required width/height ratio to downsize to before computing the render pass.
  62346. * @param camera The camera to apply the render pass to.
  62347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62348. * @param engine The engine which the post process will be applied. (default: current engine)
  62349. * @param reusable If the post process can be reused on the same frame. (default: false)
  62350. */
  62351. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62352. }
  62353. }
  62354. declare module "babylonjs/Shaders/filter.fragment" {
  62355. /** @hidden */
  62356. export var filterPixelShader: {
  62357. name: string;
  62358. shader: string;
  62359. };
  62360. }
  62361. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62362. import { Nullable } from "babylonjs/types";
  62363. import { Matrix } from "babylonjs/Maths/math.vector";
  62364. import { Camera } from "babylonjs/Cameras/camera";
  62365. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62366. import { Engine } from "babylonjs/Engines/engine";
  62367. import "babylonjs/Shaders/filter.fragment";
  62368. /**
  62369. * Applies a kernel filter to the image
  62370. */
  62371. export class FilterPostProcess extends PostProcess {
  62372. /** The matrix to be applied to the image */
  62373. kernelMatrix: Matrix;
  62374. /**
  62375. *
  62376. * @param name The name of the effect.
  62377. * @param kernelMatrix The matrix to be applied to the image
  62378. * @param options The required width/height ratio to downsize to before computing the render pass.
  62379. * @param camera The camera to apply the render pass to.
  62380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62381. * @param engine The engine which the post process will be applied. (default: current engine)
  62382. * @param reusable If the post process can be reused on the same frame. (default: false)
  62383. */
  62384. constructor(name: string,
  62385. /** The matrix to be applied to the image */
  62386. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62387. }
  62388. }
  62389. declare module "babylonjs/Shaders/fxaa.fragment" {
  62390. /** @hidden */
  62391. export var fxaaPixelShader: {
  62392. name: string;
  62393. shader: string;
  62394. };
  62395. }
  62396. declare module "babylonjs/Shaders/fxaa.vertex" {
  62397. /** @hidden */
  62398. export var fxaaVertexShader: {
  62399. name: string;
  62400. shader: string;
  62401. };
  62402. }
  62403. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62404. import { Nullable } from "babylonjs/types";
  62405. import { Camera } from "babylonjs/Cameras/camera";
  62406. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62407. import { Engine } from "babylonjs/Engines/engine";
  62408. import "babylonjs/Shaders/fxaa.fragment";
  62409. import "babylonjs/Shaders/fxaa.vertex";
  62410. /**
  62411. * Fxaa post process
  62412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62413. */
  62414. export class FxaaPostProcess extends PostProcess {
  62415. /** @hidden */
  62416. texelWidth: number;
  62417. /** @hidden */
  62418. texelHeight: number;
  62419. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62420. private _getDefines;
  62421. }
  62422. }
  62423. declare module "babylonjs/Shaders/grain.fragment" {
  62424. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62425. /** @hidden */
  62426. export var grainPixelShader: {
  62427. name: string;
  62428. shader: string;
  62429. };
  62430. }
  62431. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62432. import { Nullable } from "babylonjs/types";
  62433. import { Camera } from "babylonjs/Cameras/camera";
  62434. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62435. import { Engine } from "babylonjs/Engines/engine";
  62436. import "babylonjs/Shaders/grain.fragment";
  62437. /**
  62438. * The GrainPostProcess adds noise to the image at mid luminance levels
  62439. */
  62440. export class GrainPostProcess extends PostProcess {
  62441. /**
  62442. * The intensity of the grain added (default: 30)
  62443. */
  62444. intensity: number;
  62445. /**
  62446. * If the grain should be randomized on every frame
  62447. */
  62448. animated: boolean;
  62449. /**
  62450. * Creates a new instance of @see GrainPostProcess
  62451. * @param name The name of the effect.
  62452. * @param options The required width/height ratio to downsize to before computing the render pass.
  62453. * @param camera The camera to apply the render pass to.
  62454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62455. * @param engine The engine which the post process will be applied. (default: current engine)
  62456. * @param reusable If the post process can be reused on the same frame. (default: false)
  62457. * @param textureType Type of textures used when performing the post process. (default: 0)
  62458. * @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)
  62459. */
  62460. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62461. }
  62462. }
  62463. declare module "babylonjs/Shaders/highlights.fragment" {
  62464. /** @hidden */
  62465. export var highlightsPixelShader: {
  62466. name: string;
  62467. shader: string;
  62468. };
  62469. }
  62470. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62471. import { Nullable } from "babylonjs/types";
  62472. import { Camera } from "babylonjs/Cameras/camera";
  62473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62474. import { Engine } from "babylonjs/Engines/engine";
  62475. import "babylonjs/Shaders/highlights.fragment";
  62476. /**
  62477. * Extracts highlights from the image
  62478. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62479. */
  62480. export class HighlightsPostProcess extends PostProcess {
  62481. /**
  62482. * Extracts highlights from the image
  62483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62484. * @param name The name of the effect.
  62485. * @param options The required width/height ratio to downsize to before computing the render pass.
  62486. * @param camera The camera to apply the render pass to.
  62487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62488. * @param engine The engine which the post process will be applied. (default: current engine)
  62489. * @param reusable If the post process can be reused on the same frame. (default: false)
  62490. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62491. */
  62492. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62493. }
  62494. }
  62495. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62496. /** @hidden */
  62497. export var mrtFragmentDeclaration: {
  62498. name: string;
  62499. shader: string;
  62500. };
  62501. }
  62502. declare module "babylonjs/Shaders/geometry.fragment" {
  62503. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62504. /** @hidden */
  62505. export var geometryPixelShader: {
  62506. name: string;
  62507. shader: string;
  62508. };
  62509. }
  62510. declare module "babylonjs/Shaders/geometry.vertex" {
  62511. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62512. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62514. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62515. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62516. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62517. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62518. /** @hidden */
  62519. export var geometryVertexShader: {
  62520. name: string;
  62521. shader: string;
  62522. };
  62523. }
  62524. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62525. import { Matrix } from "babylonjs/Maths/math.vector";
  62526. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62527. import { Mesh } from "babylonjs/Meshes/mesh";
  62528. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62529. import { Effect } from "babylonjs/Materials/effect";
  62530. import { Scene } from "babylonjs/scene";
  62531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62532. import "babylonjs/Shaders/geometry.fragment";
  62533. import "babylonjs/Shaders/geometry.vertex";
  62534. /** @hidden */
  62535. interface ISavedTransformationMatrix {
  62536. world: Matrix;
  62537. viewProjection: Matrix;
  62538. }
  62539. /**
  62540. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62541. */
  62542. export class GeometryBufferRenderer {
  62543. /**
  62544. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62545. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62546. */
  62547. static readonly POSITION_TEXTURE_TYPE: number;
  62548. /**
  62549. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62550. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62551. */
  62552. static readonly VELOCITY_TEXTURE_TYPE: number;
  62553. /**
  62554. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62555. * in order to compute objects velocities when enableVelocity is set to "true"
  62556. * @hidden
  62557. */
  62558. _previousTransformationMatrices: {
  62559. [index: number]: ISavedTransformationMatrix;
  62560. };
  62561. /**
  62562. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62563. * in order to compute objects velocities when enableVelocity is set to "true"
  62564. * @hidden
  62565. */
  62566. _previousBonesTransformationMatrices: {
  62567. [index: number]: Float32Array;
  62568. };
  62569. /**
  62570. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62571. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62572. */
  62573. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62574. private _scene;
  62575. private _multiRenderTarget;
  62576. private _ratio;
  62577. private _enablePosition;
  62578. private _enableVelocity;
  62579. private _positionIndex;
  62580. private _velocityIndex;
  62581. protected _effect: Effect;
  62582. protected _cachedDefines: string;
  62583. /**
  62584. * Set the render list (meshes to be rendered) used in the G buffer.
  62585. */
  62586. renderList: Mesh[];
  62587. /**
  62588. * Gets wether or not G buffer are supported by the running hardware.
  62589. * This requires draw buffer supports
  62590. */
  62591. readonly isSupported: boolean;
  62592. /**
  62593. * Returns the index of the given texture type in the G-Buffer textures array
  62594. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62595. * @returns the index of the given texture type in the G-Buffer textures array
  62596. */
  62597. getTextureIndex(textureType: number): number;
  62598. /**
  62599. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62600. */
  62601. /**
  62602. * Sets whether or not objects positions are enabled for the G buffer.
  62603. */
  62604. enablePosition: boolean;
  62605. /**
  62606. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62607. */
  62608. /**
  62609. * Sets wether or not objects velocities are enabled for the G buffer.
  62610. */
  62611. enableVelocity: boolean;
  62612. /**
  62613. * Gets the scene associated with the buffer.
  62614. */
  62615. readonly scene: Scene;
  62616. /**
  62617. * Gets the ratio used by the buffer during its creation.
  62618. * How big is the buffer related to the main canvas.
  62619. */
  62620. readonly ratio: number;
  62621. /** @hidden */
  62622. static _SceneComponentInitialization: (scene: Scene) => void;
  62623. /**
  62624. * Creates a new G Buffer for the scene
  62625. * @param scene The scene the buffer belongs to
  62626. * @param ratio How big is the buffer related to the main canvas.
  62627. */
  62628. constructor(scene: Scene, ratio?: number);
  62629. /**
  62630. * Checks wether everything is ready to render a submesh to the G buffer.
  62631. * @param subMesh the submesh to check readiness for
  62632. * @param useInstances is the mesh drawn using instance or not
  62633. * @returns true if ready otherwise false
  62634. */
  62635. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62636. /**
  62637. * Gets the current underlying G Buffer.
  62638. * @returns the buffer
  62639. */
  62640. getGBuffer(): MultiRenderTarget;
  62641. /**
  62642. * Gets the number of samples used to render the buffer (anti aliasing).
  62643. */
  62644. /**
  62645. * Sets the number of samples used to render the buffer (anti aliasing).
  62646. */
  62647. samples: number;
  62648. /**
  62649. * Disposes the renderer and frees up associated resources.
  62650. */
  62651. dispose(): void;
  62652. protected _createRenderTargets(): void;
  62653. private _copyBonesTransformationMatrices;
  62654. }
  62655. }
  62656. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62657. import { Nullable } from "babylonjs/types";
  62658. import { Scene } from "babylonjs/scene";
  62659. import { ISceneComponent } from "babylonjs/sceneComponent";
  62660. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62661. module "babylonjs/scene" {
  62662. interface Scene {
  62663. /** @hidden (Backing field) */
  62664. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62665. /**
  62666. * Gets or Sets the current geometry buffer associated to the scene.
  62667. */
  62668. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62669. /**
  62670. * Enables a GeometryBufferRender and associates it with the scene
  62671. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62672. * @returns the GeometryBufferRenderer
  62673. */
  62674. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62675. /**
  62676. * Disables the GeometryBufferRender associated with the scene
  62677. */
  62678. disableGeometryBufferRenderer(): void;
  62679. }
  62680. }
  62681. /**
  62682. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62683. * in several rendering techniques.
  62684. */
  62685. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62686. /**
  62687. * The component name helpful to identify the component in the list of scene components.
  62688. */
  62689. readonly name: string;
  62690. /**
  62691. * The scene the component belongs to.
  62692. */
  62693. scene: Scene;
  62694. /**
  62695. * Creates a new instance of the component for the given scene
  62696. * @param scene Defines the scene to register the component in
  62697. */
  62698. constructor(scene: Scene);
  62699. /**
  62700. * Registers the component in a given scene
  62701. */
  62702. register(): void;
  62703. /**
  62704. * Rebuilds the elements related to this component in case of
  62705. * context lost for instance.
  62706. */
  62707. rebuild(): void;
  62708. /**
  62709. * Disposes the component and the associated ressources
  62710. */
  62711. dispose(): void;
  62712. private _gatherRenderTargets;
  62713. }
  62714. }
  62715. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62716. /** @hidden */
  62717. export var motionBlurPixelShader: {
  62718. name: string;
  62719. shader: string;
  62720. };
  62721. }
  62722. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62723. import { Nullable } from "babylonjs/types";
  62724. import { Camera } from "babylonjs/Cameras/camera";
  62725. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62726. import { Scene } from "babylonjs/scene";
  62727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62728. import "babylonjs/Animations/animatable";
  62729. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62730. import "babylonjs/Shaders/motionBlur.fragment";
  62731. import { Engine } from "babylonjs/Engines/engine";
  62732. /**
  62733. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62734. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62735. * As an example, all you have to do is to create the post-process:
  62736. * var mb = new BABYLON.MotionBlurPostProcess(
  62737. * 'mb', // The name of the effect.
  62738. * scene, // The scene containing the objects to blur according to their velocity.
  62739. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62740. * camera // The camera to apply the render pass to.
  62741. * );
  62742. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62743. */
  62744. export class MotionBlurPostProcess extends PostProcess {
  62745. /**
  62746. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62747. */
  62748. motionStrength: number;
  62749. /**
  62750. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62751. */
  62752. /**
  62753. * Sets the number of iterations to be used for motion blur quality
  62754. */
  62755. motionBlurSamples: number;
  62756. private _motionBlurSamples;
  62757. private _geometryBufferRenderer;
  62758. /**
  62759. * Creates a new instance MotionBlurPostProcess
  62760. * @param name The name of the effect.
  62761. * @param scene The scene containing the objects to blur according to their velocity.
  62762. * @param options The required width/height ratio to downsize to before computing the render pass.
  62763. * @param camera The camera to apply the render pass to.
  62764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62765. * @param engine The engine which the post process will be applied. (default: current engine)
  62766. * @param reusable If the post process can be reused on the same frame. (default: false)
  62767. * @param textureType Type of textures used when performing the post process. (default: 0)
  62768. * @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)
  62769. */
  62770. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62771. /**
  62772. * Excludes the given skinned mesh from computing bones velocities.
  62773. * 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.
  62774. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62775. */
  62776. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62777. /**
  62778. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62779. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62780. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62781. */
  62782. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62783. /**
  62784. * Disposes the post process.
  62785. * @param camera The camera to dispose the post process on.
  62786. */
  62787. dispose(camera?: Camera): void;
  62788. }
  62789. }
  62790. declare module "babylonjs/Shaders/refraction.fragment" {
  62791. /** @hidden */
  62792. export var refractionPixelShader: {
  62793. name: string;
  62794. shader: string;
  62795. };
  62796. }
  62797. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62798. import { Color3 } from "babylonjs/Maths/math.color";
  62799. import { Camera } from "babylonjs/Cameras/camera";
  62800. import { Texture } from "babylonjs/Materials/Textures/texture";
  62801. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62802. import { Engine } from "babylonjs/Engines/engine";
  62803. import "babylonjs/Shaders/refraction.fragment";
  62804. /**
  62805. * Post process which applies a refractin texture
  62806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62807. */
  62808. export class RefractionPostProcess extends PostProcess {
  62809. /** the base color of the refraction (used to taint the rendering) */
  62810. color: Color3;
  62811. /** simulated refraction depth */
  62812. depth: number;
  62813. /** the coefficient of the base color (0 to remove base color tainting) */
  62814. colorLevel: number;
  62815. private _refTexture;
  62816. private _ownRefractionTexture;
  62817. /**
  62818. * Gets or sets the refraction texture
  62819. * Please note that you are responsible for disposing the texture if you set it manually
  62820. */
  62821. refractionTexture: Texture;
  62822. /**
  62823. * Initializes the RefractionPostProcess
  62824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62825. * @param name The name of the effect.
  62826. * @param refractionTextureUrl Url of the refraction texture to use
  62827. * @param color the base color of the refraction (used to taint the rendering)
  62828. * @param depth simulated refraction depth
  62829. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62830. * @param camera The camera to apply the render pass to.
  62831. * @param options The required width/height ratio to downsize to before computing the render pass.
  62832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62833. * @param engine The engine which the post process will be applied. (default: current engine)
  62834. * @param reusable If the post process can be reused on the same frame. (default: false)
  62835. */
  62836. constructor(name: string, refractionTextureUrl: string,
  62837. /** the base color of the refraction (used to taint the rendering) */
  62838. color: Color3,
  62839. /** simulated refraction depth */
  62840. depth: number,
  62841. /** the coefficient of the base color (0 to remove base color tainting) */
  62842. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62843. /**
  62844. * Disposes of the post process
  62845. * @param camera Camera to dispose post process on
  62846. */
  62847. dispose(camera: Camera): void;
  62848. }
  62849. }
  62850. declare module "babylonjs/Shaders/sharpen.fragment" {
  62851. /** @hidden */
  62852. export var sharpenPixelShader: {
  62853. name: string;
  62854. shader: string;
  62855. };
  62856. }
  62857. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62858. import { Nullable } from "babylonjs/types";
  62859. import { Camera } from "babylonjs/Cameras/camera";
  62860. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62861. import "babylonjs/Shaders/sharpen.fragment";
  62862. import { Engine } from "babylonjs/Engines/engine";
  62863. /**
  62864. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62865. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62866. */
  62867. export class SharpenPostProcess extends PostProcess {
  62868. /**
  62869. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62870. */
  62871. colorAmount: number;
  62872. /**
  62873. * How much sharpness should be applied (default: 0.3)
  62874. */
  62875. edgeAmount: number;
  62876. /**
  62877. * Creates a new instance ConvolutionPostProcess
  62878. * @param name The name of the effect.
  62879. * @param options The required width/height ratio to downsize to before computing the render pass.
  62880. * @param camera The camera to apply the render pass to.
  62881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62882. * @param engine The engine which the post process will be applied. (default: current engine)
  62883. * @param reusable If the post process can be reused on the same frame. (default: false)
  62884. * @param textureType Type of textures used when performing the post process. (default: 0)
  62885. * @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)
  62886. */
  62887. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62888. }
  62889. }
  62890. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62891. import { Nullable } from "babylonjs/types";
  62892. import { Camera } from "babylonjs/Cameras/camera";
  62893. import { Engine } from "babylonjs/Engines/engine";
  62894. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62895. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62896. /**
  62897. * PostProcessRenderPipeline
  62898. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62899. */
  62900. export class PostProcessRenderPipeline {
  62901. private engine;
  62902. private _renderEffects;
  62903. private _renderEffectsForIsolatedPass;
  62904. /**
  62905. * List of inspectable custom properties (used by the Inspector)
  62906. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62907. */
  62908. inspectableCustomProperties: IInspectable[];
  62909. /**
  62910. * @hidden
  62911. */
  62912. protected _cameras: Camera[];
  62913. /** @hidden */
  62914. _name: string;
  62915. /**
  62916. * Gets pipeline name
  62917. */
  62918. readonly name: string;
  62919. /**
  62920. * Initializes a PostProcessRenderPipeline
  62921. * @param engine engine to add the pipeline to
  62922. * @param name name of the pipeline
  62923. */
  62924. constructor(engine: Engine, name: string);
  62925. /**
  62926. * Gets the class name
  62927. * @returns "PostProcessRenderPipeline"
  62928. */
  62929. getClassName(): string;
  62930. /**
  62931. * If all the render effects in the pipeline are supported
  62932. */
  62933. readonly isSupported: boolean;
  62934. /**
  62935. * Adds an effect to the pipeline
  62936. * @param renderEffect the effect to add
  62937. */
  62938. addEffect(renderEffect: PostProcessRenderEffect): void;
  62939. /** @hidden */
  62940. _rebuild(): void;
  62941. /** @hidden */
  62942. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62943. /** @hidden */
  62944. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62945. /** @hidden */
  62946. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62947. /** @hidden */
  62948. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62949. /** @hidden */
  62950. _attachCameras(cameras: Camera, unique: boolean): void;
  62951. /** @hidden */
  62952. _attachCameras(cameras: Camera[], unique: boolean): void;
  62953. /** @hidden */
  62954. _detachCameras(cameras: Camera): void;
  62955. /** @hidden */
  62956. _detachCameras(cameras: Nullable<Camera[]>): void;
  62957. /** @hidden */
  62958. _update(): void;
  62959. /** @hidden */
  62960. _reset(): void;
  62961. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62962. /**
  62963. * Disposes of the pipeline
  62964. */
  62965. dispose(): void;
  62966. }
  62967. }
  62968. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62969. import { Camera } from "babylonjs/Cameras/camera";
  62970. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62971. /**
  62972. * PostProcessRenderPipelineManager class
  62973. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62974. */
  62975. export class PostProcessRenderPipelineManager {
  62976. private _renderPipelines;
  62977. /**
  62978. * Initializes a PostProcessRenderPipelineManager
  62979. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62980. */
  62981. constructor();
  62982. /**
  62983. * Gets the list of supported render pipelines
  62984. */
  62985. readonly supportedPipelines: PostProcessRenderPipeline[];
  62986. /**
  62987. * Adds a pipeline to the manager
  62988. * @param renderPipeline The pipeline to add
  62989. */
  62990. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62991. /**
  62992. * Attaches a camera to the pipeline
  62993. * @param renderPipelineName The name of the pipeline to attach to
  62994. * @param cameras the camera to attach
  62995. * @param unique if the camera can be attached multiple times to the pipeline
  62996. */
  62997. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62998. /**
  62999. * Detaches a camera from the pipeline
  63000. * @param renderPipelineName The name of the pipeline to detach from
  63001. * @param cameras the camera to detach
  63002. */
  63003. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63004. /**
  63005. * Enables an effect by name on a pipeline
  63006. * @param renderPipelineName the name of the pipeline to enable the effect in
  63007. * @param renderEffectName the name of the effect to enable
  63008. * @param cameras the cameras that the effect should be enabled on
  63009. */
  63010. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63011. /**
  63012. * Disables an effect by name on a pipeline
  63013. * @param renderPipelineName the name of the pipeline to disable the effect in
  63014. * @param renderEffectName the name of the effect to disable
  63015. * @param cameras the cameras that the effect should be disabled on
  63016. */
  63017. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63018. /**
  63019. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63020. */
  63021. update(): void;
  63022. /** @hidden */
  63023. _rebuild(): void;
  63024. /**
  63025. * Disposes of the manager and pipelines
  63026. */
  63027. dispose(): void;
  63028. }
  63029. }
  63030. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63031. import { ISceneComponent } from "babylonjs/sceneComponent";
  63032. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63033. import { Scene } from "babylonjs/scene";
  63034. module "babylonjs/scene" {
  63035. interface Scene {
  63036. /** @hidden (Backing field) */
  63037. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63038. /**
  63039. * Gets the postprocess render pipeline manager
  63040. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63041. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63042. */
  63043. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63044. }
  63045. }
  63046. /**
  63047. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63048. */
  63049. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63050. /**
  63051. * The component name helpfull to identify the component in the list of scene components.
  63052. */
  63053. readonly name: string;
  63054. /**
  63055. * The scene the component belongs to.
  63056. */
  63057. scene: Scene;
  63058. /**
  63059. * Creates a new instance of the component for the given scene
  63060. * @param scene Defines the scene to register the component in
  63061. */
  63062. constructor(scene: Scene);
  63063. /**
  63064. * Registers the component in a given scene
  63065. */
  63066. register(): void;
  63067. /**
  63068. * Rebuilds the elements related to this component in case of
  63069. * context lost for instance.
  63070. */
  63071. rebuild(): void;
  63072. /**
  63073. * Disposes the component and the associated ressources
  63074. */
  63075. dispose(): void;
  63076. private _gatherRenderTargets;
  63077. }
  63078. }
  63079. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63080. import { Nullable } from "babylonjs/types";
  63081. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63082. import { Camera } from "babylonjs/Cameras/camera";
  63083. import { IDisposable } from "babylonjs/scene";
  63084. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63085. import { Scene } from "babylonjs/scene";
  63086. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63087. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63088. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63089. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63090. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63091. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63092. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63093. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63094. import { Animation } from "babylonjs/Animations/animation";
  63095. /**
  63096. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63097. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63098. */
  63099. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63100. private _scene;
  63101. private _camerasToBeAttached;
  63102. /**
  63103. * ID of the sharpen post process,
  63104. */
  63105. private readonly SharpenPostProcessId;
  63106. /**
  63107. * @ignore
  63108. * ID of the image processing post process;
  63109. */
  63110. readonly ImageProcessingPostProcessId: string;
  63111. /**
  63112. * @ignore
  63113. * ID of the Fast Approximate Anti-Aliasing post process;
  63114. */
  63115. readonly FxaaPostProcessId: string;
  63116. /**
  63117. * ID of the chromatic aberration post process,
  63118. */
  63119. private readonly ChromaticAberrationPostProcessId;
  63120. /**
  63121. * ID of the grain post process
  63122. */
  63123. private readonly GrainPostProcessId;
  63124. /**
  63125. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63126. */
  63127. sharpen: SharpenPostProcess;
  63128. private _sharpenEffect;
  63129. private bloom;
  63130. /**
  63131. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63132. */
  63133. depthOfField: DepthOfFieldEffect;
  63134. /**
  63135. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63136. */
  63137. fxaa: FxaaPostProcess;
  63138. /**
  63139. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63140. */
  63141. imageProcessing: ImageProcessingPostProcess;
  63142. /**
  63143. * Chromatic aberration post process which will shift rgb colors in the image
  63144. */
  63145. chromaticAberration: ChromaticAberrationPostProcess;
  63146. private _chromaticAberrationEffect;
  63147. /**
  63148. * Grain post process which add noise to the image
  63149. */
  63150. grain: GrainPostProcess;
  63151. private _grainEffect;
  63152. /**
  63153. * Glow post process which adds a glow to emissive areas of the image
  63154. */
  63155. private _glowLayer;
  63156. /**
  63157. * Animations which can be used to tweak settings over a period of time
  63158. */
  63159. animations: Animation[];
  63160. private _imageProcessingConfigurationObserver;
  63161. private _sharpenEnabled;
  63162. private _bloomEnabled;
  63163. private _depthOfFieldEnabled;
  63164. private _depthOfFieldBlurLevel;
  63165. private _fxaaEnabled;
  63166. private _imageProcessingEnabled;
  63167. private _defaultPipelineTextureType;
  63168. private _bloomScale;
  63169. private _chromaticAberrationEnabled;
  63170. private _grainEnabled;
  63171. private _buildAllowed;
  63172. /**
  63173. * Gets active scene
  63174. */
  63175. readonly scene: Scene;
  63176. /**
  63177. * Enable or disable the sharpen process from the pipeline
  63178. */
  63179. sharpenEnabled: boolean;
  63180. private _resizeObserver;
  63181. private _hardwareScaleLevel;
  63182. private _bloomKernel;
  63183. /**
  63184. * Specifies the size of the bloom blur kernel, relative to the final output size
  63185. */
  63186. bloomKernel: number;
  63187. /**
  63188. * Specifies the weight of the bloom in the final rendering
  63189. */
  63190. private _bloomWeight;
  63191. /**
  63192. * Specifies the luma threshold for the area that will be blurred by the bloom
  63193. */
  63194. private _bloomThreshold;
  63195. private _hdr;
  63196. /**
  63197. * The strength of the bloom.
  63198. */
  63199. bloomWeight: number;
  63200. /**
  63201. * The strength of the bloom.
  63202. */
  63203. bloomThreshold: number;
  63204. /**
  63205. * The scale of the bloom, lower value will provide better performance.
  63206. */
  63207. bloomScale: number;
  63208. /**
  63209. * Enable or disable the bloom from the pipeline
  63210. */
  63211. bloomEnabled: boolean;
  63212. private _rebuildBloom;
  63213. /**
  63214. * If the depth of field is enabled.
  63215. */
  63216. depthOfFieldEnabled: boolean;
  63217. /**
  63218. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63219. */
  63220. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63221. /**
  63222. * If the anti aliasing is enabled.
  63223. */
  63224. fxaaEnabled: boolean;
  63225. private _samples;
  63226. /**
  63227. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63228. */
  63229. samples: number;
  63230. /**
  63231. * If image processing is enabled.
  63232. */
  63233. imageProcessingEnabled: boolean;
  63234. /**
  63235. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63236. */
  63237. glowLayerEnabled: boolean;
  63238. /**
  63239. * Gets the glow layer (or null if not defined)
  63240. */
  63241. readonly glowLayer: Nullable<GlowLayer>;
  63242. /**
  63243. * Enable or disable the chromaticAberration process from the pipeline
  63244. */
  63245. chromaticAberrationEnabled: boolean;
  63246. /**
  63247. * Enable or disable the grain process from the pipeline
  63248. */
  63249. grainEnabled: boolean;
  63250. /**
  63251. * @constructor
  63252. * @param name - The rendering pipeline name (default: "")
  63253. * @param hdr - If high dynamic range textures should be used (default: true)
  63254. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63255. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63256. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63257. */
  63258. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63259. /**
  63260. * Get the class name
  63261. * @returns "DefaultRenderingPipeline"
  63262. */
  63263. getClassName(): string;
  63264. /**
  63265. * Force the compilation of the entire pipeline.
  63266. */
  63267. prepare(): void;
  63268. private _hasCleared;
  63269. private _prevPostProcess;
  63270. private _prevPrevPostProcess;
  63271. private _setAutoClearAndTextureSharing;
  63272. private _depthOfFieldSceneObserver;
  63273. private _buildPipeline;
  63274. private _disposePostProcesses;
  63275. /**
  63276. * Adds a camera to the pipeline
  63277. * @param camera the camera to be added
  63278. */
  63279. addCamera(camera: Camera): void;
  63280. /**
  63281. * Removes a camera from the pipeline
  63282. * @param camera the camera to remove
  63283. */
  63284. removeCamera(camera: Camera): void;
  63285. /**
  63286. * Dispose of the pipeline and stop all post processes
  63287. */
  63288. dispose(): void;
  63289. /**
  63290. * Serialize the rendering pipeline (Used when exporting)
  63291. * @returns the serialized object
  63292. */
  63293. serialize(): any;
  63294. /**
  63295. * Parse the serialized pipeline
  63296. * @param source Source pipeline.
  63297. * @param scene The scene to load the pipeline to.
  63298. * @param rootUrl The URL of the serialized pipeline.
  63299. * @returns An instantiated pipeline from the serialized object.
  63300. */
  63301. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63302. }
  63303. }
  63304. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63305. /** @hidden */
  63306. export var lensHighlightsPixelShader: {
  63307. name: string;
  63308. shader: string;
  63309. };
  63310. }
  63311. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63312. /** @hidden */
  63313. export var depthOfFieldPixelShader: {
  63314. name: string;
  63315. shader: string;
  63316. };
  63317. }
  63318. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63319. import { Camera } from "babylonjs/Cameras/camera";
  63320. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63321. import { Scene } from "babylonjs/scene";
  63322. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63323. import "babylonjs/Shaders/chromaticAberration.fragment";
  63324. import "babylonjs/Shaders/lensHighlights.fragment";
  63325. import "babylonjs/Shaders/depthOfField.fragment";
  63326. /**
  63327. * BABYLON.JS Chromatic Aberration GLSL Shader
  63328. * Author: Olivier Guyot
  63329. * Separates very slightly R, G and B colors on the edges of the screen
  63330. * Inspired by Francois Tarlier & Martins Upitis
  63331. */
  63332. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63333. /**
  63334. * @ignore
  63335. * The chromatic aberration PostProcess id in the pipeline
  63336. */
  63337. LensChromaticAberrationEffect: string;
  63338. /**
  63339. * @ignore
  63340. * The highlights enhancing PostProcess id in the pipeline
  63341. */
  63342. HighlightsEnhancingEffect: string;
  63343. /**
  63344. * @ignore
  63345. * The depth-of-field PostProcess id in the pipeline
  63346. */
  63347. LensDepthOfFieldEffect: string;
  63348. private _scene;
  63349. private _depthTexture;
  63350. private _grainTexture;
  63351. private _chromaticAberrationPostProcess;
  63352. private _highlightsPostProcess;
  63353. private _depthOfFieldPostProcess;
  63354. private _edgeBlur;
  63355. private _grainAmount;
  63356. private _chromaticAberration;
  63357. private _distortion;
  63358. private _highlightsGain;
  63359. private _highlightsThreshold;
  63360. private _dofDistance;
  63361. private _dofAperture;
  63362. private _dofDarken;
  63363. private _dofPentagon;
  63364. private _blurNoise;
  63365. /**
  63366. * @constructor
  63367. *
  63368. * Effect parameters are as follow:
  63369. * {
  63370. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63371. * edge_blur: number; // from 0 to x (1 for realism)
  63372. * distortion: number; // from 0 to x (1 for realism)
  63373. * grain_amount: number; // from 0 to 1
  63374. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63375. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63376. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63377. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63378. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63379. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63380. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63381. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63382. * }
  63383. * Note: if an effect parameter is unset, effect is disabled
  63384. *
  63385. * @param name The rendering pipeline name
  63386. * @param parameters - An object containing all parameters (see above)
  63387. * @param scene The scene linked to this pipeline
  63388. * @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)
  63389. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63390. */
  63391. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63392. /**
  63393. * Get the class name
  63394. * @returns "LensRenderingPipeline"
  63395. */
  63396. getClassName(): string;
  63397. /**
  63398. * Gets associated scene
  63399. */
  63400. readonly scene: Scene;
  63401. /**
  63402. * Gets or sets the edge blur
  63403. */
  63404. edgeBlur: number;
  63405. /**
  63406. * Gets or sets the grain amount
  63407. */
  63408. grainAmount: number;
  63409. /**
  63410. * Gets or sets the chromatic aberration amount
  63411. */
  63412. chromaticAberration: number;
  63413. /**
  63414. * Gets or sets the depth of field aperture
  63415. */
  63416. dofAperture: number;
  63417. /**
  63418. * Gets or sets the edge distortion
  63419. */
  63420. edgeDistortion: number;
  63421. /**
  63422. * Gets or sets the depth of field distortion
  63423. */
  63424. dofDistortion: number;
  63425. /**
  63426. * Gets or sets the darken out of focus amount
  63427. */
  63428. darkenOutOfFocus: number;
  63429. /**
  63430. * Gets or sets a boolean indicating if blur noise is enabled
  63431. */
  63432. blurNoise: boolean;
  63433. /**
  63434. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63435. */
  63436. pentagonBokeh: boolean;
  63437. /**
  63438. * Gets or sets the highlight grain amount
  63439. */
  63440. highlightsGain: number;
  63441. /**
  63442. * Gets or sets the highlight threshold
  63443. */
  63444. highlightsThreshold: number;
  63445. /**
  63446. * Sets the amount of blur at the edges
  63447. * @param amount blur amount
  63448. */
  63449. setEdgeBlur(amount: number): void;
  63450. /**
  63451. * Sets edge blur to 0
  63452. */
  63453. disableEdgeBlur(): void;
  63454. /**
  63455. * Sets the amout of grain
  63456. * @param amount Amount of grain
  63457. */
  63458. setGrainAmount(amount: number): void;
  63459. /**
  63460. * Set grain amount to 0
  63461. */
  63462. disableGrain(): void;
  63463. /**
  63464. * Sets the chromatic aberration amount
  63465. * @param amount amount of chromatic aberration
  63466. */
  63467. setChromaticAberration(amount: number): void;
  63468. /**
  63469. * Sets chromatic aberration amount to 0
  63470. */
  63471. disableChromaticAberration(): void;
  63472. /**
  63473. * Sets the EdgeDistortion amount
  63474. * @param amount amount of EdgeDistortion
  63475. */
  63476. setEdgeDistortion(amount: number): void;
  63477. /**
  63478. * Sets edge distortion to 0
  63479. */
  63480. disableEdgeDistortion(): void;
  63481. /**
  63482. * Sets the FocusDistance amount
  63483. * @param amount amount of FocusDistance
  63484. */
  63485. setFocusDistance(amount: number): void;
  63486. /**
  63487. * Disables depth of field
  63488. */
  63489. disableDepthOfField(): void;
  63490. /**
  63491. * Sets the Aperture amount
  63492. * @param amount amount of Aperture
  63493. */
  63494. setAperture(amount: number): void;
  63495. /**
  63496. * Sets the DarkenOutOfFocus amount
  63497. * @param amount amount of DarkenOutOfFocus
  63498. */
  63499. setDarkenOutOfFocus(amount: number): void;
  63500. private _pentagonBokehIsEnabled;
  63501. /**
  63502. * Creates a pentagon bokeh effect
  63503. */
  63504. enablePentagonBokeh(): void;
  63505. /**
  63506. * Disables the pentagon bokeh effect
  63507. */
  63508. disablePentagonBokeh(): void;
  63509. /**
  63510. * Enables noise blur
  63511. */
  63512. enableNoiseBlur(): void;
  63513. /**
  63514. * Disables noise blur
  63515. */
  63516. disableNoiseBlur(): void;
  63517. /**
  63518. * Sets the HighlightsGain amount
  63519. * @param amount amount of HighlightsGain
  63520. */
  63521. setHighlightsGain(amount: number): void;
  63522. /**
  63523. * Sets the HighlightsThreshold amount
  63524. * @param amount amount of HighlightsThreshold
  63525. */
  63526. setHighlightsThreshold(amount: number): void;
  63527. /**
  63528. * Disables highlights
  63529. */
  63530. disableHighlights(): void;
  63531. /**
  63532. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63533. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63534. */
  63535. dispose(disableDepthRender?: boolean): void;
  63536. private _createChromaticAberrationPostProcess;
  63537. private _createHighlightsPostProcess;
  63538. private _createDepthOfFieldPostProcess;
  63539. private _createGrainTexture;
  63540. }
  63541. }
  63542. declare module "babylonjs/Shaders/ssao2.fragment" {
  63543. /** @hidden */
  63544. export var ssao2PixelShader: {
  63545. name: string;
  63546. shader: string;
  63547. };
  63548. }
  63549. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63550. /** @hidden */
  63551. export var ssaoCombinePixelShader: {
  63552. name: string;
  63553. shader: string;
  63554. };
  63555. }
  63556. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63557. import { Camera } from "babylonjs/Cameras/camera";
  63558. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63559. import { Scene } from "babylonjs/scene";
  63560. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63561. import "babylonjs/Shaders/ssao2.fragment";
  63562. import "babylonjs/Shaders/ssaoCombine.fragment";
  63563. /**
  63564. * Render pipeline to produce ssao effect
  63565. */
  63566. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63567. /**
  63568. * @ignore
  63569. * The PassPostProcess id in the pipeline that contains the original scene color
  63570. */
  63571. SSAOOriginalSceneColorEffect: string;
  63572. /**
  63573. * @ignore
  63574. * The SSAO PostProcess id in the pipeline
  63575. */
  63576. SSAORenderEffect: string;
  63577. /**
  63578. * @ignore
  63579. * The horizontal blur PostProcess id in the pipeline
  63580. */
  63581. SSAOBlurHRenderEffect: string;
  63582. /**
  63583. * @ignore
  63584. * The vertical blur PostProcess id in the pipeline
  63585. */
  63586. SSAOBlurVRenderEffect: string;
  63587. /**
  63588. * @ignore
  63589. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63590. */
  63591. SSAOCombineRenderEffect: string;
  63592. /**
  63593. * The output strength of the SSAO post-process. Default value is 1.0.
  63594. */
  63595. totalStrength: number;
  63596. /**
  63597. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63598. */
  63599. maxZ: number;
  63600. /**
  63601. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63602. */
  63603. minZAspect: number;
  63604. private _samples;
  63605. /**
  63606. * Number of samples used for the SSAO calculations. Default value is 8
  63607. */
  63608. samples: number;
  63609. private _textureSamples;
  63610. /**
  63611. * Number of samples to use for antialiasing
  63612. */
  63613. textureSamples: number;
  63614. /**
  63615. * Ratio object used for SSAO ratio and blur ratio
  63616. */
  63617. private _ratio;
  63618. /**
  63619. * Dynamically generated sphere sampler.
  63620. */
  63621. private _sampleSphere;
  63622. /**
  63623. * Blur filter offsets
  63624. */
  63625. private _samplerOffsets;
  63626. private _expensiveBlur;
  63627. /**
  63628. * If bilateral blur should be used
  63629. */
  63630. expensiveBlur: boolean;
  63631. /**
  63632. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63633. */
  63634. radius: number;
  63635. /**
  63636. * The base color of the SSAO post-process
  63637. * The final result is "base + ssao" between [0, 1]
  63638. */
  63639. base: number;
  63640. /**
  63641. * Support test.
  63642. */
  63643. static readonly IsSupported: boolean;
  63644. private _scene;
  63645. private _depthTexture;
  63646. private _normalTexture;
  63647. private _randomTexture;
  63648. private _originalColorPostProcess;
  63649. private _ssaoPostProcess;
  63650. private _blurHPostProcess;
  63651. private _blurVPostProcess;
  63652. private _ssaoCombinePostProcess;
  63653. private _firstUpdate;
  63654. /**
  63655. * Gets active scene
  63656. */
  63657. readonly scene: Scene;
  63658. /**
  63659. * @constructor
  63660. * @param name The rendering pipeline name
  63661. * @param scene The scene linked to this pipeline
  63662. * @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 }
  63663. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63664. */
  63665. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63666. /**
  63667. * Get the class name
  63668. * @returns "SSAO2RenderingPipeline"
  63669. */
  63670. getClassName(): string;
  63671. /**
  63672. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63673. */
  63674. dispose(disableGeometryBufferRenderer?: boolean): void;
  63675. private _createBlurPostProcess;
  63676. /** @hidden */
  63677. _rebuild(): void;
  63678. private _bits;
  63679. private _radicalInverse_VdC;
  63680. private _hammersley;
  63681. private _hemisphereSample_uniform;
  63682. private _generateHemisphere;
  63683. private _createSSAOPostProcess;
  63684. private _createSSAOCombinePostProcess;
  63685. private _createRandomTexture;
  63686. /**
  63687. * Serialize the rendering pipeline (Used when exporting)
  63688. * @returns the serialized object
  63689. */
  63690. serialize(): any;
  63691. /**
  63692. * Parse the serialized pipeline
  63693. * @param source Source pipeline.
  63694. * @param scene The scene to load the pipeline to.
  63695. * @param rootUrl The URL of the serialized pipeline.
  63696. * @returns An instantiated pipeline from the serialized object.
  63697. */
  63698. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63699. }
  63700. }
  63701. declare module "babylonjs/Shaders/ssao.fragment" {
  63702. /** @hidden */
  63703. export var ssaoPixelShader: {
  63704. name: string;
  63705. shader: string;
  63706. };
  63707. }
  63708. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63709. import { Camera } from "babylonjs/Cameras/camera";
  63710. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63711. import { Scene } from "babylonjs/scene";
  63712. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63713. import "babylonjs/Shaders/ssao.fragment";
  63714. import "babylonjs/Shaders/ssaoCombine.fragment";
  63715. /**
  63716. * Render pipeline to produce ssao effect
  63717. */
  63718. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63719. /**
  63720. * @ignore
  63721. * The PassPostProcess id in the pipeline that contains the original scene color
  63722. */
  63723. SSAOOriginalSceneColorEffect: string;
  63724. /**
  63725. * @ignore
  63726. * The SSAO PostProcess id in the pipeline
  63727. */
  63728. SSAORenderEffect: string;
  63729. /**
  63730. * @ignore
  63731. * The horizontal blur PostProcess id in the pipeline
  63732. */
  63733. SSAOBlurHRenderEffect: string;
  63734. /**
  63735. * @ignore
  63736. * The vertical blur PostProcess id in the pipeline
  63737. */
  63738. SSAOBlurVRenderEffect: string;
  63739. /**
  63740. * @ignore
  63741. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63742. */
  63743. SSAOCombineRenderEffect: string;
  63744. /**
  63745. * The output strength of the SSAO post-process. Default value is 1.0.
  63746. */
  63747. totalStrength: number;
  63748. /**
  63749. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63750. */
  63751. radius: number;
  63752. /**
  63753. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63754. * Must not be equal to fallOff and superior to fallOff.
  63755. * Default value is 0.0075
  63756. */
  63757. area: number;
  63758. /**
  63759. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63760. * Must not be equal to area and inferior to area.
  63761. * Default value is 0.000001
  63762. */
  63763. fallOff: number;
  63764. /**
  63765. * The base color of the SSAO post-process
  63766. * The final result is "base + ssao" between [0, 1]
  63767. */
  63768. base: number;
  63769. private _scene;
  63770. private _depthTexture;
  63771. private _randomTexture;
  63772. private _originalColorPostProcess;
  63773. private _ssaoPostProcess;
  63774. private _blurHPostProcess;
  63775. private _blurVPostProcess;
  63776. private _ssaoCombinePostProcess;
  63777. private _firstUpdate;
  63778. /**
  63779. * Gets active scene
  63780. */
  63781. readonly scene: Scene;
  63782. /**
  63783. * @constructor
  63784. * @param name - The rendering pipeline name
  63785. * @param scene - The scene linked to this pipeline
  63786. * @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 }
  63787. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63788. */
  63789. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63790. /**
  63791. * Get the class name
  63792. * @returns "SSAORenderingPipeline"
  63793. */
  63794. getClassName(): string;
  63795. /**
  63796. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63797. */
  63798. dispose(disableDepthRender?: boolean): void;
  63799. private _createBlurPostProcess;
  63800. /** @hidden */
  63801. _rebuild(): void;
  63802. private _createSSAOPostProcess;
  63803. private _createSSAOCombinePostProcess;
  63804. private _createRandomTexture;
  63805. }
  63806. }
  63807. declare module "babylonjs/Shaders/standard.fragment" {
  63808. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63809. /** @hidden */
  63810. export var standardPixelShader: {
  63811. name: string;
  63812. shader: string;
  63813. };
  63814. }
  63815. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63816. import { Nullable } from "babylonjs/types";
  63817. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63818. import { Camera } from "babylonjs/Cameras/camera";
  63819. import { Texture } from "babylonjs/Materials/Textures/texture";
  63820. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63821. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63822. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63823. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63824. import { IDisposable } from "babylonjs/scene";
  63825. import { SpotLight } from "babylonjs/Lights/spotLight";
  63826. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63827. import { Scene } from "babylonjs/scene";
  63828. import { Animation } from "babylonjs/Animations/animation";
  63829. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63830. import "babylonjs/Shaders/standard.fragment";
  63831. /**
  63832. * Standard rendering pipeline
  63833. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63834. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63835. */
  63836. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63837. /**
  63838. * Public members
  63839. */
  63840. /**
  63841. * Post-process which contains the original scene color before the pipeline applies all the effects
  63842. */
  63843. originalPostProcess: Nullable<PostProcess>;
  63844. /**
  63845. * Post-process used to down scale an image x4
  63846. */
  63847. downSampleX4PostProcess: Nullable<PostProcess>;
  63848. /**
  63849. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63850. */
  63851. brightPassPostProcess: Nullable<PostProcess>;
  63852. /**
  63853. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63854. */
  63855. blurHPostProcesses: PostProcess[];
  63856. /**
  63857. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63858. */
  63859. blurVPostProcesses: PostProcess[];
  63860. /**
  63861. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63862. */
  63863. textureAdderPostProcess: Nullable<PostProcess>;
  63864. /**
  63865. * Post-process used to create volumetric lighting effect
  63866. */
  63867. volumetricLightPostProcess: Nullable<PostProcess>;
  63868. /**
  63869. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63870. */
  63871. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63872. /**
  63873. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63874. */
  63875. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63876. /**
  63877. * Post-process used to merge the volumetric light effect and the real scene color
  63878. */
  63879. volumetricLightMergePostProces: Nullable<PostProcess>;
  63880. /**
  63881. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63882. */
  63883. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63884. /**
  63885. * Base post-process used to calculate the average luminance of the final image for HDR
  63886. */
  63887. luminancePostProcess: Nullable<PostProcess>;
  63888. /**
  63889. * Post-processes used to create down sample post-processes in order to get
  63890. * the average luminance of the final image for HDR
  63891. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63892. */
  63893. luminanceDownSamplePostProcesses: PostProcess[];
  63894. /**
  63895. * Post-process used to create a HDR effect (light adaptation)
  63896. */
  63897. hdrPostProcess: Nullable<PostProcess>;
  63898. /**
  63899. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63900. */
  63901. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63902. /**
  63903. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63904. */
  63905. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63906. /**
  63907. * Post-process used to merge the final HDR post-process and the real scene color
  63908. */
  63909. hdrFinalPostProcess: Nullable<PostProcess>;
  63910. /**
  63911. * Post-process used to create a lens flare effect
  63912. */
  63913. lensFlarePostProcess: Nullable<PostProcess>;
  63914. /**
  63915. * Post-process that merges the result of the lens flare post-process and the real scene color
  63916. */
  63917. lensFlareComposePostProcess: Nullable<PostProcess>;
  63918. /**
  63919. * Post-process used to create a motion blur effect
  63920. */
  63921. motionBlurPostProcess: Nullable<PostProcess>;
  63922. /**
  63923. * Post-process used to create a depth of field effect
  63924. */
  63925. depthOfFieldPostProcess: Nullable<PostProcess>;
  63926. /**
  63927. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63928. */
  63929. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63930. /**
  63931. * Represents the brightness threshold in order to configure the illuminated surfaces
  63932. */
  63933. brightThreshold: number;
  63934. /**
  63935. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63936. */
  63937. blurWidth: number;
  63938. /**
  63939. * Sets if the blur for highlighted surfaces must be only horizontal
  63940. */
  63941. horizontalBlur: boolean;
  63942. /**
  63943. * Gets the overall exposure used by the pipeline
  63944. */
  63945. /**
  63946. * Sets the overall exposure used by the pipeline
  63947. */
  63948. exposure: number;
  63949. /**
  63950. * Texture used typically to simulate "dirty" on camera lens
  63951. */
  63952. lensTexture: Nullable<Texture>;
  63953. /**
  63954. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63955. */
  63956. volumetricLightCoefficient: number;
  63957. /**
  63958. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63959. */
  63960. volumetricLightPower: number;
  63961. /**
  63962. * Used the set the blur intensity to smooth the volumetric lights
  63963. */
  63964. volumetricLightBlurScale: number;
  63965. /**
  63966. * Light (spot or directional) used to generate the volumetric lights rays
  63967. * The source light must have a shadow generate so the pipeline can get its
  63968. * depth map
  63969. */
  63970. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63971. /**
  63972. * For eye adaptation, represents the minimum luminance the eye can see
  63973. */
  63974. hdrMinimumLuminance: number;
  63975. /**
  63976. * For eye adaptation, represents the decrease luminance speed
  63977. */
  63978. hdrDecreaseRate: number;
  63979. /**
  63980. * For eye adaptation, represents the increase luminance speed
  63981. */
  63982. hdrIncreaseRate: number;
  63983. /**
  63984. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63985. */
  63986. /**
  63987. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63988. */
  63989. hdrAutoExposure: boolean;
  63990. /**
  63991. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63992. */
  63993. lensColorTexture: Nullable<Texture>;
  63994. /**
  63995. * The overall strengh for the lens flare effect
  63996. */
  63997. lensFlareStrength: number;
  63998. /**
  63999. * Dispersion coefficient for lens flare ghosts
  64000. */
  64001. lensFlareGhostDispersal: number;
  64002. /**
  64003. * Main lens flare halo width
  64004. */
  64005. lensFlareHaloWidth: number;
  64006. /**
  64007. * Based on the lens distortion effect, defines how much the lens flare result
  64008. * is distorted
  64009. */
  64010. lensFlareDistortionStrength: number;
  64011. /**
  64012. * Configures the blur intensity used for for lens flare (halo)
  64013. */
  64014. lensFlareBlurWidth: number;
  64015. /**
  64016. * Lens star texture must be used to simulate rays on the flares and is available
  64017. * in the documentation
  64018. */
  64019. lensStarTexture: Nullable<Texture>;
  64020. /**
  64021. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64022. * flare effect by taking account of the dirt texture
  64023. */
  64024. lensFlareDirtTexture: Nullable<Texture>;
  64025. /**
  64026. * Represents the focal length for the depth of field effect
  64027. */
  64028. depthOfFieldDistance: number;
  64029. /**
  64030. * Represents the blur intensity for the blurred part of the depth of field effect
  64031. */
  64032. depthOfFieldBlurWidth: number;
  64033. /**
  64034. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64035. */
  64036. /**
  64037. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64038. */
  64039. motionStrength: number;
  64040. /**
  64041. * Gets wether or not the motion blur post-process is object based or screen based.
  64042. */
  64043. /**
  64044. * Sets wether or not the motion blur post-process should be object based or screen based
  64045. */
  64046. objectBasedMotionBlur: boolean;
  64047. /**
  64048. * List of animations for the pipeline (IAnimatable implementation)
  64049. */
  64050. animations: Animation[];
  64051. /**
  64052. * Private members
  64053. */
  64054. private _scene;
  64055. private _currentDepthOfFieldSource;
  64056. private _basePostProcess;
  64057. private _fixedExposure;
  64058. private _currentExposure;
  64059. private _hdrAutoExposure;
  64060. private _hdrCurrentLuminance;
  64061. private _motionStrength;
  64062. private _isObjectBasedMotionBlur;
  64063. private _floatTextureType;
  64064. private _camerasToBeAttached;
  64065. private _ratio;
  64066. private _bloomEnabled;
  64067. private _depthOfFieldEnabled;
  64068. private _vlsEnabled;
  64069. private _lensFlareEnabled;
  64070. private _hdrEnabled;
  64071. private _motionBlurEnabled;
  64072. private _fxaaEnabled;
  64073. private _motionBlurSamples;
  64074. private _volumetricLightStepsCount;
  64075. private _samples;
  64076. /**
  64077. * @ignore
  64078. * Specifies if the bloom pipeline is enabled
  64079. */
  64080. BloomEnabled: boolean;
  64081. /**
  64082. * @ignore
  64083. * Specifies if the depth of field pipeline is enabed
  64084. */
  64085. DepthOfFieldEnabled: boolean;
  64086. /**
  64087. * @ignore
  64088. * Specifies if the lens flare pipeline is enabed
  64089. */
  64090. LensFlareEnabled: boolean;
  64091. /**
  64092. * @ignore
  64093. * Specifies if the HDR pipeline is enabled
  64094. */
  64095. HDREnabled: boolean;
  64096. /**
  64097. * @ignore
  64098. * Specifies if the volumetric lights scattering effect is enabled
  64099. */
  64100. VLSEnabled: boolean;
  64101. /**
  64102. * @ignore
  64103. * Specifies if the motion blur effect is enabled
  64104. */
  64105. MotionBlurEnabled: boolean;
  64106. /**
  64107. * Specifies if anti-aliasing is enabled
  64108. */
  64109. fxaaEnabled: boolean;
  64110. /**
  64111. * Specifies the number of steps used to calculate the volumetric lights
  64112. * Typically in interval [50, 200]
  64113. */
  64114. volumetricLightStepsCount: number;
  64115. /**
  64116. * Specifies the number of samples used for the motion blur effect
  64117. * Typically in interval [16, 64]
  64118. */
  64119. motionBlurSamples: number;
  64120. /**
  64121. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64122. */
  64123. samples: number;
  64124. /**
  64125. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64126. * @constructor
  64127. * @param name The rendering pipeline name
  64128. * @param scene The scene linked to this pipeline
  64129. * @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)
  64130. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64131. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64132. */
  64133. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64134. private _buildPipeline;
  64135. private _createDownSampleX4PostProcess;
  64136. private _createBrightPassPostProcess;
  64137. private _createBlurPostProcesses;
  64138. private _createTextureAdderPostProcess;
  64139. private _createVolumetricLightPostProcess;
  64140. private _createLuminancePostProcesses;
  64141. private _createHdrPostProcess;
  64142. private _createLensFlarePostProcess;
  64143. private _createDepthOfFieldPostProcess;
  64144. private _createMotionBlurPostProcess;
  64145. private _getDepthTexture;
  64146. private _disposePostProcesses;
  64147. /**
  64148. * Dispose of the pipeline and stop all post processes
  64149. */
  64150. dispose(): void;
  64151. /**
  64152. * Serialize the rendering pipeline (Used when exporting)
  64153. * @returns the serialized object
  64154. */
  64155. serialize(): any;
  64156. /**
  64157. * Parse the serialized pipeline
  64158. * @param source Source pipeline.
  64159. * @param scene The scene to load the pipeline to.
  64160. * @param rootUrl The URL of the serialized pipeline.
  64161. * @returns An instantiated pipeline from the serialized object.
  64162. */
  64163. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64164. /**
  64165. * Luminance steps
  64166. */
  64167. static LuminanceSteps: number;
  64168. }
  64169. }
  64170. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64171. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64172. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64173. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64174. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64175. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64176. }
  64177. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64178. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64179. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64180. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64181. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64182. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64183. }
  64184. declare module "babylonjs/Shaders/tonemap.fragment" {
  64185. /** @hidden */
  64186. export var tonemapPixelShader: {
  64187. name: string;
  64188. shader: string;
  64189. };
  64190. }
  64191. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64192. import { Camera } from "babylonjs/Cameras/camera";
  64193. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64194. import "babylonjs/Shaders/tonemap.fragment";
  64195. import { Engine } from "babylonjs/Engines/engine";
  64196. /** Defines operator used for tonemapping */
  64197. export enum TonemappingOperator {
  64198. /** Hable */
  64199. Hable = 0,
  64200. /** Reinhard */
  64201. Reinhard = 1,
  64202. /** HejiDawson */
  64203. HejiDawson = 2,
  64204. /** Photographic */
  64205. Photographic = 3
  64206. }
  64207. /**
  64208. * Defines a post process to apply tone mapping
  64209. */
  64210. export class TonemapPostProcess extends PostProcess {
  64211. private _operator;
  64212. /** Defines the required exposure adjustement */
  64213. exposureAdjustment: number;
  64214. /**
  64215. * Creates a new TonemapPostProcess
  64216. * @param name defines the name of the postprocess
  64217. * @param _operator defines the operator to use
  64218. * @param exposureAdjustment defines the required exposure adjustement
  64219. * @param camera defines the camera to use (can be null)
  64220. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64221. * @param engine defines the hosting engine (can be ignore if camera is set)
  64222. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64223. */
  64224. constructor(name: string, _operator: TonemappingOperator,
  64225. /** Defines the required exposure adjustement */
  64226. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64227. }
  64228. }
  64229. declare module "babylonjs/Shaders/depth.vertex" {
  64230. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64231. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64232. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64233. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64234. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64235. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64236. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64237. /** @hidden */
  64238. export var depthVertexShader: {
  64239. name: string;
  64240. shader: string;
  64241. };
  64242. }
  64243. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64244. /** @hidden */
  64245. export var volumetricLightScatteringPixelShader: {
  64246. name: string;
  64247. shader: string;
  64248. };
  64249. }
  64250. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64251. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64253. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64254. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64255. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64256. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64257. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64258. /** @hidden */
  64259. export var volumetricLightScatteringPassVertexShader: {
  64260. name: string;
  64261. shader: string;
  64262. };
  64263. }
  64264. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64265. /** @hidden */
  64266. export var volumetricLightScatteringPassPixelShader: {
  64267. name: string;
  64268. shader: string;
  64269. };
  64270. }
  64271. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64272. import { Vector3 } from "babylonjs/Maths/math.vector";
  64273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64274. import { Mesh } from "babylonjs/Meshes/mesh";
  64275. import { Camera } from "babylonjs/Cameras/camera";
  64276. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64277. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64278. import { Scene } from "babylonjs/scene";
  64279. import "babylonjs/Meshes/Builders/planeBuilder";
  64280. import "babylonjs/Shaders/depth.vertex";
  64281. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64282. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64283. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64284. import { Engine } from "babylonjs/Engines/engine";
  64285. /**
  64286. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64287. */
  64288. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64289. private _volumetricLightScatteringPass;
  64290. private _volumetricLightScatteringRTT;
  64291. private _viewPort;
  64292. private _screenCoordinates;
  64293. private _cachedDefines;
  64294. /**
  64295. * If not undefined, the mesh position is computed from the attached node position
  64296. */
  64297. attachedNode: {
  64298. position: Vector3;
  64299. };
  64300. /**
  64301. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64302. */
  64303. customMeshPosition: Vector3;
  64304. /**
  64305. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64306. */
  64307. useCustomMeshPosition: boolean;
  64308. /**
  64309. * If the post-process should inverse the light scattering direction
  64310. */
  64311. invert: boolean;
  64312. /**
  64313. * The internal mesh used by the post-process
  64314. */
  64315. mesh: Mesh;
  64316. /**
  64317. * @hidden
  64318. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64319. */
  64320. useDiffuseColor: boolean;
  64321. /**
  64322. * Array containing the excluded meshes not rendered in the internal pass
  64323. */
  64324. excludedMeshes: AbstractMesh[];
  64325. /**
  64326. * Controls the overall intensity of the post-process
  64327. */
  64328. exposure: number;
  64329. /**
  64330. * Dissipates each sample's contribution in range [0, 1]
  64331. */
  64332. decay: number;
  64333. /**
  64334. * Controls the overall intensity of each sample
  64335. */
  64336. weight: number;
  64337. /**
  64338. * Controls the density of each sample
  64339. */
  64340. density: number;
  64341. /**
  64342. * @constructor
  64343. * @param name The post-process name
  64344. * @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)
  64345. * @param camera The camera that the post-process will be attached to
  64346. * @param mesh The mesh used to create the light scattering
  64347. * @param samples The post-process quality, default 100
  64348. * @param samplingModeThe post-process filtering mode
  64349. * @param engine The babylon engine
  64350. * @param reusable If the post-process is reusable
  64351. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64352. */
  64353. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64354. /**
  64355. * Returns the string "VolumetricLightScatteringPostProcess"
  64356. * @returns "VolumetricLightScatteringPostProcess"
  64357. */
  64358. getClassName(): string;
  64359. private _isReady;
  64360. /**
  64361. * Sets the new light position for light scattering effect
  64362. * @param position The new custom light position
  64363. */
  64364. setCustomMeshPosition(position: Vector3): void;
  64365. /**
  64366. * Returns the light position for light scattering effect
  64367. * @return Vector3 The custom light position
  64368. */
  64369. getCustomMeshPosition(): Vector3;
  64370. /**
  64371. * Disposes the internal assets and detaches the post-process from the camera
  64372. */
  64373. dispose(camera: Camera): void;
  64374. /**
  64375. * Returns the render target texture used by the post-process
  64376. * @return the render target texture used by the post-process
  64377. */
  64378. getPass(): RenderTargetTexture;
  64379. private _meshExcluded;
  64380. private _createPass;
  64381. private _updateMeshScreenCoordinates;
  64382. /**
  64383. * Creates a default mesh for the Volumeric Light Scattering post-process
  64384. * @param name The mesh name
  64385. * @param scene The scene where to create the mesh
  64386. * @return the default mesh
  64387. */
  64388. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64389. }
  64390. }
  64391. declare module "babylonjs/PostProcesses/index" {
  64392. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64393. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64394. export * from "babylonjs/PostProcesses/bloomEffect";
  64395. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64396. export * from "babylonjs/PostProcesses/blurPostProcess";
  64397. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64398. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64399. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64400. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64401. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64402. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64403. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64404. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64405. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64406. export * from "babylonjs/PostProcesses/filterPostProcess";
  64407. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64408. export * from "babylonjs/PostProcesses/grainPostProcess";
  64409. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64410. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64411. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64412. export * from "babylonjs/PostProcesses/passPostProcess";
  64413. export * from "babylonjs/PostProcesses/postProcess";
  64414. export * from "babylonjs/PostProcesses/postProcessManager";
  64415. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64416. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64417. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64418. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64419. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64420. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64421. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64422. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64423. }
  64424. declare module "babylonjs/Probes/index" {
  64425. export * from "babylonjs/Probes/reflectionProbe";
  64426. }
  64427. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64428. import { Scene } from "babylonjs/scene";
  64429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64430. import { SmartArray } from "babylonjs/Misc/smartArray";
  64431. import { ISceneComponent } from "babylonjs/sceneComponent";
  64432. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64433. import "babylonjs/Meshes/Builders/boxBuilder";
  64434. import "babylonjs/Shaders/color.fragment";
  64435. import "babylonjs/Shaders/color.vertex";
  64436. import { Color3 } from "babylonjs/Maths/math.color";
  64437. module "babylonjs/scene" {
  64438. interface Scene {
  64439. /** @hidden (Backing field) */
  64440. _boundingBoxRenderer: BoundingBoxRenderer;
  64441. /** @hidden (Backing field) */
  64442. _forceShowBoundingBoxes: boolean;
  64443. /**
  64444. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64445. */
  64446. forceShowBoundingBoxes: boolean;
  64447. /**
  64448. * Gets the bounding box renderer associated with the scene
  64449. * @returns a BoundingBoxRenderer
  64450. */
  64451. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64452. }
  64453. }
  64454. module "babylonjs/Meshes/abstractMesh" {
  64455. interface AbstractMesh {
  64456. /** @hidden (Backing field) */
  64457. _showBoundingBox: boolean;
  64458. /**
  64459. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64460. */
  64461. showBoundingBox: boolean;
  64462. }
  64463. }
  64464. /**
  64465. * Component responsible of rendering the bounding box of the meshes in a scene.
  64466. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64467. */
  64468. export class BoundingBoxRenderer implements ISceneComponent {
  64469. /**
  64470. * The component name helpfull to identify the component in the list of scene components.
  64471. */
  64472. readonly name: string;
  64473. /**
  64474. * The scene the component belongs to.
  64475. */
  64476. scene: Scene;
  64477. /**
  64478. * Color of the bounding box lines placed in front of an object
  64479. */
  64480. frontColor: Color3;
  64481. /**
  64482. * Color of the bounding box lines placed behind an object
  64483. */
  64484. backColor: Color3;
  64485. /**
  64486. * Defines if the renderer should show the back lines or not
  64487. */
  64488. showBackLines: boolean;
  64489. /**
  64490. * @hidden
  64491. */
  64492. renderList: SmartArray<BoundingBox>;
  64493. private _colorShader;
  64494. private _vertexBuffers;
  64495. private _indexBuffer;
  64496. private _fillIndexBuffer;
  64497. private _fillIndexData;
  64498. /**
  64499. * Instantiates a new bounding box renderer in a scene.
  64500. * @param scene the scene the renderer renders in
  64501. */
  64502. constructor(scene: Scene);
  64503. /**
  64504. * Registers the component in a given scene
  64505. */
  64506. register(): void;
  64507. private _evaluateSubMesh;
  64508. private _activeMesh;
  64509. private _prepareRessources;
  64510. private _createIndexBuffer;
  64511. /**
  64512. * Rebuilds the elements related to this component in case of
  64513. * context lost for instance.
  64514. */
  64515. rebuild(): void;
  64516. /**
  64517. * @hidden
  64518. */
  64519. reset(): void;
  64520. /**
  64521. * Render the bounding boxes of a specific rendering group
  64522. * @param renderingGroupId defines the rendering group to render
  64523. */
  64524. render(renderingGroupId: number): void;
  64525. /**
  64526. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64527. * @param mesh Define the mesh to render the occlusion bounding box for
  64528. */
  64529. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64530. /**
  64531. * Dispose and release the resources attached to this renderer.
  64532. */
  64533. dispose(): void;
  64534. }
  64535. }
  64536. declare module "babylonjs/Shaders/depth.fragment" {
  64537. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64538. /** @hidden */
  64539. export var depthPixelShader: {
  64540. name: string;
  64541. shader: string;
  64542. };
  64543. }
  64544. declare module "babylonjs/Rendering/depthRenderer" {
  64545. import { Nullable } from "babylonjs/types";
  64546. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64547. import { Scene } from "babylonjs/scene";
  64548. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64549. import { Camera } from "babylonjs/Cameras/camera";
  64550. import "babylonjs/Shaders/depth.fragment";
  64551. import "babylonjs/Shaders/depth.vertex";
  64552. /**
  64553. * This represents a depth renderer in Babylon.
  64554. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64555. */
  64556. export class DepthRenderer {
  64557. private _scene;
  64558. private _depthMap;
  64559. private _effect;
  64560. private readonly _storeNonLinearDepth;
  64561. private readonly _clearColor;
  64562. /** Get if the depth renderer is using packed depth or not */
  64563. readonly isPacked: boolean;
  64564. private _cachedDefines;
  64565. private _camera;
  64566. /**
  64567. * Specifiess that the depth renderer will only be used within
  64568. * the camera it is created for.
  64569. * This can help forcing its rendering during the camera processing.
  64570. */
  64571. useOnlyInActiveCamera: boolean;
  64572. /** @hidden */
  64573. static _SceneComponentInitialization: (scene: Scene) => void;
  64574. /**
  64575. * Instantiates a depth renderer
  64576. * @param scene The scene the renderer belongs to
  64577. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64578. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64579. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64580. */
  64581. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64582. /**
  64583. * Creates the depth rendering effect and checks if the effect is ready.
  64584. * @param subMesh The submesh to be used to render the depth map of
  64585. * @param useInstances If multiple world instances should be used
  64586. * @returns if the depth renderer is ready to render the depth map
  64587. */
  64588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64589. /**
  64590. * Gets the texture which the depth map will be written to.
  64591. * @returns The depth map texture
  64592. */
  64593. getDepthMap(): RenderTargetTexture;
  64594. /**
  64595. * Disposes of the depth renderer.
  64596. */
  64597. dispose(): void;
  64598. }
  64599. }
  64600. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64601. import { Nullable } from "babylonjs/types";
  64602. import { Scene } from "babylonjs/scene";
  64603. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64604. import { Camera } from "babylonjs/Cameras/camera";
  64605. import { ISceneComponent } from "babylonjs/sceneComponent";
  64606. module "babylonjs/scene" {
  64607. interface Scene {
  64608. /** @hidden (Backing field) */
  64609. _depthRenderer: {
  64610. [id: string]: DepthRenderer;
  64611. };
  64612. /**
  64613. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64614. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64615. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64616. * @returns the created depth renderer
  64617. */
  64618. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64619. /**
  64620. * Disables a depth renderer for a given camera
  64621. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64622. */
  64623. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64624. }
  64625. }
  64626. /**
  64627. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64628. * in several rendering techniques.
  64629. */
  64630. export class DepthRendererSceneComponent implements ISceneComponent {
  64631. /**
  64632. * The component name helpfull to identify the component in the list of scene components.
  64633. */
  64634. readonly name: string;
  64635. /**
  64636. * The scene the component belongs to.
  64637. */
  64638. scene: Scene;
  64639. /**
  64640. * Creates a new instance of the component for the given scene
  64641. * @param scene Defines the scene to register the component in
  64642. */
  64643. constructor(scene: Scene);
  64644. /**
  64645. * Registers the component in a given scene
  64646. */
  64647. register(): void;
  64648. /**
  64649. * Rebuilds the elements related to this component in case of
  64650. * context lost for instance.
  64651. */
  64652. rebuild(): void;
  64653. /**
  64654. * Disposes the component and the associated ressources
  64655. */
  64656. dispose(): void;
  64657. private _gatherRenderTargets;
  64658. private _gatherActiveCameraRenderTargets;
  64659. }
  64660. }
  64661. declare module "babylonjs/Shaders/outline.fragment" {
  64662. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64663. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64664. /** @hidden */
  64665. export var outlinePixelShader: {
  64666. name: string;
  64667. shader: string;
  64668. };
  64669. }
  64670. declare module "babylonjs/Shaders/outline.vertex" {
  64671. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64672. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64673. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64674. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64675. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64676. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64677. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64678. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64679. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64680. /** @hidden */
  64681. export var outlineVertexShader: {
  64682. name: string;
  64683. shader: string;
  64684. };
  64685. }
  64686. declare module "babylonjs/Rendering/outlineRenderer" {
  64687. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64688. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64689. import { Scene } from "babylonjs/scene";
  64690. import { ISceneComponent } from "babylonjs/sceneComponent";
  64691. import "babylonjs/Shaders/outline.fragment";
  64692. import "babylonjs/Shaders/outline.vertex";
  64693. module "babylonjs/scene" {
  64694. interface Scene {
  64695. /** @hidden */
  64696. _outlineRenderer: OutlineRenderer;
  64697. /**
  64698. * Gets the outline renderer associated with the scene
  64699. * @returns a OutlineRenderer
  64700. */
  64701. getOutlineRenderer(): OutlineRenderer;
  64702. }
  64703. }
  64704. module "babylonjs/Meshes/abstractMesh" {
  64705. interface AbstractMesh {
  64706. /** @hidden (Backing field) */
  64707. _renderOutline: boolean;
  64708. /**
  64709. * Gets or sets a boolean indicating if the outline must be rendered as well
  64710. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64711. */
  64712. renderOutline: boolean;
  64713. /** @hidden (Backing field) */
  64714. _renderOverlay: boolean;
  64715. /**
  64716. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64717. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64718. */
  64719. renderOverlay: boolean;
  64720. }
  64721. }
  64722. /**
  64723. * This class is responsible to draw bothe outline/overlay of meshes.
  64724. * It should not be used directly but through the available method on mesh.
  64725. */
  64726. export class OutlineRenderer implements ISceneComponent {
  64727. /**
  64728. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64729. */
  64730. private static _StencilReference;
  64731. /**
  64732. * The name of the component. Each component must have a unique name.
  64733. */
  64734. name: string;
  64735. /**
  64736. * The scene the component belongs to.
  64737. */
  64738. scene: Scene;
  64739. /**
  64740. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64741. */
  64742. zOffset: number;
  64743. private _engine;
  64744. private _effect;
  64745. private _cachedDefines;
  64746. private _savedDepthWrite;
  64747. /**
  64748. * Instantiates a new outline renderer. (There could be only one per scene).
  64749. * @param scene Defines the scene it belongs to
  64750. */
  64751. constructor(scene: Scene);
  64752. /**
  64753. * Register the component to one instance of a scene.
  64754. */
  64755. register(): void;
  64756. /**
  64757. * Rebuilds the elements related to this component in case of
  64758. * context lost for instance.
  64759. */
  64760. rebuild(): void;
  64761. /**
  64762. * Disposes the component and the associated ressources.
  64763. */
  64764. dispose(): void;
  64765. /**
  64766. * Renders the outline in the canvas.
  64767. * @param subMesh Defines the sumesh to render
  64768. * @param batch Defines the batch of meshes in case of instances
  64769. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64770. */
  64771. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64772. /**
  64773. * Returns whether or not the outline renderer is ready for a given submesh.
  64774. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64775. * @param subMesh Defines the submesh to check readyness for
  64776. * @param useInstances Defines wheter wee are trying to render instances or not
  64777. * @returns true if ready otherwise false
  64778. */
  64779. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64780. private _beforeRenderingMesh;
  64781. private _afterRenderingMesh;
  64782. }
  64783. }
  64784. declare module "babylonjs/Rendering/index" {
  64785. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64786. export * from "babylonjs/Rendering/depthRenderer";
  64787. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64788. export * from "babylonjs/Rendering/edgesRenderer";
  64789. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64790. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64791. export * from "babylonjs/Rendering/outlineRenderer";
  64792. export * from "babylonjs/Rendering/renderingGroup";
  64793. export * from "babylonjs/Rendering/renderingManager";
  64794. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64795. }
  64796. declare module "babylonjs/Sprites/spritePackedManager" {
  64797. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64798. import { Scene } from "babylonjs/scene";
  64799. /**
  64800. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64801. * @see http://doc.babylonjs.com/babylon101/sprites
  64802. */
  64803. export class SpritePackedManager extends SpriteManager {
  64804. /** defines the packed manager's name */
  64805. name: string;
  64806. /**
  64807. * Creates a new sprite manager from a packed sprite sheet
  64808. * @param name defines the manager's name
  64809. * @param imgUrl defines the sprite sheet url
  64810. * @param capacity defines the maximum allowed number of sprites
  64811. * @param scene defines the hosting scene
  64812. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64813. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64814. * @param samplingMode defines the smapling mode to use with spritesheet
  64815. * @param fromPacked set to true; do not alter
  64816. */
  64817. constructor(
  64818. /** defines the packed manager's name */
  64819. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64820. }
  64821. }
  64822. declare module "babylonjs/Sprites/index" {
  64823. export * from "babylonjs/Sprites/sprite";
  64824. export * from "babylonjs/Sprites/spriteManager";
  64825. export * from "babylonjs/Sprites/spritePackedManager";
  64826. export * from "babylonjs/Sprites/spriteSceneComponent";
  64827. }
  64828. declare module "babylonjs/States/index" {
  64829. export * from "babylonjs/States/alphaCullingState";
  64830. export * from "babylonjs/States/depthCullingState";
  64831. export * from "babylonjs/States/stencilState";
  64832. }
  64833. declare module "babylonjs/Misc/assetsManager" {
  64834. import { Scene } from "babylonjs/scene";
  64835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64836. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64837. import { Skeleton } from "babylonjs/Bones/skeleton";
  64838. import { Observable } from "babylonjs/Misc/observable";
  64839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64840. import { Texture } from "babylonjs/Materials/Textures/texture";
  64841. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64842. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64843. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64844. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64845. /**
  64846. * Defines the list of states available for a task inside a AssetsManager
  64847. */
  64848. export enum AssetTaskState {
  64849. /**
  64850. * Initialization
  64851. */
  64852. INIT = 0,
  64853. /**
  64854. * Running
  64855. */
  64856. RUNNING = 1,
  64857. /**
  64858. * Done
  64859. */
  64860. DONE = 2,
  64861. /**
  64862. * Error
  64863. */
  64864. ERROR = 3
  64865. }
  64866. /**
  64867. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64868. */
  64869. export abstract class AbstractAssetTask {
  64870. /**
  64871. * Task name
  64872. */ name: string;
  64873. /**
  64874. * Callback called when the task is successful
  64875. */
  64876. onSuccess: (task: any) => void;
  64877. /**
  64878. * Callback called when the task is not successful
  64879. */
  64880. onError: (task: any, message?: string, exception?: any) => void;
  64881. /**
  64882. * Creates a new AssetsManager
  64883. * @param name defines the name of the task
  64884. */
  64885. constructor(
  64886. /**
  64887. * Task name
  64888. */ name: string);
  64889. private _isCompleted;
  64890. private _taskState;
  64891. private _errorObject;
  64892. /**
  64893. * Get if the task is completed
  64894. */
  64895. readonly isCompleted: boolean;
  64896. /**
  64897. * Gets the current state of the task
  64898. */
  64899. readonly taskState: AssetTaskState;
  64900. /**
  64901. * Gets the current error object (if task is in error)
  64902. */
  64903. readonly errorObject: {
  64904. message?: string;
  64905. exception?: any;
  64906. };
  64907. /**
  64908. * Internal only
  64909. * @hidden
  64910. */
  64911. _setErrorObject(message?: string, exception?: any): void;
  64912. /**
  64913. * Execute the current task
  64914. * @param scene defines the scene where you want your assets to be loaded
  64915. * @param onSuccess is a callback called when the task is successfully executed
  64916. * @param onError is a callback called if an error occurs
  64917. */
  64918. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64919. /**
  64920. * Execute the current task
  64921. * @param scene defines the scene where you want your assets to be loaded
  64922. * @param onSuccess is a callback called when the task is successfully executed
  64923. * @param onError is a callback called if an error occurs
  64924. */
  64925. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64926. /**
  64927. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64928. * This can be used with failed tasks that have the reason for failure fixed.
  64929. */
  64930. reset(): void;
  64931. private onErrorCallback;
  64932. private onDoneCallback;
  64933. }
  64934. /**
  64935. * Define the interface used by progress events raised during assets loading
  64936. */
  64937. export interface IAssetsProgressEvent {
  64938. /**
  64939. * Defines the number of remaining tasks to process
  64940. */
  64941. remainingCount: number;
  64942. /**
  64943. * Defines the total number of tasks
  64944. */
  64945. totalCount: number;
  64946. /**
  64947. * Defines the task that was just processed
  64948. */
  64949. task: AbstractAssetTask;
  64950. }
  64951. /**
  64952. * Class used to share progress information about assets loading
  64953. */
  64954. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64955. /**
  64956. * Defines the number of remaining tasks to process
  64957. */
  64958. remainingCount: number;
  64959. /**
  64960. * Defines the total number of tasks
  64961. */
  64962. totalCount: number;
  64963. /**
  64964. * Defines the task that was just processed
  64965. */
  64966. task: AbstractAssetTask;
  64967. /**
  64968. * Creates a AssetsProgressEvent
  64969. * @param remainingCount defines the number of remaining tasks to process
  64970. * @param totalCount defines the total number of tasks
  64971. * @param task defines the task that was just processed
  64972. */
  64973. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64974. }
  64975. /**
  64976. * Define a task used by AssetsManager to load meshes
  64977. */
  64978. export class MeshAssetTask extends AbstractAssetTask {
  64979. /**
  64980. * Defines the name of the task
  64981. */
  64982. name: string;
  64983. /**
  64984. * Defines the list of mesh's names you want to load
  64985. */
  64986. meshesNames: any;
  64987. /**
  64988. * Defines the root url to use as a base to load your meshes and associated resources
  64989. */
  64990. rootUrl: string;
  64991. /**
  64992. * Defines the filename of the scene to load from
  64993. */
  64994. sceneFilename: string;
  64995. /**
  64996. * Gets the list of loaded meshes
  64997. */
  64998. loadedMeshes: Array<AbstractMesh>;
  64999. /**
  65000. * Gets the list of loaded particle systems
  65001. */
  65002. loadedParticleSystems: Array<IParticleSystem>;
  65003. /**
  65004. * Gets the list of loaded skeletons
  65005. */
  65006. loadedSkeletons: Array<Skeleton>;
  65007. /**
  65008. * Gets the list of loaded animation groups
  65009. */
  65010. loadedAnimationGroups: Array<AnimationGroup>;
  65011. /**
  65012. * Callback called when the task is successful
  65013. */
  65014. onSuccess: (task: MeshAssetTask) => void;
  65015. /**
  65016. * Callback called when the task is successful
  65017. */
  65018. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65019. /**
  65020. * Creates a new MeshAssetTask
  65021. * @param name defines the name of the task
  65022. * @param meshesNames defines the list of mesh's names you want to load
  65023. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65024. * @param sceneFilename defines the filename of the scene to load from
  65025. */
  65026. constructor(
  65027. /**
  65028. * Defines the name of the task
  65029. */
  65030. name: string,
  65031. /**
  65032. * Defines the list of mesh's names you want to load
  65033. */
  65034. meshesNames: any,
  65035. /**
  65036. * Defines the root url to use as a base to load your meshes and associated resources
  65037. */
  65038. rootUrl: string,
  65039. /**
  65040. * Defines the filename of the scene to load from
  65041. */
  65042. sceneFilename: string);
  65043. /**
  65044. * Execute the current task
  65045. * @param scene defines the scene where you want your assets to be loaded
  65046. * @param onSuccess is a callback called when the task is successfully executed
  65047. * @param onError is a callback called if an error occurs
  65048. */
  65049. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65050. }
  65051. /**
  65052. * Define a task used by AssetsManager to load text content
  65053. */
  65054. export class TextFileAssetTask extends AbstractAssetTask {
  65055. /**
  65056. * Defines the name of the task
  65057. */
  65058. name: string;
  65059. /**
  65060. * Defines the location of the file to load
  65061. */
  65062. url: string;
  65063. /**
  65064. * Gets the loaded text string
  65065. */
  65066. text: string;
  65067. /**
  65068. * Callback called when the task is successful
  65069. */
  65070. onSuccess: (task: TextFileAssetTask) => void;
  65071. /**
  65072. * Callback called when the task is successful
  65073. */
  65074. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65075. /**
  65076. * Creates a new TextFileAssetTask object
  65077. * @param name defines the name of the task
  65078. * @param url defines the location of the file to load
  65079. */
  65080. constructor(
  65081. /**
  65082. * Defines the name of the task
  65083. */
  65084. name: string,
  65085. /**
  65086. * Defines the location of the file to load
  65087. */
  65088. url: string);
  65089. /**
  65090. * Execute the current task
  65091. * @param scene defines the scene where you want your assets to be loaded
  65092. * @param onSuccess is a callback called when the task is successfully executed
  65093. * @param onError is a callback called if an error occurs
  65094. */
  65095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65096. }
  65097. /**
  65098. * Define a task used by AssetsManager to load binary data
  65099. */
  65100. export class BinaryFileAssetTask extends AbstractAssetTask {
  65101. /**
  65102. * Defines the name of the task
  65103. */
  65104. name: string;
  65105. /**
  65106. * Defines the location of the file to load
  65107. */
  65108. url: string;
  65109. /**
  65110. * Gets the lodaded data (as an array buffer)
  65111. */
  65112. data: ArrayBuffer;
  65113. /**
  65114. * Callback called when the task is successful
  65115. */
  65116. onSuccess: (task: BinaryFileAssetTask) => void;
  65117. /**
  65118. * Callback called when the task is successful
  65119. */
  65120. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65121. /**
  65122. * Creates a new BinaryFileAssetTask object
  65123. * @param name defines the name of the new task
  65124. * @param url defines the location of the file to load
  65125. */
  65126. constructor(
  65127. /**
  65128. * Defines the name of the task
  65129. */
  65130. name: string,
  65131. /**
  65132. * Defines the location of the file to load
  65133. */
  65134. url: string);
  65135. /**
  65136. * Execute the current task
  65137. * @param scene defines the scene where you want your assets to be loaded
  65138. * @param onSuccess is a callback called when the task is successfully executed
  65139. * @param onError is a callback called if an error occurs
  65140. */
  65141. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65142. }
  65143. /**
  65144. * Define a task used by AssetsManager to load images
  65145. */
  65146. export class ImageAssetTask extends AbstractAssetTask {
  65147. /**
  65148. * Defines the name of the task
  65149. */
  65150. name: string;
  65151. /**
  65152. * Defines the location of the image to load
  65153. */
  65154. url: string;
  65155. /**
  65156. * Gets the loaded images
  65157. */
  65158. image: HTMLImageElement;
  65159. /**
  65160. * Callback called when the task is successful
  65161. */
  65162. onSuccess: (task: ImageAssetTask) => void;
  65163. /**
  65164. * Callback called when the task is successful
  65165. */
  65166. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65167. /**
  65168. * Creates a new ImageAssetTask
  65169. * @param name defines the name of the task
  65170. * @param url defines the location of the image to load
  65171. */
  65172. constructor(
  65173. /**
  65174. * Defines the name of the task
  65175. */
  65176. name: string,
  65177. /**
  65178. * Defines the location of the image to load
  65179. */
  65180. url: string);
  65181. /**
  65182. * Execute the current task
  65183. * @param scene defines the scene where you want your assets to be loaded
  65184. * @param onSuccess is a callback called when the task is successfully executed
  65185. * @param onError is a callback called if an error occurs
  65186. */
  65187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65188. }
  65189. /**
  65190. * Defines the interface used by texture loading tasks
  65191. */
  65192. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65193. /**
  65194. * Gets the loaded texture
  65195. */
  65196. texture: TEX;
  65197. }
  65198. /**
  65199. * Define a task used by AssetsManager to load 2D textures
  65200. */
  65201. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65202. /**
  65203. * Defines the name of the task
  65204. */
  65205. name: string;
  65206. /**
  65207. * Defines the location of the file to load
  65208. */
  65209. url: string;
  65210. /**
  65211. * Defines if mipmap should not be generated (default is false)
  65212. */
  65213. noMipmap?: boolean | undefined;
  65214. /**
  65215. * Defines if texture must be inverted on Y axis (default is false)
  65216. */
  65217. invertY?: boolean | undefined;
  65218. /**
  65219. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65220. */
  65221. samplingMode: number;
  65222. /**
  65223. * Gets the loaded texture
  65224. */
  65225. texture: Texture;
  65226. /**
  65227. * Callback called when the task is successful
  65228. */
  65229. onSuccess: (task: TextureAssetTask) => void;
  65230. /**
  65231. * Callback called when the task is successful
  65232. */
  65233. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65234. /**
  65235. * Creates a new TextureAssetTask object
  65236. * @param name defines the name of the task
  65237. * @param url defines the location of the file to load
  65238. * @param noMipmap defines if mipmap should not be generated (default is false)
  65239. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65240. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65241. */
  65242. constructor(
  65243. /**
  65244. * Defines the name of the task
  65245. */
  65246. name: string,
  65247. /**
  65248. * Defines the location of the file to load
  65249. */
  65250. url: string,
  65251. /**
  65252. * Defines if mipmap should not be generated (default is false)
  65253. */
  65254. noMipmap?: boolean | undefined,
  65255. /**
  65256. * Defines if texture must be inverted on Y axis (default is false)
  65257. */
  65258. invertY?: boolean | undefined,
  65259. /**
  65260. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65261. */
  65262. samplingMode?: number);
  65263. /**
  65264. * Execute the current task
  65265. * @param scene defines the scene where you want your assets to be loaded
  65266. * @param onSuccess is a callback called when the task is successfully executed
  65267. * @param onError is a callback called if an error occurs
  65268. */
  65269. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65270. }
  65271. /**
  65272. * Define a task used by AssetsManager to load cube textures
  65273. */
  65274. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65275. /**
  65276. * Defines the name of the task
  65277. */
  65278. name: string;
  65279. /**
  65280. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65281. */
  65282. url: string;
  65283. /**
  65284. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65285. */
  65286. extensions?: string[] | undefined;
  65287. /**
  65288. * Defines if mipmaps should not be generated (default is false)
  65289. */
  65290. noMipmap?: boolean | undefined;
  65291. /**
  65292. * Defines the explicit list of files (undefined by default)
  65293. */
  65294. files?: string[] | undefined;
  65295. /**
  65296. * Gets the loaded texture
  65297. */
  65298. texture: CubeTexture;
  65299. /**
  65300. * Callback called when the task is successful
  65301. */
  65302. onSuccess: (task: CubeTextureAssetTask) => void;
  65303. /**
  65304. * Callback called when the task is successful
  65305. */
  65306. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65307. /**
  65308. * Creates a new CubeTextureAssetTask
  65309. * @param name defines the name of the task
  65310. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65311. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65312. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65313. * @param files defines the explicit list of files (undefined by default)
  65314. */
  65315. constructor(
  65316. /**
  65317. * Defines the name of the task
  65318. */
  65319. name: string,
  65320. /**
  65321. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65322. */
  65323. url: string,
  65324. /**
  65325. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65326. */
  65327. extensions?: string[] | undefined,
  65328. /**
  65329. * Defines if mipmaps should not be generated (default is false)
  65330. */
  65331. noMipmap?: boolean | undefined,
  65332. /**
  65333. * Defines the explicit list of files (undefined by default)
  65334. */
  65335. files?: string[] | undefined);
  65336. /**
  65337. * Execute the current task
  65338. * @param scene defines the scene where you want your assets to be loaded
  65339. * @param onSuccess is a callback called when the task is successfully executed
  65340. * @param onError is a callback called if an error occurs
  65341. */
  65342. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65343. }
  65344. /**
  65345. * Define a task used by AssetsManager to load HDR cube textures
  65346. */
  65347. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65348. /**
  65349. * Defines the name of the task
  65350. */
  65351. name: string;
  65352. /**
  65353. * Defines the location of the file to load
  65354. */
  65355. url: string;
  65356. /**
  65357. * Defines the desired size (the more it increases the longer the generation will be)
  65358. */
  65359. size: number;
  65360. /**
  65361. * Defines if mipmaps should not be generated (default is false)
  65362. */
  65363. noMipmap: boolean;
  65364. /**
  65365. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65366. */
  65367. generateHarmonics: boolean;
  65368. /**
  65369. * 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)
  65370. */
  65371. gammaSpace: boolean;
  65372. /**
  65373. * Internal Use Only
  65374. */
  65375. reserved: boolean;
  65376. /**
  65377. * Gets the loaded texture
  65378. */
  65379. texture: HDRCubeTexture;
  65380. /**
  65381. * Callback called when the task is successful
  65382. */
  65383. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65384. /**
  65385. * Callback called when the task is successful
  65386. */
  65387. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65388. /**
  65389. * Creates a new HDRCubeTextureAssetTask object
  65390. * @param name defines the name of the task
  65391. * @param url defines the location of the file to load
  65392. * @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.
  65393. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65394. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65395. * @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)
  65396. * @param reserved Internal use only
  65397. */
  65398. constructor(
  65399. /**
  65400. * Defines the name of the task
  65401. */
  65402. name: string,
  65403. /**
  65404. * Defines the location of the file to load
  65405. */
  65406. url: string,
  65407. /**
  65408. * Defines the desired size (the more it increases the longer the generation will be)
  65409. */
  65410. size: number,
  65411. /**
  65412. * Defines if mipmaps should not be generated (default is false)
  65413. */
  65414. noMipmap?: boolean,
  65415. /**
  65416. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65417. */
  65418. generateHarmonics?: boolean,
  65419. /**
  65420. * 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)
  65421. */
  65422. gammaSpace?: boolean,
  65423. /**
  65424. * Internal Use Only
  65425. */
  65426. reserved?: boolean);
  65427. /**
  65428. * Execute the current task
  65429. * @param scene defines the scene where you want your assets to be loaded
  65430. * @param onSuccess is a callback called when the task is successfully executed
  65431. * @param onError is a callback called if an error occurs
  65432. */
  65433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65434. }
  65435. /**
  65436. * Define a task used by AssetsManager to load Equirectangular cube textures
  65437. */
  65438. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65439. /**
  65440. * Defines the name of the task
  65441. */
  65442. name: string;
  65443. /**
  65444. * Defines the location of the file to load
  65445. */
  65446. url: string;
  65447. /**
  65448. * Defines the desired size (the more it increases the longer the generation will be)
  65449. */
  65450. size: number;
  65451. /**
  65452. * Defines if mipmaps should not be generated (default is false)
  65453. */
  65454. noMipmap: boolean;
  65455. /**
  65456. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65457. * but the standard material would require them in Gamma space) (default is true)
  65458. */
  65459. gammaSpace: boolean;
  65460. /**
  65461. * Gets the loaded texture
  65462. */
  65463. texture: EquiRectangularCubeTexture;
  65464. /**
  65465. * Callback called when the task is successful
  65466. */
  65467. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65468. /**
  65469. * Callback called when the task is successful
  65470. */
  65471. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65472. /**
  65473. * Creates a new EquiRectangularCubeTextureAssetTask object
  65474. * @param name defines the name of the task
  65475. * @param url defines the location of the file to load
  65476. * @param size defines the desired size (the more it increases the longer the generation will be)
  65477. * If the size is omitted this implies you are using a preprocessed cubemap.
  65478. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65479. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65480. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65481. * (default is true)
  65482. */
  65483. constructor(
  65484. /**
  65485. * Defines the name of the task
  65486. */
  65487. name: string,
  65488. /**
  65489. * Defines the location of the file to load
  65490. */
  65491. url: string,
  65492. /**
  65493. * Defines the desired size (the more it increases the longer the generation will be)
  65494. */
  65495. size: number,
  65496. /**
  65497. * Defines if mipmaps should not be generated (default is false)
  65498. */
  65499. noMipmap?: boolean,
  65500. /**
  65501. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65502. * but the standard material would require them in Gamma space) (default is true)
  65503. */
  65504. gammaSpace?: boolean);
  65505. /**
  65506. * Execute the current task
  65507. * @param scene defines the scene where you want your assets to be loaded
  65508. * @param onSuccess is a callback called when the task is successfully executed
  65509. * @param onError is a callback called if an error occurs
  65510. */
  65511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65512. }
  65513. /**
  65514. * This class can be used to easily import assets into a scene
  65515. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65516. */
  65517. export class AssetsManager {
  65518. private _scene;
  65519. private _isLoading;
  65520. protected _tasks: AbstractAssetTask[];
  65521. protected _waitingTasksCount: number;
  65522. protected _totalTasksCount: number;
  65523. /**
  65524. * Callback called when all tasks are processed
  65525. */
  65526. onFinish: (tasks: AbstractAssetTask[]) => void;
  65527. /**
  65528. * Callback called when a task is successful
  65529. */
  65530. onTaskSuccess: (task: AbstractAssetTask) => void;
  65531. /**
  65532. * Callback called when a task had an error
  65533. */
  65534. onTaskError: (task: AbstractAssetTask) => void;
  65535. /**
  65536. * Callback called when a task is done (whatever the result is)
  65537. */
  65538. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65539. /**
  65540. * Observable called when all tasks are processed
  65541. */
  65542. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65543. /**
  65544. * Observable called when a task had an error
  65545. */
  65546. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65547. /**
  65548. * Observable called when all tasks were executed
  65549. */
  65550. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65551. /**
  65552. * Observable called when a task is done (whatever the result is)
  65553. */
  65554. onProgressObservable: Observable<IAssetsProgressEvent>;
  65555. /**
  65556. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65557. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65558. */
  65559. useDefaultLoadingScreen: boolean;
  65560. /**
  65561. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65562. * when all assets have been downloaded.
  65563. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65564. */
  65565. autoHideLoadingUI: boolean;
  65566. /**
  65567. * Creates a new AssetsManager
  65568. * @param scene defines the scene to work on
  65569. */
  65570. constructor(scene: Scene);
  65571. /**
  65572. * Add a MeshAssetTask to the list of active tasks
  65573. * @param taskName defines the name of the new task
  65574. * @param meshesNames defines the name of meshes to load
  65575. * @param rootUrl defines the root url to use to locate files
  65576. * @param sceneFilename defines the filename of the scene file
  65577. * @returns a new MeshAssetTask object
  65578. */
  65579. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65580. /**
  65581. * Add a TextFileAssetTask to the list of active tasks
  65582. * @param taskName defines the name of the new task
  65583. * @param url defines the url of the file to load
  65584. * @returns a new TextFileAssetTask object
  65585. */
  65586. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65587. /**
  65588. * Add a BinaryFileAssetTask to the list of active tasks
  65589. * @param taskName defines the name of the new task
  65590. * @param url defines the url of the file to load
  65591. * @returns a new BinaryFileAssetTask object
  65592. */
  65593. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65594. /**
  65595. * Add a ImageAssetTask to the list of active tasks
  65596. * @param taskName defines the name of the new task
  65597. * @param url defines the url of the file to load
  65598. * @returns a new ImageAssetTask object
  65599. */
  65600. addImageTask(taskName: string, url: string): ImageAssetTask;
  65601. /**
  65602. * Add a TextureAssetTask to the list of active tasks
  65603. * @param taskName defines the name of the new task
  65604. * @param url defines the url of the file to load
  65605. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65606. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65607. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65608. * @returns a new TextureAssetTask object
  65609. */
  65610. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65611. /**
  65612. * Add a CubeTextureAssetTask to the list of active tasks
  65613. * @param taskName defines the name of the new task
  65614. * @param url defines the url of the file to load
  65615. * @param extensions defines the extension to use to load the cube map (can be null)
  65616. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65617. * @param files defines the list of files to load (can be null)
  65618. * @returns a new CubeTextureAssetTask object
  65619. */
  65620. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65621. /**
  65622. *
  65623. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65624. * @param taskName defines the name of the new task
  65625. * @param url defines the url of the file to load
  65626. * @param size defines the size you want for the cubemap (can be null)
  65627. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65628. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65629. * @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)
  65630. * @param reserved Internal use only
  65631. * @returns a new HDRCubeTextureAssetTask object
  65632. */
  65633. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65634. /**
  65635. *
  65636. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65637. * @param taskName defines the name of the new task
  65638. * @param url defines the url of the file to load
  65639. * @param size defines the size you want for the cubemap (can be null)
  65640. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65641. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65642. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65643. * @returns a new EquiRectangularCubeTextureAssetTask object
  65644. */
  65645. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65646. /**
  65647. * Remove a task from the assets manager.
  65648. * @param task the task to remove
  65649. */
  65650. removeTask(task: AbstractAssetTask): void;
  65651. private _decreaseWaitingTasksCount;
  65652. private _runTask;
  65653. /**
  65654. * Reset the AssetsManager and remove all tasks
  65655. * @return the current instance of the AssetsManager
  65656. */
  65657. reset(): AssetsManager;
  65658. /**
  65659. * Start the loading process
  65660. * @return the current instance of the AssetsManager
  65661. */
  65662. load(): AssetsManager;
  65663. /**
  65664. * Start the loading process as an async operation
  65665. * @return a promise returning the list of failed tasks
  65666. */
  65667. loadAsync(): Promise<void>;
  65668. }
  65669. }
  65670. declare module "babylonjs/Misc/deferred" {
  65671. /**
  65672. * Wrapper class for promise with external resolve and reject.
  65673. */
  65674. export class Deferred<T> {
  65675. /**
  65676. * The promise associated with this deferred object.
  65677. */
  65678. readonly promise: Promise<T>;
  65679. private _resolve;
  65680. private _reject;
  65681. /**
  65682. * The resolve method of the promise associated with this deferred object.
  65683. */
  65684. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65685. /**
  65686. * The reject method of the promise associated with this deferred object.
  65687. */
  65688. readonly reject: (reason?: any) => void;
  65689. /**
  65690. * Constructor for this deferred object.
  65691. */
  65692. constructor();
  65693. }
  65694. }
  65695. declare module "babylonjs/Misc/meshExploder" {
  65696. import { Mesh } from "babylonjs/Meshes/mesh";
  65697. /**
  65698. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65699. */
  65700. export class MeshExploder {
  65701. private _centerMesh;
  65702. private _meshes;
  65703. private _meshesOrigins;
  65704. private _toCenterVectors;
  65705. private _scaledDirection;
  65706. private _newPosition;
  65707. private _centerPosition;
  65708. /**
  65709. * Explodes meshes from a center mesh.
  65710. * @param meshes The meshes to explode.
  65711. * @param centerMesh The mesh to be center of explosion.
  65712. */
  65713. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65714. private _setCenterMesh;
  65715. /**
  65716. * Get class name
  65717. * @returns "MeshExploder"
  65718. */
  65719. getClassName(): string;
  65720. /**
  65721. * "Exploded meshes"
  65722. * @returns Array of meshes with the centerMesh at index 0.
  65723. */
  65724. getMeshes(): Array<Mesh>;
  65725. /**
  65726. * Explodes meshes giving a specific direction
  65727. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65728. */
  65729. explode(direction?: number): void;
  65730. }
  65731. }
  65732. declare module "babylonjs/Misc/filesInput" {
  65733. import { Engine } from "babylonjs/Engines/engine";
  65734. import { Scene } from "babylonjs/scene";
  65735. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65736. /**
  65737. * Class used to help managing file picking and drag'n'drop
  65738. */
  65739. export class FilesInput {
  65740. /**
  65741. * List of files ready to be loaded
  65742. */
  65743. static readonly FilesToLoad: {
  65744. [key: string]: File;
  65745. };
  65746. /**
  65747. * Callback called when a file is processed
  65748. */
  65749. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65750. private _engine;
  65751. private _currentScene;
  65752. private _sceneLoadedCallback;
  65753. private _progressCallback;
  65754. private _additionalRenderLoopLogicCallback;
  65755. private _textureLoadingCallback;
  65756. private _startingProcessingFilesCallback;
  65757. private _onReloadCallback;
  65758. private _errorCallback;
  65759. private _elementToMonitor;
  65760. private _sceneFileToLoad;
  65761. private _filesToLoad;
  65762. /**
  65763. * Creates a new FilesInput
  65764. * @param engine defines the rendering engine
  65765. * @param scene defines the hosting scene
  65766. * @param sceneLoadedCallback callback called when scene is loaded
  65767. * @param progressCallback callback called to track progress
  65768. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65769. * @param textureLoadingCallback callback called when a texture is loading
  65770. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65771. * @param onReloadCallback callback called when a reload is requested
  65772. * @param errorCallback callback call if an error occurs
  65773. */
  65774. 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);
  65775. private _dragEnterHandler;
  65776. private _dragOverHandler;
  65777. private _dropHandler;
  65778. /**
  65779. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65780. * @param elementToMonitor defines the DOM element to track
  65781. */
  65782. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65783. /**
  65784. * Release all associated resources
  65785. */
  65786. dispose(): void;
  65787. private renderFunction;
  65788. private drag;
  65789. private drop;
  65790. private _traverseFolder;
  65791. private _processFiles;
  65792. /**
  65793. * Load files from a drop event
  65794. * @param event defines the drop event to use as source
  65795. */
  65796. loadFiles(event: any): void;
  65797. private _processReload;
  65798. /**
  65799. * Reload the current scene from the loaded files
  65800. */
  65801. reload(): void;
  65802. }
  65803. }
  65804. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65805. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65806. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65807. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65808. }
  65809. declare module "babylonjs/Misc/sceneOptimizer" {
  65810. import { Scene, IDisposable } from "babylonjs/scene";
  65811. import { Observable } from "babylonjs/Misc/observable";
  65812. /**
  65813. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65815. */
  65816. export class SceneOptimization {
  65817. /**
  65818. * Defines the priority of this optimization (0 by default which means first in the list)
  65819. */
  65820. priority: number;
  65821. /**
  65822. * Gets a string describing the action executed by the current optimization
  65823. * @returns description string
  65824. */
  65825. getDescription(): string;
  65826. /**
  65827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65828. * @param scene defines the current scene where to apply this optimization
  65829. * @param optimizer defines the current optimizer
  65830. * @returns true if everything that can be done was applied
  65831. */
  65832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65833. /**
  65834. * Creates the SceneOptimization object
  65835. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65836. * @param desc defines the description associated with the optimization
  65837. */
  65838. constructor(
  65839. /**
  65840. * Defines the priority of this optimization (0 by default which means first in the list)
  65841. */
  65842. priority?: number);
  65843. }
  65844. /**
  65845. * Defines an optimization used to reduce the size of render target textures
  65846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65847. */
  65848. export class TextureOptimization extends SceneOptimization {
  65849. /**
  65850. * Defines the priority of this optimization (0 by default which means first in the list)
  65851. */
  65852. priority: number;
  65853. /**
  65854. * 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
  65855. */
  65856. maximumSize: number;
  65857. /**
  65858. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65859. */
  65860. step: number;
  65861. /**
  65862. * Gets a string describing the action executed by the current optimization
  65863. * @returns description string
  65864. */
  65865. getDescription(): string;
  65866. /**
  65867. * Creates the TextureOptimization object
  65868. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65869. * @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
  65870. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65871. */
  65872. constructor(
  65873. /**
  65874. * Defines the priority of this optimization (0 by default which means first in the list)
  65875. */
  65876. priority?: number,
  65877. /**
  65878. * 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
  65879. */
  65880. maximumSize?: number,
  65881. /**
  65882. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65883. */
  65884. step?: number);
  65885. /**
  65886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65887. * @param scene defines the current scene where to apply this optimization
  65888. * @param optimizer defines the current optimizer
  65889. * @returns true if everything that can be done was applied
  65890. */
  65891. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65892. }
  65893. /**
  65894. * Defines an optimization used to increase or decrease the rendering resolution
  65895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65896. */
  65897. export class HardwareScalingOptimization extends SceneOptimization {
  65898. /**
  65899. * Defines the priority of this optimization (0 by default which means first in the list)
  65900. */
  65901. priority: number;
  65902. /**
  65903. * Defines the maximum scale to use (2 by default)
  65904. */
  65905. maximumScale: number;
  65906. /**
  65907. * Defines the step to use between two passes (0.5 by default)
  65908. */
  65909. step: number;
  65910. private _currentScale;
  65911. private _directionOffset;
  65912. /**
  65913. * Gets a string describing the action executed by the current optimization
  65914. * @return description string
  65915. */
  65916. getDescription(): string;
  65917. /**
  65918. * Creates the HardwareScalingOptimization object
  65919. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65920. * @param maximumScale defines the maximum scale to use (2 by default)
  65921. * @param step defines the step to use between two passes (0.5 by default)
  65922. */
  65923. constructor(
  65924. /**
  65925. * Defines the priority of this optimization (0 by default which means first in the list)
  65926. */
  65927. priority?: number,
  65928. /**
  65929. * Defines the maximum scale to use (2 by default)
  65930. */
  65931. maximumScale?: number,
  65932. /**
  65933. * Defines the step to use between two passes (0.5 by default)
  65934. */
  65935. step?: number);
  65936. /**
  65937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65938. * @param scene defines the current scene where to apply this optimization
  65939. * @param optimizer defines the current optimizer
  65940. * @returns true if everything that can be done was applied
  65941. */
  65942. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65943. }
  65944. /**
  65945. * Defines an optimization used to remove shadows
  65946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65947. */
  65948. export class ShadowsOptimization extends SceneOptimization {
  65949. /**
  65950. * Gets a string describing the action executed by the current optimization
  65951. * @return description string
  65952. */
  65953. getDescription(): string;
  65954. /**
  65955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65956. * @param scene defines the current scene where to apply this optimization
  65957. * @param optimizer defines the current optimizer
  65958. * @returns true if everything that can be done was applied
  65959. */
  65960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65961. }
  65962. /**
  65963. * Defines an optimization used to turn post-processes off
  65964. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65965. */
  65966. export class PostProcessesOptimization extends SceneOptimization {
  65967. /**
  65968. * Gets a string describing the action executed by the current optimization
  65969. * @return description string
  65970. */
  65971. getDescription(): string;
  65972. /**
  65973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65974. * @param scene defines the current scene where to apply this optimization
  65975. * @param optimizer defines the current optimizer
  65976. * @returns true if everything that can be done was applied
  65977. */
  65978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65979. }
  65980. /**
  65981. * Defines an optimization used to turn lens flares off
  65982. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65983. */
  65984. export class LensFlaresOptimization extends SceneOptimization {
  65985. /**
  65986. * Gets a string describing the action executed by the current optimization
  65987. * @return description string
  65988. */
  65989. getDescription(): string;
  65990. /**
  65991. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65992. * @param scene defines the current scene where to apply this optimization
  65993. * @param optimizer defines the current optimizer
  65994. * @returns true if everything that can be done was applied
  65995. */
  65996. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65997. }
  65998. /**
  65999. * Defines an optimization based on user defined callback.
  66000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66001. */
  66002. export class CustomOptimization extends SceneOptimization {
  66003. /**
  66004. * Callback called to apply the custom optimization.
  66005. */
  66006. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66007. /**
  66008. * Callback called to get custom description
  66009. */
  66010. onGetDescription: () => string;
  66011. /**
  66012. * Gets a string describing the action executed by the current optimization
  66013. * @returns description string
  66014. */
  66015. getDescription(): string;
  66016. /**
  66017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66018. * @param scene defines the current scene where to apply this optimization
  66019. * @param optimizer defines the current optimizer
  66020. * @returns true if everything that can be done was applied
  66021. */
  66022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66023. }
  66024. /**
  66025. * Defines an optimization used to turn particles off
  66026. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66027. */
  66028. export class ParticlesOptimization extends SceneOptimization {
  66029. /**
  66030. * Gets a string describing the action executed by the current optimization
  66031. * @return description string
  66032. */
  66033. getDescription(): string;
  66034. /**
  66035. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66036. * @param scene defines the current scene where to apply this optimization
  66037. * @param optimizer defines the current optimizer
  66038. * @returns true if everything that can be done was applied
  66039. */
  66040. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66041. }
  66042. /**
  66043. * Defines an optimization used to turn render targets off
  66044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66045. */
  66046. export class RenderTargetsOptimization extends SceneOptimization {
  66047. /**
  66048. * Gets a string describing the action executed by the current optimization
  66049. * @return description string
  66050. */
  66051. getDescription(): string;
  66052. /**
  66053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66054. * @param scene defines the current scene where to apply this optimization
  66055. * @param optimizer defines the current optimizer
  66056. * @returns true if everything that can be done was applied
  66057. */
  66058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66059. }
  66060. /**
  66061. * Defines an optimization used to merge meshes with compatible materials
  66062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66063. */
  66064. export class MergeMeshesOptimization extends SceneOptimization {
  66065. private static _UpdateSelectionTree;
  66066. /**
  66067. * Gets or sets a boolean which defines if optimization octree has to be updated
  66068. */
  66069. /**
  66070. * Gets or sets a boolean which defines if optimization octree has to be updated
  66071. */
  66072. static UpdateSelectionTree: boolean;
  66073. /**
  66074. * Gets a string describing the action executed by the current optimization
  66075. * @return description string
  66076. */
  66077. getDescription(): string;
  66078. private _canBeMerged;
  66079. /**
  66080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66081. * @param scene defines the current scene where to apply this optimization
  66082. * @param optimizer defines the current optimizer
  66083. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66084. * @returns true if everything that can be done was applied
  66085. */
  66086. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66087. }
  66088. /**
  66089. * Defines a list of options used by SceneOptimizer
  66090. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66091. */
  66092. export class SceneOptimizerOptions {
  66093. /**
  66094. * Defines the target frame rate to reach (60 by default)
  66095. */
  66096. targetFrameRate: number;
  66097. /**
  66098. * Defines the interval between two checkes (2000ms by default)
  66099. */
  66100. trackerDuration: number;
  66101. /**
  66102. * Gets the list of optimizations to apply
  66103. */
  66104. optimizations: SceneOptimization[];
  66105. /**
  66106. * Creates a new list of options used by SceneOptimizer
  66107. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66108. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66109. */
  66110. constructor(
  66111. /**
  66112. * Defines the target frame rate to reach (60 by default)
  66113. */
  66114. targetFrameRate?: number,
  66115. /**
  66116. * Defines the interval between two checkes (2000ms by default)
  66117. */
  66118. trackerDuration?: number);
  66119. /**
  66120. * Add a new optimization
  66121. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66122. * @returns the current SceneOptimizerOptions
  66123. */
  66124. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66125. /**
  66126. * Add a new custom optimization
  66127. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66128. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66129. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66130. * @returns the current SceneOptimizerOptions
  66131. */
  66132. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66133. /**
  66134. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66135. * @param targetFrameRate defines the target frame rate (60 by default)
  66136. * @returns a SceneOptimizerOptions object
  66137. */
  66138. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66139. /**
  66140. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66141. * @param targetFrameRate defines the target frame rate (60 by default)
  66142. * @returns a SceneOptimizerOptions object
  66143. */
  66144. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66145. /**
  66146. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66147. * @param targetFrameRate defines the target frame rate (60 by default)
  66148. * @returns a SceneOptimizerOptions object
  66149. */
  66150. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66151. }
  66152. /**
  66153. * Class used to run optimizations in order to reach a target frame rate
  66154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66155. */
  66156. export class SceneOptimizer implements IDisposable {
  66157. private _isRunning;
  66158. private _options;
  66159. private _scene;
  66160. private _currentPriorityLevel;
  66161. private _targetFrameRate;
  66162. private _trackerDuration;
  66163. private _currentFrameRate;
  66164. private _sceneDisposeObserver;
  66165. private _improvementMode;
  66166. /**
  66167. * Defines an observable called when the optimizer reaches the target frame rate
  66168. */
  66169. onSuccessObservable: Observable<SceneOptimizer>;
  66170. /**
  66171. * Defines an observable called when the optimizer enables an optimization
  66172. */
  66173. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66174. /**
  66175. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66176. */
  66177. onFailureObservable: Observable<SceneOptimizer>;
  66178. /**
  66179. * Gets a boolean indicating if the optimizer is in improvement mode
  66180. */
  66181. readonly isInImprovementMode: boolean;
  66182. /**
  66183. * Gets the current priority level (0 at start)
  66184. */
  66185. readonly currentPriorityLevel: number;
  66186. /**
  66187. * Gets the current frame rate checked by the SceneOptimizer
  66188. */
  66189. readonly currentFrameRate: number;
  66190. /**
  66191. * Gets or sets the current target frame rate (60 by default)
  66192. */
  66193. /**
  66194. * Gets or sets the current target frame rate (60 by default)
  66195. */
  66196. targetFrameRate: number;
  66197. /**
  66198. * Gets or sets the current interval between two checks (every 2000ms by default)
  66199. */
  66200. /**
  66201. * Gets or sets the current interval between two checks (every 2000ms by default)
  66202. */
  66203. trackerDuration: number;
  66204. /**
  66205. * Gets the list of active optimizations
  66206. */
  66207. readonly optimizations: SceneOptimization[];
  66208. /**
  66209. * Creates a new SceneOptimizer
  66210. * @param scene defines the scene to work on
  66211. * @param options defines the options to use with the SceneOptimizer
  66212. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66213. * @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)
  66214. */
  66215. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66216. /**
  66217. * Stops the current optimizer
  66218. */
  66219. stop(): void;
  66220. /**
  66221. * Reset the optimizer to initial step (current priority level = 0)
  66222. */
  66223. reset(): void;
  66224. /**
  66225. * Start the optimizer. By default it will try to reach a specific framerate
  66226. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66227. */
  66228. start(): void;
  66229. private _checkCurrentState;
  66230. /**
  66231. * Release all resources
  66232. */
  66233. dispose(): void;
  66234. /**
  66235. * Helper function to create a SceneOptimizer with one single line of code
  66236. * @param scene defines the scene to work on
  66237. * @param options defines the options to use with the SceneOptimizer
  66238. * @param onSuccess defines a callback to call on success
  66239. * @param onFailure defines a callback to call on failure
  66240. * @returns the new SceneOptimizer object
  66241. */
  66242. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66243. }
  66244. }
  66245. declare module "babylonjs/Misc/sceneSerializer" {
  66246. import { Scene } from "babylonjs/scene";
  66247. /**
  66248. * Class used to serialize a scene into a string
  66249. */
  66250. export class SceneSerializer {
  66251. /**
  66252. * Clear cache used by a previous serialization
  66253. */
  66254. static ClearCache(): void;
  66255. /**
  66256. * Serialize a scene into a JSON compatible object
  66257. * @param scene defines the scene to serialize
  66258. * @returns a JSON compatible object
  66259. */
  66260. static Serialize(scene: Scene): any;
  66261. /**
  66262. * Serialize a mesh into a JSON compatible object
  66263. * @param toSerialize defines the mesh to serialize
  66264. * @param withParents defines if parents must be serialized as well
  66265. * @param withChildren defines if children must be serialized as well
  66266. * @returns a JSON compatible object
  66267. */
  66268. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66269. }
  66270. }
  66271. declare module "babylonjs/Misc/textureTools" {
  66272. import { Texture } from "babylonjs/Materials/Textures/texture";
  66273. /**
  66274. * Class used to host texture specific utilities
  66275. */
  66276. export class TextureTools {
  66277. /**
  66278. * Uses the GPU to create a copy texture rescaled at a given size
  66279. * @param texture Texture to copy from
  66280. * @param width defines the desired width
  66281. * @param height defines the desired height
  66282. * @param useBilinearMode defines if bilinear mode has to be used
  66283. * @return the generated texture
  66284. */
  66285. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66286. }
  66287. }
  66288. declare module "babylonjs/Misc/videoRecorder" {
  66289. import { Nullable } from "babylonjs/types";
  66290. import { Engine } from "babylonjs/Engines/engine";
  66291. /**
  66292. * This represents the different options available for the video capture.
  66293. */
  66294. export interface VideoRecorderOptions {
  66295. /** Defines the mime type of the video. */
  66296. mimeType: string;
  66297. /** Defines the FPS the video should be recorded at. */
  66298. fps: number;
  66299. /** Defines the chunk size for the recording data. */
  66300. recordChunckSize: number;
  66301. /** The audio tracks to attach to the recording. */
  66302. audioTracks?: MediaStreamTrack[];
  66303. }
  66304. /**
  66305. * This can help with recording videos from BabylonJS.
  66306. * This is based on the available WebRTC functionalities of the browser.
  66307. *
  66308. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66309. */
  66310. export class VideoRecorder {
  66311. private static readonly _defaultOptions;
  66312. /**
  66313. * Returns whether or not the VideoRecorder is available in your browser.
  66314. * @param engine Defines the Babylon Engine.
  66315. * @returns true if supported otherwise false.
  66316. */
  66317. static IsSupported(engine: Engine): boolean;
  66318. private readonly _options;
  66319. private _canvas;
  66320. private _mediaRecorder;
  66321. private _recordedChunks;
  66322. private _fileName;
  66323. private _resolve;
  66324. private _reject;
  66325. /**
  66326. * True when a recording is already in progress.
  66327. */
  66328. readonly isRecording: boolean;
  66329. /**
  66330. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66331. * @param engine Defines the BabylonJS Engine you wish to record.
  66332. * @param options Defines options that can be used to customize the capture.
  66333. */
  66334. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66335. /**
  66336. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66337. */
  66338. stopRecording(): void;
  66339. /**
  66340. * Starts recording the canvas for a max duration specified in parameters.
  66341. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66342. * If null no automatic download will start and you can rely on the promise to get the data back.
  66343. * @param maxDuration Defines the maximum recording time in seconds.
  66344. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66345. * @return A promise callback at the end of the recording with the video data in Blob.
  66346. */
  66347. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66348. /**
  66349. * Releases internal resources used during the recording.
  66350. */
  66351. dispose(): void;
  66352. private _handleDataAvailable;
  66353. private _handleError;
  66354. private _handleStop;
  66355. }
  66356. }
  66357. declare module "babylonjs/Misc/screenshotTools" {
  66358. import { Camera } from "babylonjs/Cameras/camera";
  66359. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66360. import { Engine } from "babylonjs/Engines/engine";
  66361. /**
  66362. * Class containing a set of static utilities functions for screenshots
  66363. */
  66364. export class ScreenshotTools {
  66365. /**
  66366. * Captures a screenshot of the current rendering
  66367. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66368. * @param engine defines the rendering engine
  66369. * @param camera defines the source camera
  66370. * @param size This parameter can be set to a single number or to an object with the
  66371. * following (optional) properties: precision, width, height. If a single number is passed,
  66372. * it will be used for both width and height. If an object is passed, the screenshot size
  66373. * will be derived from the parameters. The precision property is a multiplier allowing
  66374. * rendering at a higher or lower resolution
  66375. * @param successCallback defines the callback receives a single parameter which contains the
  66376. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66377. * src parameter of an <img> to display it
  66378. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66379. * Check your browser for supported MIME types
  66380. */
  66381. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66382. /**
  66383. * Captures a screenshot of the current rendering
  66384. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66385. * @param engine defines the rendering engine
  66386. * @param camera defines the source camera
  66387. * @param size This parameter can be set to a single number or to an object with the
  66388. * following (optional) properties: precision, width, height. If a single number is passed,
  66389. * it will be used for both width and height. If an object is passed, the screenshot size
  66390. * will be derived from the parameters. The precision property is a multiplier allowing
  66391. * rendering at a higher or lower resolution
  66392. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66393. * Check your browser for supported MIME types
  66394. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66395. * to the src parameter of an <img> to display it
  66396. */
  66397. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66398. /**
  66399. * Generates an image screenshot from the specified camera.
  66400. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66401. * @param engine The engine to use for rendering
  66402. * @param camera The camera to use for rendering
  66403. * @param size This parameter can be set to a single number or to an object with the
  66404. * following (optional) properties: precision, width, height. If a single number is passed,
  66405. * it will be used for both width and height. If an object is passed, the screenshot size
  66406. * will be derived from the parameters. The precision property is a multiplier allowing
  66407. * rendering at a higher or lower resolution
  66408. * @param successCallback The callback receives a single parameter which contains the
  66409. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66410. * src parameter of an <img> to display it
  66411. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66412. * Check your browser for supported MIME types
  66413. * @param samples Texture samples (default: 1)
  66414. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66415. * @param fileName A name for for the downloaded file.
  66416. */
  66417. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66418. /**
  66419. * Generates an image screenshot from the specified camera.
  66420. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66421. * @param engine The engine to use for rendering
  66422. * @param camera The camera to use for rendering
  66423. * @param size This parameter can be set to a single number or to an object with the
  66424. * following (optional) properties: precision, width, height. If a single number is passed,
  66425. * it will be used for both width and height. If an object is passed, the screenshot size
  66426. * will be derived from the parameters. The precision property is a multiplier allowing
  66427. * rendering at a higher or lower resolution
  66428. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66429. * Check your browser for supported MIME types
  66430. * @param samples Texture samples (default: 1)
  66431. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66432. * @param fileName A name for for the downloaded file.
  66433. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66434. * to the src parameter of an <img> to display it
  66435. */
  66436. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66437. /**
  66438. * Gets height and width for screenshot size
  66439. * @private
  66440. */
  66441. private static _getScreenshotSize;
  66442. }
  66443. }
  66444. declare module "babylonjs/Misc/index" {
  66445. export * from "babylonjs/Misc/andOrNotEvaluator";
  66446. export * from "babylonjs/Misc/assetsManager";
  66447. export * from "babylonjs/Misc/dds";
  66448. export * from "babylonjs/Misc/decorators";
  66449. export * from "babylonjs/Misc/deferred";
  66450. export * from "babylonjs/Misc/environmentTextureTools";
  66451. export * from "babylonjs/Misc/meshExploder";
  66452. export * from "babylonjs/Misc/filesInput";
  66453. export * from "babylonjs/Misc/HighDynamicRange/index";
  66454. export * from "babylonjs/Misc/khronosTextureContainer";
  66455. export * from "babylonjs/Misc/observable";
  66456. export * from "babylonjs/Misc/performanceMonitor";
  66457. export * from "babylonjs/Misc/promise";
  66458. export * from "babylonjs/Misc/sceneOptimizer";
  66459. export * from "babylonjs/Misc/sceneSerializer";
  66460. export * from "babylonjs/Misc/smartArray";
  66461. export * from "babylonjs/Misc/stringDictionary";
  66462. export * from "babylonjs/Misc/tags";
  66463. export * from "babylonjs/Misc/textureTools";
  66464. export * from "babylonjs/Misc/tga";
  66465. export * from "babylonjs/Misc/tools";
  66466. export * from "babylonjs/Misc/videoRecorder";
  66467. export * from "babylonjs/Misc/virtualJoystick";
  66468. export * from "babylonjs/Misc/workerPool";
  66469. export * from "babylonjs/Misc/logger";
  66470. export * from "babylonjs/Misc/typeStore";
  66471. export * from "babylonjs/Misc/filesInputStore";
  66472. export * from "babylonjs/Misc/deepCopier";
  66473. export * from "babylonjs/Misc/pivotTools";
  66474. export * from "babylonjs/Misc/precisionDate";
  66475. export * from "babylonjs/Misc/screenshotTools";
  66476. export * from "babylonjs/Misc/typeStore";
  66477. export * from "babylonjs/Misc/webRequest";
  66478. export * from "babylonjs/Misc/iInspectable";
  66479. export * from "babylonjs/Misc/brdfTextureTools";
  66480. export * from "babylonjs/Misc/rgbdTextureTools";
  66481. export * from "babylonjs/Misc/gradients";
  66482. export * from "babylonjs/Misc/perfCounter";
  66483. export * from "babylonjs/Misc/fileRequest";
  66484. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66485. export * from "babylonjs/Misc/retryStrategy";
  66486. export * from "babylonjs/Misc/loadFileError";
  66487. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66488. }
  66489. declare module "babylonjs/index" {
  66490. export * from "babylonjs/abstractScene";
  66491. export * from "babylonjs/Actions/index";
  66492. export * from "babylonjs/Animations/index";
  66493. export * from "babylonjs/assetContainer";
  66494. export * from "babylonjs/Audio/index";
  66495. export * from "babylonjs/Behaviors/index";
  66496. export * from "babylonjs/Bones/index";
  66497. export * from "babylonjs/Cameras/index";
  66498. export * from "babylonjs/Collisions/index";
  66499. export * from "babylonjs/Culling/index";
  66500. export * from "babylonjs/Debug/index";
  66501. export * from "babylonjs/Engines/index";
  66502. export * from "babylonjs/Events/index";
  66503. export * from "babylonjs/Gamepads/index";
  66504. export * from "babylonjs/Gizmos/index";
  66505. export * from "babylonjs/Helpers/index";
  66506. export * from "babylonjs/Instrumentation/index";
  66507. export * from "babylonjs/Layers/index";
  66508. export * from "babylonjs/LensFlares/index";
  66509. export * from "babylonjs/Lights/index";
  66510. export * from "babylonjs/Loading/index";
  66511. export * from "babylonjs/Materials/index";
  66512. export * from "babylonjs/Maths/index";
  66513. export * from "babylonjs/Meshes/index";
  66514. export * from "babylonjs/Morph/index";
  66515. export * from "babylonjs/Navigation/index";
  66516. export * from "babylonjs/node";
  66517. export * from "babylonjs/Offline/index";
  66518. export * from "babylonjs/Particles/index";
  66519. export * from "babylonjs/Physics/index";
  66520. export * from "babylonjs/PostProcesses/index";
  66521. export * from "babylonjs/Probes/index";
  66522. export * from "babylonjs/Rendering/index";
  66523. export * from "babylonjs/scene";
  66524. export * from "babylonjs/sceneComponent";
  66525. export * from "babylonjs/Sprites/index";
  66526. export * from "babylonjs/States/index";
  66527. export * from "babylonjs/Misc/index";
  66528. export * from "babylonjs/types";
  66529. }
  66530. declare module "babylonjs/Animations/pathCursor" {
  66531. import { Vector3 } from "babylonjs/Maths/math.vector";
  66532. import { Path2 } from "babylonjs/Maths/math.path";
  66533. /**
  66534. * A cursor which tracks a point on a path
  66535. */
  66536. export class PathCursor {
  66537. private path;
  66538. /**
  66539. * Stores path cursor callbacks for when an onchange event is triggered
  66540. */
  66541. private _onchange;
  66542. /**
  66543. * The value of the path cursor
  66544. */
  66545. value: number;
  66546. /**
  66547. * The animation array of the path cursor
  66548. */
  66549. animations: Animation[];
  66550. /**
  66551. * Initializes the path cursor
  66552. * @param path The path to track
  66553. */
  66554. constructor(path: Path2);
  66555. /**
  66556. * Gets the cursor point on the path
  66557. * @returns A point on the path cursor at the cursor location
  66558. */
  66559. getPoint(): Vector3;
  66560. /**
  66561. * Moves the cursor ahead by the step amount
  66562. * @param step The amount to move the cursor forward
  66563. * @returns This path cursor
  66564. */
  66565. moveAhead(step?: number): PathCursor;
  66566. /**
  66567. * Moves the cursor behind by the step amount
  66568. * @param step The amount to move the cursor back
  66569. * @returns This path cursor
  66570. */
  66571. moveBack(step?: number): PathCursor;
  66572. /**
  66573. * Moves the cursor by the step amount
  66574. * If the step amount is greater than one, an exception is thrown
  66575. * @param step The amount to move the cursor
  66576. * @returns This path cursor
  66577. */
  66578. move(step: number): PathCursor;
  66579. /**
  66580. * Ensures that the value is limited between zero and one
  66581. * @returns This path cursor
  66582. */
  66583. private ensureLimits;
  66584. /**
  66585. * Runs onchange callbacks on change (used by the animation engine)
  66586. * @returns This path cursor
  66587. */
  66588. private raiseOnChange;
  66589. /**
  66590. * Executes a function on change
  66591. * @param f A path cursor onchange callback
  66592. * @returns This path cursor
  66593. */
  66594. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66595. }
  66596. }
  66597. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66598. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66599. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66600. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66601. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66602. }
  66603. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66604. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66605. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66606. }
  66607. declare module "babylonjs/Engines/Processors/index" {
  66608. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66609. export * from "babylonjs/Engines/Processors/Expressions/index";
  66610. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66611. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66612. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66613. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66614. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66615. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66616. }
  66617. declare module "babylonjs/Legacy/legacy" {
  66618. import * as Babylon from "babylonjs/index";
  66619. export * from "babylonjs/index";
  66620. }
  66621. declare module "babylonjs/Shaders/blur.fragment" {
  66622. /** @hidden */
  66623. export var blurPixelShader: {
  66624. name: string;
  66625. shader: string;
  66626. };
  66627. }
  66628. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66629. /** @hidden */
  66630. export var pointCloudVertexDeclaration: {
  66631. name: string;
  66632. shader: string;
  66633. };
  66634. }
  66635. declare module "babylonjs" {
  66636. export * from "babylonjs/Legacy/legacy";
  66637. }
  66638. declare module BABYLON {
  66639. /** Alias type for value that can be null */
  66640. export type Nullable<T> = T | null;
  66641. /**
  66642. * Alias type for number that are floats
  66643. * @ignorenaming
  66644. */
  66645. export type float = number;
  66646. /**
  66647. * Alias type for number that are doubles.
  66648. * @ignorenaming
  66649. */
  66650. export type double = number;
  66651. /**
  66652. * Alias type for number that are integer
  66653. * @ignorenaming
  66654. */
  66655. export type int = number;
  66656. /** Alias type for number array or Float32Array */
  66657. export type FloatArray = number[] | Float32Array;
  66658. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66659. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66660. /**
  66661. * Alias for types that can be used by a Buffer or VertexBuffer.
  66662. */
  66663. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66664. /**
  66665. * Alias type for primitive types
  66666. * @ignorenaming
  66667. */
  66668. type Primitive = undefined | null | boolean | string | number | Function;
  66669. /**
  66670. * Type modifier to make all the properties of an object Readonly
  66671. */
  66672. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66673. /**
  66674. * Type modifier to make all the properties of an object Readonly recursively
  66675. */
  66676. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66677. /**
  66678. * Type modifier to make object properties readonly.
  66679. */
  66680. export type DeepImmutableObject<T> = {
  66681. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66682. };
  66683. /** @hidden */
  66684. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66685. }
  66686. }
  66687. declare module BABYLON {
  66688. /**
  66689. * A class serves as a medium between the observable and its observers
  66690. */
  66691. export class EventState {
  66692. /**
  66693. * Create a new EventState
  66694. * @param mask defines the mask associated with this state
  66695. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66696. * @param target defines the original target of the state
  66697. * @param currentTarget defines the current target of the state
  66698. */
  66699. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66700. /**
  66701. * Initialize the current event state
  66702. * @param mask defines the mask associated with this state
  66703. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66704. * @param target defines the original target of the state
  66705. * @param currentTarget defines the current target of the state
  66706. * @returns the current event state
  66707. */
  66708. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66709. /**
  66710. * An Observer can set this property to true to prevent subsequent observers of being notified
  66711. */
  66712. skipNextObservers: boolean;
  66713. /**
  66714. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66715. */
  66716. mask: number;
  66717. /**
  66718. * The object that originally notified the event
  66719. */
  66720. target?: any;
  66721. /**
  66722. * The current object in the bubbling phase
  66723. */
  66724. currentTarget?: any;
  66725. /**
  66726. * This will be populated with the return value of the last function that was executed.
  66727. * If it is the first function in the callback chain it will be the event data.
  66728. */
  66729. lastReturnValue?: any;
  66730. }
  66731. /**
  66732. * Represent an Observer registered to a given Observable object.
  66733. */
  66734. export class Observer<T> {
  66735. /**
  66736. * Defines the callback to call when the observer is notified
  66737. */
  66738. callback: (eventData: T, eventState: EventState) => void;
  66739. /**
  66740. * Defines the mask of the observer (used to filter notifications)
  66741. */
  66742. mask: number;
  66743. /**
  66744. * Defines the current scope used to restore the JS context
  66745. */
  66746. scope: any;
  66747. /** @hidden */
  66748. _willBeUnregistered: boolean;
  66749. /**
  66750. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66751. */
  66752. unregisterOnNextCall: boolean;
  66753. /**
  66754. * Creates a new observer
  66755. * @param callback defines the callback to call when the observer is notified
  66756. * @param mask defines the mask of the observer (used to filter notifications)
  66757. * @param scope defines the current scope used to restore the JS context
  66758. */
  66759. constructor(
  66760. /**
  66761. * Defines the callback to call when the observer is notified
  66762. */
  66763. callback: (eventData: T, eventState: EventState) => void,
  66764. /**
  66765. * Defines the mask of the observer (used to filter notifications)
  66766. */
  66767. mask: number,
  66768. /**
  66769. * Defines the current scope used to restore the JS context
  66770. */
  66771. scope?: any);
  66772. }
  66773. /**
  66774. * Represent a list of observers registered to multiple Observables object.
  66775. */
  66776. export class MultiObserver<T> {
  66777. private _observers;
  66778. private _observables;
  66779. /**
  66780. * Release associated resources
  66781. */
  66782. dispose(): void;
  66783. /**
  66784. * Raise a callback when one of the observable will notify
  66785. * @param observables defines a list of observables to watch
  66786. * @param callback defines the callback to call on notification
  66787. * @param mask defines the mask used to filter notifications
  66788. * @param scope defines the current scope used to restore the JS context
  66789. * @returns the new MultiObserver
  66790. */
  66791. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66792. }
  66793. /**
  66794. * The Observable class is a simple implementation of the Observable pattern.
  66795. *
  66796. * 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.
  66797. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66798. * 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).
  66799. * 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.
  66800. */
  66801. export class Observable<T> {
  66802. private _observers;
  66803. private _eventState;
  66804. private _onObserverAdded;
  66805. /**
  66806. * Gets the list of observers
  66807. */
  66808. readonly observers: Array<Observer<T>>;
  66809. /**
  66810. * Creates a new observable
  66811. * @param onObserverAdded defines a callback to call when a new observer is added
  66812. */
  66813. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66814. /**
  66815. * Create a new Observer with the specified callback
  66816. * @param callback the callback that will be executed for that Observer
  66817. * @param mask the mask used to filter observers
  66818. * @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.
  66819. * @param scope optional scope for the callback to be called from
  66820. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66821. * @returns the new observer created for the callback
  66822. */
  66823. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66824. /**
  66825. * Create a new Observer with the specified callback and unregisters after the next notification
  66826. * @param callback the callback that will be executed for that Observer
  66827. * @returns the new observer created for the callback
  66828. */
  66829. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66830. /**
  66831. * Remove an Observer from the Observable object
  66832. * @param observer the instance of the Observer to remove
  66833. * @returns false if it doesn't belong to this Observable
  66834. */
  66835. remove(observer: Nullable<Observer<T>>): boolean;
  66836. /**
  66837. * Remove a callback from the Observable object
  66838. * @param callback the callback to remove
  66839. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66840. * @returns false if it doesn't belong to this Observable
  66841. */
  66842. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66843. private _deferUnregister;
  66844. private _remove;
  66845. /**
  66846. * Moves the observable to the top of the observer list making it get called first when notified
  66847. * @param observer the observer to move
  66848. */
  66849. makeObserverTopPriority(observer: Observer<T>): void;
  66850. /**
  66851. * Moves the observable to the bottom of the observer list making it get called last when notified
  66852. * @param observer the observer to move
  66853. */
  66854. makeObserverBottomPriority(observer: Observer<T>): void;
  66855. /**
  66856. * Notify all Observers by calling their respective callback with the given data
  66857. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66858. * @param eventData defines the data to send to all observers
  66859. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66860. * @param target defines the original target of the state
  66861. * @param currentTarget defines the current target of the state
  66862. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66863. */
  66864. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66865. /**
  66866. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66867. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66868. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66869. * and it is crucial that all callbacks will be executed.
  66870. * The order of the callbacks is kept, callbacks are not executed parallel.
  66871. *
  66872. * @param eventData The data to be sent to each callback
  66873. * @param mask is used to filter observers defaults to -1
  66874. * @param target defines the callback target (see EventState)
  66875. * @param currentTarget defines he current object in the bubbling phase
  66876. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66877. */
  66878. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66879. /**
  66880. * Notify a specific observer
  66881. * @param observer defines the observer to notify
  66882. * @param eventData defines the data to be sent to each callback
  66883. * @param mask is used to filter observers defaults to -1
  66884. */
  66885. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66886. /**
  66887. * Gets a boolean indicating if the observable has at least one observer
  66888. * @returns true is the Observable has at least one Observer registered
  66889. */
  66890. hasObservers(): boolean;
  66891. /**
  66892. * Clear the list of observers
  66893. */
  66894. clear(): void;
  66895. /**
  66896. * Clone the current observable
  66897. * @returns a new observable
  66898. */
  66899. clone(): Observable<T>;
  66900. /**
  66901. * Does this observable handles observer registered with a given mask
  66902. * @param mask defines the mask to be tested
  66903. * @return whether or not one observer registered with the given mask is handeled
  66904. **/
  66905. hasSpecificMask(mask?: number): boolean;
  66906. }
  66907. }
  66908. declare module BABYLON {
  66909. /**
  66910. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66911. * Babylon.js
  66912. */
  66913. export class DomManagement {
  66914. /**
  66915. * Checks if the window object exists
  66916. * @returns true if the window object exists
  66917. */
  66918. static IsWindowObjectExist(): boolean;
  66919. /**
  66920. * Checks if the navigator object exists
  66921. * @returns true if the navigator object exists
  66922. */
  66923. static IsNavigatorAvailable(): boolean;
  66924. /**
  66925. * Extracts text content from a DOM element hierarchy
  66926. * @param element defines the root element
  66927. * @returns a string
  66928. */
  66929. static GetDOMTextContent(element: HTMLElement): string;
  66930. }
  66931. }
  66932. declare module BABYLON {
  66933. /**
  66934. * Logger used througouht the application to allow configuration of
  66935. * the log level required for the messages.
  66936. */
  66937. export class Logger {
  66938. /**
  66939. * No log
  66940. */
  66941. static readonly NoneLogLevel: number;
  66942. /**
  66943. * Only message logs
  66944. */
  66945. static readonly MessageLogLevel: number;
  66946. /**
  66947. * Only warning logs
  66948. */
  66949. static readonly WarningLogLevel: number;
  66950. /**
  66951. * Only error logs
  66952. */
  66953. static readonly ErrorLogLevel: number;
  66954. /**
  66955. * All logs
  66956. */
  66957. static readonly AllLogLevel: number;
  66958. private static _LogCache;
  66959. /**
  66960. * Gets a value indicating the number of loading errors
  66961. * @ignorenaming
  66962. */
  66963. static errorsCount: number;
  66964. /**
  66965. * Callback called when a new log is added
  66966. */
  66967. static OnNewCacheEntry: (entry: string) => void;
  66968. private static _AddLogEntry;
  66969. private static _FormatMessage;
  66970. private static _LogDisabled;
  66971. private static _LogEnabled;
  66972. private static _WarnDisabled;
  66973. private static _WarnEnabled;
  66974. private static _ErrorDisabled;
  66975. private static _ErrorEnabled;
  66976. /**
  66977. * Log a message to the console
  66978. */
  66979. static Log: (message: string) => void;
  66980. /**
  66981. * Write a warning message to the console
  66982. */
  66983. static Warn: (message: string) => void;
  66984. /**
  66985. * Write an error message to the console
  66986. */
  66987. static Error: (message: string) => void;
  66988. /**
  66989. * Gets current log cache (list of logs)
  66990. */
  66991. static readonly LogCache: string;
  66992. /**
  66993. * Clears the log cache
  66994. */
  66995. static ClearLogCache(): void;
  66996. /**
  66997. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66998. */
  66999. static LogLevels: number;
  67000. }
  67001. }
  67002. declare module BABYLON {
  67003. /** @hidden */
  67004. export class _TypeStore {
  67005. /** @hidden */
  67006. static RegisteredTypes: {
  67007. [key: string]: Object;
  67008. };
  67009. /** @hidden */
  67010. static GetClass(fqdn: string): any;
  67011. }
  67012. }
  67013. declare module BABYLON {
  67014. /**
  67015. * Class containing a set of static utilities functions for deep copy.
  67016. */
  67017. export class DeepCopier {
  67018. /**
  67019. * Tries to copy an object by duplicating every property
  67020. * @param source defines the source object
  67021. * @param destination defines the target object
  67022. * @param doNotCopyList defines a list of properties to avoid
  67023. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67024. */
  67025. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67026. }
  67027. }
  67028. declare module BABYLON {
  67029. /**
  67030. * Class containing a set of static utilities functions for precision date
  67031. */
  67032. export class PrecisionDate {
  67033. /**
  67034. * Gets either window.performance.now() if supported or Date.now() else
  67035. */
  67036. static readonly Now: number;
  67037. }
  67038. }
  67039. declare module BABYLON {
  67040. /** @hidden */
  67041. export class _DevTools {
  67042. static WarnImport(name: string): string;
  67043. }
  67044. }
  67045. declare module BABYLON {
  67046. /**
  67047. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67048. */
  67049. export class WebRequest {
  67050. private _xhr;
  67051. /**
  67052. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67053. * i.e. when loading files, where the server/service expects an Authorization header
  67054. */
  67055. static CustomRequestHeaders: {
  67056. [key: string]: string;
  67057. };
  67058. /**
  67059. * Add callback functions in this array to update all the requests before they get sent to the network
  67060. */
  67061. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67062. private _injectCustomRequestHeaders;
  67063. /**
  67064. * Gets or sets a function to be called when loading progress changes
  67065. */
  67066. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67067. /**
  67068. * Returns client's state
  67069. */
  67070. readonly readyState: number;
  67071. /**
  67072. * Returns client's status
  67073. */
  67074. readonly status: number;
  67075. /**
  67076. * Returns client's status as a text
  67077. */
  67078. readonly statusText: string;
  67079. /**
  67080. * Returns client's response
  67081. */
  67082. readonly response: any;
  67083. /**
  67084. * Returns client's response url
  67085. */
  67086. readonly responseURL: string;
  67087. /**
  67088. * Returns client's response as text
  67089. */
  67090. readonly responseText: string;
  67091. /**
  67092. * Gets or sets the expected response type
  67093. */
  67094. responseType: XMLHttpRequestResponseType;
  67095. /** @hidden */
  67096. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67097. /** @hidden */
  67098. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67099. /**
  67100. * Cancels any network activity
  67101. */
  67102. abort(): void;
  67103. /**
  67104. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67105. * @param body defines an optional request body
  67106. */
  67107. send(body?: Document | BodyInit | null): void;
  67108. /**
  67109. * Sets the request method, request URL
  67110. * @param method defines the method to use (GET, POST, etc..)
  67111. * @param url defines the url to connect with
  67112. */
  67113. open(method: string, url: string): void;
  67114. }
  67115. }
  67116. declare module BABYLON {
  67117. /**
  67118. * File request interface
  67119. */
  67120. export interface IFileRequest {
  67121. /**
  67122. * Raised when the request is complete (success or error).
  67123. */
  67124. onCompleteObservable: Observable<IFileRequest>;
  67125. /**
  67126. * Aborts the request for a file.
  67127. */
  67128. abort: () => void;
  67129. }
  67130. }
  67131. declare module BABYLON {
  67132. /**
  67133. * Scalar computation library
  67134. */
  67135. export class Scalar {
  67136. /**
  67137. * Two pi constants convenient for computation.
  67138. */
  67139. static TwoPi: number;
  67140. /**
  67141. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67142. * @param a number
  67143. * @param b number
  67144. * @param epsilon (default = 1.401298E-45)
  67145. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67146. */
  67147. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  67148. /**
  67149. * Returns a string : the upper case translation of the number i to hexadecimal.
  67150. * @param i number
  67151. * @returns the upper case translation of the number i to hexadecimal.
  67152. */
  67153. static ToHex(i: number): string;
  67154. /**
  67155. * Returns -1 if value is negative and +1 is value is positive.
  67156. * @param value the value
  67157. * @returns the value itself if it's equal to zero.
  67158. */
  67159. static Sign(value: number): number;
  67160. /**
  67161. * Returns the value itself if it's between min and max.
  67162. * Returns min if the value is lower than min.
  67163. * Returns max if the value is greater than max.
  67164. * @param value the value to clmap
  67165. * @param min the min value to clamp to (default: 0)
  67166. * @param max the max value to clamp to (default: 1)
  67167. * @returns the clamped value
  67168. */
  67169. static Clamp(value: number, min?: number, max?: number): number;
  67170. /**
  67171. * the log2 of value.
  67172. * @param value the value to compute log2 of
  67173. * @returns the log2 of value.
  67174. */
  67175. static Log2(value: number): number;
  67176. /**
  67177. * Loops the value, so that it is never larger than length and never smaller than 0.
  67178. *
  67179. * This is similar to the modulo operator but it works with floating point numbers.
  67180. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67181. * With t = 5 and length = 2.5, the result would be 0.0.
  67182. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67183. * @param value the value
  67184. * @param length the length
  67185. * @returns the looped value
  67186. */
  67187. static Repeat(value: number, length: number): number;
  67188. /**
  67189. * Normalize the value between 0.0 and 1.0 using min and max values
  67190. * @param value value to normalize
  67191. * @param min max to normalize between
  67192. * @param max min to normalize between
  67193. * @returns the normalized value
  67194. */
  67195. static Normalize(value: number, min: number, max: number): number;
  67196. /**
  67197. * Denormalize the value from 0.0 and 1.0 using min and max values
  67198. * @param normalized value to denormalize
  67199. * @param min max to denormalize between
  67200. * @param max min to denormalize between
  67201. * @returns the denormalized value
  67202. */
  67203. static Denormalize(normalized: number, min: number, max: number): number;
  67204. /**
  67205. * Calculates the shortest difference between two given angles given in degrees.
  67206. * @param current current angle in degrees
  67207. * @param target target angle in degrees
  67208. * @returns the delta
  67209. */
  67210. static DeltaAngle(current: number, target: number): number;
  67211. /**
  67212. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67213. * @param tx value
  67214. * @param length length
  67215. * @returns The returned value will move back and forth between 0 and length
  67216. */
  67217. static PingPong(tx: number, length: number): number;
  67218. /**
  67219. * Interpolates between min and max with smoothing at the limits.
  67220. *
  67221. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67222. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67223. * @param from from
  67224. * @param to to
  67225. * @param tx value
  67226. * @returns the smooth stepped value
  67227. */
  67228. static SmoothStep(from: number, to: number, tx: number): number;
  67229. /**
  67230. * Moves a value current towards target.
  67231. *
  67232. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67233. * Negative values of maxDelta pushes the value away from target.
  67234. * @param current current value
  67235. * @param target target value
  67236. * @param maxDelta max distance to move
  67237. * @returns resulting value
  67238. */
  67239. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67240. /**
  67241. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67242. *
  67243. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67244. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67245. * @param current current value
  67246. * @param target target value
  67247. * @param maxDelta max distance to move
  67248. * @returns resulting angle
  67249. */
  67250. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67251. /**
  67252. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67253. * @param start start value
  67254. * @param end target value
  67255. * @param amount amount to lerp between
  67256. * @returns the lerped value
  67257. */
  67258. static Lerp(start: number, end: number, amount: number): number;
  67259. /**
  67260. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67261. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67262. * @param start start value
  67263. * @param end target value
  67264. * @param amount amount to lerp between
  67265. * @returns the lerped value
  67266. */
  67267. static LerpAngle(start: number, end: number, amount: number): number;
  67268. /**
  67269. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67270. * @param a start value
  67271. * @param b target value
  67272. * @param value value between a and b
  67273. * @returns the inverseLerp value
  67274. */
  67275. static InverseLerp(a: number, b: number, value: number): number;
  67276. /**
  67277. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67278. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67279. * @param value1 spline value
  67280. * @param tangent1 spline value
  67281. * @param value2 spline value
  67282. * @param tangent2 spline value
  67283. * @param amount input value
  67284. * @returns hermite result
  67285. */
  67286. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67287. /**
  67288. * Returns a random float number between and min and max values
  67289. * @param min min value of random
  67290. * @param max max value of random
  67291. * @returns random value
  67292. */
  67293. static RandomRange(min: number, max: number): number;
  67294. /**
  67295. * This function returns percentage of a number in a given range.
  67296. *
  67297. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67298. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67299. * @param number to convert to percentage
  67300. * @param min min range
  67301. * @param max max range
  67302. * @returns the percentage
  67303. */
  67304. static RangeToPercent(number: number, min: number, max: number): number;
  67305. /**
  67306. * This function returns number that corresponds to the percentage in a given range.
  67307. *
  67308. * PercentToRange(0.34,0,100) will return 34.
  67309. * @param percent to convert to number
  67310. * @param min min range
  67311. * @param max max range
  67312. * @returns the number
  67313. */
  67314. static PercentToRange(percent: number, min: number, max: number): number;
  67315. /**
  67316. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67317. * @param angle The angle to normalize in radian.
  67318. * @return The converted angle.
  67319. */
  67320. static NormalizeRadians(angle: number): number;
  67321. }
  67322. }
  67323. declare module BABYLON {
  67324. /**
  67325. * Constant used to convert a value to gamma space
  67326. * @ignorenaming
  67327. */
  67328. export const ToGammaSpace: number;
  67329. /**
  67330. * Constant used to convert a value to linear space
  67331. * @ignorenaming
  67332. */
  67333. export const ToLinearSpace = 2.2;
  67334. /**
  67335. * Constant used to define the minimal number value in Babylon.js
  67336. * @ignorenaming
  67337. */
  67338. let Epsilon: number;
  67339. }
  67340. declare module BABYLON {
  67341. /**
  67342. * Class used to represent a viewport on screen
  67343. */
  67344. export class Viewport {
  67345. /** viewport left coordinate */
  67346. x: number;
  67347. /** viewport top coordinate */
  67348. y: number;
  67349. /**viewport width */
  67350. width: number;
  67351. /** viewport height */
  67352. height: number;
  67353. /**
  67354. * Creates a Viewport object located at (x, y) and sized (width, height)
  67355. * @param x defines viewport left coordinate
  67356. * @param y defines viewport top coordinate
  67357. * @param width defines the viewport width
  67358. * @param height defines the viewport height
  67359. */
  67360. constructor(
  67361. /** viewport left coordinate */
  67362. x: number,
  67363. /** viewport top coordinate */
  67364. y: number,
  67365. /**viewport width */
  67366. width: number,
  67367. /** viewport height */
  67368. height: number);
  67369. /**
  67370. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67371. * @param renderWidth defines the rendering width
  67372. * @param renderHeight defines the rendering height
  67373. * @returns a new Viewport
  67374. */
  67375. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67376. /**
  67377. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67378. * @param renderWidth defines the rendering width
  67379. * @param renderHeight defines the rendering height
  67380. * @param ref defines the target viewport
  67381. * @returns the current viewport
  67382. */
  67383. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67384. /**
  67385. * Returns a new Viewport copied from the current one
  67386. * @returns a new Viewport
  67387. */
  67388. clone(): Viewport;
  67389. }
  67390. }
  67391. declare module BABYLON {
  67392. /**
  67393. * Class containing a set of static utilities functions for arrays.
  67394. */
  67395. export class ArrayTools {
  67396. /**
  67397. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67398. * @param size the number of element to construct and put in the array
  67399. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67400. * @returns a new array filled with new objects
  67401. */
  67402. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67403. }
  67404. }
  67405. declare module BABYLON {
  67406. /**
  67407. * @hidden
  67408. */
  67409. export interface IColor4Like {
  67410. r: float;
  67411. g: float;
  67412. b: float;
  67413. a: float;
  67414. }
  67415. /**
  67416. * @hidden
  67417. */
  67418. export interface IColor3Like {
  67419. r: float;
  67420. g: float;
  67421. b: float;
  67422. }
  67423. /**
  67424. * @hidden
  67425. */
  67426. export interface IVector4Like {
  67427. x: float;
  67428. y: float;
  67429. z: float;
  67430. w: float;
  67431. }
  67432. /**
  67433. * @hidden
  67434. */
  67435. export interface IVector3Like {
  67436. x: float;
  67437. y: float;
  67438. z: float;
  67439. }
  67440. /**
  67441. * @hidden
  67442. */
  67443. export interface IVector2Like {
  67444. x: float;
  67445. y: float;
  67446. }
  67447. /**
  67448. * @hidden
  67449. */
  67450. export interface IMatrixLike {
  67451. toArray(): DeepImmutable<Float32Array>;
  67452. updateFlag: int;
  67453. }
  67454. /**
  67455. * @hidden
  67456. */
  67457. export interface IViewportLike {
  67458. x: float;
  67459. y: float;
  67460. width: float;
  67461. height: float;
  67462. }
  67463. /**
  67464. * @hidden
  67465. */
  67466. export interface IPlaneLike {
  67467. normal: IVector3Like;
  67468. d: float;
  67469. normalize(): void;
  67470. }
  67471. }
  67472. declare module BABYLON {
  67473. /**
  67474. * Class representing a vector containing 2 coordinates
  67475. */
  67476. export class Vector2 {
  67477. /** defines the first coordinate */
  67478. x: number;
  67479. /** defines the second coordinate */
  67480. y: number;
  67481. /**
  67482. * Creates a new Vector2 from the given x and y coordinates
  67483. * @param x defines the first coordinate
  67484. * @param y defines the second coordinate
  67485. */
  67486. constructor(
  67487. /** defines the first coordinate */
  67488. x?: number,
  67489. /** defines the second coordinate */
  67490. y?: number);
  67491. /**
  67492. * Gets a string with the Vector2 coordinates
  67493. * @returns a string with the Vector2 coordinates
  67494. */
  67495. toString(): string;
  67496. /**
  67497. * Gets class name
  67498. * @returns the string "Vector2"
  67499. */
  67500. getClassName(): string;
  67501. /**
  67502. * Gets current vector hash code
  67503. * @returns the Vector2 hash code as a number
  67504. */
  67505. getHashCode(): number;
  67506. /**
  67507. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67508. * @param array defines the source array
  67509. * @param index defines the offset in source array
  67510. * @returns the current Vector2
  67511. */
  67512. toArray(array: FloatArray, index?: number): Vector2;
  67513. /**
  67514. * Copy the current vector to an array
  67515. * @returns a new array with 2 elements: the Vector2 coordinates.
  67516. */
  67517. asArray(): number[];
  67518. /**
  67519. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67520. * @param source defines the source Vector2
  67521. * @returns the current updated Vector2
  67522. */
  67523. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67524. /**
  67525. * Sets the Vector2 coordinates with the given floats
  67526. * @param x defines the first coordinate
  67527. * @param y defines the second coordinate
  67528. * @returns the current updated Vector2
  67529. */
  67530. copyFromFloats(x: number, y: number): Vector2;
  67531. /**
  67532. * Sets the Vector2 coordinates with the given floats
  67533. * @param x defines the first coordinate
  67534. * @param y defines the second coordinate
  67535. * @returns the current updated Vector2
  67536. */
  67537. set(x: number, y: number): Vector2;
  67538. /**
  67539. * Add another vector with the current one
  67540. * @param otherVector defines the other vector
  67541. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67542. */
  67543. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67544. /**
  67545. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67546. * @param otherVector defines the other vector
  67547. * @param result defines the target vector
  67548. * @returns the unmodified current Vector2
  67549. */
  67550. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67551. /**
  67552. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67553. * @param otherVector defines the other vector
  67554. * @returns the current updated Vector2
  67555. */
  67556. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67557. /**
  67558. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67559. * @param otherVector defines the other vector
  67560. * @returns a new Vector2
  67561. */
  67562. addVector3(otherVector: Vector3): Vector2;
  67563. /**
  67564. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67565. * @param otherVector defines the other vector
  67566. * @returns a new Vector2
  67567. */
  67568. subtract(otherVector: Vector2): Vector2;
  67569. /**
  67570. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67571. * @param otherVector defines the other vector
  67572. * @param result defines the target vector
  67573. * @returns the unmodified current Vector2
  67574. */
  67575. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67576. /**
  67577. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67578. * @param otherVector defines the other vector
  67579. * @returns the current updated Vector2
  67580. */
  67581. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67582. /**
  67583. * Multiplies in place the current Vector2 coordinates by the given ones
  67584. * @param otherVector defines the other vector
  67585. * @returns the current updated Vector2
  67586. */
  67587. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67588. /**
  67589. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67590. * @param otherVector defines the other vector
  67591. * @returns a new Vector2
  67592. */
  67593. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67594. /**
  67595. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67596. * @param otherVector defines the other vector
  67597. * @param result defines the target vector
  67598. * @returns the unmodified current Vector2
  67599. */
  67600. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67601. /**
  67602. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67603. * @param x defines the first coordinate
  67604. * @param y defines the second coordinate
  67605. * @returns a new Vector2
  67606. */
  67607. multiplyByFloats(x: number, y: number): Vector2;
  67608. /**
  67609. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67610. * @param otherVector defines the other vector
  67611. * @returns a new Vector2
  67612. */
  67613. divide(otherVector: Vector2): Vector2;
  67614. /**
  67615. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67616. * @param otherVector defines the other vector
  67617. * @param result defines the target vector
  67618. * @returns the unmodified current Vector2
  67619. */
  67620. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67621. /**
  67622. * Divides the current Vector2 coordinates by the given ones
  67623. * @param otherVector defines the other vector
  67624. * @returns the current updated Vector2
  67625. */
  67626. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67627. /**
  67628. * Gets a new Vector2 with current Vector2 negated coordinates
  67629. * @returns a new Vector2
  67630. */
  67631. negate(): Vector2;
  67632. /**
  67633. * Multiply the Vector2 coordinates by scale
  67634. * @param scale defines the scaling factor
  67635. * @returns the current updated Vector2
  67636. */
  67637. scaleInPlace(scale: number): Vector2;
  67638. /**
  67639. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67640. * @param scale defines the scaling factor
  67641. * @returns a new Vector2
  67642. */
  67643. scale(scale: number): Vector2;
  67644. /**
  67645. * Scale the current Vector2 values by a factor to a given Vector2
  67646. * @param scale defines the scale factor
  67647. * @param result defines the Vector2 object where to store the result
  67648. * @returns the unmodified current Vector2
  67649. */
  67650. scaleToRef(scale: number, result: Vector2): Vector2;
  67651. /**
  67652. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67653. * @param scale defines the scale factor
  67654. * @param result defines the Vector2 object where to store the result
  67655. * @returns the unmodified current Vector2
  67656. */
  67657. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67658. /**
  67659. * Gets a boolean if two vectors are equals
  67660. * @param otherVector defines the other vector
  67661. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67662. */
  67663. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67664. /**
  67665. * Gets a boolean if two vectors are equals (using an epsilon value)
  67666. * @param otherVector defines the other vector
  67667. * @param epsilon defines the minimal distance to consider equality
  67668. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67669. */
  67670. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67671. /**
  67672. * Gets a new Vector2 from current Vector2 floored values
  67673. * @returns a new Vector2
  67674. */
  67675. floor(): Vector2;
  67676. /**
  67677. * Gets a new Vector2 from current Vector2 floored values
  67678. * @returns a new Vector2
  67679. */
  67680. fract(): Vector2;
  67681. /**
  67682. * Gets the length of the vector
  67683. * @returns the vector length (float)
  67684. */
  67685. length(): number;
  67686. /**
  67687. * Gets the vector squared length
  67688. * @returns the vector squared length (float)
  67689. */
  67690. lengthSquared(): number;
  67691. /**
  67692. * Normalize the vector
  67693. * @returns the current updated Vector2
  67694. */
  67695. normalize(): Vector2;
  67696. /**
  67697. * Gets a new Vector2 copied from the Vector2
  67698. * @returns a new Vector2
  67699. */
  67700. clone(): Vector2;
  67701. /**
  67702. * Gets a new Vector2(0, 0)
  67703. * @returns a new Vector2
  67704. */
  67705. static Zero(): Vector2;
  67706. /**
  67707. * Gets a new Vector2(1, 1)
  67708. * @returns a new Vector2
  67709. */
  67710. static One(): Vector2;
  67711. /**
  67712. * Gets a new Vector2 set from the given index element of the given array
  67713. * @param array defines the data source
  67714. * @param offset defines the offset in the data source
  67715. * @returns a new Vector2
  67716. */
  67717. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67718. /**
  67719. * Sets "result" from the given index element of the given array
  67720. * @param array defines the data source
  67721. * @param offset defines the offset in the data source
  67722. * @param result defines the target vector
  67723. */
  67724. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67725. /**
  67726. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67727. * @param value1 defines 1st point of control
  67728. * @param value2 defines 2nd point of control
  67729. * @param value3 defines 3rd point of control
  67730. * @param value4 defines 4th point of control
  67731. * @param amount defines the interpolation factor
  67732. * @returns a new Vector2
  67733. */
  67734. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67735. /**
  67736. * 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".
  67737. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67738. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67739. * @param value defines the value to clamp
  67740. * @param min defines the lower limit
  67741. * @param max defines the upper limit
  67742. * @returns a new Vector2
  67743. */
  67744. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67745. /**
  67746. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67747. * @param value1 defines the 1st control point
  67748. * @param tangent1 defines the outgoing tangent
  67749. * @param value2 defines the 2nd control point
  67750. * @param tangent2 defines the incoming tangent
  67751. * @param amount defines the interpolation factor
  67752. * @returns a new Vector2
  67753. */
  67754. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67755. /**
  67756. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67757. * @param start defines the start vector
  67758. * @param end defines the end vector
  67759. * @param amount defines the interpolation factor
  67760. * @returns a new Vector2
  67761. */
  67762. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67763. /**
  67764. * Gets the dot product of the vector "left" and the vector "right"
  67765. * @param left defines first vector
  67766. * @param right defines second vector
  67767. * @returns the dot product (float)
  67768. */
  67769. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67770. /**
  67771. * Returns a new Vector2 equal to the normalized given vector
  67772. * @param vector defines the vector to normalize
  67773. * @returns a new Vector2
  67774. */
  67775. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67776. /**
  67777. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67778. * @param left defines 1st vector
  67779. * @param right defines 2nd vector
  67780. * @returns a new Vector2
  67781. */
  67782. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67783. /**
  67784. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67785. * @param left defines 1st vector
  67786. * @param right defines 2nd vector
  67787. * @returns a new Vector2
  67788. */
  67789. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67790. /**
  67791. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67792. * @param vector defines the vector to transform
  67793. * @param transformation defines the matrix to apply
  67794. * @returns a new Vector2
  67795. */
  67796. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67797. /**
  67798. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67799. * @param vector defines the vector to transform
  67800. * @param transformation defines the matrix to apply
  67801. * @param result defines the target vector
  67802. */
  67803. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67804. /**
  67805. * Determines if a given vector is included in a triangle
  67806. * @param p defines the vector to test
  67807. * @param p0 defines 1st triangle point
  67808. * @param p1 defines 2nd triangle point
  67809. * @param p2 defines 3rd triangle point
  67810. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67811. */
  67812. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67813. /**
  67814. * Gets the distance between the vectors "value1" and "value2"
  67815. * @param value1 defines first vector
  67816. * @param value2 defines second vector
  67817. * @returns the distance between vectors
  67818. */
  67819. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67820. /**
  67821. * Returns the squared distance between the vectors "value1" and "value2"
  67822. * @param value1 defines first vector
  67823. * @param value2 defines second vector
  67824. * @returns the squared distance between vectors
  67825. */
  67826. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67827. /**
  67828. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67829. * @param value1 defines first vector
  67830. * @param value2 defines second vector
  67831. * @returns a new Vector2
  67832. */
  67833. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67834. /**
  67835. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67836. * @param p defines the middle point
  67837. * @param segA defines one point of the segment
  67838. * @param segB defines the other point of the segment
  67839. * @returns the shortest distance
  67840. */
  67841. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67842. }
  67843. /**
  67844. * Classed used to store (x,y,z) vector representation
  67845. * A Vector3 is the main object used in 3D geometry
  67846. * It can represent etiher the coordinates of a point the space, either a direction
  67847. * Reminder: js uses a left handed forward facing system
  67848. */
  67849. export class Vector3 {
  67850. /**
  67851. * Defines the first coordinates (on X axis)
  67852. */
  67853. x: number;
  67854. /**
  67855. * Defines the second coordinates (on Y axis)
  67856. */
  67857. y: number;
  67858. /**
  67859. * Defines the third coordinates (on Z axis)
  67860. */
  67861. z: number;
  67862. private static _UpReadOnly;
  67863. private static _ZeroReadOnly;
  67864. /**
  67865. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67866. * @param x defines the first coordinates (on X axis)
  67867. * @param y defines the second coordinates (on Y axis)
  67868. * @param z defines the third coordinates (on Z axis)
  67869. */
  67870. constructor(
  67871. /**
  67872. * Defines the first coordinates (on X axis)
  67873. */
  67874. x?: number,
  67875. /**
  67876. * Defines the second coordinates (on Y axis)
  67877. */
  67878. y?: number,
  67879. /**
  67880. * Defines the third coordinates (on Z axis)
  67881. */
  67882. z?: number);
  67883. /**
  67884. * Creates a string representation of the Vector3
  67885. * @returns a string with the Vector3 coordinates.
  67886. */
  67887. toString(): string;
  67888. /**
  67889. * Gets the class name
  67890. * @returns the string "Vector3"
  67891. */
  67892. getClassName(): string;
  67893. /**
  67894. * Creates the Vector3 hash code
  67895. * @returns a number which tends to be unique between Vector3 instances
  67896. */
  67897. getHashCode(): number;
  67898. /**
  67899. * Creates an array containing three elements : the coordinates of the Vector3
  67900. * @returns a new array of numbers
  67901. */
  67902. asArray(): number[];
  67903. /**
  67904. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67905. * @param array defines the destination array
  67906. * @param index defines the offset in the destination array
  67907. * @returns the current Vector3
  67908. */
  67909. toArray(array: FloatArray, index?: number): Vector3;
  67910. /**
  67911. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67912. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67913. */
  67914. toQuaternion(): Quaternion;
  67915. /**
  67916. * Adds the given vector to the current Vector3
  67917. * @param otherVector defines the second operand
  67918. * @returns the current updated Vector3
  67919. */
  67920. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67921. /**
  67922. * Adds the given coordinates to the current Vector3
  67923. * @param x defines the x coordinate of the operand
  67924. * @param y defines the y coordinate of the operand
  67925. * @param z defines the z coordinate of the operand
  67926. * @returns the current updated Vector3
  67927. */
  67928. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67929. /**
  67930. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67931. * @param otherVector defines the second operand
  67932. * @returns the resulting Vector3
  67933. */
  67934. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67935. /**
  67936. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67937. * @param otherVector defines the second operand
  67938. * @param result defines the Vector3 object where to store the result
  67939. * @returns the current Vector3
  67940. */
  67941. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67942. /**
  67943. * Subtract the given vector from the current Vector3
  67944. * @param otherVector defines the second operand
  67945. * @returns the current updated Vector3
  67946. */
  67947. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67948. /**
  67949. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67950. * @param otherVector defines the second operand
  67951. * @returns the resulting Vector3
  67952. */
  67953. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67954. /**
  67955. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67956. * @param otherVector defines the second operand
  67957. * @param result defines the Vector3 object where to store the result
  67958. * @returns the current Vector3
  67959. */
  67960. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67961. /**
  67962. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67963. * @param x defines the x coordinate of the operand
  67964. * @param y defines the y coordinate of the operand
  67965. * @param z defines the z coordinate of the operand
  67966. * @returns the resulting Vector3
  67967. */
  67968. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67969. /**
  67970. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67971. * @param x defines the x coordinate of the operand
  67972. * @param y defines the y coordinate of the operand
  67973. * @param z defines the z coordinate of the operand
  67974. * @param result defines the Vector3 object where to store the result
  67975. * @returns the current Vector3
  67976. */
  67977. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67978. /**
  67979. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67980. * @returns a new Vector3
  67981. */
  67982. negate(): Vector3;
  67983. /**
  67984. * Multiplies the Vector3 coordinates by the float "scale"
  67985. * @param scale defines the multiplier factor
  67986. * @returns the current updated Vector3
  67987. */
  67988. scaleInPlace(scale: number): Vector3;
  67989. /**
  67990. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67991. * @param scale defines the multiplier factor
  67992. * @returns a new Vector3
  67993. */
  67994. scale(scale: number): Vector3;
  67995. /**
  67996. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67997. * @param scale defines the multiplier factor
  67998. * @param result defines the Vector3 object where to store the result
  67999. * @returns the current Vector3
  68000. */
  68001. scaleToRef(scale: number, result: Vector3): Vector3;
  68002. /**
  68003. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  68004. * @param scale defines the scale factor
  68005. * @param result defines the Vector3 object where to store the result
  68006. * @returns the unmodified current Vector3
  68007. */
  68008. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  68009. /**
  68010. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  68011. * @param otherVector defines the second operand
  68012. * @returns true if both vectors are equals
  68013. */
  68014. equals(otherVector: DeepImmutable<Vector3>): boolean;
  68015. /**
  68016. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  68017. * @param otherVector defines the second operand
  68018. * @param epsilon defines the minimal distance to define values as equals
  68019. * @returns true if both vectors are distant less than epsilon
  68020. */
  68021. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  68022. /**
  68023. * Returns true if the current Vector3 coordinates equals the given floats
  68024. * @param x defines the x coordinate of the operand
  68025. * @param y defines the y coordinate of the operand
  68026. * @param z defines the z coordinate of the operand
  68027. * @returns true if both vectors are equals
  68028. */
  68029. equalsToFloats(x: number, y: number, z: number): boolean;
  68030. /**
  68031. * Multiplies the current Vector3 coordinates by the given ones
  68032. * @param otherVector defines the second operand
  68033. * @returns the current updated Vector3
  68034. */
  68035. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68036. /**
  68037. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  68038. * @param otherVector defines the second operand
  68039. * @returns the new Vector3
  68040. */
  68041. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  68042. /**
  68043. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  68044. * @param otherVector defines the second operand
  68045. * @param result defines the Vector3 object where to store the result
  68046. * @returns the current Vector3
  68047. */
  68048. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68049. /**
  68050. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  68051. * @param x defines the x coordinate of the operand
  68052. * @param y defines the y coordinate of the operand
  68053. * @param z defines the z coordinate of the operand
  68054. * @returns the new Vector3
  68055. */
  68056. multiplyByFloats(x: number, y: number, z: number): Vector3;
  68057. /**
  68058. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  68059. * @param otherVector defines the second operand
  68060. * @returns the new Vector3
  68061. */
  68062. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  68063. /**
  68064. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  68065. * @param otherVector defines the second operand
  68066. * @param result defines the Vector3 object where to store the result
  68067. * @returns the current Vector3
  68068. */
  68069. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68070. /**
  68071. * Divides the current Vector3 coordinates by the given ones.
  68072. * @param otherVector defines the second operand
  68073. * @returns the current updated Vector3
  68074. */
  68075. divideInPlace(otherVector: Vector3): Vector3;
  68076. /**
  68077. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  68078. * @param other defines the second operand
  68079. * @returns the current updated Vector3
  68080. */
  68081. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68082. /**
  68083. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  68084. * @param other defines the second operand
  68085. * @returns the current updated Vector3
  68086. */
  68087. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68088. /**
  68089. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68090. * @param x defines the x coordinate of the operand
  68091. * @param y defines the y coordinate of the operand
  68092. * @param z defines the z coordinate of the operand
  68093. * @returns the current updated Vector3
  68094. */
  68095. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68096. /**
  68097. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68098. * @param x defines the x coordinate of the operand
  68099. * @param y defines the y coordinate of the operand
  68100. * @param z defines the z coordinate of the operand
  68101. * @returns the current updated Vector3
  68102. */
  68103. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68104. /**
  68105. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68106. * Check if is non uniform within a certain amount of decimal places to account for this
  68107. * @param epsilon the amount the values can differ
  68108. * @returns if the the vector is non uniform to a certain number of decimal places
  68109. */
  68110. isNonUniformWithinEpsilon(epsilon: number): boolean;
  68111. /**
  68112. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68113. */
  68114. readonly isNonUniform: boolean;
  68115. /**
  68116. * Gets a new Vector3 from current Vector3 floored values
  68117. * @returns a new Vector3
  68118. */
  68119. floor(): Vector3;
  68120. /**
  68121. * Gets a new Vector3 from current Vector3 floored values
  68122. * @returns a new Vector3
  68123. */
  68124. fract(): Vector3;
  68125. /**
  68126. * Gets the length of the Vector3
  68127. * @returns the length of the Vector3
  68128. */
  68129. length(): number;
  68130. /**
  68131. * Gets the squared length of the Vector3
  68132. * @returns squared length of the Vector3
  68133. */
  68134. lengthSquared(): number;
  68135. /**
  68136. * Normalize the current Vector3.
  68137. * Please note that this is an in place operation.
  68138. * @returns the current updated Vector3
  68139. */
  68140. normalize(): Vector3;
  68141. /**
  68142. * Reorders the x y z properties of the vector in place
  68143. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68144. * @returns the current updated vector
  68145. */
  68146. reorderInPlace(order: string): this;
  68147. /**
  68148. * Rotates the vector around 0,0,0 by a quaternion
  68149. * @param quaternion the rotation quaternion
  68150. * @param result vector to store the result
  68151. * @returns the resulting vector
  68152. */
  68153. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  68154. /**
  68155. * Rotates a vector around a given point
  68156. * @param quaternion the rotation quaternion
  68157. * @param point the point to rotate around
  68158. * @param result vector to store the result
  68159. * @returns the resulting vector
  68160. */
  68161. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  68162. /**
  68163. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  68164. * The cross product is then orthogonal to both current and "other"
  68165. * @param other defines the right operand
  68166. * @returns the cross product
  68167. */
  68168. cross(other: Vector3): Vector3;
  68169. /**
  68170. * Normalize the current Vector3 with the given input length.
  68171. * Please note that this is an in place operation.
  68172. * @param len the length of the vector
  68173. * @returns the current updated Vector3
  68174. */
  68175. normalizeFromLength(len: number): Vector3;
  68176. /**
  68177. * Normalize the current Vector3 to a new vector
  68178. * @returns the new Vector3
  68179. */
  68180. normalizeToNew(): Vector3;
  68181. /**
  68182. * Normalize the current Vector3 to the reference
  68183. * @param reference define the Vector3 to update
  68184. * @returns the updated Vector3
  68185. */
  68186. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  68187. /**
  68188. * Creates a new Vector3 copied from the current Vector3
  68189. * @returns the new Vector3
  68190. */
  68191. clone(): Vector3;
  68192. /**
  68193. * Copies the given vector coordinates to the current Vector3 ones
  68194. * @param source defines the source Vector3
  68195. * @returns the current updated Vector3
  68196. */
  68197. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  68198. /**
  68199. * Copies the given floats to the current Vector3 coordinates
  68200. * @param x defines the x coordinate of the operand
  68201. * @param y defines the y coordinate of the operand
  68202. * @param z defines the z coordinate of the operand
  68203. * @returns the current updated Vector3
  68204. */
  68205. copyFromFloats(x: number, y: number, z: number): Vector3;
  68206. /**
  68207. * Copies the given floats to the current Vector3 coordinates
  68208. * @param x defines the x coordinate of the operand
  68209. * @param y defines the y coordinate of the operand
  68210. * @param z defines the z coordinate of the operand
  68211. * @returns the current updated Vector3
  68212. */
  68213. set(x: number, y: number, z: number): Vector3;
  68214. /**
  68215. * Copies the given float to the current Vector3 coordinates
  68216. * @param v defines the x, y and z coordinates of the operand
  68217. * @returns the current updated Vector3
  68218. */
  68219. setAll(v: number): Vector3;
  68220. /**
  68221. * Get the clip factor between two vectors
  68222. * @param vector0 defines the first operand
  68223. * @param vector1 defines the second operand
  68224. * @param axis defines the axis to use
  68225. * @param size defines the size along the axis
  68226. * @returns the clip factor
  68227. */
  68228. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  68229. /**
  68230. * Get angle between two vectors
  68231. * @param vector0 angle between vector0 and vector1
  68232. * @param vector1 angle between vector0 and vector1
  68233. * @param normal direction of the normal
  68234. * @return the angle between vector0 and vector1
  68235. */
  68236. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68237. /**
  68238. * Returns a new Vector3 set from the index "offset" of the given array
  68239. * @param array defines the source array
  68240. * @param offset defines the offset in the source array
  68241. * @returns the new Vector3
  68242. */
  68243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68244. /**
  68245. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68246. * This function is deprecated. Use FromArray instead
  68247. * @param array defines the source array
  68248. * @param offset defines the offset in the source array
  68249. * @returns the new Vector3
  68250. */
  68251. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68252. /**
  68253. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68254. * @param array defines the source array
  68255. * @param offset defines the offset in the source array
  68256. * @param result defines the Vector3 where to store the result
  68257. */
  68258. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68259. /**
  68260. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68261. * This function is deprecated. Use FromArrayToRef instead.
  68262. * @param array defines the source array
  68263. * @param offset defines the offset in the source array
  68264. * @param result defines the Vector3 where to store the result
  68265. */
  68266. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68267. /**
  68268. * Sets the given vector "result" with the given floats.
  68269. * @param x defines the x coordinate of the source
  68270. * @param y defines the y coordinate of the source
  68271. * @param z defines the z coordinate of the source
  68272. * @param result defines the Vector3 where to store the result
  68273. */
  68274. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68275. /**
  68276. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68277. * @returns a new empty Vector3
  68278. */
  68279. static Zero(): Vector3;
  68280. /**
  68281. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68282. * @returns a new unit Vector3
  68283. */
  68284. static One(): Vector3;
  68285. /**
  68286. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68287. * @returns a new up Vector3
  68288. */
  68289. static Up(): Vector3;
  68290. /**
  68291. * Gets a up Vector3 that must not be updated
  68292. */
  68293. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68294. /**
  68295. * Gets a zero Vector3 that must not be updated
  68296. */
  68297. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68298. /**
  68299. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68300. * @returns a new down Vector3
  68301. */
  68302. static Down(): Vector3;
  68303. /**
  68304. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68305. * @returns a new forward Vector3
  68306. */
  68307. static Forward(): Vector3;
  68308. /**
  68309. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68310. * @returns a new forward Vector3
  68311. */
  68312. static Backward(): Vector3;
  68313. /**
  68314. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68315. * @returns a new right Vector3
  68316. */
  68317. static Right(): Vector3;
  68318. /**
  68319. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68320. * @returns a new left Vector3
  68321. */
  68322. static Left(): Vector3;
  68323. /**
  68324. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68325. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68326. * @param vector defines the Vector3 to transform
  68327. * @param transformation defines the transformation matrix
  68328. * @returns the transformed Vector3
  68329. */
  68330. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68331. /**
  68332. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68333. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68334. * @param vector defines the Vector3 to transform
  68335. * @param transformation defines the transformation matrix
  68336. * @param result defines the Vector3 where to store the result
  68337. */
  68338. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68339. /**
  68340. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68341. * This method computes tranformed coordinates only, not transformed direction vectors
  68342. * @param x define the x coordinate of the source vector
  68343. * @param y define the y coordinate of the source vector
  68344. * @param z define the z coordinate of the source vector
  68345. * @param transformation defines the transformation matrix
  68346. * @param result defines the Vector3 where to store the result
  68347. */
  68348. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68349. /**
  68350. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68351. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68352. * @param vector defines the Vector3 to transform
  68353. * @param transformation defines the transformation matrix
  68354. * @returns the new Vector3
  68355. */
  68356. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68357. /**
  68358. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68359. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68360. * @param vector defines the Vector3 to transform
  68361. * @param transformation defines the transformation matrix
  68362. * @param result defines the Vector3 where to store the result
  68363. */
  68364. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68365. /**
  68366. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68367. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68368. * @param x define the x coordinate of the source vector
  68369. * @param y define the y coordinate of the source vector
  68370. * @param z define the z coordinate of the source vector
  68371. * @param transformation defines the transformation matrix
  68372. * @param result defines the Vector3 where to store the result
  68373. */
  68374. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68375. /**
  68376. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68377. * @param value1 defines the first control point
  68378. * @param value2 defines the second control point
  68379. * @param value3 defines the third control point
  68380. * @param value4 defines the fourth control point
  68381. * @param amount defines the amount on the spline to use
  68382. * @returns the new Vector3
  68383. */
  68384. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68385. /**
  68386. * 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"
  68387. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68388. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68389. * @param value defines the current value
  68390. * @param min defines the lower range value
  68391. * @param max defines the upper range value
  68392. * @returns the new Vector3
  68393. */
  68394. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68395. /**
  68396. * 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"
  68397. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68398. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68399. * @param value defines the current value
  68400. * @param min defines the lower range value
  68401. * @param max defines the upper range value
  68402. * @param result defines the Vector3 where to store the result
  68403. */
  68404. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68405. /**
  68406. * Checks if a given vector is inside a specific range
  68407. * @param v defines the vector to test
  68408. * @param min defines the minimum range
  68409. * @param max defines the maximum range
  68410. */
  68411. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68412. /**
  68413. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68414. * @param value1 defines the first control point
  68415. * @param tangent1 defines the first tangent vector
  68416. * @param value2 defines the second control point
  68417. * @param tangent2 defines the second tangent vector
  68418. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68419. * @returns the new Vector3
  68420. */
  68421. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68422. /**
  68423. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68424. * @param start defines the start value
  68425. * @param end defines the end value
  68426. * @param amount max defines amount between both (between 0 and 1)
  68427. * @returns the new Vector3
  68428. */
  68429. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68430. /**
  68431. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68432. * @param start defines the start value
  68433. * @param end defines the end value
  68434. * @param amount max defines amount between both (between 0 and 1)
  68435. * @param result defines the Vector3 where to store the result
  68436. */
  68437. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68438. /**
  68439. * Returns the dot product (float) between the vectors "left" and "right"
  68440. * @param left defines the left operand
  68441. * @param right defines the right operand
  68442. * @returns the dot product
  68443. */
  68444. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68445. /**
  68446. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68447. * The cross product is then orthogonal to both "left" and "right"
  68448. * @param left defines the left operand
  68449. * @param right defines the right operand
  68450. * @returns the cross product
  68451. */
  68452. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68453. /**
  68454. * Sets the given vector "result" with the cross product of "left" and "right"
  68455. * The cross product is then orthogonal to both "left" and "right"
  68456. * @param left defines the left operand
  68457. * @param right defines the right operand
  68458. * @param result defines the Vector3 where to store the result
  68459. */
  68460. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68461. /**
  68462. * Returns a new Vector3 as the normalization of the given vector
  68463. * @param vector defines the Vector3 to normalize
  68464. * @returns the new Vector3
  68465. */
  68466. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68467. /**
  68468. * Sets the given vector "result" with the normalization of the given first vector
  68469. * @param vector defines the Vector3 to normalize
  68470. * @param result defines the Vector3 where to store the result
  68471. */
  68472. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68473. /**
  68474. * Project a Vector3 onto screen space
  68475. * @param vector defines the Vector3 to project
  68476. * @param world defines the world matrix to use
  68477. * @param transform defines the transform (view x projection) matrix to use
  68478. * @param viewport defines the screen viewport to use
  68479. * @returns the new Vector3
  68480. */
  68481. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68482. /** @hidden */
  68483. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68484. /**
  68485. * Unproject from screen space to object space
  68486. * @param source defines the screen space Vector3 to use
  68487. * @param viewportWidth defines the current width of the viewport
  68488. * @param viewportHeight defines the current height of the viewport
  68489. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68490. * @param transform defines the transform (view x projection) matrix to use
  68491. * @returns the new Vector3
  68492. */
  68493. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68494. /**
  68495. * Unproject from screen space to object space
  68496. * @param source defines the screen space Vector3 to use
  68497. * @param viewportWidth defines the current width of the viewport
  68498. * @param viewportHeight defines the current height of the viewport
  68499. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68500. * @param view defines the view matrix to use
  68501. * @param projection defines the projection matrix to use
  68502. * @returns the new Vector3
  68503. */
  68504. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68505. /**
  68506. * Unproject from screen space to object space
  68507. * @param source defines the screen space Vector3 to use
  68508. * @param viewportWidth defines the current width of the viewport
  68509. * @param viewportHeight defines the current height of the viewport
  68510. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68511. * @param view defines the view matrix to use
  68512. * @param projection defines the projection matrix to use
  68513. * @param result defines the Vector3 where to store the result
  68514. */
  68515. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68516. /**
  68517. * Unproject from screen space to object space
  68518. * @param sourceX defines the screen space x coordinate to use
  68519. * @param sourceY defines the screen space y coordinate to use
  68520. * @param sourceZ defines the screen space z coordinate to use
  68521. * @param viewportWidth defines the current width of the viewport
  68522. * @param viewportHeight defines the current height of the viewport
  68523. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68524. * @param view defines the view matrix to use
  68525. * @param projection defines the projection matrix to use
  68526. * @param result defines the Vector3 where to store the result
  68527. */
  68528. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68529. /**
  68530. * Gets the minimal coordinate values between two Vector3
  68531. * @param left defines the first operand
  68532. * @param right defines the second operand
  68533. * @returns the new Vector3
  68534. */
  68535. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68536. /**
  68537. * Gets the maximal coordinate values between two Vector3
  68538. * @param left defines the first operand
  68539. * @param right defines the second operand
  68540. * @returns the new Vector3
  68541. */
  68542. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68543. /**
  68544. * Returns the distance between the vectors "value1" and "value2"
  68545. * @param value1 defines the first operand
  68546. * @param value2 defines the second operand
  68547. * @returns the distance
  68548. */
  68549. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68550. /**
  68551. * Returns the squared distance between the vectors "value1" and "value2"
  68552. * @param value1 defines the first operand
  68553. * @param value2 defines the second operand
  68554. * @returns the squared distance
  68555. */
  68556. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68557. /**
  68558. * Returns a new Vector3 located at the center between "value1" and "value2"
  68559. * @param value1 defines the first operand
  68560. * @param value2 defines the second operand
  68561. * @returns the new Vector3
  68562. */
  68563. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68564. /**
  68565. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68566. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68567. * to something in order to rotate it from its local system to the given target system
  68568. * Note: axis1, axis2 and axis3 are normalized during this operation
  68569. * @param axis1 defines the first axis
  68570. * @param axis2 defines the second axis
  68571. * @param axis3 defines the third axis
  68572. * @returns a new Vector3
  68573. */
  68574. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68575. /**
  68576. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68577. * @param axis1 defines the first axis
  68578. * @param axis2 defines the second axis
  68579. * @param axis3 defines the third axis
  68580. * @param ref defines the Vector3 where to store the result
  68581. */
  68582. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68583. }
  68584. /**
  68585. * Vector4 class created for EulerAngle class conversion to Quaternion
  68586. */
  68587. export class Vector4 {
  68588. /** x value of the vector */
  68589. x: number;
  68590. /** y value of the vector */
  68591. y: number;
  68592. /** z value of the vector */
  68593. z: number;
  68594. /** w value of the vector */
  68595. w: number;
  68596. /**
  68597. * Creates a Vector4 object from the given floats.
  68598. * @param x x value of the vector
  68599. * @param y y value of the vector
  68600. * @param z z value of the vector
  68601. * @param w w value of the vector
  68602. */
  68603. constructor(
  68604. /** x value of the vector */
  68605. x: number,
  68606. /** y value of the vector */
  68607. y: number,
  68608. /** z value of the vector */
  68609. z: number,
  68610. /** w value of the vector */
  68611. w: number);
  68612. /**
  68613. * Returns the string with the Vector4 coordinates.
  68614. * @returns a string containing all the vector values
  68615. */
  68616. toString(): string;
  68617. /**
  68618. * Returns the string "Vector4".
  68619. * @returns "Vector4"
  68620. */
  68621. getClassName(): string;
  68622. /**
  68623. * Returns the Vector4 hash code.
  68624. * @returns a unique hash code
  68625. */
  68626. getHashCode(): number;
  68627. /**
  68628. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68629. * @returns the resulting array
  68630. */
  68631. asArray(): number[];
  68632. /**
  68633. * Populates the given array from the given index with the Vector4 coordinates.
  68634. * @param array array to populate
  68635. * @param index index of the array to start at (default: 0)
  68636. * @returns the Vector4.
  68637. */
  68638. toArray(array: FloatArray, index?: number): Vector4;
  68639. /**
  68640. * Adds the given vector to the current Vector4.
  68641. * @param otherVector the vector to add
  68642. * @returns the updated Vector4.
  68643. */
  68644. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68645. /**
  68646. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68647. * @param otherVector the vector to add
  68648. * @returns the resulting vector
  68649. */
  68650. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68651. /**
  68652. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68653. * @param otherVector the vector to add
  68654. * @param result the vector to store the result
  68655. * @returns the current Vector4.
  68656. */
  68657. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68658. /**
  68659. * Subtract in place the given vector from the current Vector4.
  68660. * @param otherVector the vector to subtract
  68661. * @returns the updated Vector4.
  68662. */
  68663. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68664. /**
  68665. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68666. * @param otherVector the vector to add
  68667. * @returns the new vector with the result
  68668. */
  68669. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68670. /**
  68671. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68672. * @param otherVector the vector to subtract
  68673. * @param result the vector to store the result
  68674. * @returns the current Vector4.
  68675. */
  68676. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68677. /**
  68678. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68679. */
  68680. /**
  68681. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68682. * @param x value to subtract
  68683. * @param y value to subtract
  68684. * @param z value to subtract
  68685. * @param w value to subtract
  68686. * @returns new vector containing the result
  68687. */
  68688. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68689. /**
  68690. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68691. * @param x value to subtract
  68692. * @param y value to subtract
  68693. * @param z value to subtract
  68694. * @param w value to subtract
  68695. * @param result the vector to store the result in
  68696. * @returns the current Vector4.
  68697. */
  68698. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68699. /**
  68700. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68701. * @returns a new vector with the negated values
  68702. */
  68703. negate(): Vector4;
  68704. /**
  68705. * Multiplies the current Vector4 coordinates by scale (float).
  68706. * @param scale the number to scale with
  68707. * @returns the updated Vector4.
  68708. */
  68709. scaleInPlace(scale: number): Vector4;
  68710. /**
  68711. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68712. * @param scale the number to scale with
  68713. * @returns a new vector with the result
  68714. */
  68715. scale(scale: number): Vector4;
  68716. /**
  68717. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68718. * @param scale the number to scale with
  68719. * @param result a vector to store the result in
  68720. * @returns the current Vector4.
  68721. */
  68722. scaleToRef(scale: number, result: Vector4): Vector4;
  68723. /**
  68724. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68725. * @param scale defines the scale factor
  68726. * @param result defines the Vector4 object where to store the result
  68727. * @returns the unmodified current Vector4
  68728. */
  68729. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68730. /**
  68731. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68732. * @param otherVector the vector to compare against
  68733. * @returns true if they are equal
  68734. */
  68735. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68736. /**
  68737. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68738. * @param otherVector vector to compare against
  68739. * @param epsilon (Default: very small number)
  68740. * @returns true if they are equal
  68741. */
  68742. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68743. /**
  68744. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68745. * @param x x value to compare against
  68746. * @param y y value to compare against
  68747. * @param z z value to compare against
  68748. * @param w w value to compare against
  68749. * @returns true if equal
  68750. */
  68751. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68752. /**
  68753. * Multiplies in place the current Vector4 by the given one.
  68754. * @param otherVector vector to multiple with
  68755. * @returns the updated Vector4.
  68756. */
  68757. multiplyInPlace(otherVector: Vector4): Vector4;
  68758. /**
  68759. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68760. * @param otherVector vector to multiple with
  68761. * @returns resulting new vector
  68762. */
  68763. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68764. /**
  68765. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68766. * @param otherVector vector to multiple with
  68767. * @param result vector to store the result
  68768. * @returns the current Vector4.
  68769. */
  68770. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68771. /**
  68772. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68773. * @param x x value multiply with
  68774. * @param y y value multiply with
  68775. * @param z z value multiply with
  68776. * @param w w value multiply with
  68777. * @returns resulting new vector
  68778. */
  68779. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68780. /**
  68781. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68782. * @param otherVector vector to devide with
  68783. * @returns resulting new vector
  68784. */
  68785. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68786. /**
  68787. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68788. * @param otherVector vector to devide with
  68789. * @param result vector to store the result
  68790. * @returns the current Vector4.
  68791. */
  68792. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68793. /**
  68794. * Divides the current Vector3 coordinates by the given ones.
  68795. * @param otherVector vector to devide with
  68796. * @returns the updated Vector3.
  68797. */
  68798. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68799. /**
  68800. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68801. * @param other defines the second operand
  68802. * @returns the current updated Vector4
  68803. */
  68804. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68805. /**
  68806. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68807. * @param other defines the second operand
  68808. * @returns the current updated Vector4
  68809. */
  68810. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68811. /**
  68812. * Gets a new Vector4 from current Vector4 floored values
  68813. * @returns a new Vector4
  68814. */
  68815. floor(): Vector4;
  68816. /**
  68817. * Gets a new Vector4 from current Vector3 floored values
  68818. * @returns a new Vector4
  68819. */
  68820. fract(): Vector4;
  68821. /**
  68822. * Returns the Vector4 length (float).
  68823. * @returns the length
  68824. */
  68825. length(): number;
  68826. /**
  68827. * Returns the Vector4 squared length (float).
  68828. * @returns the length squared
  68829. */
  68830. lengthSquared(): number;
  68831. /**
  68832. * Normalizes in place the Vector4.
  68833. * @returns the updated Vector4.
  68834. */
  68835. normalize(): Vector4;
  68836. /**
  68837. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68838. * @returns this converted to a new vector3
  68839. */
  68840. toVector3(): Vector3;
  68841. /**
  68842. * Returns a new Vector4 copied from the current one.
  68843. * @returns the new cloned vector
  68844. */
  68845. clone(): Vector4;
  68846. /**
  68847. * Updates the current Vector4 with the given one coordinates.
  68848. * @param source the source vector to copy from
  68849. * @returns the updated Vector4.
  68850. */
  68851. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68852. /**
  68853. * Updates the current Vector4 coordinates with the given floats.
  68854. * @param x float to copy from
  68855. * @param y float to copy from
  68856. * @param z float to copy from
  68857. * @param w float to copy from
  68858. * @returns the updated Vector4.
  68859. */
  68860. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68861. /**
  68862. * Updates the current Vector4 coordinates with the given floats.
  68863. * @param x float to set from
  68864. * @param y float to set from
  68865. * @param z float to set from
  68866. * @param w float to set from
  68867. * @returns the updated Vector4.
  68868. */
  68869. set(x: number, y: number, z: number, w: number): Vector4;
  68870. /**
  68871. * Copies the given float to the current Vector3 coordinates
  68872. * @param v defines the x, y, z and w coordinates of the operand
  68873. * @returns the current updated Vector3
  68874. */
  68875. setAll(v: number): Vector4;
  68876. /**
  68877. * Returns a new Vector4 set from the starting index of the given array.
  68878. * @param array the array to pull values from
  68879. * @param offset the offset into the array to start at
  68880. * @returns the new vector
  68881. */
  68882. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68883. /**
  68884. * Updates the given vector "result" from the starting index of the given array.
  68885. * @param array the array to pull values from
  68886. * @param offset the offset into the array to start at
  68887. * @param result the vector to store the result in
  68888. */
  68889. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68890. /**
  68891. * Updates the given vector "result" from the starting index of the given Float32Array.
  68892. * @param array the array to pull values from
  68893. * @param offset the offset into the array to start at
  68894. * @param result the vector to store the result in
  68895. */
  68896. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68897. /**
  68898. * Updates the given vector "result" coordinates from the given floats.
  68899. * @param x float to set from
  68900. * @param y float to set from
  68901. * @param z float to set from
  68902. * @param w float to set from
  68903. * @param result the vector to the floats in
  68904. */
  68905. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68906. /**
  68907. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68908. * @returns the new vector
  68909. */
  68910. static Zero(): Vector4;
  68911. /**
  68912. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68913. * @returns the new vector
  68914. */
  68915. static One(): Vector4;
  68916. /**
  68917. * Returns a new normalized Vector4 from the given one.
  68918. * @param vector the vector to normalize
  68919. * @returns the vector
  68920. */
  68921. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68922. /**
  68923. * Updates the given vector "result" from the normalization of the given one.
  68924. * @param vector the vector to normalize
  68925. * @param result the vector to store the result in
  68926. */
  68927. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68928. /**
  68929. * Returns a vector with the minimum values from the left and right vectors
  68930. * @param left left vector to minimize
  68931. * @param right right vector to minimize
  68932. * @returns a new vector with the minimum of the left and right vector values
  68933. */
  68934. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68935. /**
  68936. * Returns a vector with the maximum values from the left and right vectors
  68937. * @param left left vector to maximize
  68938. * @param right right vector to maximize
  68939. * @returns a new vector with the maximum of the left and right vector values
  68940. */
  68941. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68942. /**
  68943. * Returns the distance (float) between the vectors "value1" and "value2".
  68944. * @param value1 value to calulate the distance between
  68945. * @param value2 value to calulate the distance between
  68946. * @return the distance between the two vectors
  68947. */
  68948. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68949. /**
  68950. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68951. * @param value1 value to calulate the distance between
  68952. * @param value2 value to calulate the distance between
  68953. * @return the distance between the two vectors squared
  68954. */
  68955. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68956. /**
  68957. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68958. * @param value1 value to calulate the center between
  68959. * @param value2 value to calulate the center between
  68960. * @return the center between the two vectors
  68961. */
  68962. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68963. /**
  68964. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68965. * This methods computes transformed normalized direction vectors only.
  68966. * @param vector the vector to transform
  68967. * @param transformation the transformation matrix to apply
  68968. * @returns the new vector
  68969. */
  68970. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68971. /**
  68972. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68973. * This methods computes transformed normalized direction vectors only.
  68974. * @param vector the vector to transform
  68975. * @param transformation the transformation matrix to apply
  68976. * @param result the vector to store the result in
  68977. */
  68978. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68979. /**
  68980. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68981. * This methods computes transformed normalized direction vectors only.
  68982. * @param x value to transform
  68983. * @param y value to transform
  68984. * @param z value to transform
  68985. * @param w value to transform
  68986. * @param transformation the transformation matrix to apply
  68987. * @param result the vector to store the results in
  68988. */
  68989. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68990. /**
  68991. * Creates a new Vector4 from a Vector3
  68992. * @param source defines the source data
  68993. * @param w defines the 4th component (default is 0)
  68994. * @returns a new Vector4
  68995. */
  68996. static FromVector3(source: Vector3, w?: number): Vector4;
  68997. }
  68998. /**
  68999. * Class used to store quaternion data
  69000. * @see https://en.wikipedia.org/wiki/Quaternion
  69001. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  69002. */
  69003. export class Quaternion {
  69004. /** defines the first component (0 by default) */
  69005. x: number;
  69006. /** defines the second component (0 by default) */
  69007. y: number;
  69008. /** defines the third component (0 by default) */
  69009. z: number;
  69010. /** defines the fourth component (1.0 by default) */
  69011. w: number;
  69012. /**
  69013. * Creates a new Quaternion from the given floats
  69014. * @param x defines the first component (0 by default)
  69015. * @param y defines the second component (0 by default)
  69016. * @param z defines the third component (0 by default)
  69017. * @param w defines the fourth component (1.0 by default)
  69018. */
  69019. constructor(
  69020. /** defines the first component (0 by default) */
  69021. x?: number,
  69022. /** defines the second component (0 by default) */
  69023. y?: number,
  69024. /** defines the third component (0 by default) */
  69025. z?: number,
  69026. /** defines the fourth component (1.0 by default) */
  69027. w?: number);
  69028. /**
  69029. * Gets a string representation for the current quaternion
  69030. * @returns a string with the Quaternion coordinates
  69031. */
  69032. toString(): string;
  69033. /**
  69034. * Gets the class name of the quaternion
  69035. * @returns the string "Quaternion"
  69036. */
  69037. getClassName(): string;
  69038. /**
  69039. * Gets a hash code for this quaternion
  69040. * @returns the quaternion hash code
  69041. */
  69042. getHashCode(): number;
  69043. /**
  69044. * Copy the quaternion to an array
  69045. * @returns a new array populated with 4 elements from the quaternion coordinates
  69046. */
  69047. asArray(): number[];
  69048. /**
  69049. * Check if two quaternions are equals
  69050. * @param otherQuaternion defines the second operand
  69051. * @return true if the current quaternion and the given one coordinates are strictly equals
  69052. */
  69053. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  69054. /**
  69055. * Clone the current quaternion
  69056. * @returns a new quaternion copied from the current one
  69057. */
  69058. clone(): Quaternion;
  69059. /**
  69060. * Copy a quaternion to the current one
  69061. * @param other defines the other quaternion
  69062. * @returns the updated current quaternion
  69063. */
  69064. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  69065. /**
  69066. * Updates the current quaternion with the given float coordinates
  69067. * @param x defines the x coordinate
  69068. * @param y defines the y coordinate
  69069. * @param z defines the z coordinate
  69070. * @param w defines the w coordinate
  69071. * @returns the updated current quaternion
  69072. */
  69073. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  69074. /**
  69075. * Updates the current quaternion from the given float coordinates
  69076. * @param x defines the x coordinate
  69077. * @param y defines the y coordinate
  69078. * @param z defines the z coordinate
  69079. * @param w defines the w coordinate
  69080. * @returns the updated current quaternion
  69081. */
  69082. set(x: number, y: number, z: number, w: number): Quaternion;
  69083. /**
  69084. * Adds two quaternions
  69085. * @param other defines the second operand
  69086. * @returns a new quaternion as the addition result of the given one and the current quaternion
  69087. */
  69088. add(other: DeepImmutable<Quaternion>): Quaternion;
  69089. /**
  69090. * Add a quaternion to the current one
  69091. * @param other defines the quaternion to add
  69092. * @returns the current quaternion
  69093. */
  69094. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  69095. /**
  69096. * Subtract two quaternions
  69097. * @param other defines the second operand
  69098. * @returns a new quaternion as the subtraction result of the given one from the current one
  69099. */
  69100. subtract(other: Quaternion): Quaternion;
  69101. /**
  69102. * Multiplies the current quaternion by a scale factor
  69103. * @param value defines the scale factor
  69104. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  69105. */
  69106. scale(value: number): Quaternion;
  69107. /**
  69108. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  69109. * @param scale defines the scale factor
  69110. * @param result defines the Quaternion object where to store the result
  69111. * @returns the unmodified current quaternion
  69112. */
  69113. scaleToRef(scale: number, result: Quaternion): Quaternion;
  69114. /**
  69115. * Multiplies in place the current quaternion by a scale factor
  69116. * @param value defines the scale factor
  69117. * @returns the current modified quaternion
  69118. */
  69119. scaleInPlace(value: number): Quaternion;
  69120. /**
  69121. * Scale the current quaternion values by a factor and add the result to a given quaternion
  69122. * @param scale defines the scale factor
  69123. * @param result defines the Quaternion object where to store the result
  69124. * @returns the unmodified current quaternion
  69125. */
  69126. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  69127. /**
  69128. * Multiplies two quaternions
  69129. * @param q1 defines the second operand
  69130. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  69131. */
  69132. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  69133. /**
  69134. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  69135. * @param q1 defines the second operand
  69136. * @param result defines the target quaternion
  69137. * @returns the current quaternion
  69138. */
  69139. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  69140. /**
  69141. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  69142. * @param q1 defines the second operand
  69143. * @returns the currentupdated quaternion
  69144. */
  69145. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  69146. /**
  69147. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  69148. * @param ref defines the target quaternion
  69149. * @returns the current quaternion
  69150. */
  69151. conjugateToRef(ref: Quaternion): Quaternion;
  69152. /**
  69153. * Conjugates in place (1-q) the current quaternion
  69154. * @returns the current updated quaternion
  69155. */
  69156. conjugateInPlace(): Quaternion;
  69157. /**
  69158. * Conjugates in place (1-q) the current quaternion
  69159. * @returns a new quaternion
  69160. */
  69161. conjugate(): Quaternion;
  69162. /**
  69163. * Gets length of current quaternion
  69164. * @returns the quaternion length (float)
  69165. */
  69166. length(): number;
  69167. /**
  69168. * Normalize in place the current quaternion
  69169. * @returns the current updated quaternion
  69170. */
  69171. normalize(): Quaternion;
  69172. /**
  69173. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  69174. * @param order is a reserved parameter and is ignore for now
  69175. * @returns a new Vector3 containing the Euler angles
  69176. */
  69177. toEulerAngles(order?: string): Vector3;
  69178. /**
  69179. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  69180. * @param result defines the vector which will be filled with the Euler angles
  69181. * @param order is a reserved parameter and is ignore for now
  69182. * @returns the current unchanged quaternion
  69183. */
  69184. toEulerAnglesToRef(result: Vector3): Quaternion;
  69185. /**
  69186. * Updates the given rotation matrix with the current quaternion values
  69187. * @param result defines the target matrix
  69188. * @returns the current unchanged quaternion
  69189. */
  69190. toRotationMatrix(result: Matrix): Quaternion;
  69191. /**
  69192. * Updates the current quaternion from the given rotation matrix values
  69193. * @param matrix defines the source matrix
  69194. * @returns the current updated quaternion
  69195. */
  69196. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69197. /**
  69198. * Creates a new quaternion from a rotation matrix
  69199. * @param matrix defines the source matrix
  69200. * @returns a new quaternion created from the given rotation matrix values
  69201. */
  69202. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69203. /**
  69204. * Updates the given quaternion with the given rotation matrix values
  69205. * @param matrix defines the source matrix
  69206. * @param result defines the target quaternion
  69207. */
  69208. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  69209. /**
  69210. * Returns the dot product (float) between the quaternions "left" and "right"
  69211. * @param left defines the left operand
  69212. * @param right defines the right operand
  69213. * @returns the dot product
  69214. */
  69215. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  69216. /**
  69217. * Checks if the two quaternions are close to each other
  69218. * @param quat0 defines the first quaternion to check
  69219. * @param quat1 defines the second quaternion to check
  69220. * @returns true if the two quaternions are close to each other
  69221. */
  69222. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  69223. /**
  69224. * Creates an empty quaternion
  69225. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  69226. */
  69227. static Zero(): Quaternion;
  69228. /**
  69229. * Inverse a given quaternion
  69230. * @param q defines the source quaternion
  69231. * @returns a new quaternion as the inverted current quaternion
  69232. */
  69233. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69234. /**
  69235. * Inverse a given quaternion
  69236. * @param q defines the source quaternion
  69237. * @param result the quaternion the result will be stored in
  69238. * @returns the result quaternion
  69239. */
  69240. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69241. /**
  69242. * Creates an identity quaternion
  69243. * @returns the identity quaternion
  69244. */
  69245. static Identity(): Quaternion;
  69246. /**
  69247. * Gets a boolean indicating if the given quaternion is identity
  69248. * @param quaternion defines the quaternion to check
  69249. * @returns true if the quaternion is identity
  69250. */
  69251. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69252. /**
  69253. * Creates a quaternion from a rotation around an axis
  69254. * @param axis defines the axis to use
  69255. * @param angle defines the angle to use
  69256. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69257. */
  69258. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69259. /**
  69260. * Creates a rotation around an axis and stores it into the given quaternion
  69261. * @param axis defines the axis to use
  69262. * @param angle defines the angle to use
  69263. * @param result defines the target quaternion
  69264. * @returns the target quaternion
  69265. */
  69266. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69267. /**
  69268. * Creates a new quaternion from data stored into an array
  69269. * @param array defines the data source
  69270. * @param offset defines the offset in the source array where the data starts
  69271. * @returns a new quaternion
  69272. */
  69273. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69274. /**
  69275. * Create a quaternion from Euler rotation angles
  69276. * @param x Pitch
  69277. * @param y Yaw
  69278. * @param z Roll
  69279. * @returns the new Quaternion
  69280. */
  69281. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69282. /**
  69283. * Updates a quaternion from Euler rotation angles
  69284. * @param x Pitch
  69285. * @param y Yaw
  69286. * @param z Roll
  69287. * @param result the quaternion to store the result
  69288. * @returns the updated quaternion
  69289. */
  69290. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69291. /**
  69292. * Create a quaternion from Euler rotation vector
  69293. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69294. * @returns the new Quaternion
  69295. */
  69296. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69297. /**
  69298. * Updates a quaternion from Euler rotation vector
  69299. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69300. * @param result the quaternion to store the result
  69301. * @returns the updated quaternion
  69302. */
  69303. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69304. /**
  69305. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69306. * @param yaw defines the rotation around Y axis
  69307. * @param pitch defines the rotation around X axis
  69308. * @param roll defines the rotation around Z axis
  69309. * @returns the new quaternion
  69310. */
  69311. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69312. /**
  69313. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69314. * @param yaw defines the rotation around Y axis
  69315. * @param pitch defines the rotation around X axis
  69316. * @param roll defines the rotation around Z axis
  69317. * @param result defines the target quaternion
  69318. */
  69319. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69320. /**
  69321. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69322. * @param alpha defines the rotation around first axis
  69323. * @param beta defines the rotation around second axis
  69324. * @param gamma defines the rotation around third axis
  69325. * @returns the new quaternion
  69326. */
  69327. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69328. /**
  69329. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69330. * @param alpha defines the rotation around first axis
  69331. * @param beta defines the rotation around second axis
  69332. * @param gamma defines the rotation around third axis
  69333. * @param result defines the target quaternion
  69334. */
  69335. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69336. /**
  69337. * 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)
  69338. * @param axis1 defines the first axis
  69339. * @param axis2 defines the second axis
  69340. * @param axis3 defines the third axis
  69341. * @returns the new quaternion
  69342. */
  69343. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69344. /**
  69345. * 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
  69346. * @param axis1 defines the first axis
  69347. * @param axis2 defines the second axis
  69348. * @param axis3 defines the third axis
  69349. * @param ref defines the target quaternion
  69350. */
  69351. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69352. /**
  69353. * Interpolates between two quaternions
  69354. * @param left defines first quaternion
  69355. * @param right defines second quaternion
  69356. * @param amount defines the gradient to use
  69357. * @returns the new interpolated quaternion
  69358. */
  69359. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69360. /**
  69361. * Interpolates between two quaternions and stores it into a target quaternion
  69362. * @param left defines first quaternion
  69363. * @param right defines second quaternion
  69364. * @param amount defines the gradient to use
  69365. * @param result defines the target quaternion
  69366. */
  69367. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69368. /**
  69369. * Interpolate between two quaternions using Hermite interpolation
  69370. * @param value1 defines first quaternion
  69371. * @param tangent1 defines the incoming tangent
  69372. * @param value2 defines second quaternion
  69373. * @param tangent2 defines the outgoing tangent
  69374. * @param amount defines the target quaternion
  69375. * @returns the new interpolated quaternion
  69376. */
  69377. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69378. }
  69379. /**
  69380. * Class used to store matrix data (4x4)
  69381. */
  69382. export class Matrix {
  69383. private static _updateFlagSeed;
  69384. private static _identityReadOnly;
  69385. private _isIdentity;
  69386. private _isIdentityDirty;
  69387. private _isIdentity3x2;
  69388. private _isIdentity3x2Dirty;
  69389. /**
  69390. * Gets the update flag of the matrix which is an unique number for the matrix.
  69391. * It will be incremented every time the matrix data change.
  69392. * You can use it to speed the comparison between two versions of the same matrix.
  69393. */
  69394. updateFlag: number;
  69395. private readonly _m;
  69396. /**
  69397. * Gets the internal data of the matrix
  69398. */
  69399. readonly m: DeepImmutable<Float32Array>;
  69400. /** @hidden */
  69401. _markAsUpdated(): void;
  69402. /** @hidden */
  69403. private _updateIdentityStatus;
  69404. /**
  69405. * Creates an empty matrix (filled with zeros)
  69406. */
  69407. constructor();
  69408. /**
  69409. * Check if the current matrix is identity
  69410. * @returns true is the matrix is the identity matrix
  69411. */
  69412. isIdentity(): boolean;
  69413. /**
  69414. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69415. * @returns true is the matrix is the identity matrix
  69416. */
  69417. isIdentityAs3x2(): boolean;
  69418. /**
  69419. * Gets the determinant of the matrix
  69420. * @returns the matrix determinant
  69421. */
  69422. determinant(): number;
  69423. /**
  69424. * Returns the matrix as a Float32Array
  69425. * @returns the matrix underlying array
  69426. */
  69427. toArray(): DeepImmutable<Float32Array>;
  69428. /**
  69429. * Returns the matrix as a Float32Array
  69430. * @returns the matrix underlying array.
  69431. */
  69432. asArray(): DeepImmutable<Float32Array>;
  69433. /**
  69434. * Inverts the current matrix in place
  69435. * @returns the current inverted matrix
  69436. */
  69437. invert(): Matrix;
  69438. /**
  69439. * Sets all the matrix elements to zero
  69440. * @returns the current matrix
  69441. */
  69442. reset(): Matrix;
  69443. /**
  69444. * Adds the current matrix with a second one
  69445. * @param other defines the matrix to add
  69446. * @returns a new matrix as the addition of the current matrix and the given one
  69447. */
  69448. add(other: DeepImmutable<Matrix>): Matrix;
  69449. /**
  69450. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69451. * @param other defines the matrix to add
  69452. * @param result defines the target matrix
  69453. * @returns the current matrix
  69454. */
  69455. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69456. /**
  69457. * Adds in place the given matrix to the current matrix
  69458. * @param other defines the second operand
  69459. * @returns the current updated matrix
  69460. */
  69461. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69462. /**
  69463. * Sets the given matrix to the current inverted Matrix
  69464. * @param other defines the target matrix
  69465. * @returns the unmodified current matrix
  69466. */
  69467. invertToRef(other: Matrix): Matrix;
  69468. /**
  69469. * add a value at the specified position in the current Matrix
  69470. * @param index the index of the value within the matrix. between 0 and 15.
  69471. * @param value the value to be added
  69472. * @returns the current updated matrix
  69473. */
  69474. addAtIndex(index: number, value: number): Matrix;
  69475. /**
  69476. * mutiply the specified position in the current Matrix by a value
  69477. * @param index the index of the value within the matrix. between 0 and 15.
  69478. * @param value the value to be added
  69479. * @returns the current updated matrix
  69480. */
  69481. multiplyAtIndex(index: number, value: number): Matrix;
  69482. /**
  69483. * Inserts the translation vector (using 3 floats) in the current matrix
  69484. * @param x defines the 1st component of the translation
  69485. * @param y defines the 2nd component of the translation
  69486. * @param z defines the 3rd component of the translation
  69487. * @returns the current updated matrix
  69488. */
  69489. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69490. /**
  69491. * Adds the translation vector (using 3 floats) in the current matrix
  69492. * @param x defines the 1st component of the translation
  69493. * @param y defines the 2nd component of the translation
  69494. * @param z defines the 3rd component of the translation
  69495. * @returns the current updated matrix
  69496. */
  69497. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69498. /**
  69499. * Inserts the translation vector in the current matrix
  69500. * @param vector3 defines the translation to insert
  69501. * @returns the current updated matrix
  69502. */
  69503. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69504. /**
  69505. * Gets the translation value of the current matrix
  69506. * @returns a new Vector3 as the extracted translation from the matrix
  69507. */
  69508. getTranslation(): Vector3;
  69509. /**
  69510. * Fill a Vector3 with the extracted translation from the matrix
  69511. * @param result defines the Vector3 where to store the translation
  69512. * @returns the current matrix
  69513. */
  69514. getTranslationToRef(result: Vector3): Matrix;
  69515. /**
  69516. * Remove rotation and scaling part from the matrix
  69517. * @returns the updated matrix
  69518. */
  69519. removeRotationAndScaling(): Matrix;
  69520. /**
  69521. * Multiply two matrices
  69522. * @param other defines the second operand
  69523. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69524. */
  69525. multiply(other: DeepImmutable<Matrix>): Matrix;
  69526. /**
  69527. * Copy the current matrix from the given one
  69528. * @param other defines the source matrix
  69529. * @returns the current updated matrix
  69530. */
  69531. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69532. /**
  69533. * Populates the given array from the starting index with the current matrix values
  69534. * @param array defines the target array
  69535. * @param offset defines the offset in the target array where to start storing values
  69536. * @returns the current matrix
  69537. */
  69538. copyToArray(array: Float32Array, offset?: number): Matrix;
  69539. /**
  69540. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69541. * @param other defines the second operand
  69542. * @param result defines the matrix where to store the multiplication
  69543. * @returns the current matrix
  69544. */
  69545. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69546. /**
  69547. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69548. * @param other defines the second operand
  69549. * @param result defines the array where to store the multiplication
  69550. * @param offset defines the offset in the target array where to start storing values
  69551. * @returns the current matrix
  69552. */
  69553. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69554. /**
  69555. * Check equality between this matrix and a second one
  69556. * @param value defines the second matrix to compare
  69557. * @returns true is the current matrix and the given one values are strictly equal
  69558. */
  69559. equals(value: DeepImmutable<Matrix>): boolean;
  69560. /**
  69561. * Clone the current matrix
  69562. * @returns a new matrix from the current matrix
  69563. */
  69564. clone(): Matrix;
  69565. /**
  69566. * Returns the name of the current matrix class
  69567. * @returns the string "Matrix"
  69568. */
  69569. getClassName(): string;
  69570. /**
  69571. * Gets the hash code of the current matrix
  69572. * @returns the hash code
  69573. */
  69574. getHashCode(): number;
  69575. /**
  69576. * Decomposes the current Matrix into a translation, rotation and scaling components
  69577. * @param scale defines the scale vector3 given as a reference to update
  69578. * @param rotation defines the rotation quaternion given as a reference to update
  69579. * @param translation defines the translation vector3 given as a reference to update
  69580. * @returns true if operation was successful
  69581. */
  69582. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69583. /**
  69584. * Gets specific row of the matrix
  69585. * @param index defines the number of the row to get
  69586. * @returns the index-th row of the current matrix as a new Vector4
  69587. */
  69588. getRow(index: number): Nullable<Vector4>;
  69589. /**
  69590. * Sets the index-th row of the current matrix to the vector4 values
  69591. * @param index defines the number of the row to set
  69592. * @param row defines the target vector4
  69593. * @returns the updated current matrix
  69594. */
  69595. setRow(index: number, row: Vector4): Matrix;
  69596. /**
  69597. * Compute the transpose of the matrix
  69598. * @returns the new transposed matrix
  69599. */
  69600. transpose(): Matrix;
  69601. /**
  69602. * Compute the transpose of the matrix and store it in a given matrix
  69603. * @param result defines the target matrix
  69604. * @returns the current matrix
  69605. */
  69606. transposeToRef(result: Matrix): Matrix;
  69607. /**
  69608. * Sets the index-th row of the current matrix with the given 4 x float values
  69609. * @param index defines the row index
  69610. * @param x defines the x component to set
  69611. * @param y defines the y component to set
  69612. * @param z defines the z component to set
  69613. * @param w defines the w component to set
  69614. * @returns the updated current matrix
  69615. */
  69616. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69617. /**
  69618. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69619. * @param scale defines the scale factor
  69620. * @returns a new matrix
  69621. */
  69622. scale(scale: number): Matrix;
  69623. /**
  69624. * Scale the current matrix values by a factor to a given result matrix
  69625. * @param scale defines the scale factor
  69626. * @param result defines the matrix to store the result
  69627. * @returns the current matrix
  69628. */
  69629. scaleToRef(scale: number, result: Matrix): Matrix;
  69630. /**
  69631. * Scale the current matrix values by a factor and add the result to a given matrix
  69632. * @param scale defines the scale factor
  69633. * @param result defines the Matrix to store the result
  69634. * @returns the current matrix
  69635. */
  69636. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69637. /**
  69638. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69639. * @param ref matrix to store the result
  69640. */
  69641. toNormalMatrix(ref: Matrix): void;
  69642. /**
  69643. * Gets only rotation part of the current matrix
  69644. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69645. */
  69646. getRotationMatrix(): Matrix;
  69647. /**
  69648. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69649. * @param result defines the target matrix to store data to
  69650. * @returns the current matrix
  69651. */
  69652. getRotationMatrixToRef(result: Matrix): Matrix;
  69653. /**
  69654. * Toggles model matrix from being right handed to left handed in place and vice versa
  69655. */
  69656. toggleModelMatrixHandInPlace(): void;
  69657. /**
  69658. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69659. */
  69660. toggleProjectionMatrixHandInPlace(): void;
  69661. /**
  69662. * Creates a matrix from an array
  69663. * @param array defines the source array
  69664. * @param offset defines an offset in the source array
  69665. * @returns a new Matrix set from the starting index of the given array
  69666. */
  69667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69668. /**
  69669. * Copy the content of an array into a given matrix
  69670. * @param array defines the source array
  69671. * @param offset defines an offset in the source array
  69672. * @param result defines the target matrix
  69673. */
  69674. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69675. /**
  69676. * Stores an array into a matrix after having multiplied each component by a given factor
  69677. * @param array defines the source array
  69678. * @param offset defines the offset in the source array
  69679. * @param scale defines the scaling factor
  69680. * @param result defines the target matrix
  69681. */
  69682. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69683. /**
  69684. * Gets an identity matrix that must not be updated
  69685. */
  69686. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69687. /**
  69688. * Stores a list of values (16) inside a given matrix
  69689. * @param initialM11 defines 1st value of 1st row
  69690. * @param initialM12 defines 2nd value of 1st row
  69691. * @param initialM13 defines 3rd value of 1st row
  69692. * @param initialM14 defines 4th value of 1st row
  69693. * @param initialM21 defines 1st value of 2nd row
  69694. * @param initialM22 defines 2nd value of 2nd row
  69695. * @param initialM23 defines 3rd value of 2nd row
  69696. * @param initialM24 defines 4th value of 2nd row
  69697. * @param initialM31 defines 1st value of 3rd row
  69698. * @param initialM32 defines 2nd value of 3rd row
  69699. * @param initialM33 defines 3rd value of 3rd row
  69700. * @param initialM34 defines 4th value of 3rd row
  69701. * @param initialM41 defines 1st value of 4th row
  69702. * @param initialM42 defines 2nd value of 4th row
  69703. * @param initialM43 defines 3rd value of 4th row
  69704. * @param initialM44 defines 4th value of 4th row
  69705. * @param result defines the target matrix
  69706. */
  69707. 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;
  69708. /**
  69709. * Creates new matrix from a list of values (16)
  69710. * @param initialM11 defines 1st value of 1st row
  69711. * @param initialM12 defines 2nd value of 1st row
  69712. * @param initialM13 defines 3rd value of 1st row
  69713. * @param initialM14 defines 4th value of 1st row
  69714. * @param initialM21 defines 1st value of 2nd row
  69715. * @param initialM22 defines 2nd value of 2nd row
  69716. * @param initialM23 defines 3rd value of 2nd row
  69717. * @param initialM24 defines 4th value of 2nd row
  69718. * @param initialM31 defines 1st value of 3rd row
  69719. * @param initialM32 defines 2nd value of 3rd row
  69720. * @param initialM33 defines 3rd value of 3rd row
  69721. * @param initialM34 defines 4th value of 3rd row
  69722. * @param initialM41 defines 1st value of 4th row
  69723. * @param initialM42 defines 2nd value of 4th row
  69724. * @param initialM43 defines 3rd value of 4th row
  69725. * @param initialM44 defines 4th value of 4th row
  69726. * @returns the new matrix
  69727. */
  69728. 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;
  69729. /**
  69730. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69731. * @param scale defines the scale vector3
  69732. * @param rotation defines the rotation quaternion
  69733. * @param translation defines the translation vector3
  69734. * @returns a new matrix
  69735. */
  69736. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69737. /**
  69738. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69739. * @param scale defines the scale vector3
  69740. * @param rotation defines the rotation quaternion
  69741. * @param translation defines the translation vector3
  69742. * @param result defines the target matrix
  69743. */
  69744. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69745. /**
  69746. * Creates a new identity matrix
  69747. * @returns a new identity matrix
  69748. */
  69749. static Identity(): Matrix;
  69750. /**
  69751. * Creates a new identity matrix and stores the result in a given matrix
  69752. * @param result defines the target matrix
  69753. */
  69754. static IdentityToRef(result: Matrix): void;
  69755. /**
  69756. * Creates a new zero matrix
  69757. * @returns a new zero matrix
  69758. */
  69759. static Zero(): Matrix;
  69760. /**
  69761. * Creates a new rotation matrix for "angle" radians around the X axis
  69762. * @param angle defines the angle (in radians) to use
  69763. * @return the new matrix
  69764. */
  69765. static RotationX(angle: number): Matrix;
  69766. /**
  69767. * Creates a new matrix as the invert of a given matrix
  69768. * @param source defines the source matrix
  69769. * @returns the new matrix
  69770. */
  69771. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69772. /**
  69773. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69774. * @param angle defines the angle (in radians) to use
  69775. * @param result defines the target matrix
  69776. */
  69777. static RotationXToRef(angle: number, result: Matrix): void;
  69778. /**
  69779. * Creates a new rotation matrix for "angle" radians around the Y axis
  69780. * @param angle defines the angle (in radians) to use
  69781. * @return the new matrix
  69782. */
  69783. static RotationY(angle: number): Matrix;
  69784. /**
  69785. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69786. * @param angle defines the angle (in radians) to use
  69787. * @param result defines the target matrix
  69788. */
  69789. static RotationYToRef(angle: number, result: Matrix): void;
  69790. /**
  69791. * Creates a new rotation matrix for "angle" radians around the Z axis
  69792. * @param angle defines the angle (in radians) to use
  69793. * @return the new matrix
  69794. */
  69795. static RotationZ(angle: number): Matrix;
  69796. /**
  69797. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69798. * @param angle defines the angle (in radians) to use
  69799. * @param result defines the target matrix
  69800. */
  69801. static RotationZToRef(angle: number, result: Matrix): void;
  69802. /**
  69803. * Creates a new rotation matrix for "angle" radians around the given axis
  69804. * @param axis defines the axis to use
  69805. * @param angle defines the angle (in radians) to use
  69806. * @return the new matrix
  69807. */
  69808. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69809. /**
  69810. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69811. * @param axis defines the axis to use
  69812. * @param angle defines the angle (in radians) to use
  69813. * @param result defines the target matrix
  69814. */
  69815. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69816. /**
  69817. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69818. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69819. * @param from defines the vector to align
  69820. * @param to defines the vector to align to
  69821. * @param result defines the target matrix
  69822. */
  69823. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69824. /**
  69825. * Creates a rotation matrix
  69826. * @param yaw defines the yaw angle in radians (Y axis)
  69827. * @param pitch defines the pitch angle in radians (X axis)
  69828. * @param roll defines the roll angle in radians (X axis)
  69829. * @returns the new rotation matrix
  69830. */
  69831. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69832. /**
  69833. * Creates a rotation matrix and stores it in a given matrix
  69834. * @param yaw defines the yaw angle in radians (Y axis)
  69835. * @param pitch defines the pitch angle in radians (X axis)
  69836. * @param roll defines the roll angle in radians (X axis)
  69837. * @param result defines the target matrix
  69838. */
  69839. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69840. /**
  69841. * Creates a scaling matrix
  69842. * @param x defines the scale factor on X axis
  69843. * @param y defines the scale factor on Y axis
  69844. * @param z defines the scale factor on Z axis
  69845. * @returns the new matrix
  69846. */
  69847. static Scaling(x: number, y: number, z: number): Matrix;
  69848. /**
  69849. * Creates a scaling matrix and stores it in a given matrix
  69850. * @param x defines the scale factor on X axis
  69851. * @param y defines the scale factor on Y axis
  69852. * @param z defines the scale factor on Z axis
  69853. * @param result defines the target matrix
  69854. */
  69855. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69856. /**
  69857. * Creates a translation matrix
  69858. * @param x defines the translation on X axis
  69859. * @param y defines the translation on Y axis
  69860. * @param z defines the translationon Z axis
  69861. * @returns the new matrix
  69862. */
  69863. static Translation(x: number, y: number, z: number): Matrix;
  69864. /**
  69865. * Creates a translation matrix and stores it in a given matrix
  69866. * @param x defines the translation on X axis
  69867. * @param y defines the translation on Y axis
  69868. * @param z defines the translationon Z axis
  69869. * @param result defines the target matrix
  69870. */
  69871. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69872. /**
  69873. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69874. * @param startValue defines the start value
  69875. * @param endValue defines the end value
  69876. * @param gradient defines the gradient factor
  69877. * @returns the new matrix
  69878. */
  69879. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69880. /**
  69881. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69882. * @param startValue defines the start value
  69883. * @param endValue defines the end value
  69884. * @param gradient defines the gradient factor
  69885. * @param result defines the Matrix object where to store data
  69886. */
  69887. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69888. /**
  69889. * Builds a new matrix whose values are computed by:
  69890. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69891. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69892. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69893. * @param startValue defines the first matrix
  69894. * @param endValue defines the second matrix
  69895. * @param gradient defines the gradient between the two matrices
  69896. * @returns the new matrix
  69897. */
  69898. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69899. /**
  69900. * Update a matrix to values which are computed by:
  69901. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69902. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69903. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69904. * @param startValue defines the first matrix
  69905. * @param endValue defines the second matrix
  69906. * @param gradient defines the gradient between the two matrices
  69907. * @param result defines the target matrix
  69908. */
  69909. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69910. /**
  69911. * 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"
  69912. * This function works in left handed mode
  69913. * @param eye defines the final position of the entity
  69914. * @param target defines where the entity should look at
  69915. * @param up defines the up vector for the entity
  69916. * @returns the new matrix
  69917. */
  69918. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69919. /**
  69920. * 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".
  69921. * This function works in left handed mode
  69922. * @param eye defines the final position of the entity
  69923. * @param target defines where the entity should look at
  69924. * @param up defines the up vector for the entity
  69925. * @param result defines the target matrix
  69926. */
  69927. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69928. /**
  69929. * 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"
  69930. * This function works in right handed mode
  69931. * @param eye defines the final position of the entity
  69932. * @param target defines where the entity should look at
  69933. * @param up defines the up vector for the entity
  69934. * @returns the new matrix
  69935. */
  69936. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69937. /**
  69938. * 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".
  69939. * This function works in right handed mode
  69940. * @param eye defines the final position of the entity
  69941. * @param target defines where the entity should look at
  69942. * @param up defines the up vector for the entity
  69943. * @param result defines the target matrix
  69944. */
  69945. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69946. /**
  69947. * Create a left-handed orthographic projection matrix
  69948. * @param width defines the viewport width
  69949. * @param height defines the viewport height
  69950. * @param znear defines the near clip plane
  69951. * @param zfar defines the far clip plane
  69952. * @returns a new matrix as a left-handed orthographic projection matrix
  69953. */
  69954. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69955. /**
  69956. * Store a left-handed orthographic projection to a given matrix
  69957. * @param width defines the viewport width
  69958. * @param height defines the viewport height
  69959. * @param znear defines the near clip plane
  69960. * @param zfar defines the far clip plane
  69961. * @param result defines the target matrix
  69962. */
  69963. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69964. /**
  69965. * Create a left-handed orthographic projection matrix
  69966. * @param left defines the viewport left coordinate
  69967. * @param right defines the viewport right coordinate
  69968. * @param bottom defines the viewport bottom coordinate
  69969. * @param top defines the viewport top coordinate
  69970. * @param znear defines the near clip plane
  69971. * @param zfar defines the far clip plane
  69972. * @returns a new matrix as a left-handed orthographic projection matrix
  69973. */
  69974. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69975. /**
  69976. * Stores a left-handed orthographic projection into a given matrix
  69977. * @param left defines the viewport left coordinate
  69978. * @param right defines the viewport right coordinate
  69979. * @param bottom defines the viewport bottom coordinate
  69980. * @param top defines the viewport top coordinate
  69981. * @param znear defines the near clip plane
  69982. * @param zfar defines the far clip plane
  69983. * @param result defines the target matrix
  69984. */
  69985. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69986. /**
  69987. * Creates a right-handed orthographic projection matrix
  69988. * @param left defines the viewport left coordinate
  69989. * @param right defines the viewport right coordinate
  69990. * @param bottom defines the viewport bottom coordinate
  69991. * @param top defines the viewport top coordinate
  69992. * @param znear defines the near clip plane
  69993. * @param zfar defines the far clip plane
  69994. * @returns a new matrix as a right-handed orthographic projection matrix
  69995. */
  69996. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69997. /**
  69998. * Stores a right-handed orthographic projection into a given matrix
  69999. * @param left defines the viewport left coordinate
  70000. * @param right defines the viewport right coordinate
  70001. * @param bottom defines the viewport bottom coordinate
  70002. * @param top defines the viewport top coordinate
  70003. * @param znear defines the near clip plane
  70004. * @param zfar defines the far clip plane
  70005. * @param result defines the target matrix
  70006. */
  70007. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70008. /**
  70009. * Creates a left-handed perspective projection matrix
  70010. * @param width defines the viewport width
  70011. * @param height defines the viewport height
  70012. * @param znear defines the near clip plane
  70013. * @param zfar defines the far clip plane
  70014. * @returns a new matrix as a left-handed perspective projection matrix
  70015. */
  70016. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70017. /**
  70018. * Creates a left-handed perspective projection matrix
  70019. * @param fov defines the horizontal field of view
  70020. * @param aspect defines the aspect ratio
  70021. * @param znear defines the near clip plane
  70022. * @param zfar defines the far clip plane
  70023. * @returns a new matrix as a left-handed perspective projection matrix
  70024. */
  70025. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70026. /**
  70027. * Stores a left-handed perspective projection into a given matrix
  70028. * @param fov defines the horizontal field of view
  70029. * @param aspect defines the aspect ratio
  70030. * @param znear defines the near clip plane
  70031. * @param zfar defines the far clip plane
  70032. * @param result defines the target matrix
  70033. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70034. */
  70035. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70036. /**
  70037. * Creates a right-handed perspective projection matrix
  70038. * @param fov defines the horizontal field of view
  70039. * @param aspect defines the aspect ratio
  70040. * @param znear defines the near clip plane
  70041. * @param zfar defines the far clip plane
  70042. * @returns a new matrix as a right-handed perspective projection matrix
  70043. */
  70044. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70045. /**
  70046. * Stores a right-handed perspective projection into a given matrix
  70047. * @param fov defines the horizontal field of view
  70048. * @param aspect defines the aspect ratio
  70049. * @param znear defines the near clip plane
  70050. * @param zfar defines the far clip plane
  70051. * @param result defines the target matrix
  70052. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70053. */
  70054. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70055. /**
  70056. * Stores a perspective projection for WebVR info a given matrix
  70057. * @param fov defines the field of view
  70058. * @param znear defines the near clip plane
  70059. * @param zfar defines the far clip plane
  70060. * @param result defines the target matrix
  70061. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  70062. */
  70063. static PerspectiveFovWebVRToRef(fov: {
  70064. upDegrees: number;
  70065. downDegrees: number;
  70066. leftDegrees: number;
  70067. rightDegrees: number;
  70068. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  70069. /**
  70070. * Computes a complete transformation matrix
  70071. * @param viewport defines the viewport to use
  70072. * @param world defines the world matrix
  70073. * @param view defines the view matrix
  70074. * @param projection defines the projection matrix
  70075. * @param zmin defines the near clip plane
  70076. * @param zmax defines the far clip plane
  70077. * @returns the transformation matrix
  70078. */
  70079. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  70080. /**
  70081. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  70082. * @param matrix defines the matrix to use
  70083. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  70084. */
  70085. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  70086. /**
  70087. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  70088. * @param matrix defines the matrix to use
  70089. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  70090. */
  70091. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  70092. /**
  70093. * Compute the transpose of a given matrix
  70094. * @param matrix defines the matrix to transpose
  70095. * @returns the new matrix
  70096. */
  70097. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  70098. /**
  70099. * Compute the transpose of a matrix and store it in a target matrix
  70100. * @param matrix defines the matrix to transpose
  70101. * @param result defines the target matrix
  70102. */
  70103. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  70104. /**
  70105. * Computes a reflection matrix from a plane
  70106. * @param plane defines the reflection plane
  70107. * @returns a new matrix
  70108. */
  70109. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  70110. /**
  70111. * Computes a reflection matrix from a plane
  70112. * @param plane defines the reflection plane
  70113. * @param result defines the target matrix
  70114. */
  70115. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  70116. /**
  70117. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  70118. * @param xaxis defines the value of the 1st axis
  70119. * @param yaxis defines the value of the 2nd axis
  70120. * @param zaxis defines the value of the 3rd axis
  70121. * @param result defines the target matrix
  70122. */
  70123. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  70124. /**
  70125. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  70126. * @param quat defines the quaternion to use
  70127. * @param result defines the target matrix
  70128. */
  70129. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  70130. }
  70131. /**
  70132. * @hidden
  70133. */
  70134. export class TmpVectors {
  70135. static Vector2: Vector2[];
  70136. static Vector3: Vector3[];
  70137. static Vector4: Vector4[];
  70138. static Quaternion: Quaternion[];
  70139. static Matrix: Matrix[];
  70140. }
  70141. }
  70142. declare module BABYLON {
  70143. /**
  70144. * Class used to hold a RBG color
  70145. */
  70146. export class Color3 {
  70147. /**
  70148. * Defines the red component (between 0 and 1, default is 0)
  70149. */
  70150. r: number;
  70151. /**
  70152. * Defines the green component (between 0 and 1, default is 0)
  70153. */
  70154. g: number;
  70155. /**
  70156. * Defines the blue component (between 0 and 1, default is 0)
  70157. */
  70158. b: number;
  70159. /**
  70160. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70161. * @param r defines the red component (between 0 and 1, default is 0)
  70162. * @param g defines the green component (between 0 and 1, default is 0)
  70163. * @param b defines the blue component (between 0 and 1, default is 0)
  70164. */
  70165. constructor(
  70166. /**
  70167. * Defines the red component (between 0 and 1, default is 0)
  70168. */
  70169. r?: number,
  70170. /**
  70171. * Defines the green component (between 0 and 1, default is 0)
  70172. */
  70173. g?: number,
  70174. /**
  70175. * Defines the blue component (between 0 and 1, default is 0)
  70176. */
  70177. b?: number);
  70178. /**
  70179. * Creates a string with the Color3 current values
  70180. * @returns the string representation of the Color3 object
  70181. */
  70182. toString(): string;
  70183. /**
  70184. * Returns the string "Color3"
  70185. * @returns "Color3"
  70186. */
  70187. getClassName(): string;
  70188. /**
  70189. * Compute the Color3 hash code
  70190. * @returns an unique number that can be used to hash Color3 objects
  70191. */
  70192. getHashCode(): number;
  70193. /**
  70194. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70195. * @param array defines the array where to store the r,g,b components
  70196. * @param index defines an optional index in the target array to define where to start storing values
  70197. * @returns the current Color3 object
  70198. */
  70199. toArray(array: FloatArray, index?: number): Color3;
  70200. /**
  70201. * Returns a new Color4 object from the current Color3 and the given alpha
  70202. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70203. * @returns a new Color4 object
  70204. */
  70205. toColor4(alpha?: number): Color4;
  70206. /**
  70207. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70208. * @returns the new array
  70209. */
  70210. asArray(): number[];
  70211. /**
  70212. * Returns the luminance value
  70213. * @returns a float value
  70214. */
  70215. toLuminance(): number;
  70216. /**
  70217. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70218. * @param otherColor defines the second operand
  70219. * @returns the new Color3 object
  70220. */
  70221. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70222. /**
  70223. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70224. * @param otherColor defines the second operand
  70225. * @param result defines the Color3 object where to store the result
  70226. * @returns the current Color3
  70227. */
  70228. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70229. /**
  70230. * Determines equality between Color3 objects
  70231. * @param otherColor defines the second operand
  70232. * @returns true if the rgb values are equal to the given ones
  70233. */
  70234. equals(otherColor: DeepImmutable<Color3>): boolean;
  70235. /**
  70236. * Determines equality between the current Color3 object and a set of r,b,g values
  70237. * @param r defines the red component to check
  70238. * @param g defines the green component to check
  70239. * @param b defines the blue component to check
  70240. * @returns true if the rgb values are equal to the given ones
  70241. */
  70242. equalsFloats(r: number, g: number, b: number): boolean;
  70243. /**
  70244. * Multiplies in place each rgb value by scale
  70245. * @param scale defines the scaling factor
  70246. * @returns the updated Color3
  70247. */
  70248. scale(scale: number): Color3;
  70249. /**
  70250. * Multiplies the rgb values by scale and stores the result into "result"
  70251. * @param scale defines the scaling factor
  70252. * @param result defines the Color3 object where to store the result
  70253. * @returns the unmodified current Color3
  70254. */
  70255. scaleToRef(scale: number, result: Color3): Color3;
  70256. /**
  70257. * Scale the current Color3 values by a factor and add the result to a given Color3
  70258. * @param scale defines the scale factor
  70259. * @param result defines color to store the result into
  70260. * @returns the unmodified current Color3
  70261. */
  70262. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70263. /**
  70264. * Clamps the rgb values by the min and max values and stores the result into "result"
  70265. * @param min defines minimum clamping value (default is 0)
  70266. * @param max defines maximum clamping value (default is 1)
  70267. * @param result defines color to store the result into
  70268. * @returns the original Color3
  70269. */
  70270. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70271. /**
  70272. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70273. * @param otherColor defines the second operand
  70274. * @returns the new Color3
  70275. */
  70276. add(otherColor: DeepImmutable<Color3>): Color3;
  70277. /**
  70278. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70279. * @param otherColor defines the second operand
  70280. * @param result defines Color3 object to store the result into
  70281. * @returns the unmodified current Color3
  70282. */
  70283. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70284. /**
  70285. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70286. * @param otherColor defines the second operand
  70287. * @returns the new Color3
  70288. */
  70289. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70290. /**
  70291. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70292. * @param otherColor defines the second operand
  70293. * @param result defines Color3 object to store the result into
  70294. * @returns the unmodified current Color3
  70295. */
  70296. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70297. /**
  70298. * Copy the current object
  70299. * @returns a new Color3 copied the current one
  70300. */
  70301. clone(): Color3;
  70302. /**
  70303. * Copies the rgb values from the source in the current Color3
  70304. * @param source defines the source Color3 object
  70305. * @returns the updated Color3 object
  70306. */
  70307. copyFrom(source: DeepImmutable<Color3>): Color3;
  70308. /**
  70309. * Updates the Color3 rgb values from the given floats
  70310. * @param r defines the red component to read from
  70311. * @param g defines the green component to read from
  70312. * @param b defines the blue component to read from
  70313. * @returns the current Color3 object
  70314. */
  70315. copyFromFloats(r: number, g: number, b: number): Color3;
  70316. /**
  70317. * Updates the Color3 rgb values from the given floats
  70318. * @param r defines the red component to read from
  70319. * @param g defines the green component to read from
  70320. * @param b defines the blue component to read from
  70321. * @returns the current Color3 object
  70322. */
  70323. set(r: number, g: number, b: number): Color3;
  70324. /**
  70325. * Compute the Color3 hexadecimal code as a string
  70326. * @returns a string containing the hexadecimal representation of the Color3 object
  70327. */
  70328. toHexString(): string;
  70329. /**
  70330. * Computes a new Color3 converted from the current one to linear space
  70331. * @returns a new Color3 object
  70332. */
  70333. toLinearSpace(): Color3;
  70334. /**
  70335. * Converts current color in rgb space to HSV values
  70336. * @returns a new color3 representing the HSV values
  70337. */
  70338. toHSV(): Color3;
  70339. /**
  70340. * Converts current color in rgb space to HSV values
  70341. * @param result defines the Color3 where to store the HSV values
  70342. */
  70343. toHSVToRef(result: Color3): void;
  70344. /**
  70345. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70346. * @param convertedColor defines the Color3 object where to store the linear space version
  70347. * @returns the unmodified Color3
  70348. */
  70349. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70350. /**
  70351. * Computes a new Color3 converted from the current one to gamma space
  70352. * @returns a new Color3 object
  70353. */
  70354. toGammaSpace(): Color3;
  70355. /**
  70356. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70357. * @param convertedColor defines the Color3 object where to store the gamma space version
  70358. * @returns the unmodified Color3
  70359. */
  70360. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70361. private static _BlackReadOnly;
  70362. /**
  70363. * Convert Hue, saturation and value to a Color3 (RGB)
  70364. * @param hue defines the hue
  70365. * @param saturation defines the saturation
  70366. * @param value defines the value
  70367. * @param result defines the Color3 where to store the RGB values
  70368. */
  70369. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70370. /**
  70371. * Creates a new Color3 from the string containing valid hexadecimal values
  70372. * @param hex defines a string containing valid hexadecimal values
  70373. * @returns a new Color3 object
  70374. */
  70375. static FromHexString(hex: string): Color3;
  70376. /**
  70377. * Creates a new Color3 from the starting index of the given array
  70378. * @param array defines the source array
  70379. * @param offset defines an offset in the source array
  70380. * @returns a new Color3 object
  70381. */
  70382. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70383. /**
  70384. * Creates a new Color3 from integer values (< 256)
  70385. * @param r defines the red component to read from (value between 0 and 255)
  70386. * @param g defines the green component to read from (value between 0 and 255)
  70387. * @param b defines the blue component to read from (value between 0 and 255)
  70388. * @returns a new Color3 object
  70389. */
  70390. static FromInts(r: number, g: number, b: number): Color3;
  70391. /**
  70392. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70393. * @param start defines the start Color3 value
  70394. * @param end defines the end Color3 value
  70395. * @param amount defines the gradient value between start and end
  70396. * @returns a new Color3 object
  70397. */
  70398. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70399. /**
  70400. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70401. * @param left defines the start value
  70402. * @param right defines the end value
  70403. * @param amount defines the gradient factor
  70404. * @param result defines the Color3 object where to store the result
  70405. */
  70406. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70407. /**
  70408. * Returns a Color3 value containing a red color
  70409. * @returns a new Color3 object
  70410. */
  70411. static Red(): Color3;
  70412. /**
  70413. * Returns a Color3 value containing a green color
  70414. * @returns a new Color3 object
  70415. */
  70416. static Green(): Color3;
  70417. /**
  70418. * Returns a Color3 value containing a blue color
  70419. * @returns a new Color3 object
  70420. */
  70421. static Blue(): Color3;
  70422. /**
  70423. * Returns a Color3 value containing a black color
  70424. * @returns a new Color3 object
  70425. */
  70426. static Black(): Color3;
  70427. /**
  70428. * Gets a Color3 value containing a black color that must not be updated
  70429. */
  70430. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70431. /**
  70432. * Returns a Color3 value containing a white color
  70433. * @returns a new Color3 object
  70434. */
  70435. static White(): Color3;
  70436. /**
  70437. * Returns a Color3 value containing a purple color
  70438. * @returns a new Color3 object
  70439. */
  70440. static Purple(): Color3;
  70441. /**
  70442. * Returns a Color3 value containing a magenta color
  70443. * @returns a new Color3 object
  70444. */
  70445. static Magenta(): Color3;
  70446. /**
  70447. * Returns a Color3 value containing a yellow color
  70448. * @returns a new Color3 object
  70449. */
  70450. static Yellow(): Color3;
  70451. /**
  70452. * Returns a Color3 value containing a gray color
  70453. * @returns a new Color3 object
  70454. */
  70455. static Gray(): Color3;
  70456. /**
  70457. * Returns a Color3 value containing a teal color
  70458. * @returns a new Color3 object
  70459. */
  70460. static Teal(): Color3;
  70461. /**
  70462. * Returns a Color3 value containing a random color
  70463. * @returns a new Color3 object
  70464. */
  70465. static Random(): Color3;
  70466. }
  70467. /**
  70468. * Class used to hold a RBGA color
  70469. */
  70470. export class Color4 {
  70471. /**
  70472. * Defines the red component (between 0 and 1, default is 0)
  70473. */
  70474. r: number;
  70475. /**
  70476. * Defines the green component (between 0 and 1, default is 0)
  70477. */
  70478. g: number;
  70479. /**
  70480. * Defines the blue component (between 0 and 1, default is 0)
  70481. */
  70482. b: number;
  70483. /**
  70484. * Defines the alpha component (between 0 and 1, default is 1)
  70485. */
  70486. a: number;
  70487. /**
  70488. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70489. * @param r defines the red component (between 0 and 1, default is 0)
  70490. * @param g defines the green component (between 0 and 1, default is 0)
  70491. * @param b defines the blue component (between 0 and 1, default is 0)
  70492. * @param a defines the alpha component (between 0 and 1, default is 1)
  70493. */
  70494. constructor(
  70495. /**
  70496. * Defines the red component (between 0 and 1, default is 0)
  70497. */
  70498. r?: number,
  70499. /**
  70500. * Defines the green component (between 0 and 1, default is 0)
  70501. */
  70502. g?: number,
  70503. /**
  70504. * Defines the blue component (between 0 and 1, default is 0)
  70505. */
  70506. b?: number,
  70507. /**
  70508. * Defines the alpha component (between 0 and 1, default is 1)
  70509. */
  70510. a?: number);
  70511. /**
  70512. * Adds in place the given Color4 values to the current Color4 object
  70513. * @param right defines the second operand
  70514. * @returns the current updated Color4 object
  70515. */
  70516. addInPlace(right: DeepImmutable<Color4>): Color4;
  70517. /**
  70518. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70519. * @returns the new array
  70520. */
  70521. asArray(): number[];
  70522. /**
  70523. * Stores from the starting index in the given array the Color4 successive values
  70524. * @param array defines the array where to store the r,g,b components
  70525. * @param index defines an optional index in the target array to define where to start storing values
  70526. * @returns the current Color4 object
  70527. */
  70528. toArray(array: number[], index?: number): Color4;
  70529. /**
  70530. * Determines equality between Color4 objects
  70531. * @param otherColor defines the second operand
  70532. * @returns true if the rgba values are equal to the given ones
  70533. */
  70534. equals(otherColor: DeepImmutable<Color4>): boolean;
  70535. /**
  70536. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70537. * @param right defines the second operand
  70538. * @returns a new Color4 object
  70539. */
  70540. add(right: DeepImmutable<Color4>): Color4;
  70541. /**
  70542. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70543. * @param right defines the second operand
  70544. * @returns a new Color4 object
  70545. */
  70546. subtract(right: DeepImmutable<Color4>): Color4;
  70547. /**
  70548. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70549. * @param right defines the second operand
  70550. * @param result defines the Color4 object where to store the result
  70551. * @returns the current Color4 object
  70552. */
  70553. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70554. /**
  70555. * Creates a new Color4 with the current Color4 values multiplied by scale
  70556. * @param scale defines the scaling factor to apply
  70557. * @returns a new Color4 object
  70558. */
  70559. scale(scale: number): Color4;
  70560. /**
  70561. * Multiplies the current Color4 values by scale and stores the result in "result"
  70562. * @param scale defines the scaling factor to apply
  70563. * @param result defines the Color4 object where to store the result
  70564. * @returns the current unmodified Color4
  70565. */
  70566. scaleToRef(scale: number, result: Color4): Color4;
  70567. /**
  70568. * Scale the current Color4 values by a factor and add the result to a given Color4
  70569. * @param scale defines the scale factor
  70570. * @param result defines the Color4 object where to store the result
  70571. * @returns the unmodified current Color4
  70572. */
  70573. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70574. /**
  70575. * Clamps the rgb values by the min and max values and stores the result into "result"
  70576. * @param min defines minimum clamping value (default is 0)
  70577. * @param max defines maximum clamping value (default is 1)
  70578. * @param result defines color to store the result into.
  70579. * @returns the cuurent Color4
  70580. */
  70581. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70582. /**
  70583. * Multipy an Color4 value by another and return a new Color4 object
  70584. * @param color defines the Color4 value to multiply by
  70585. * @returns a new Color4 object
  70586. */
  70587. multiply(color: Color4): Color4;
  70588. /**
  70589. * Multipy a Color4 value by another and push the result in a reference value
  70590. * @param color defines the Color4 value to multiply by
  70591. * @param result defines the Color4 to fill the result in
  70592. * @returns the result Color4
  70593. */
  70594. multiplyToRef(color: Color4, result: Color4): Color4;
  70595. /**
  70596. * Creates a string with the Color4 current values
  70597. * @returns the string representation of the Color4 object
  70598. */
  70599. toString(): string;
  70600. /**
  70601. * Returns the string "Color4"
  70602. * @returns "Color4"
  70603. */
  70604. getClassName(): string;
  70605. /**
  70606. * Compute the Color4 hash code
  70607. * @returns an unique number that can be used to hash Color4 objects
  70608. */
  70609. getHashCode(): number;
  70610. /**
  70611. * Creates a new Color4 copied from the current one
  70612. * @returns a new Color4 object
  70613. */
  70614. clone(): Color4;
  70615. /**
  70616. * Copies the given Color4 values into the current one
  70617. * @param source defines the source Color4 object
  70618. * @returns the current updated Color4 object
  70619. */
  70620. copyFrom(source: Color4): Color4;
  70621. /**
  70622. * Copies the given float values into the current one
  70623. * @param r defines the red component to read from
  70624. * @param g defines the green component to read from
  70625. * @param b defines the blue component to read from
  70626. * @param a defines the alpha component to read from
  70627. * @returns the current updated Color4 object
  70628. */
  70629. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70630. /**
  70631. * Copies the given float values into the current one
  70632. * @param r defines the red component to read from
  70633. * @param g defines the green component to read from
  70634. * @param b defines the blue component to read from
  70635. * @param a defines the alpha component to read from
  70636. * @returns the current updated Color4 object
  70637. */
  70638. set(r: number, g: number, b: number, a: number): Color4;
  70639. /**
  70640. * Compute the Color4 hexadecimal code as a string
  70641. * @returns a string containing the hexadecimal representation of the Color4 object
  70642. */
  70643. toHexString(): string;
  70644. /**
  70645. * Computes a new Color4 converted from the current one to linear space
  70646. * @returns a new Color4 object
  70647. */
  70648. toLinearSpace(): Color4;
  70649. /**
  70650. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70651. * @param convertedColor defines the Color4 object where to store the linear space version
  70652. * @returns the unmodified Color4
  70653. */
  70654. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70655. /**
  70656. * Computes a new Color4 converted from the current one to gamma space
  70657. * @returns a new Color4 object
  70658. */
  70659. toGammaSpace(): Color4;
  70660. /**
  70661. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70662. * @param convertedColor defines the Color4 object where to store the gamma space version
  70663. * @returns the unmodified Color4
  70664. */
  70665. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70666. /**
  70667. * Creates a new Color4 from the string containing valid hexadecimal values
  70668. * @param hex defines a string containing valid hexadecimal values
  70669. * @returns a new Color4 object
  70670. */
  70671. static FromHexString(hex: string): Color4;
  70672. /**
  70673. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70674. * @param left defines the start value
  70675. * @param right defines the end value
  70676. * @param amount defines the gradient factor
  70677. * @returns a new Color4 object
  70678. */
  70679. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70680. /**
  70681. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70682. * @param left defines the start value
  70683. * @param right defines the end value
  70684. * @param amount defines the gradient factor
  70685. * @param result defines the Color4 object where to store data
  70686. */
  70687. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70688. /**
  70689. * Creates a new Color4 from a Color3 and an alpha value
  70690. * @param color3 defines the source Color3 to read from
  70691. * @param alpha defines the alpha component (1.0 by default)
  70692. * @returns a new Color4 object
  70693. */
  70694. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70695. /**
  70696. * Creates a new Color4 from the starting index element of the given array
  70697. * @param array defines the source array to read from
  70698. * @param offset defines the offset in the source array
  70699. * @returns a new Color4 object
  70700. */
  70701. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70702. /**
  70703. * Creates a new Color3 from integer values (< 256)
  70704. * @param r defines the red component to read from (value between 0 and 255)
  70705. * @param g defines the green component to read from (value between 0 and 255)
  70706. * @param b defines the blue component to read from (value between 0 and 255)
  70707. * @param a defines the alpha component to read from (value between 0 and 255)
  70708. * @returns a new Color3 object
  70709. */
  70710. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70711. /**
  70712. * Check the content of a given array and convert it to an array containing RGBA data
  70713. * If the original array was already containing count * 4 values then it is returned directly
  70714. * @param colors defines the array to check
  70715. * @param count defines the number of RGBA data to expect
  70716. * @returns an array containing count * 4 values (RGBA)
  70717. */
  70718. static CheckColors4(colors: number[], count: number): number[];
  70719. }
  70720. /**
  70721. * @hidden
  70722. */
  70723. export class TmpColors {
  70724. static Color3: Color3[];
  70725. static Color4: Color4[];
  70726. }
  70727. }
  70728. declare module BABYLON {
  70729. /**
  70730. * Class representing spherical harmonics coefficients to the 3rd degree
  70731. */
  70732. export class SphericalHarmonics {
  70733. /**
  70734. * Defines whether or not the harmonics have been prescaled for rendering.
  70735. */
  70736. preScaled: boolean;
  70737. /**
  70738. * The l0,0 coefficients of the spherical harmonics
  70739. */
  70740. l00: Vector3;
  70741. /**
  70742. * The l1,-1 coefficients of the spherical harmonics
  70743. */
  70744. l1_1: Vector3;
  70745. /**
  70746. * The l1,0 coefficients of the spherical harmonics
  70747. */
  70748. l10: Vector3;
  70749. /**
  70750. * The l1,1 coefficients of the spherical harmonics
  70751. */
  70752. l11: Vector3;
  70753. /**
  70754. * The l2,-2 coefficients of the spherical harmonics
  70755. */
  70756. l2_2: Vector3;
  70757. /**
  70758. * The l2,-1 coefficients of the spherical harmonics
  70759. */
  70760. l2_1: Vector3;
  70761. /**
  70762. * The l2,0 coefficients of the spherical harmonics
  70763. */
  70764. l20: Vector3;
  70765. /**
  70766. * The l2,1 coefficients of the spherical harmonics
  70767. */
  70768. l21: Vector3;
  70769. /**
  70770. * The l2,2 coefficients of the spherical harmonics
  70771. */
  70772. l22: Vector3;
  70773. /**
  70774. * Adds a light to the spherical harmonics
  70775. * @param direction the direction of the light
  70776. * @param color the color of the light
  70777. * @param deltaSolidAngle the delta solid angle of the light
  70778. */
  70779. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70780. /**
  70781. * Scales the spherical harmonics by the given amount
  70782. * @param scale the amount to scale
  70783. */
  70784. scaleInPlace(scale: number): void;
  70785. /**
  70786. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70787. *
  70788. * ```
  70789. * E_lm = A_l * L_lm
  70790. * ```
  70791. *
  70792. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70793. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70794. * the scaling factors are given in equation 9.
  70795. */
  70796. convertIncidentRadianceToIrradiance(): void;
  70797. /**
  70798. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70799. *
  70800. * ```
  70801. * L = (1/pi) * E * rho
  70802. * ```
  70803. *
  70804. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70805. */
  70806. convertIrradianceToLambertianRadiance(): void;
  70807. /**
  70808. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70809. * required operations at run time.
  70810. *
  70811. * This is simply done by scaling back the SH with Ylm constants parameter.
  70812. * The trigonometric part being applied by the shader at run time.
  70813. */
  70814. preScaleForRendering(): void;
  70815. /**
  70816. * Constructs a spherical harmonics from an array.
  70817. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70818. * @returns the spherical harmonics
  70819. */
  70820. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70821. /**
  70822. * Gets the spherical harmonics from polynomial
  70823. * @param polynomial the spherical polynomial
  70824. * @returns the spherical harmonics
  70825. */
  70826. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70827. }
  70828. /**
  70829. * Class representing spherical polynomial coefficients to the 3rd degree
  70830. */
  70831. export class SphericalPolynomial {
  70832. private _harmonics;
  70833. /**
  70834. * The spherical harmonics used to create the polynomials.
  70835. */
  70836. readonly preScaledHarmonics: SphericalHarmonics;
  70837. /**
  70838. * The x coefficients of the spherical polynomial
  70839. */
  70840. x: Vector3;
  70841. /**
  70842. * The y coefficients of the spherical polynomial
  70843. */
  70844. y: Vector3;
  70845. /**
  70846. * The z coefficients of the spherical polynomial
  70847. */
  70848. z: Vector3;
  70849. /**
  70850. * The xx coefficients of the spherical polynomial
  70851. */
  70852. xx: Vector3;
  70853. /**
  70854. * The yy coefficients of the spherical polynomial
  70855. */
  70856. yy: Vector3;
  70857. /**
  70858. * The zz coefficients of the spherical polynomial
  70859. */
  70860. zz: Vector3;
  70861. /**
  70862. * The xy coefficients of the spherical polynomial
  70863. */
  70864. xy: Vector3;
  70865. /**
  70866. * The yz coefficients of the spherical polynomial
  70867. */
  70868. yz: Vector3;
  70869. /**
  70870. * The zx coefficients of the spherical polynomial
  70871. */
  70872. zx: Vector3;
  70873. /**
  70874. * Adds an ambient color to the spherical polynomial
  70875. * @param color the color to add
  70876. */
  70877. addAmbient(color: Color3): void;
  70878. /**
  70879. * Scales the spherical polynomial by the given amount
  70880. * @param scale the amount to scale
  70881. */
  70882. scaleInPlace(scale: number): void;
  70883. /**
  70884. * Gets the spherical polynomial from harmonics
  70885. * @param harmonics the spherical harmonics
  70886. * @returns the spherical polynomial
  70887. */
  70888. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70889. /**
  70890. * Constructs a spherical polynomial from an array.
  70891. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70892. * @returns the spherical polynomial
  70893. */
  70894. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70895. }
  70896. }
  70897. declare module BABYLON {
  70898. /**
  70899. * Define options used to create a render target texture
  70900. */
  70901. export class RenderTargetCreationOptions {
  70902. /**
  70903. * Specifies is mipmaps must be generated
  70904. */
  70905. generateMipMaps?: boolean;
  70906. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70907. generateDepthBuffer?: boolean;
  70908. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70909. generateStencilBuffer?: boolean;
  70910. /** Defines texture type (int by default) */
  70911. type?: number;
  70912. /** Defines sampling mode (trilinear by default) */
  70913. samplingMode?: number;
  70914. /** Defines format (RGBA by default) */
  70915. format?: number;
  70916. }
  70917. }
  70918. declare module BABYLON {
  70919. /**
  70920. * @hidden
  70921. **/
  70922. export class _TimeToken {
  70923. _startTimeQuery: Nullable<WebGLQuery>;
  70924. _endTimeQuery: Nullable<WebGLQuery>;
  70925. _timeElapsedQuery: Nullable<WebGLQuery>;
  70926. _timeElapsedQueryEnded: boolean;
  70927. }
  70928. }
  70929. declare module BABYLON {
  70930. /** Defines the cross module used constants to avoid circular dependncies */
  70931. export class Constants {
  70932. /** Defines that alpha blending is disabled */
  70933. static readonly ALPHA_DISABLE: number;
  70934. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  70935. static readonly ALPHA_ADD: number;
  70936. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  70937. static readonly ALPHA_COMBINE: number;
  70938. /** Defines that alpha blending to DEST - SRC * DEST */
  70939. static readonly ALPHA_SUBTRACT: number;
  70940. /** Defines that alpha blending to SRC * DEST */
  70941. static readonly ALPHA_MULTIPLY: number;
  70942. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  70943. static readonly ALPHA_MAXIMIZED: number;
  70944. /** Defines that alpha blending to SRC + DEST */
  70945. static readonly ALPHA_ONEONE: number;
  70946. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  70947. static readonly ALPHA_PREMULTIPLIED: number;
  70948. /**
  70949. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  70950. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  70951. */
  70952. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  70953. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  70954. static readonly ALPHA_INTERPOLATE: number;
  70955. /**
  70956. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  70957. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  70958. */
  70959. static readonly ALPHA_SCREENMODE: number;
  70960. /**
  70961. * Defines that alpha blending to SRC + DST
  70962. * Alpha will be set to SRC ALPHA + DST ALPHA
  70963. */
  70964. static readonly ALPHA_ONEONE_ONEONE: number;
  70965. /**
  70966. * Defines that alpha blending to SRC * DST ALPHA + DST
  70967. * Alpha will be set to 0
  70968. */
  70969. static readonly ALPHA_ALPHATOCOLOR: number;
  70970. /**
  70971. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  70972. */
  70973. static readonly ALPHA_REVERSEONEMINUS: number;
  70974. /**
  70975. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  70976. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  70977. */
  70978. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  70979. /**
  70980. * Defines that alpha blending to SRC + DST
  70981. * Alpha will be set to SRC ALPHA
  70982. */
  70983. static readonly ALPHA_ONEONE_ONEZERO: number;
  70984. /** Defines that alpha blending equation a SUM */
  70985. static readonly ALPHA_EQUATION_ADD: number;
  70986. /** Defines that alpha blending equation a SUBSTRACTION */
  70987. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  70988. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  70989. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70990. /** Defines that alpha blending equation a MAX operation */
  70991. static readonly ALPHA_EQUATION_MAX: number;
  70992. /** Defines that alpha blending equation a MIN operation */
  70993. static readonly ALPHA_EQUATION_MIN: number;
  70994. /**
  70995. * Defines that alpha blending equation a DARKEN operation:
  70996. * It takes the min of the src and sums the alpha channels.
  70997. */
  70998. static readonly ALPHA_EQUATION_DARKEN: number;
  70999. /** Defines that the ressource is not delayed*/
  71000. static readonly DELAYLOADSTATE_NONE: number;
  71001. /** Defines that the ressource was successfully delay loaded */
  71002. static readonly DELAYLOADSTATE_LOADED: number;
  71003. /** Defines that the ressource is currently delay loading */
  71004. static readonly DELAYLOADSTATE_LOADING: number;
  71005. /** Defines that the ressource is delayed and has not started loading */
  71006. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71007. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71008. static readonly NEVER: number;
  71009. /** 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 */
  71010. static readonly ALWAYS: number;
  71011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71012. static readonly LESS: number;
  71013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71014. static readonly EQUAL: number;
  71015. /** 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 */
  71016. static readonly LEQUAL: number;
  71017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71018. static readonly GREATER: number;
  71019. /** 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 */
  71020. static readonly GEQUAL: number;
  71021. /** 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 */
  71022. static readonly NOTEQUAL: number;
  71023. /** Passed to stencilOperation to specify that stencil value must be kept */
  71024. static readonly KEEP: number;
  71025. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71026. static readonly REPLACE: number;
  71027. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71028. static readonly INCR: number;
  71029. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71030. static readonly DECR: number;
  71031. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71032. static readonly INVERT: number;
  71033. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71034. static readonly INCR_WRAP: number;
  71035. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71036. static readonly DECR_WRAP: number;
  71037. /** Texture is not repeating outside of 0..1 UVs */
  71038. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71039. /** Texture is repeating outside of 0..1 UVs */
  71040. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71041. /** Texture is repeating and mirrored */
  71042. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71043. /** ALPHA */
  71044. static readonly TEXTUREFORMAT_ALPHA: number;
  71045. /** LUMINANCE */
  71046. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71047. /** LUMINANCE_ALPHA */
  71048. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71049. /** RGB */
  71050. static readonly TEXTUREFORMAT_RGB: number;
  71051. /** RGBA */
  71052. static readonly TEXTUREFORMAT_RGBA: number;
  71053. /** RED */
  71054. static readonly TEXTUREFORMAT_RED: number;
  71055. /** RED (2nd reference) */
  71056. static readonly TEXTUREFORMAT_R: number;
  71057. /** RG */
  71058. static readonly TEXTUREFORMAT_RG: number;
  71059. /** RED_INTEGER */
  71060. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71061. /** RED_INTEGER (2nd reference) */
  71062. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71063. /** RG_INTEGER */
  71064. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71065. /** RGB_INTEGER */
  71066. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71067. /** RGBA_INTEGER */
  71068. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71069. /** UNSIGNED_BYTE */
  71070. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71071. /** UNSIGNED_BYTE (2nd reference) */
  71072. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71073. /** FLOAT */
  71074. static readonly TEXTURETYPE_FLOAT: number;
  71075. /** HALF_FLOAT */
  71076. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71077. /** BYTE */
  71078. static readonly TEXTURETYPE_BYTE: number;
  71079. /** SHORT */
  71080. static readonly TEXTURETYPE_SHORT: number;
  71081. /** UNSIGNED_SHORT */
  71082. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71083. /** INT */
  71084. static readonly TEXTURETYPE_INT: number;
  71085. /** UNSIGNED_INT */
  71086. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71087. /** UNSIGNED_SHORT_4_4_4_4 */
  71088. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71089. /** UNSIGNED_SHORT_5_5_5_1 */
  71090. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71091. /** UNSIGNED_SHORT_5_6_5 */
  71092. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71093. /** UNSIGNED_INT_2_10_10_10_REV */
  71094. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71095. /** UNSIGNED_INT_24_8 */
  71096. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71097. /** UNSIGNED_INT_10F_11F_11F_REV */
  71098. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71099. /** UNSIGNED_INT_5_9_9_9_REV */
  71100. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71101. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71102. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71103. /** nearest is mag = nearest and min = nearest and mip = linear */
  71104. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71105. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71106. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71107. /** Trilinear is mag = linear and min = linear and mip = linear */
  71108. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71109. /** nearest is mag = nearest and min = nearest and mip = linear */
  71110. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71111. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71112. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71113. /** Trilinear is mag = linear and min = linear and mip = linear */
  71114. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71115. /** mag = nearest and min = nearest and mip = nearest */
  71116. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71117. /** mag = nearest and min = linear and mip = nearest */
  71118. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71119. /** mag = nearest and min = linear and mip = linear */
  71120. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71121. /** mag = nearest and min = linear and mip = none */
  71122. static readonly TEXTURE_NEAREST_LINEAR: number;
  71123. /** mag = nearest and min = nearest and mip = none */
  71124. static readonly TEXTURE_NEAREST_NEAREST: number;
  71125. /** mag = linear and min = nearest and mip = nearest */
  71126. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71127. /** mag = linear and min = nearest and mip = linear */
  71128. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71129. /** mag = linear and min = linear and mip = none */
  71130. static readonly TEXTURE_LINEAR_LINEAR: number;
  71131. /** mag = linear and min = nearest and mip = none */
  71132. static readonly TEXTURE_LINEAR_NEAREST: number;
  71133. /** Explicit coordinates mode */
  71134. static readonly TEXTURE_EXPLICIT_MODE: number;
  71135. /** Spherical coordinates mode */
  71136. static readonly TEXTURE_SPHERICAL_MODE: number;
  71137. /** Planar coordinates mode */
  71138. static readonly TEXTURE_PLANAR_MODE: number;
  71139. /** Cubic coordinates mode */
  71140. static readonly TEXTURE_CUBIC_MODE: number;
  71141. /** Projection coordinates mode */
  71142. static readonly TEXTURE_PROJECTION_MODE: number;
  71143. /** Skybox coordinates mode */
  71144. static readonly TEXTURE_SKYBOX_MODE: number;
  71145. /** Inverse Cubic coordinates mode */
  71146. static readonly TEXTURE_INVCUBIC_MODE: number;
  71147. /** Equirectangular coordinates mode */
  71148. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71149. /** Equirectangular Fixed coordinates mode */
  71150. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71151. /** Equirectangular Fixed Mirrored coordinates mode */
  71152. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71153. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71154. static readonly SCALEMODE_FLOOR: number;
  71155. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71156. static readonly SCALEMODE_NEAREST: number;
  71157. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71158. static readonly SCALEMODE_CEILING: number;
  71159. /**
  71160. * The dirty texture flag value
  71161. */
  71162. static readonly MATERIAL_TextureDirtyFlag: number;
  71163. /**
  71164. * The dirty light flag value
  71165. */
  71166. static readonly MATERIAL_LightDirtyFlag: number;
  71167. /**
  71168. * The dirty fresnel flag value
  71169. */
  71170. static readonly MATERIAL_FresnelDirtyFlag: number;
  71171. /**
  71172. * The dirty attribute flag value
  71173. */
  71174. static readonly MATERIAL_AttributesDirtyFlag: number;
  71175. /**
  71176. * The dirty misc flag value
  71177. */
  71178. static readonly MATERIAL_MiscDirtyFlag: number;
  71179. /**
  71180. * The all dirty flag value
  71181. */
  71182. static readonly MATERIAL_AllDirtyFlag: number;
  71183. /**
  71184. * Returns the triangle fill mode
  71185. */
  71186. static readonly MATERIAL_TriangleFillMode: number;
  71187. /**
  71188. * Returns the wireframe mode
  71189. */
  71190. static readonly MATERIAL_WireFrameFillMode: number;
  71191. /**
  71192. * Returns the point fill mode
  71193. */
  71194. static readonly MATERIAL_PointFillMode: number;
  71195. /**
  71196. * Returns the point list draw mode
  71197. */
  71198. static readonly MATERIAL_PointListDrawMode: number;
  71199. /**
  71200. * Returns the line list draw mode
  71201. */
  71202. static readonly MATERIAL_LineListDrawMode: number;
  71203. /**
  71204. * Returns the line loop draw mode
  71205. */
  71206. static readonly MATERIAL_LineLoopDrawMode: number;
  71207. /**
  71208. * Returns the line strip draw mode
  71209. */
  71210. static readonly MATERIAL_LineStripDrawMode: number;
  71211. /**
  71212. * Returns the triangle strip draw mode
  71213. */
  71214. static readonly MATERIAL_TriangleStripDrawMode: number;
  71215. /**
  71216. * Returns the triangle fan draw mode
  71217. */
  71218. static readonly MATERIAL_TriangleFanDrawMode: number;
  71219. /**
  71220. * Stores the clock-wise side orientation
  71221. */
  71222. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71223. /**
  71224. * Stores the counter clock-wise side orientation
  71225. */
  71226. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71227. /**
  71228. * Nothing
  71229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71230. */
  71231. static readonly ACTION_NothingTrigger: number;
  71232. /**
  71233. * On pick
  71234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71235. */
  71236. static readonly ACTION_OnPickTrigger: number;
  71237. /**
  71238. * On left pick
  71239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71240. */
  71241. static readonly ACTION_OnLeftPickTrigger: number;
  71242. /**
  71243. * On right pick
  71244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71245. */
  71246. static readonly ACTION_OnRightPickTrigger: number;
  71247. /**
  71248. * On center pick
  71249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71250. */
  71251. static readonly ACTION_OnCenterPickTrigger: number;
  71252. /**
  71253. * On pick down
  71254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71255. */
  71256. static readonly ACTION_OnPickDownTrigger: number;
  71257. /**
  71258. * On double pick
  71259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71260. */
  71261. static readonly ACTION_OnDoublePickTrigger: number;
  71262. /**
  71263. * On pick up
  71264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71265. */
  71266. static readonly ACTION_OnPickUpTrigger: number;
  71267. /**
  71268. * On pick out.
  71269. * This trigger will only be raised if you also declared a OnPickDown
  71270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71271. */
  71272. static readonly ACTION_OnPickOutTrigger: number;
  71273. /**
  71274. * On long press
  71275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71276. */
  71277. static readonly ACTION_OnLongPressTrigger: number;
  71278. /**
  71279. * On pointer over
  71280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71281. */
  71282. static readonly ACTION_OnPointerOverTrigger: number;
  71283. /**
  71284. * On pointer out
  71285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71286. */
  71287. static readonly ACTION_OnPointerOutTrigger: number;
  71288. /**
  71289. * On every frame
  71290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71291. */
  71292. static readonly ACTION_OnEveryFrameTrigger: number;
  71293. /**
  71294. * On intersection enter
  71295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71296. */
  71297. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71298. /**
  71299. * On intersection exit
  71300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71301. */
  71302. static readonly ACTION_OnIntersectionExitTrigger: number;
  71303. /**
  71304. * On key down
  71305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71306. */
  71307. static readonly ACTION_OnKeyDownTrigger: number;
  71308. /**
  71309. * On key up
  71310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71311. */
  71312. static readonly ACTION_OnKeyUpTrigger: number;
  71313. /**
  71314. * Billboard mode will only apply to Y axis
  71315. */
  71316. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71317. /**
  71318. * Billboard mode will apply to all axes
  71319. */
  71320. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71321. /**
  71322. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71323. */
  71324. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71325. /**
  71326. * Gets or sets base Assets URL
  71327. */
  71328. static PARTICLES_BaseAssetsUrl: string;
  71329. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71330. * Test order :
  71331. * Is the bounding sphere outside the frustum ?
  71332. * If not, are the bounding box vertices outside the frustum ?
  71333. * It not, then the cullable object is in the frustum.
  71334. */
  71335. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71336. /** Culling strategy : Bounding Sphere Only.
  71337. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71338. * It's also less accurate than the standard because some not visible objects can still be selected.
  71339. * Test : is the bounding sphere outside the frustum ?
  71340. * If not, then the cullable object is in the frustum.
  71341. */
  71342. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71343. /** Culling strategy : Optimistic Inclusion.
  71344. * This in an inclusion test first, then the standard exclusion test.
  71345. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71346. * 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.
  71347. * Anyway, it's as accurate as the standard strategy.
  71348. * Test :
  71349. * Is the cullable object bounding sphere center in the frustum ?
  71350. * If not, apply the default culling strategy.
  71351. */
  71352. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71353. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71354. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71355. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71356. * 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.
  71357. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71358. * Test :
  71359. * Is the cullable object bounding sphere center in the frustum ?
  71360. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71361. */
  71362. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71363. /**
  71364. * No logging while loading
  71365. */
  71366. static readonly SCENELOADER_NO_LOGGING: number;
  71367. /**
  71368. * Minimal logging while loading
  71369. */
  71370. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71371. /**
  71372. * Summary logging while loading
  71373. */
  71374. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71375. /**
  71376. * Detailled logging while loading
  71377. */
  71378. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71379. }
  71380. }
  71381. declare module BABYLON {
  71382. /**
  71383. * This represents the required contract to create a new type of texture loader.
  71384. */
  71385. export interface IInternalTextureLoader {
  71386. /**
  71387. * Defines wether the loader supports cascade loading the different faces.
  71388. */
  71389. supportCascades: boolean;
  71390. /**
  71391. * This returns if the loader support the current file information.
  71392. * @param extension defines the file extension of the file being loaded
  71393. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71394. * @param fallback defines the fallback internal texture if any
  71395. * @param isBase64 defines whether the texture is encoded as a base64
  71396. * @param isBuffer defines whether the texture data are stored as a buffer
  71397. * @returns true if the loader can load the specified file
  71398. */
  71399. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71400. /**
  71401. * Transform the url before loading if required.
  71402. * @param rootUrl the url of the texture
  71403. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71404. * @returns the transformed texture
  71405. */
  71406. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71407. /**
  71408. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71409. * @param rootUrl the url of the texture
  71410. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71411. * @returns the fallback texture
  71412. */
  71413. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71414. /**
  71415. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71416. * @param data contains the texture data
  71417. * @param texture defines the BabylonJS internal texture
  71418. * @param createPolynomials will be true if polynomials have been requested
  71419. * @param onLoad defines the callback to trigger once the texture is ready
  71420. * @param onError defines the callback to trigger in case of error
  71421. */
  71422. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71423. /**
  71424. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71425. * @param data contains the texture data
  71426. * @param texture defines the BabylonJS internal texture
  71427. * @param callback defines the method to call once ready to upload
  71428. */
  71429. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71430. }
  71431. }
  71432. declare module BABYLON {
  71433. /**
  71434. * Class used to store and describe the pipeline context associated with an effect
  71435. */
  71436. export interface IPipelineContext {
  71437. /**
  71438. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71439. */
  71440. isAsync: boolean;
  71441. /**
  71442. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71443. */
  71444. isReady: boolean;
  71445. /** @hidden */
  71446. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71447. }
  71448. }
  71449. declare module BABYLON {
  71450. /**
  71451. * Class used to store gfx data (like WebGLBuffer)
  71452. */
  71453. export class DataBuffer {
  71454. /**
  71455. * Gets or sets the number of objects referencing this buffer
  71456. */
  71457. references: number;
  71458. /** Gets or sets the size of the underlying buffer */
  71459. capacity: number;
  71460. /**
  71461. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71462. */
  71463. is32Bits: boolean;
  71464. /**
  71465. * Gets the underlying buffer
  71466. */
  71467. readonly underlyingResource: any;
  71468. }
  71469. }
  71470. declare module BABYLON {
  71471. /** @hidden */
  71472. export interface IShaderProcessor {
  71473. attributeProcessor?: (attribute: string) => string;
  71474. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71475. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71476. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71477. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71478. lineProcessor?: (line: string, isFragment: boolean) => string;
  71479. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71480. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71481. }
  71482. }
  71483. declare module BABYLON {
  71484. /** @hidden */
  71485. export interface ProcessingOptions {
  71486. defines: string[];
  71487. indexParameters: any;
  71488. isFragment: boolean;
  71489. shouldUseHighPrecisionShader: boolean;
  71490. supportsUniformBuffers: boolean;
  71491. shadersRepository: string;
  71492. includesShadersStore: {
  71493. [key: string]: string;
  71494. };
  71495. processor?: IShaderProcessor;
  71496. version: string;
  71497. platformName: string;
  71498. lookForClosingBracketForUniformBuffer?: boolean;
  71499. }
  71500. }
  71501. declare module BABYLON {
  71502. /**
  71503. * Helper to manipulate strings
  71504. */
  71505. export class StringTools {
  71506. /**
  71507. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71508. * @param str Source string
  71509. * @param suffix Suffix to search for in the source string
  71510. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71511. */
  71512. static EndsWith(str: string, suffix: string): boolean;
  71513. /**
  71514. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71515. * @param str Source string
  71516. * @param suffix Suffix to search for in the source string
  71517. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71518. */
  71519. static StartsWith(str: string, suffix: string): boolean;
  71520. }
  71521. }
  71522. declare module BABYLON {
  71523. /** @hidden */
  71524. export class ShaderCodeNode {
  71525. line: string;
  71526. children: ShaderCodeNode[];
  71527. additionalDefineKey?: string;
  71528. additionalDefineValue?: string;
  71529. isValid(preprocessors: {
  71530. [key: string]: string;
  71531. }): boolean;
  71532. process(preprocessors: {
  71533. [key: string]: string;
  71534. }, options: ProcessingOptions): string;
  71535. }
  71536. }
  71537. declare module BABYLON {
  71538. /** @hidden */
  71539. export class ShaderCodeCursor {
  71540. private _lines;
  71541. lineIndex: number;
  71542. readonly currentLine: string;
  71543. readonly canRead: boolean;
  71544. lines: string[];
  71545. }
  71546. }
  71547. declare module BABYLON {
  71548. /** @hidden */
  71549. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71550. process(preprocessors: {
  71551. [key: string]: string;
  71552. }, options: ProcessingOptions): string;
  71553. }
  71554. }
  71555. declare module BABYLON {
  71556. /** @hidden */
  71557. export class ShaderDefineExpression {
  71558. isTrue(preprocessors: {
  71559. [key: string]: string;
  71560. }): boolean;
  71561. }
  71562. }
  71563. declare module BABYLON {
  71564. /** @hidden */
  71565. export class ShaderCodeTestNode extends ShaderCodeNode {
  71566. testExpression: ShaderDefineExpression;
  71567. isValid(preprocessors: {
  71568. [key: string]: string;
  71569. }): boolean;
  71570. }
  71571. }
  71572. declare module BABYLON {
  71573. /** @hidden */
  71574. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71575. define: string;
  71576. not: boolean;
  71577. constructor(define: string, not?: boolean);
  71578. isTrue(preprocessors: {
  71579. [key: string]: string;
  71580. }): boolean;
  71581. }
  71582. }
  71583. declare module BABYLON {
  71584. /** @hidden */
  71585. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71586. leftOperand: ShaderDefineExpression;
  71587. rightOperand: ShaderDefineExpression;
  71588. isTrue(preprocessors: {
  71589. [key: string]: string;
  71590. }): boolean;
  71591. }
  71592. }
  71593. declare module BABYLON {
  71594. /** @hidden */
  71595. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71596. leftOperand: ShaderDefineExpression;
  71597. rightOperand: ShaderDefineExpression;
  71598. isTrue(preprocessors: {
  71599. [key: string]: string;
  71600. }): boolean;
  71601. }
  71602. }
  71603. declare module BABYLON {
  71604. /** @hidden */
  71605. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71606. define: string;
  71607. operand: string;
  71608. testValue: string;
  71609. constructor(define: string, operand: string, testValue: string);
  71610. isTrue(preprocessors: {
  71611. [key: string]: string;
  71612. }): boolean;
  71613. }
  71614. }
  71615. declare module BABYLON {
  71616. /**
  71617. * @ignore
  71618. * Application error to support additional information when loading a file
  71619. */
  71620. export class LoadFileError extends Error {
  71621. /** defines the optional web request */
  71622. request?: WebRequest | undefined;
  71623. private static _setPrototypeOf;
  71624. /**
  71625. * Creates a new LoadFileError
  71626. * @param message defines the message of the error
  71627. * @param request defines the optional web request
  71628. */
  71629. constructor(message: string,
  71630. /** defines the optional web request */
  71631. request?: WebRequest | undefined);
  71632. }
  71633. }
  71634. declare module BABYLON {
  71635. /**
  71636. * Class used to enable access to offline support
  71637. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71638. */
  71639. export interface IOfflineProvider {
  71640. /**
  71641. * Gets a boolean indicating if scene must be saved in the database
  71642. */
  71643. enableSceneOffline: boolean;
  71644. /**
  71645. * Gets a boolean indicating if textures must be saved in the database
  71646. */
  71647. enableTexturesOffline: boolean;
  71648. /**
  71649. * Open the offline support and make it available
  71650. * @param successCallback defines the callback to call on success
  71651. * @param errorCallback defines the callback to call on error
  71652. */
  71653. open(successCallback: () => void, errorCallback: () => void): void;
  71654. /**
  71655. * Loads an image from the offline support
  71656. * @param url defines the url to load from
  71657. * @param image defines the target DOM image
  71658. */
  71659. loadImage(url: string, image: HTMLImageElement): void;
  71660. /**
  71661. * Loads a file from offline support
  71662. * @param url defines the URL to load from
  71663. * @param sceneLoaded defines a callback to call on success
  71664. * @param progressCallBack defines a callback to call when progress changed
  71665. * @param errorCallback defines a callback to call on error
  71666. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71667. */
  71668. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71669. }
  71670. }
  71671. declare module BABYLON {
  71672. /**
  71673. * Class used to help managing file picking and drag'n'drop
  71674. * File Storage
  71675. */
  71676. export class FilesInputStore {
  71677. /**
  71678. * List of files ready to be loaded
  71679. */
  71680. static FilesToLoad: {
  71681. [key: string]: File;
  71682. };
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /**
  71687. * Class used to define a retry strategy when error happens while loading assets
  71688. */
  71689. export class RetryStrategy {
  71690. /**
  71691. * Function used to defines an exponential back off strategy
  71692. * @param maxRetries defines the maximum number of retries (3 by default)
  71693. * @param baseInterval defines the interval between retries
  71694. * @returns the strategy function to use
  71695. */
  71696. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71697. }
  71698. }
  71699. declare module BABYLON {
  71700. /**
  71701. * @hidden
  71702. */
  71703. export class FileTools {
  71704. /**
  71705. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71706. */
  71707. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71708. /**
  71709. * Gets or sets the base URL to use to load assets
  71710. */
  71711. static BaseUrl: string;
  71712. /**
  71713. * Default behaviour for cors in the application.
  71714. * It can be a string if the expected behavior is identical in the entire app.
  71715. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71716. */
  71717. static CorsBehavior: string | ((url: string | string[]) => string);
  71718. /**
  71719. * Gets or sets a function used to pre-process url before using them to load assets
  71720. */
  71721. static PreprocessUrl: (url: string) => string;
  71722. /**
  71723. * Removes unwanted characters from an url
  71724. * @param url defines the url to clean
  71725. * @returns the cleaned url
  71726. */
  71727. private static _CleanUrl;
  71728. /**
  71729. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71730. * @param url define the url we are trying
  71731. * @param element define the dom element where to configure the cors policy
  71732. */
  71733. static SetCorsBehavior(url: string | string[], element: {
  71734. crossOrigin: string | null;
  71735. }): void;
  71736. /**
  71737. * Loads an image as an HTMLImageElement.
  71738. * @param input url string, ArrayBuffer, or Blob to load
  71739. * @param onLoad callback called when the image successfully loads
  71740. * @param onError callback called when the image fails to load
  71741. * @param offlineProvider offline provider for caching
  71742. * @returns the HTMLImageElement of the loaded image
  71743. */
  71744. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71745. /**
  71746. * Loads a file
  71747. * @param fileToLoad defines the file to load
  71748. * @param callback defines the callback to call when data is loaded
  71749. * @param progressCallBack defines the callback to call during loading process
  71750. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71751. * @returns a file request object
  71752. */
  71753. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71754. /**
  71755. * Loads a file
  71756. * @param url url string, ArrayBuffer, or Blob to load
  71757. * @param onSuccess callback called when the file successfully loads
  71758. * @param onProgress callback called while file is loading (if the server supports this mode)
  71759. * @param offlineProvider defines the offline provider for caching
  71760. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71761. * @param onError callback called when the file fails to load
  71762. * @returns a file request object
  71763. */
  71764. 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;
  71765. /**
  71766. * Checks if the loaded document was accessed via `file:`-Protocol.
  71767. * @returns boolean
  71768. */
  71769. static IsFileURL(): boolean;
  71770. }
  71771. }
  71772. declare module BABYLON {
  71773. /** @hidden */
  71774. export class ShaderProcessor {
  71775. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71776. private static _ProcessPrecision;
  71777. private static _ExtractOperation;
  71778. private static _BuildSubExpression;
  71779. private static _BuildExpression;
  71780. private static _MoveCursorWithinIf;
  71781. private static _MoveCursor;
  71782. private static _EvaluatePreProcessors;
  71783. private static _PreparePreProcessors;
  71784. private static _ProcessShaderConversion;
  71785. private static _ProcessIncludes;
  71786. }
  71787. }
  71788. declare module BABYLON {
  71789. /**
  71790. * Interface used to define common properties for effect fallbacks
  71791. */
  71792. export interface IEffectFallbacks {
  71793. /**
  71794. * Removes the defines that should be removed when falling back.
  71795. * @param currentDefines defines the current define statements for the shader.
  71796. * @param effect defines the current effect we try to compile
  71797. * @returns The resulting defines with defines of the current rank removed.
  71798. */
  71799. reduce(currentDefines: string, effect: Effect): string;
  71800. /**
  71801. * Removes the fallback from the bound mesh.
  71802. */
  71803. unBindMesh(): void;
  71804. /**
  71805. * Checks to see if more fallbacks are still availible.
  71806. */
  71807. hasMoreFallbacks: boolean;
  71808. }
  71809. }
  71810. declare module BABYLON {
  71811. /**
  71812. * Class used to evalaute queries containing `and` and `or` operators
  71813. */
  71814. export class AndOrNotEvaluator {
  71815. /**
  71816. * Evaluate a query
  71817. * @param query defines the query to evaluate
  71818. * @param evaluateCallback defines the callback used to filter result
  71819. * @returns true if the query matches
  71820. */
  71821. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71822. private static _HandleParenthesisContent;
  71823. private static _SimplifyNegation;
  71824. }
  71825. }
  71826. declare module BABYLON {
  71827. /**
  71828. * Class used to store custom tags
  71829. */
  71830. export class Tags {
  71831. /**
  71832. * Adds support for tags on the given object
  71833. * @param obj defines the object to use
  71834. */
  71835. static EnableFor(obj: any): void;
  71836. /**
  71837. * Removes tags support
  71838. * @param obj defines the object to use
  71839. */
  71840. static DisableFor(obj: any): void;
  71841. /**
  71842. * Gets a boolean indicating if the given object has tags
  71843. * @param obj defines the object to use
  71844. * @returns a boolean
  71845. */
  71846. static HasTags(obj: any): boolean;
  71847. /**
  71848. * Gets the tags available on a given object
  71849. * @param obj defines the object to use
  71850. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71851. * @returns the tags
  71852. */
  71853. static GetTags(obj: any, asString?: boolean): any;
  71854. /**
  71855. * Adds tags to an object
  71856. * @param obj defines the object to use
  71857. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71858. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71859. */
  71860. static AddTagsTo(obj: any, tagsString: string): void;
  71861. /**
  71862. * @hidden
  71863. */
  71864. static _AddTagTo(obj: any, tag: string): void;
  71865. /**
  71866. * Removes specific tags from a specific object
  71867. * @param obj defines the object to use
  71868. * @param tagsString defines the tags to remove
  71869. */
  71870. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71871. /**
  71872. * @hidden
  71873. */
  71874. static _RemoveTagFrom(obj: any, tag: string): void;
  71875. /**
  71876. * Defines if tags hosted on an object match a given query
  71877. * @param obj defines the object to use
  71878. * @param tagsQuery defines the tag query
  71879. * @returns a boolean
  71880. */
  71881. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71882. }
  71883. }
  71884. declare module BABYLON {
  71885. /**
  71886. * Defines potential orientation for back face culling
  71887. */
  71888. export enum Orientation {
  71889. /**
  71890. * Clockwise
  71891. */
  71892. CW = 0,
  71893. /** Counter clockwise */
  71894. CCW = 1
  71895. }
  71896. /** Class used to represent a Bezier curve */
  71897. export class BezierCurve {
  71898. /**
  71899. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71900. * @param t defines the time
  71901. * @param x1 defines the left coordinate on X axis
  71902. * @param y1 defines the left coordinate on Y axis
  71903. * @param x2 defines the right coordinate on X axis
  71904. * @param y2 defines the right coordinate on Y axis
  71905. * @returns the interpolated value
  71906. */
  71907. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71908. }
  71909. /**
  71910. * Defines angle representation
  71911. */
  71912. export class Angle {
  71913. private _radians;
  71914. /**
  71915. * Creates an Angle object of "radians" radians (float).
  71916. * @param radians the angle in radians
  71917. */
  71918. constructor(radians: number);
  71919. /**
  71920. * Get value in degrees
  71921. * @returns the Angle value in degrees (float)
  71922. */
  71923. degrees(): number;
  71924. /**
  71925. * Get value in radians
  71926. * @returns the Angle value in radians (float)
  71927. */
  71928. radians(): number;
  71929. /**
  71930. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71931. * @param a defines first vector
  71932. * @param b defines second vector
  71933. * @returns a new Angle
  71934. */
  71935. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71936. /**
  71937. * Gets a new Angle object from the given float in radians
  71938. * @param radians defines the angle value in radians
  71939. * @returns a new Angle
  71940. */
  71941. static FromRadians(radians: number): Angle;
  71942. /**
  71943. * Gets a new Angle object from the given float in degrees
  71944. * @param degrees defines the angle value in degrees
  71945. * @returns a new Angle
  71946. */
  71947. static FromDegrees(degrees: number): Angle;
  71948. }
  71949. /**
  71950. * This represents an arc in a 2d space.
  71951. */
  71952. export class Arc2 {
  71953. /** Defines the start point of the arc */
  71954. startPoint: Vector2;
  71955. /** Defines the mid point of the arc */
  71956. midPoint: Vector2;
  71957. /** Defines the end point of the arc */
  71958. endPoint: Vector2;
  71959. /**
  71960. * Defines the center point of the arc.
  71961. */
  71962. centerPoint: Vector2;
  71963. /**
  71964. * Defines the radius of the arc.
  71965. */
  71966. radius: number;
  71967. /**
  71968. * Defines the angle of the arc (from mid point to end point).
  71969. */
  71970. angle: Angle;
  71971. /**
  71972. * Defines the start angle of the arc (from start point to middle point).
  71973. */
  71974. startAngle: Angle;
  71975. /**
  71976. * Defines the orientation of the arc (clock wise/counter clock wise).
  71977. */
  71978. orientation: Orientation;
  71979. /**
  71980. * Creates an Arc object from the three given points : start, middle and end.
  71981. * @param startPoint Defines the start point of the arc
  71982. * @param midPoint Defines the midlle point of the arc
  71983. * @param endPoint Defines the end point of the arc
  71984. */
  71985. constructor(
  71986. /** Defines the start point of the arc */
  71987. startPoint: Vector2,
  71988. /** Defines the mid point of the arc */
  71989. midPoint: Vector2,
  71990. /** Defines the end point of the arc */
  71991. endPoint: Vector2);
  71992. }
  71993. /**
  71994. * Represents a 2D path made up of multiple 2D points
  71995. */
  71996. export class Path2 {
  71997. private _points;
  71998. private _length;
  71999. /**
  72000. * If the path start and end point are the same
  72001. */
  72002. closed: boolean;
  72003. /**
  72004. * Creates a Path2 object from the starting 2D coordinates x and y.
  72005. * @param x the starting points x value
  72006. * @param y the starting points y value
  72007. */
  72008. constructor(x: number, y: number);
  72009. /**
  72010. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72011. * @param x the added points x value
  72012. * @param y the added points y value
  72013. * @returns the updated Path2.
  72014. */
  72015. addLineTo(x: number, y: number): Path2;
  72016. /**
  72017. * 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.
  72018. * @param midX middle point x value
  72019. * @param midY middle point y value
  72020. * @param endX end point x value
  72021. * @param endY end point y value
  72022. * @param numberOfSegments (default: 36)
  72023. * @returns the updated Path2.
  72024. */
  72025. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72026. /**
  72027. * Closes the Path2.
  72028. * @returns the Path2.
  72029. */
  72030. close(): Path2;
  72031. /**
  72032. * Gets the sum of the distance between each sequential point in the path
  72033. * @returns the Path2 total length (float).
  72034. */
  72035. length(): number;
  72036. /**
  72037. * Gets the points which construct the path
  72038. * @returns the Path2 internal array of points.
  72039. */
  72040. getPoints(): Vector2[];
  72041. /**
  72042. * Retreives the point at the distance aways from the starting point
  72043. * @param normalizedLengthPosition the length along the path to retreive the point from
  72044. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72045. */
  72046. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72047. /**
  72048. * Creates a new path starting from an x and y position
  72049. * @param x starting x value
  72050. * @param y starting y value
  72051. * @returns a new Path2 starting at the coordinates (x, y).
  72052. */
  72053. static StartingAt(x: number, y: number): Path2;
  72054. }
  72055. /**
  72056. * Represents a 3D path made up of multiple 3D points
  72057. */
  72058. export class Path3D {
  72059. /**
  72060. * an array of Vector3, the curve axis of the Path3D
  72061. */
  72062. path: Vector3[];
  72063. private _curve;
  72064. private _distances;
  72065. private _tangents;
  72066. private _normals;
  72067. private _binormals;
  72068. private _raw;
  72069. /**
  72070. * new Path3D(path, normal, raw)
  72071. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72072. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72073. * @param path an array of Vector3, the curve axis of the Path3D
  72074. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72075. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72076. */
  72077. constructor(
  72078. /**
  72079. * an array of Vector3, the curve axis of the Path3D
  72080. */
  72081. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72082. /**
  72083. * Returns the Path3D array of successive Vector3 designing its curve.
  72084. * @returns the Path3D array of successive Vector3 designing its curve.
  72085. */
  72086. getCurve(): Vector3[];
  72087. /**
  72088. * Returns an array populated with tangent vectors on each Path3D curve point.
  72089. * @returns an array populated with tangent vectors on each Path3D curve point.
  72090. */
  72091. getTangents(): Vector3[];
  72092. /**
  72093. * Returns an array populated with normal vectors on each Path3D curve point.
  72094. * @returns an array populated with normal vectors on each Path3D curve point.
  72095. */
  72096. getNormals(): Vector3[];
  72097. /**
  72098. * Returns an array populated with binormal vectors on each Path3D curve point.
  72099. * @returns an array populated with binormal vectors on each Path3D curve point.
  72100. */
  72101. getBinormals(): Vector3[];
  72102. /**
  72103. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72104. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72105. */
  72106. getDistances(): number[];
  72107. /**
  72108. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72109. * @param path path which all values are copied into the curves points
  72110. * @param firstNormal which should be projected onto the curve
  72111. * @returns the same object updated.
  72112. */
  72113. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72114. private _compute;
  72115. private _getFirstNonNullVector;
  72116. private _getLastNonNullVector;
  72117. private _normalVector;
  72118. }
  72119. /**
  72120. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72121. * A Curve3 is designed from a series of successive Vector3.
  72122. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72123. */
  72124. export class Curve3 {
  72125. private _points;
  72126. private _length;
  72127. /**
  72128. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72129. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72130. * @param v1 (Vector3) the control point
  72131. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72132. * @param nbPoints (integer) the wanted number of points in the curve
  72133. * @returns the created Curve3
  72134. */
  72135. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72136. /**
  72137. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72138. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72139. * @param v1 (Vector3) the first control point
  72140. * @param v2 (Vector3) the second control point
  72141. * @param v3 (Vector3) the end point of the Cubic Bezier
  72142. * @param nbPoints (integer) the wanted number of points in the curve
  72143. * @returns the created Curve3
  72144. */
  72145. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72146. /**
  72147. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72148. * @param p1 (Vector3) the origin point of the Hermite Spline
  72149. * @param t1 (Vector3) the tangent vector at the origin point
  72150. * @param p2 (Vector3) the end point of the Hermite Spline
  72151. * @param t2 (Vector3) the tangent vector at the end point
  72152. * @param nbPoints (integer) the wanted number of points in the curve
  72153. * @returns the created Curve3
  72154. */
  72155. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72156. /**
  72157. * Returns a Curve3 object along a CatmullRom Spline curve :
  72158. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72159. * @param nbPoints (integer) the wanted number of points between each curve control points
  72160. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72161. * @returns the created Curve3
  72162. */
  72163. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72164. /**
  72165. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72166. * A Curve3 is designed from a series of successive Vector3.
  72167. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72168. * @param points points which make up the curve
  72169. */
  72170. constructor(points: Vector3[]);
  72171. /**
  72172. * @returns the Curve3 stored array of successive Vector3
  72173. */
  72174. getPoints(): Vector3[];
  72175. /**
  72176. * @returns the computed length (float) of the curve.
  72177. */
  72178. length(): number;
  72179. /**
  72180. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72181. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72182. * curveA and curveB keep unchanged.
  72183. * @param curve the curve to continue from this curve
  72184. * @returns the newly constructed curve
  72185. */
  72186. continue(curve: DeepImmutable<Curve3>): Curve3;
  72187. private _computeLength;
  72188. }
  72189. }
  72190. declare module BABYLON {
  72191. /**
  72192. * This represents the main contract an easing function should follow.
  72193. * Easing functions are used throughout the animation system.
  72194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72195. */
  72196. export interface IEasingFunction {
  72197. /**
  72198. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72199. * of the easing function.
  72200. * The link below provides some of the most common examples of easing functions.
  72201. * @see https://easings.net/
  72202. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72203. * @returns the corresponding value on the curve defined by the easing function
  72204. */
  72205. ease(gradient: number): number;
  72206. }
  72207. /**
  72208. * Base class used for every default easing function.
  72209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72210. */
  72211. export class EasingFunction implements IEasingFunction {
  72212. /**
  72213. * Interpolation follows the mathematical formula associated with the easing function.
  72214. */
  72215. static readonly EASINGMODE_EASEIN: number;
  72216. /**
  72217. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72218. */
  72219. static readonly EASINGMODE_EASEOUT: number;
  72220. /**
  72221. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72222. */
  72223. static readonly EASINGMODE_EASEINOUT: number;
  72224. private _easingMode;
  72225. /**
  72226. * Sets the easing mode of the current function.
  72227. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72228. */
  72229. setEasingMode(easingMode: number): void;
  72230. /**
  72231. * Gets the current easing mode.
  72232. * @returns the easing mode
  72233. */
  72234. getEasingMode(): number;
  72235. /**
  72236. * @hidden
  72237. */
  72238. easeInCore(gradient: number): number;
  72239. /**
  72240. * Given an input gradient between 0 and 1, this returns the corresponding value
  72241. * of the easing function.
  72242. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72243. * @returns the corresponding value on the curve defined by the easing function
  72244. */
  72245. ease(gradient: number): number;
  72246. }
  72247. /**
  72248. * Easing function with a circle shape (see link below).
  72249. * @see https://easings.net/#easeInCirc
  72250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72251. */
  72252. export class CircleEase extends EasingFunction implements IEasingFunction {
  72253. /** @hidden */
  72254. easeInCore(gradient: number): number;
  72255. }
  72256. /**
  72257. * Easing function with a ease back shape (see link below).
  72258. * @see https://easings.net/#easeInBack
  72259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72260. */
  72261. export class BackEase extends EasingFunction implements IEasingFunction {
  72262. /** Defines the amplitude of the function */
  72263. amplitude: number;
  72264. /**
  72265. * Instantiates a back ease easing
  72266. * @see https://easings.net/#easeInBack
  72267. * @param amplitude Defines the amplitude of the function
  72268. */
  72269. constructor(
  72270. /** Defines the amplitude of the function */
  72271. amplitude?: number);
  72272. /** @hidden */
  72273. easeInCore(gradient: number): number;
  72274. }
  72275. /**
  72276. * Easing function with a bouncing shape (see link below).
  72277. * @see https://easings.net/#easeInBounce
  72278. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72279. */
  72280. export class BounceEase extends EasingFunction implements IEasingFunction {
  72281. /** Defines the number of bounces */
  72282. bounces: number;
  72283. /** Defines the amplitude of the bounce */
  72284. bounciness: number;
  72285. /**
  72286. * Instantiates a bounce easing
  72287. * @see https://easings.net/#easeInBounce
  72288. * @param bounces Defines the number of bounces
  72289. * @param bounciness Defines the amplitude of the bounce
  72290. */
  72291. constructor(
  72292. /** Defines the number of bounces */
  72293. bounces?: number,
  72294. /** Defines the amplitude of the bounce */
  72295. bounciness?: number);
  72296. /** @hidden */
  72297. easeInCore(gradient: number): number;
  72298. }
  72299. /**
  72300. * Easing function with a power of 3 shape (see link below).
  72301. * @see https://easings.net/#easeInCubic
  72302. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72303. */
  72304. export class CubicEase extends EasingFunction implements IEasingFunction {
  72305. /** @hidden */
  72306. easeInCore(gradient: number): number;
  72307. }
  72308. /**
  72309. * Easing function with an elastic shape (see link below).
  72310. * @see https://easings.net/#easeInElastic
  72311. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72312. */
  72313. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72314. /** Defines the number of oscillations*/
  72315. oscillations: number;
  72316. /** Defines the amplitude of the oscillations*/
  72317. springiness: number;
  72318. /**
  72319. * Instantiates an elastic easing function
  72320. * @see https://easings.net/#easeInElastic
  72321. * @param oscillations Defines the number of oscillations
  72322. * @param springiness Defines the amplitude of the oscillations
  72323. */
  72324. constructor(
  72325. /** Defines the number of oscillations*/
  72326. oscillations?: number,
  72327. /** Defines the amplitude of the oscillations*/
  72328. springiness?: number);
  72329. /** @hidden */
  72330. easeInCore(gradient: number): number;
  72331. }
  72332. /**
  72333. * Easing function with an exponential shape (see link below).
  72334. * @see https://easings.net/#easeInExpo
  72335. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72336. */
  72337. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72338. /** Defines the exponent of the function */
  72339. exponent: number;
  72340. /**
  72341. * Instantiates an exponential easing function
  72342. * @see https://easings.net/#easeInExpo
  72343. * @param exponent Defines the exponent of the function
  72344. */
  72345. constructor(
  72346. /** Defines the exponent of the function */
  72347. exponent?: number);
  72348. /** @hidden */
  72349. easeInCore(gradient: number): number;
  72350. }
  72351. /**
  72352. * Easing function with a power shape (see link below).
  72353. * @see https://easings.net/#easeInQuad
  72354. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72355. */
  72356. export class PowerEase extends EasingFunction implements IEasingFunction {
  72357. /** Defines the power of the function */
  72358. power: number;
  72359. /**
  72360. * Instantiates an power base easing function
  72361. * @see https://easings.net/#easeInQuad
  72362. * @param power Defines the power of the function
  72363. */
  72364. constructor(
  72365. /** Defines the power of the function */
  72366. power?: number);
  72367. /** @hidden */
  72368. easeInCore(gradient: number): number;
  72369. }
  72370. /**
  72371. * Easing function with a power of 2 shape (see link below).
  72372. * @see https://easings.net/#easeInQuad
  72373. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72374. */
  72375. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72376. /** @hidden */
  72377. easeInCore(gradient: number): number;
  72378. }
  72379. /**
  72380. * Easing function with a power of 4 shape (see link below).
  72381. * @see https://easings.net/#easeInQuart
  72382. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72383. */
  72384. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72385. /** @hidden */
  72386. easeInCore(gradient: number): number;
  72387. }
  72388. /**
  72389. * Easing function with a power of 5 shape (see link below).
  72390. * @see https://easings.net/#easeInQuint
  72391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72392. */
  72393. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72394. /** @hidden */
  72395. easeInCore(gradient: number): number;
  72396. }
  72397. /**
  72398. * Easing function with a sin shape (see link below).
  72399. * @see https://easings.net/#easeInSine
  72400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72401. */
  72402. export class SineEase extends EasingFunction implements IEasingFunction {
  72403. /** @hidden */
  72404. easeInCore(gradient: number): number;
  72405. }
  72406. /**
  72407. * Easing function with a bezier shape (see link below).
  72408. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72409. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72410. */
  72411. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72412. /** Defines the x component of the start tangent in the bezier curve */
  72413. x1: number;
  72414. /** Defines the y component of the start tangent in the bezier curve */
  72415. y1: number;
  72416. /** Defines the x component of the end tangent in the bezier curve */
  72417. x2: number;
  72418. /** Defines the y component of the end tangent in the bezier curve */
  72419. y2: number;
  72420. /**
  72421. * Instantiates a bezier function
  72422. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72423. * @param x1 Defines the x component of the start tangent in the bezier curve
  72424. * @param y1 Defines the y component of the start tangent in the bezier curve
  72425. * @param x2 Defines the x component of the end tangent in the bezier curve
  72426. * @param y2 Defines the y component of the end tangent in the bezier curve
  72427. */
  72428. constructor(
  72429. /** Defines the x component of the start tangent in the bezier curve */
  72430. x1?: number,
  72431. /** Defines the y component of the start tangent in the bezier curve */
  72432. y1?: number,
  72433. /** Defines the x component of the end tangent in the bezier curve */
  72434. x2?: number,
  72435. /** Defines the y component of the end tangent in the bezier curve */
  72436. y2?: number);
  72437. /** @hidden */
  72438. easeInCore(gradient: number): number;
  72439. }
  72440. }
  72441. declare module BABYLON {
  72442. /**
  72443. * Defines an interface which represents an animation key frame
  72444. */
  72445. export interface IAnimationKey {
  72446. /**
  72447. * Frame of the key frame
  72448. */
  72449. frame: number;
  72450. /**
  72451. * Value at the specifies key frame
  72452. */
  72453. value: any;
  72454. /**
  72455. * The input tangent for the cubic hermite spline
  72456. */
  72457. inTangent?: any;
  72458. /**
  72459. * The output tangent for the cubic hermite spline
  72460. */
  72461. outTangent?: any;
  72462. /**
  72463. * The animation interpolation type
  72464. */
  72465. interpolation?: AnimationKeyInterpolation;
  72466. }
  72467. /**
  72468. * Enum for the animation key frame interpolation type
  72469. */
  72470. export enum AnimationKeyInterpolation {
  72471. /**
  72472. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72473. */
  72474. STEP = 1
  72475. }
  72476. }
  72477. declare module BABYLON {
  72478. /**
  72479. * Represents the range of an animation
  72480. */
  72481. export class AnimationRange {
  72482. /**The name of the animation range**/
  72483. name: string;
  72484. /**The starting frame of the animation */
  72485. from: number;
  72486. /**The ending frame of the animation*/
  72487. to: number;
  72488. /**
  72489. * Initializes the range of an animation
  72490. * @param name The name of the animation range
  72491. * @param from The starting frame of the animation
  72492. * @param to The ending frame of the animation
  72493. */
  72494. constructor(
  72495. /**The name of the animation range**/
  72496. name: string,
  72497. /**The starting frame of the animation */
  72498. from: number,
  72499. /**The ending frame of the animation*/
  72500. to: number);
  72501. /**
  72502. * Makes a copy of the animation range
  72503. * @returns A copy of the animation range
  72504. */
  72505. clone(): AnimationRange;
  72506. }
  72507. }
  72508. declare module BABYLON {
  72509. /**
  72510. * Composed of a frame, and an action function
  72511. */
  72512. export class AnimationEvent {
  72513. /** The frame for which the event is triggered **/
  72514. frame: number;
  72515. /** The event to perform when triggered **/
  72516. action: (currentFrame: number) => void;
  72517. /** Specifies if the event should be triggered only once**/
  72518. onlyOnce?: boolean | undefined;
  72519. /**
  72520. * Specifies if the animation event is done
  72521. */
  72522. isDone: boolean;
  72523. /**
  72524. * Initializes the animation event
  72525. * @param frame The frame for which the event is triggered
  72526. * @param action The event to perform when triggered
  72527. * @param onlyOnce Specifies if the event should be triggered only once
  72528. */
  72529. constructor(
  72530. /** The frame for which the event is triggered **/
  72531. frame: number,
  72532. /** The event to perform when triggered **/
  72533. action: (currentFrame: number) => void,
  72534. /** Specifies if the event should be triggered only once**/
  72535. onlyOnce?: boolean | undefined);
  72536. /** @hidden */
  72537. _clone(): AnimationEvent;
  72538. }
  72539. }
  72540. declare module BABYLON {
  72541. /**
  72542. * Interface used to define a behavior
  72543. */
  72544. export interface Behavior<T> {
  72545. /** gets or sets behavior's name */
  72546. name: string;
  72547. /**
  72548. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72549. */
  72550. init(): void;
  72551. /**
  72552. * Called when the behavior is attached to a target
  72553. * @param target defines the target where the behavior is attached to
  72554. */
  72555. attach(target: T): void;
  72556. /**
  72557. * Called when the behavior is detached from its target
  72558. */
  72559. detach(): void;
  72560. }
  72561. /**
  72562. * Interface implemented by classes supporting behaviors
  72563. */
  72564. export interface IBehaviorAware<T> {
  72565. /**
  72566. * Attach a behavior
  72567. * @param behavior defines the behavior to attach
  72568. * @returns the current host
  72569. */
  72570. addBehavior(behavior: Behavior<T>): T;
  72571. /**
  72572. * Remove a behavior from the current object
  72573. * @param behavior defines the behavior to detach
  72574. * @returns the current host
  72575. */
  72576. removeBehavior(behavior: Behavior<T>): T;
  72577. /**
  72578. * Gets a behavior using its name to search
  72579. * @param name defines the name to search
  72580. * @returns the behavior or null if not found
  72581. */
  72582. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72583. }
  72584. }
  72585. declare module BABYLON {
  72586. /**
  72587. * Defines an array and its length.
  72588. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72589. */
  72590. export interface ISmartArrayLike<T> {
  72591. /**
  72592. * The data of the array.
  72593. */
  72594. data: Array<T>;
  72595. /**
  72596. * The active length of the array.
  72597. */
  72598. length: number;
  72599. }
  72600. /**
  72601. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72602. */
  72603. export class SmartArray<T> implements ISmartArrayLike<T> {
  72604. /**
  72605. * The full set of data from the array.
  72606. */
  72607. data: Array<T>;
  72608. /**
  72609. * The active length of the array.
  72610. */
  72611. length: number;
  72612. protected _id: number;
  72613. /**
  72614. * Instantiates a Smart Array.
  72615. * @param capacity defines the default capacity of the array.
  72616. */
  72617. constructor(capacity: number);
  72618. /**
  72619. * Pushes a value at the end of the active data.
  72620. * @param value defines the object to push in the array.
  72621. */
  72622. push(value: T): void;
  72623. /**
  72624. * Iterates over the active data and apply the lambda to them.
  72625. * @param func defines the action to apply on each value.
  72626. */
  72627. forEach(func: (content: T) => void): void;
  72628. /**
  72629. * Sorts the full sets of data.
  72630. * @param compareFn defines the comparison function to apply.
  72631. */
  72632. sort(compareFn: (a: T, b: T) => number): void;
  72633. /**
  72634. * Resets the active data to an empty array.
  72635. */
  72636. reset(): void;
  72637. /**
  72638. * Releases all the data from the array as well as the array.
  72639. */
  72640. dispose(): void;
  72641. /**
  72642. * Concats the active data with a given array.
  72643. * @param array defines the data to concatenate with.
  72644. */
  72645. concat(array: any): void;
  72646. /**
  72647. * Returns the position of a value in the active data.
  72648. * @param value defines the value to find the index for
  72649. * @returns the index if found in the active data otherwise -1
  72650. */
  72651. indexOf(value: T): number;
  72652. /**
  72653. * Returns whether an element is part of the active data.
  72654. * @param value defines the value to look for
  72655. * @returns true if found in the active data otherwise false
  72656. */
  72657. contains(value: T): boolean;
  72658. private static _GlobalId;
  72659. }
  72660. /**
  72661. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72662. * The data in this array can only be present once
  72663. */
  72664. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72665. private _duplicateId;
  72666. /**
  72667. * Pushes a value at the end of the active data.
  72668. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72669. * @param value defines the object to push in the array.
  72670. */
  72671. push(value: T): void;
  72672. /**
  72673. * Pushes a value at the end of the active data.
  72674. * If the data is already present, it won t be added again
  72675. * @param value defines the object to push in the array.
  72676. * @returns true if added false if it was already present
  72677. */
  72678. pushNoDuplicate(value: T): boolean;
  72679. /**
  72680. * Resets the active data to an empty array.
  72681. */
  72682. reset(): void;
  72683. /**
  72684. * Concats the active data with a given array.
  72685. * This ensures no dupplicate will be present in the result.
  72686. * @param array defines the data to concatenate with.
  72687. */
  72688. concatWithNoDuplicate(array: any): void;
  72689. }
  72690. }
  72691. declare module BABYLON {
  72692. /**
  72693. * @ignore
  72694. * This is a list of all the different input types that are available in the application.
  72695. * Fo instance: ArcRotateCameraGamepadInput...
  72696. */
  72697. export var CameraInputTypes: {};
  72698. /**
  72699. * This is the contract to implement in order to create a new input class.
  72700. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72701. */
  72702. export interface ICameraInput<TCamera extends Camera> {
  72703. /**
  72704. * Defines the camera the input is attached to.
  72705. */
  72706. camera: Nullable<TCamera>;
  72707. /**
  72708. * Gets the class name of the current intput.
  72709. * @returns the class name
  72710. */
  72711. getClassName(): string;
  72712. /**
  72713. * Get the friendly name associated with the input class.
  72714. * @returns the input friendly name
  72715. */
  72716. getSimpleName(): string;
  72717. /**
  72718. * Attach the input controls to a specific dom element to get the input from.
  72719. * @param element Defines the element the controls should be listened from
  72720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72721. */
  72722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72723. /**
  72724. * Detach the current controls from the specified dom element.
  72725. * @param element Defines the element to stop listening the inputs from
  72726. */
  72727. detachControl(element: Nullable<HTMLElement>): void;
  72728. /**
  72729. * Update the current camera state depending on the inputs that have been used this frame.
  72730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72731. */
  72732. checkInputs?: () => void;
  72733. }
  72734. /**
  72735. * Represents a map of input types to input instance or input index to input instance.
  72736. */
  72737. export interface CameraInputsMap<TCamera extends Camera> {
  72738. /**
  72739. * Accessor to the input by input type.
  72740. */
  72741. [name: string]: ICameraInput<TCamera>;
  72742. /**
  72743. * Accessor to the input by input index.
  72744. */
  72745. [idx: number]: ICameraInput<TCamera>;
  72746. }
  72747. /**
  72748. * This represents the input manager used within a camera.
  72749. * It helps dealing with all the different kind of input attached to a camera.
  72750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72751. */
  72752. export class CameraInputsManager<TCamera extends Camera> {
  72753. /**
  72754. * Defines the list of inputs attahed to the camera.
  72755. */
  72756. attached: CameraInputsMap<TCamera>;
  72757. /**
  72758. * Defines the dom element the camera is collecting inputs from.
  72759. * This is null if the controls have not been attached.
  72760. */
  72761. attachedElement: Nullable<HTMLElement>;
  72762. /**
  72763. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72764. */
  72765. noPreventDefault: boolean;
  72766. /**
  72767. * Defined the camera the input manager belongs to.
  72768. */
  72769. camera: TCamera;
  72770. /**
  72771. * Update the current camera state depending on the inputs that have been used this frame.
  72772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72773. */
  72774. checkInputs: () => void;
  72775. /**
  72776. * Instantiate a new Camera Input Manager.
  72777. * @param camera Defines the camera the input manager blongs to
  72778. */
  72779. constructor(camera: TCamera);
  72780. /**
  72781. * Add an input method to a camera
  72782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72783. * @param input camera input method
  72784. */
  72785. add(input: ICameraInput<TCamera>): void;
  72786. /**
  72787. * Remove a specific input method from a camera
  72788. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72789. * @param inputToRemove camera input method
  72790. */
  72791. remove(inputToRemove: ICameraInput<TCamera>): void;
  72792. /**
  72793. * Remove a specific input type from a camera
  72794. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72795. * @param inputType the type of the input to remove
  72796. */
  72797. removeByType(inputType: string): void;
  72798. private _addCheckInputs;
  72799. /**
  72800. * Attach the input controls to the currently attached dom element to listen the events from.
  72801. * @param input Defines the input to attach
  72802. */
  72803. attachInput(input: ICameraInput<TCamera>): void;
  72804. /**
  72805. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72806. * @param element Defines the dom element to collect the events from
  72807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72808. */
  72809. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72810. /**
  72811. * Detach the current manager inputs controls from a specific dom element.
  72812. * @param element Defines the dom element to collect the events from
  72813. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72814. */
  72815. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72816. /**
  72817. * Rebuild the dynamic inputCheck function from the current list of
  72818. * defined inputs in the manager.
  72819. */
  72820. rebuildInputCheck(): void;
  72821. /**
  72822. * Remove all attached input methods from a camera
  72823. */
  72824. clear(): void;
  72825. /**
  72826. * Serialize the current input manager attached to a camera.
  72827. * This ensures than once parsed,
  72828. * the input associated to the camera will be identical to the current ones
  72829. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72830. */
  72831. serialize(serializedCamera: any): void;
  72832. /**
  72833. * Parses an input manager serialized JSON to restore the previous list of inputs
  72834. * and states associated to a camera.
  72835. * @param parsedCamera Defines the JSON to parse
  72836. */
  72837. parse(parsedCamera: any): void;
  72838. }
  72839. }
  72840. declare module BABYLON {
  72841. /**
  72842. * Class used to store data that will be store in GPU memory
  72843. */
  72844. export class Buffer {
  72845. private _engine;
  72846. private _buffer;
  72847. /** @hidden */
  72848. _data: Nullable<DataArray>;
  72849. private _updatable;
  72850. private _instanced;
  72851. /**
  72852. * Gets the byte stride.
  72853. */
  72854. readonly byteStride: number;
  72855. /**
  72856. * Constructor
  72857. * @param engine the engine
  72858. * @param data the data to use for this buffer
  72859. * @param updatable whether the data is updatable
  72860. * @param stride the stride (optional)
  72861. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72862. * @param instanced whether the buffer is instanced (optional)
  72863. * @param useBytes set to true if the stride in in bytes (optional)
  72864. */
  72865. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72866. /**
  72867. * Create a new VertexBuffer based on the current buffer
  72868. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72869. * @param offset defines offset in the buffer (0 by default)
  72870. * @param size defines the size in floats of attributes (position is 3 for instance)
  72871. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72872. * @param instanced defines if the vertex buffer contains indexed data
  72873. * @param useBytes defines if the offset and stride are in bytes
  72874. * @returns the new vertex buffer
  72875. */
  72876. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72877. /**
  72878. * Gets a boolean indicating if the Buffer is updatable?
  72879. * @returns true if the buffer is updatable
  72880. */
  72881. isUpdatable(): boolean;
  72882. /**
  72883. * Gets current buffer's data
  72884. * @returns a DataArray or null
  72885. */
  72886. getData(): Nullable<DataArray>;
  72887. /**
  72888. * Gets underlying native buffer
  72889. * @returns underlying native buffer
  72890. */
  72891. getBuffer(): Nullable<DataBuffer>;
  72892. /**
  72893. * Gets the stride in float32 units (i.e. byte stride / 4).
  72894. * May not be an integer if the byte stride is not divisible by 4.
  72895. * DEPRECATED. Use byteStride instead.
  72896. * @returns the stride in float32 units
  72897. */
  72898. getStrideSize(): number;
  72899. /**
  72900. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72901. * @param data defines the data to store
  72902. */
  72903. create(data?: Nullable<DataArray>): void;
  72904. /** @hidden */
  72905. _rebuild(): void;
  72906. /**
  72907. * Update current buffer data
  72908. * @param data defines the data to store
  72909. */
  72910. update(data: DataArray): void;
  72911. /**
  72912. * Updates the data directly.
  72913. * @param data the new data
  72914. * @param offset the new offset
  72915. * @param vertexCount the vertex count (optional)
  72916. * @param useBytes set to true if the offset is in bytes
  72917. */
  72918. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72919. /**
  72920. * Release all resources
  72921. */
  72922. dispose(): void;
  72923. }
  72924. /**
  72925. * Specialized buffer used to store vertex data
  72926. */
  72927. export class VertexBuffer {
  72928. /** @hidden */
  72929. _buffer: Buffer;
  72930. private _kind;
  72931. private _size;
  72932. private _ownsBuffer;
  72933. private _instanced;
  72934. private _instanceDivisor;
  72935. /**
  72936. * The byte type.
  72937. */
  72938. static readonly BYTE: number;
  72939. /**
  72940. * The unsigned byte type.
  72941. */
  72942. static readonly UNSIGNED_BYTE: number;
  72943. /**
  72944. * The short type.
  72945. */
  72946. static readonly SHORT: number;
  72947. /**
  72948. * The unsigned short type.
  72949. */
  72950. static readonly UNSIGNED_SHORT: number;
  72951. /**
  72952. * The integer type.
  72953. */
  72954. static readonly INT: number;
  72955. /**
  72956. * The unsigned integer type.
  72957. */
  72958. static readonly UNSIGNED_INT: number;
  72959. /**
  72960. * The float type.
  72961. */
  72962. static readonly FLOAT: number;
  72963. /**
  72964. * Gets or sets the instance divisor when in instanced mode
  72965. */
  72966. instanceDivisor: number;
  72967. /**
  72968. * Gets the byte stride.
  72969. */
  72970. readonly byteStride: number;
  72971. /**
  72972. * Gets the byte offset.
  72973. */
  72974. readonly byteOffset: number;
  72975. /**
  72976. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  72977. */
  72978. readonly normalized: boolean;
  72979. /**
  72980. * Gets the data type of each component in the array.
  72981. */
  72982. readonly type: number;
  72983. /**
  72984. * Constructor
  72985. * @param engine the engine
  72986. * @param data the data to use for this vertex buffer
  72987. * @param kind the vertex buffer kind
  72988. * @param updatable whether the data is updatable
  72989. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72990. * @param stride the stride (optional)
  72991. * @param instanced whether the buffer is instanced (optional)
  72992. * @param offset the offset of the data (optional)
  72993. * @param size the number of components (optional)
  72994. * @param type the type of the component (optional)
  72995. * @param normalized whether the data contains normalized data (optional)
  72996. * @param useBytes set to true if stride and offset are in bytes (optional)
  72997. */
  72998. 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);
  72999. /** @hidden */
  73000. _rebuild(): void;
  73001. /**
  73002. * Returns the kind of the VertexBuffer (string)
  73003. * @returns a string
  73004. */
  73005. getKind(): string;
  73006. /**
  73007. * Gets a boolean indicating if the VertexBuffer is updatable?
  73008. * @returns true if the buffer is updatable
  73009. */
  73010. isUpdatable(): boolean;
  73011. /**
  73012. * Gets current buffer's data
  73013. * @returns a DataArray or null
  73014. */
  73015. getData(): Nullable<DataArray>;
  73016. /**
  73017. * Gets underlying native buffer
  73018. * @returns underlying native buffer
  73019. */
  73020. getBuffer(): Nullable<DataBuffer>;
  73021. /**
  73022. * Gets the stride in float32 units (i.e. byte stride / 4).
  73023. * May not be an integer if the byte stride is not divisible by 4.
  73024. * DEPRECATED. Use byteStride instead.
  73025. * @returns the stride in float32 units
  73026. */
  73027. getStrideSize(): number;
  73028. /**
  73029. * Returns the offset as a multiple of the type byte length.
  73030. * DEPRECATED. Use byteOffset instead.
  73031. * @returns the offset in bytes
  73032. */
  73033. getOffset(): number;
  73034. /**
  73035. * Returns the number of components per vertex attribute (integer)
  73036. * @returns the size in float
  73037. */
  73038. getSize(): number;
  73039. /**
  73040. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73041. * @returns true if this buffer is instanced
  73042. */
  73043. getIsInstanced(): boolean;
  73044. /**
  73045. * Returns the instancing divisor, zero for non-instanced (integer).
  73046. * @returns a number
  73047. */
  73048. getInstanceDivisor(): number;
  73049. /**
  73050. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73051. * @param data defines the data to store
  73052. */
  73053. create(data?: DataArray): void;
  73054. /**
  73055. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73056. * This function will create a new buffer if the current one is not updatable
  73057. * @param data defines the data to store
  73058. */
  73059. update(data: DataArray): void;
  73060. /**
  73061. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73062. * Returns the directly updated WebGLBuffer.
  73063. * @param data the new data
  73064. * @param offset the new offset
  73065. * @param useBytes set to true if the offset is in bytes
  73066. */
  73067. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73068. /**
  73069. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73070. */
  73071. dispose(): void;
  73072. /**
  73073. * Enumerates each value of this vertex buffer as numbers.
  73074. * @param count the number of values to enumerate
  73075. * @param callback the callback function called for each value
  73076. */
  73077. forEach(count: number, callback: (value: number, index: number) => void): void;
  73078. /**
  73079. * Positions
  73080. */
  73081. static readonly PositionKind: string;
  73082. /**
  73083. * Normals
  73084. */
  73085. static readonly NormalKind: string;
  73086. /**
  73087. * Tangents
  73088. */
  73089. static readonly TangentKind: string;
  73090. /**
  73091. * Texture coordinates
  73092. */
  73093. static readonly UVKind: string;
  73094. /**
  73095. * Texture coordinates 2
  73096. */
  73097. static readonly UV2Kind: string;
  73098. /**
  73099. * Texture coordinates 3
  73100. */
  73101. static readonly UV3Kind: string;
  73102. /**
  73103. * Texture coordinates 4
  73104. */
  73105. static readonly UV4Kind: string;
  73106. /**
  73107. * Texture coordinates 5
  73108. */
  73109. static readonly UV5Kind: string;
  73110. /**
  73111. * Texture coordinates 6
  73112. */
  73113. static readonly UV6Kind: string;
  73114. /**
  73115. * Colors
  73116. */
  73117. static readonly ColorKind: string;
  73118. /**
  73119. * Matrix indices (for bones)
  73120. */
  73121. static readonly MatricesIndicesKind: string;
  73122. /**
  73123. * Matrix weights (for bones)
  73124. */
  73125. static readonly MatricesWeightsKind: string;
  73126. /**
  73127. * Additional matrix indices (for bones)
  73128. */
  73129. static readonly MatricesIndicesExtraKind: string;
  73130. /**
  73131. * Additional matrix weights (for bones)
  73132. */
  73133. static readonly MatricesWeightsExtraKind: string;
  73134. /**
  73135. * Deduces the stride given a kind.
  73136. * @param kind The kind string to deduce
  73137. * @returns The deduced stride
  73138. */
  73139. static DeduceStride(kind: string): number;
  73140. /**
  73141. * Gets the byte length of the given type.
  73142. * @param type the type
  73143. * @returns the number of bytes
  73144. */
  73145. static GetTypeByteLength(type: number): number;
  73146. /**
  73147. * Enumerates each value of the given parameters as numbers.
  73148. * @param data the data to enumerate
  73149. * @param byteOffset the byte offset of the data
  73150. * @param byteStride the byte stride of the data
  73151. * @param componentCount the number of components per element
  73152. * @param componentType the type of the component
  73153. * @param count the number of values to enumerate
  73154. * @param normalized whether the data is normalized
  73155. * @param callback the callback function called for each value
  73156. */
  73157. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73158. private static _GetFloatValue;
  73159. }
  73160. }
  73161. declare module BABYLON {
  73162. /**
  73163. * @hidden
  73164. */
  73165. export class IntersectionInfo {
  73166. bu: Nullable<number>;
  73167. bv: Nullable<number>;
  73168. distance: number;
  73169. faceId: number;
  73170. subMeshId: number;
  73171. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73172. }
  73173. }
  73174. declare module BABYLON {
  73175. /**
  73176. * Represens a plane by the equation ax + by + cz + d = 0
  73177. */
  73178. export class Plane {
  73179. private static _TmpMatrix;
  73180. /**
  73181. * Normal of the plane (a,b,c)
  73182. */
  73183. normal: Vector3;
  73184. /**
  73185. * d component of the plane
  73186. */
  73187. d: number;
  73188. /**
  73189. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73190. * @param a a component of the plane
  73191. * @param b b component of the plane
  73192. * @param c c component of the plane
  73193. * @param d d component of the plane
  73194. */
  73195. constructor(a: number, b: number, c: number, d: number);
  73196. /**
  73197. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73198. */
  73199. asArray(): number[];
  73200. /**
  73201. * @returns a new plane copied from the current Plane.
  73202. */
  73203. clone(): Plane;
  73204. /**
  73205. * @returns the string "Plane".
  73206. */
  73207. getClassName(): string;
  73208. /**
  73209. * @returns the Plane hash code.
  73210. */
  73211. getHashCode(): number;
  73212. /**
  73213. * Normalize the current Plane in place.
  73214. * @returns the updated Plane.
  73215. */
  73216. normalize(): Plane;
  73217. /**
  73218. * Applies a transformation the plane and returns the result
  73219. * @param transformation the transformation matrix to be applied to the plane
  73220. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73221. */
  73222. transform(transformation: DeepImmutable<Matrix>): Plane;
  73223. /**
  73224. * Calcualtte the dot product between the point and the plane normal
  73225. * @param point point to calculate the dot product with
  73226. * @returns the dot product (float) of the point coordinates and the plane normal.
  73227. */
  73228. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73229. /**
  73230. * Updates the current Plane from the plane defined by the three given points.
  73231. * @param point1 one of the points used to contruct the plane
  73232. * @param point2 one of the points used to contruct the plane
  73233. * @param point3 one of the points used to contruct the plane
  73234. * @returns the updated Plane.
  73235. */
  73236. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73237. /**
  73238. * Checks if the plane is facing a given direction
  73239. * @param direction the direction to check if the plane is facing
  73240. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73241. * @returns True is the vector "direction" is the same side than the plane normal.
  73242. */
  73243. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73244. /**
  73245. * Calculates the distance to a point
  73246. * @param point point to calculate distance to
  73247. * @returns the signed distance (float) from the given point to the Plane.
  73248. */
  73249. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73250. /**
  73251. * Creates a plane from an array
  73252. * @param array the array to create a plane from
  73253. * @returns a new Plane from the given array.
  73254. */
  73255. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73256. /**
  73257. * Creates a plane from three points
  73258. * @param point1 point used to create the plane
  73259. * @param point2 point used to create the plane
  73260. * @param point3 point used to create the plane
  73261. * @returns a new Plane defined by the three given points.
  73262. */
  73263. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73264. /**
  73265. * Creates a plane from an origin point and a normal
  73266. * @param origin origin of the plane to be constructed
  73267. * @param normal normal of the plane to be constructed
  73268. * @returns a new Plane the normal vector to this plane at the given origin point.
  73269. * Note : the vector "normal" is updated because normalized.
  73270. */
  73271. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73272. /**
  73273. * Calculates the distance from a plane and a point
  73274. * @param origin origin of the plane to be constructed
  73275. * @param normal normal of the plane to be constructed
  73276. * @param point point to calculate distance to
  73277. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73278. */
  73279. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73280. }
  73281. }
  73282. declare module BABYLON {
  73283. /**
  73284. * Class used to store bounding sphere information
  73285. */
  73286. export class BoundingSphere {
  73287. /**
  73288. * Gets the center of the bounding sphere in local space
  73289. */
  73290. readonly center: Vector3;
  73291. /**
  73292. * Radius of the bounding sphere in local space
  73293. */
  73294. radius: number;
  73295. /**
  73296. * Gets the center of the bounding sphere in world space
  73297. */
  73298. readonly centerWorld: Vector3;
  73299. /**
  73300. * Radius of the bounding sphere in world space
  73301. */
  73302. radiusWorld: number;
  73303. /**
  73304. * Gets the minimum vector in local space
  73305. */
  73306. readonly minimum: Vector3;
  73307. /**
  73308. * Gets the maximum vector in local space
  73309. */
  73310. readonly maximum: Vector3;
  73311. private _worldMatrix;
  73312. private static readonly TmpVector3;
  73313. /**
  73314. * Creates a new bounding sphere
  73315. * @param min defines the minimum vector (in local space)
  73316. * @param max defines the maximum vector (in local space)
  73317. * @param worldMatrix defines the new world matrix
  73318. */
  73319. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73320. /**
  73321. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73322. * @param min defines the new minimum vector (in local space)
  73323. * @param max defines the new maximum vector (in local space)
  73324. * @param worldMatrix defines the new world matrix
  73325. */
  73326. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73327. /**
  73328. * Scale the current bounding sphere by applying a scale factor
  73329. * @param factor defines the scale factor to apply
  73330. * @returns the current bounding box
  73331. */
  73332. scale(factor: number): BoundingSphere;
  73333. /**
  73334. * Gets the world matrix of the bounding box
  73335. * @returns a matrix
  73336. */
  73337. getWorldMatrix(): DeepImmutable<Matrix>;
  73338. /** @hidden */
  73339. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73340. /**
  73341. * Tests if the bounding sphere is intersecting the frustum planes
  73342. * @param frustumPlanes defines the frustum planes to test
  73343. * @returns true if there is an intersection
  73344. */
  73345. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73346. /**
  73347. * Tests if the bounding sphere center is in between the frustum planes.
  73348. * Used for optimistic fast inclusion.
  73349. * @param frustumPlanes defines the frustum planes to test
  73350. * @returns true if the sphere center is in between the frustum planes
  73351. */
  73352. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73353. /**
  73354. * Tests if a point is inside the bounding sphere
  73355. * @param point defines the point to test
  73356. * @returns true if the point is inside the bounding sphere
  73357. */
  73358. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73359. /**
  73360. * Checks if two sphere intersct
  73361. * @param sphere0 sphere 0
  73362. * @param sphere1 sphere 1
  73363. * @returns true if the speres intersect
  73364. */
  73365. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73366. }
  73367. }
  73368. declare module BABYLON {
  73369. /**
  73370. * Class used to store bounding box information
  73371. */
  73372. export class BoundingBox implements ICullable {
  73373. /**
  73374. * Gets the 8 vectors representing the bounding box in local space
  73375. */
  73376. readonly vectors: Vector3[];
  73377. /**
  73378. * Gets the center of the bounding box in local space
  73379. */
  73380. readonly center: Vector3;
  73381. /**
  73382. * Gets the center of the bounding box in world space
  73383. */
  73384. readonly centerWorld: Vector3;
  73385. /**
  73386. * Gets the extend size in local space
  73387. */
  73388. readonly extendSize: Vector3;
  73389. /**
  73390. * Gets the extend size in world space
  73391. */
  73392. readonly extendSizeWorld: Vector3;
  73393. /**
  73394. * Gets the OBB (object bounding box) directions
  73395. */
  73396. readonly directions: Vector3[];
  73397. /**
  73398. * Gets the 8 vectors representing the bounding box in world space
  73399. */
  73400. readonly vectorsWorld: Vector3[];
  73401. /**
  73402. * Gets the minimum vector in world space
  73403. */
  73404. readonly minimumWorld: Vector3;
  73405. /**
  73406. * Gets the maximum vector in world space
  73407. */
  73408. readonly maximumWorld: Vector3;
  73409. /**
  73410. * Gets the minimum vector in local space
  73411. */
  73412. readonly minimum: Vector3;
  73413. /**
  73414. * Gets the maximum vector in local space
  73415. */
  73416. readonly maximum: Vector3;
  73417. private _worldMatrix;
  73418. private static readonly TmpVector3;
  73419. /**
  73420. * @hidden
  73421. */
  73422. _tag: number;
  73423. /**
  73424. * Creates a new bounding box
  73425. * @param min defines the minimum vector (in local space)
  73426. * @param max defines the maximum vector (in local space)
  73427. * @param worldMatrix defines the new world matrix
  73428. */
  73429. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73430. /**
  73431. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73432. * @param min defines the new minimum vector (in local space)
  73433. * @param max defines the new maximum vector (in local space)
  73434. * @param worldMatrix defines the new world matrix
  73435. */
  73436. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73437. /**
  73438. * Scale the current bounding box by applying a scale factor
  73439. * @param factor defines the scale factor to apply
  73440. * @returns the current bounding box
  73441. */
  73442. scale(factor: number): BoundingBox;
  73443. /**
  73444. * Gets the world matrix of the bounding box
  73445. * @returns a matrix
  73446. */
  73447. getWorldMatrix(): DeepImmutable<Matrix>;
  73448. /** @hidden */
  73449. _update(world: DeepImmutable<Matrix>): void;
  73450. /**
  73451. * Tests if the bounding box is intersecting the frustum planes
  73452. * @param frustumPlanes defines the frustum planes to test
  73453. * @returns true if there is an intersection
  73454. */
  73455. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73456. /**
  73457. * Tests if the bounding box is entirely inside the frustum planes
  73458. * @param frustumPlanes defines the frustum planes to test
  73459. * @returns true if there is an inclusion
  73460. */
  73461. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73462. /**
  73463. * Tests if a point is inside the bounding box
  73464. * @param point defines the point to test
  73465. * @returns true if the point is inside the bounding box
  73466. */
  73467. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73468. /**
  73469. * Tests if the bounding box intersects with a bounding sphere
  73470. * @param sphere defines the sphere to test
  73471. * @returns true if there is an intersection
  73472. */
  73473. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73474. /**
  73475. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73476. * @param min defines the min vector to use
  73477. * @param max defines the max vector to use
  73478. * @returns true if there is an intersection
  73479. */
  73480. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73481. /**
  73482. * Tests if two bounding boxes are intersections
  73483. * @param box0 defines the first box to test
  73484. * @param box1 defines the second box to test
  73485. * @returns true if there is an intersection
  73486. */
  73487. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73488. /**
  73489. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73490. * @param minPoint defines the minimum vector of the bounding box
  73491. * @param maxPoint defines the maximum vector of the bounding box
  73492. * @param sphereCenter defines the sphere center
  73493. * @param sphereRadius defines the sphere radius
  73494. * @returns true if there is an intersection
  73495. */
  73496. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73497. /**
  73498. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73499. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73500. * @param frustumPlanes defines the frustum planes to test
  73501. * @return true if there is an inclusion
  73502. */
  73503. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73504. /**
  73505. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73506. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73507. * @param frustumPlanes defines the frustum planes to test
  73508. * @return true if there is an intersection
  73509. */
  73510. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73511. }
  73512. }
  73513. declare module BABYLON {
  73514. /** @hidden */
  73515. export class Collider {
  73516. /** Define if a collision was found */
  73517. collisionFound: boolean;
  73518. /**
  73519. * Define last intersection point in local space
  73520. */
  73521. intersectionPoint: Vector3;
  73522. /**
  73523. * Define last collided mesh
  73524. */
  73525. collidedMesh: Nullable<AbstractMesh>;
  73526. private _collisionPoint;
  73527. private _planeIntersectionPoint;
  73528. private _tempVector;
  73529. private _tempVector2;
  73530. private _tempVector3;
  73531. private _tempVector4;
  73532. private _edge;
  73533. private _baseToVertex;
  73534. private _destinationPoint;
  73535. private _slidePlaneNormal;
  73536. private _displacementVector;
  73537. /** @hidden */
  73538. _radius: Vector3;
  73539. /** @hidden */
  73540. _retry: number;
  73541. private _velocity;
  73542. private _basePoint;
  73543. private _epsilon;
  73544. /** @hidden */
  73545. _velocityWorldLength: number;
  73546. /** @hidden */
  73547. _basePointWorld: Vector3;
  73548. private _velocityWorld;
  73549. private _normalizedVelocity;
  73550. /** @hidden */
  73551. _initialVelocity: Vector3;
  73552. /** @hidden */
  73553. _initialPosition: Vector3;
  73554. private _nearestDistance;
  73555. private _collisionMask;
  73556. collisionMask: number;
  73557. /**
  73558. * Gets the plane normal used to compute the sliding response (in local space)
  73559. */
  73560. readonly slidePlaneNormal: Vector3;
  73561. /** @hidden */
  73562. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73563. /** @hidden */
  73564. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73565. /** @hidden */
  73566. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73567. /** @hidden */
  73568. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73569. /** @hidden */
  73570. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73571. /** @hidden */
  73572. _getResponse(pos: Vector3, vel: Vector3): void;
  73573. }
  73574. }
  73575. declare module BABYLON {
  73576. /**
  73577. * Interface for cullable objects
  73578. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73579. */
  73580. export interface ICullable {
  73581. /**
  73582. * Checks if the object or part of the object is in the frustum
  73583. * @param frustumPlanes Camera near/planes
  73584. * @returns true if the object is in frustum otherwise false
  73585. */
  73586. isInFrustum(frustumPlanes: Plane[]): boolean;
  73587. /**
  73588. * Checks if a cullable object (mesh...) is in the camera frustum
  73589. * Unlike isInFrustum this cheks the full bounding box
  73590. * @param frustumPlanes Camera near/planes
  73591. * @returns true if the object is in frustum otherwise false
  73592. */
  73593. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73594. }
  73595. /**
  73596. * Info for a bounding data of a mesh
  73597. */
  73598. export class BoundingInfo implements ICullable {
  73599. /**
  73600. * Bounding box for the mesh
  73601. */
  73602. readonly boundingBox: BoundingBox;
  73603. /**
  73604. * Bounding sphere for the mesh
  73605. */
  73606. readonly boundingSphere: BoundingSphere;
  73607. private _isLocked;
  73608. private static readonly TmpVector3;
  73609. /**
  73610. * Constructs bounding info
  73611. * @param minimum min vector of the bounding box/sphere
  73612. * @param maximum max vector of the bounding box/sphere
  73613. * @param worldMatrix defines the new world matrix
  73614. */
  73615. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73616. /**
  73617. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73618. * @param min defines the new minimum vector (in local space)
  73619. * @param max defines the new maximum vector (in local space)
  73620. * @param worldMatrix defines the new world matrix
  73621. */
  73622. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73623. /**
  73624. * min vector of the bounding box/sphere
  73625. */
  73626. readonly minimum: Vector3;
  73627. /**
  73628. * max vector of the bounding box/sphere
  73629. */
  73630. readonly maximum: Vector3;
  73631. /**
  73632. * If the info is locked and won't be updated to avoid perf overhead
  73633. */
  73634. isLocked: boolean;
  73635. /**
  73636. * Updates the bounding sphere and box
  73637. * @param world world matrix to be used to update
  73638. */
  73639. update(world: DeepImmutable<Matrix>): void;
  73640. /**
  73641. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73642. * @param center New center of the bounding info
  73643. * @param extend New extend of the bounding info
  73644. * @returns the current bounding info
  73645. */
  73646. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73647. /**
  73648. * Scale the current bounding info by applying a scale factor
  73649. * @param factor defines the scale factor to apply
  73650. * @returns the current bounding info
  73651. */
  73652. scale(factor: number): BoundingInfo;
  73653. /**
  73654. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73655. * @param frustumPlanes defines the frustum to test
  73656. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73657. * @returns true if the bounding info is in the frustum planes
  73658. */
  73659. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73660. /**
  73661. * Gets the world distance between the min and max points of the bounding box
  73662. */
  73663. readonly diagonalLength: number;
  73664. /**
  73665. * Checks if a cullable object (mesh...) is in the camera frustum
  73666. * Unlike isInFrustum this cheks the full bounding box
  73667. * @param frustumPlanes Camera near/planes
  73668. * @returns true if the object is in frustum otherwise false
  73669. */
  73670. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73671. /** @hidden */
  73672. _checkCollision(collider: Collider): boolean;
  73673. /**
  73674. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73675. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73676. * @param point the point to check intersection with
  73677. * @returns if the point intersects
  73678. */
  73679. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73680. /**
  73681. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73682. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73683. * @param boundingInfo the bounding info to check intersection with
  73684. * @param precise if the intersection should be done using OBB
  73685. * @returns if the bounding info intersects
  73686. */
  73687. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73688. }
  73689. }
  73690. declare module BABYLON {
  73691. /**
  73692. * Extracts minimum and maximum values from a list of indexed positions
  73693. * @param positions defines the positions to use
  73694. * @param indices defines the indices to the positions
  73695. * @param indexStart defines the start index
  73696. * @param indexCount defines the end index
  73697. * @param bias defines bias value to add to the result
  73698. * @return minimum and maximum values
  73699. */
  73700. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73701. minimum: Vector3;
  73702. maximum: Vector3;
  73703. };
  73704. /**
  73705. * Extracts minimum and maximum values from a list of positions
  73706. * @param positions defines the positions to use
  73707. * @param start defines the start index in the positions array
  73708. * @param count defines the number of positions to handle
  73709. * @param bias defines bias value to add to the result
  73710. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73711. * @return minimum and maximum values
  73712. */
  73713. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73714. minimum: Vector3;
  73715. maximum: Vector3;
  73716. };
  73717. }
  73718. declare module BABYLON {
  73719. /** @hidden */
  73720. export class WebGLDataBuffer extends DataBuffer {
  73721. private _buffer;
  73722. constructor(resource: WebGLBuffer);
  73723. readonly underlyingResource: any;
  73724. }
  73725. }
  73726. declare module BABYLON {
  73727. /** @hidden */
  73728. export class WebGLPipelineContext implements IPipelineContext {
  73729. engine: ThinEngine;
  73730. program: Nullable<WebGLProgram>;
  73731. context?: WebGLRenderingContext;
  73732. vertexShader?: WebGLShader;
  73733. fragmentShader?: WebGLShader;
  73734. isParallelCompiled: boolean;
  73735. onCompiled?: () => void;
  73736. transformFeedback?: WebGLTransformFeedback | null;
  73737. readonly isAsync: boolean;
  73738. readonly isReady: boolean;
  73739. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73740. }
  73741. }
  73742. declare module BABYLON {
  73743. interface ThinEngine {
  73744. /**
  73745. * Create an uniform buffer
  73746. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73747. * @param elements defines the content of the uniform buffer
  73748. * @returns the webGL uniform buffer
  73749. */
  73750. createUniformBuffer(elements: FloatArray): DataBuffer;
  73751. /**
  73752. * Create a dynamic uniform buffer
  73753. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73754. * @param elements defines the content of the uniform buffer
  73755. * @returns the webGL uniform buffer
  73756. */
  73757. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73758. /**
  73759. * Update an existing uniform buffer
  73760. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73761. * @param uniformBuffer defines the target uniform buffer
  73762. * @param elements defines the content to update
  73763. * @param offset defines the offset in the uniform buffer where update should start
  73764. * @param count defines the size of the data to update
  73765. */
  73766. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73767. /**
  73768. * Bind an uniform buffer to the current webGL context
  73769. * @param buffer defines the buffer to bind
  73770. */
  73771. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73772. /**
  73773. * Bind a buffer to the current webGL context at a given location
  73774. * @param buffer defines the buffer to bind
  73775. * @param location defines the index where to bind the buffer
  73776. */
  73777. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73778. /**
  73779. * Bind a specific block at a given index in a specific shader program
  73780. * @param pipelineContext defines the pipeline context to use
  73781. * @param blockName defines the block name
  73782. * @param index defines the index where to bind the block
  73783. */
  73784. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73785. }
  73786. }
  73787. declare module BABYLON {
  73788. /**
  73789. * Uniform buffer objects.
  73790. *
  73791. * Handles blocks of uniform on the GPU.
  73792. *
  73793. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73794. *
  73795. * For more information, please refer to :
  73796. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73797. */
  73798. export class UniformBuffer {
  73799. private _engine;
  73800. private _buffer;
  73801. private _data;
  73802. private _bufferData;
  73803. private _dynamic?;
  73804. private _uniformLocations;
  73805. private _uniformSizes;
  73806. private _uniformLocationPointer;
  73807. private _needSync;
  73808. private _noUBO;
  73809. private _currentEffect;
  73810. private static _MAX_UNIFORM_SIZE;
  73811. private static _tempBuffer;
  73812. /**
  73813. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73814. * This is dynamic to allow compat with webgl 1 and 2.
  73815. * You will need to pass the name of the uniform as well as the value.
  73816. */
  73817. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73818. /**
  73819. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73820. * This is dynamic to allow compat with webgl 1 and 2.
  73821. * You will need to pass the name of the uniform as well as the value.
  73822. */
  73823. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73824. /**
  73825. * Lambda to Update a single float in a uniform buffer.
  73826. * This is dynamic to allow compat with webgl 1 and 2.
  73827. * You will need to pass the name of the uniform as well as the value.
  73828. */
  73829. updateFloat: (name: string, x: number) => void;
  73830. /**
  73831. * Lambda to Update a vec2 of float in a uniform buffer.
  73832. * This is dynamic to allow compat with webgl 1 and 2.
  73833. * You will need to pass the name of the uniform as well as the value.
  73834. */
  73835. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73836. /**
  73837. * Lambda to Update a vec3 of float in a uniform buffer.
  73838. * This is dynamic to allow compat with webgl 1 and 2.
  73839. * You will need to pass the name of the uniform as well as the value.
  73840. */
  73841. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73842. /**
  73843. * Lambda to Update a vec4 of float in a uniform buffer.
  73844. * This is dynamic to allow compat with webgl 1 and 2.
  73845. * You will need to pass the name of the uniform as well as the value.
  73846. */
  73847. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73848. /**
  73849. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73850. * This is dynamic to allow compat with webgl 1 and 2.
  73851. * You will need to pass the name of the uniform as well as the value.
  73852. */
  73853. updateMatrix: (name: string, mat: Matrix) => void;
  73854. /**
  73855. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73856. * This is dynamic to allow compat with webgl 1 and 2.
  73857. * You will need to pass the name of the uniform as well as the value.
  73858. */
  73859. updateVector3: (name: string, vector: Vector3) => void;
  73860. /**
  73861. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73862. * This is dynamic to allow compat with webgl 1 and 2.
  73863. * You will need to pass the name of the uniform as well as the value.
  73864. */
  73865. updateVector4: (name: string, vector: Vector4) => void;
  73866. /**
  73867. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73868. * This is dynamic to allow compat with webgl 1 and 2.
  73869. * You will need to pass the name of the uniform as well as the value.
  73870. */
  73871. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73872. /**
  73873. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73874. * This is dynamic to allow compat with webgl 1 and 2.
  73875. * You will need to pass the name of the uniform as well as the value.
  73876. */
  73877. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73878. /**
  73879. * Instantiates a new Uniform buffer objects.
  73880. *
  73881. * Handles blocks of uniform on the GPU.
  73882. *
  73883. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73884. *
  73885. * For more information, please refer to :
  73886. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73887. * @param engine Define the engine the buffer is associated with
  73888. * @param data Define the data contained in the buffer
  73889. * @param dynamic Define if the buffer is updatable
  73890. */
  73891. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73892. /**
  73893. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73894. * or just falling back on setUniformXXX calls.
  73895. */
  73896. readonly useUbo: boolean;
  73897. /**
  73898. * Indicates if the WebGL underlying uniform buffer is in sync
  73899. * with the javascript cache data.
  73900. */
  73901. readonly isSync: boolean;
  73902. /**
  73903. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73904. * Also, a dynamic UniformBuffer will disable cache verification and always
  73905. * update the underlying WebGL uniform buffer to the GPU.
  73906. * @returns if Dynamic, otherwise false
  73907. */
  73908. isDynamic(): boolean;
  73909. /**
  73910. * The data cache on JS side.
  73911. * @returns the underlying data as a float array
  73912. */
  73913. getData(): Float32Array;
  73914. /**
  73915. * The underlying WebGL Uniform buffer.
  73916. * @returns the webgl buffer
  73917. */
  73918. getBuffer(): Nullable<DataBuffer>;
  73919. /**
  73920. * std140 layout specifies how to align data within an UBO structure.
  73921. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73922. * for specs.
  73923. */
  73924. private _fillAlignment;
  73925. /**
  73926. * Adds an uniform in the buffer.
  73927. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73928. * for the layout to be correct !
  73929. * @param name Name of the uniform, as used in the uniform block in the shader.
  73930. * @param size Data size, or data directly.
  73931. */
  73932. addUniform(name: string, size: number | number[]): void;
  73933. /**
  73934. * Adds a Matrix 4x4 to the uniform buffer.
  73935. * @param name Name of the uniform, as used in the uniform block in the shader.
  73936. * @param mat A 4x4 matrix.
  73937. */
  73938. addMatrix(name: string, mat: Matrix): void;
  73939. /**
  73940. * Adds a vec2 to the uniform buffer.
  73941. * @param name Name of the uniform, as used in the uniform block in the shader.
  73942. * @param x Define the x component value of the vec2
  73943. * @param y Define the y component value of the vec2
  73944. */
  73945. addFloat2(name: string, x: number, y: number): void;
  73946. /**
  73947. * Adds a vec3 to the uniform buffer.
  73948. * @param name Name of the uniform, as used in the uniform block in the shader.
  73949. * @param x Define the x component value of the vec3
  73950. * @param y Define the y component value of the vec3
  73951. * @param z Define the z component value of the vec3
  73952. */
  73953. addFloat3(name: string, x: number, y: number, z: number): void;
  73954. /**
  73955. * Adds a vec3 to the uniform buffer.
  73956. * @param name Name of the uniform, as used in the uniform block in the shader.
  73957. * @param color Define the vec3 from a Color
  73958. */
  73959. addColor3(name: string, color: Color3): void;
  73960. /**
  73961. * Adds a vec4 to the uniform buffer.
  73962. * @param name Name of the uniform, as used in the uniform block in the shader.
  73963. * @param color Define the rgb components from a Color
  73964. * @param alpha Define the a component of the vec4
  73965. */
  73966. addColor4(name: string, color: Color3, alpha: number): void;
  73967. /**
  73968. * Adds a vec3 to the uniform buffer.
  73969. * @param name Name of the uniform, as used in the uniform block in the shader.
  73970. * @param vector Define the vec3 components from a Vector
  73971. */
  73972. addVector3(name: string, vector: Vector3): void;
  73973. /**
  73974. * Adds a Matrix 3x3 to the uniform buffer.
  73975. * @param name Name of the uniform, as used in the uniform block in the shader.
  73976. */
  73977. addMatrix3x3(name: string): void;
  73978. /**
  73979. * Adds a Matrix 2x2 to the uniform buffer.
  73980. * @param name Name of the uniform, as used in the uniform block in the shader.
  73981. */
  73982. addMatrix2x2(name: string): void;
  73983. /**
  73984. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  73985. */
  73986. create(): void;
  73987. /** @hidden */
  73988. _rebuild(): void;
  73989. /**
  73990. * Updates the WebGL Uniform Buffer on the GPU.
  73991. * If the `dynamic` flag is set to true, no cache comparison is done.
  73992. * Otherwise, the buffer will be updated only if the cache differs.
  73993. */
  73994. update(): void;
  73995. /**
  73996. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  73997. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  73998. * @param data Define the flattened data
  73999. * @param size Define the size of the data.
  74000. */
  74001. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74002. private _valueCache;
  74003. private _cacheMatrix;
  74004. private _updateMatrix3x3ForUniform;
  74005. private _updateMatrix3x3ForEffect;
  74006. private _updateMatrix2x2ForEffect;
  74007. private _updateMatrix2x2ForUniform;
  74008. private _updateFloatForEffect;
  74009. private _updateFloatForUniform;
  74010. private _updateFloat2ForEffect;
  74011. private _updateFloat2ForUniform;
  74012. private _updateFloat3ForEffect;
  74013. private _updateFloat3ForUniform;
  74014. private _updateFloat4ForEffect;
  74015. private _updateFloat4ForUniform;
  74016. private _updateMatrixForEffect;
  74017. private _updateMatrixForUniform;
  74018. private _updateVector3ForEffect;
  74019. private _updateVector3ForUniform;
  74020. private _updateVector4ForEffect;
  74021. private _updateVector4ForUniform;
  74022. private _updateColor3ForEffect;
  74023. private _updateColor3ForUniform;
  74024. private _updateColor4ForEffect;
  74025. private _updateColor4ForUniform;
  74026. /**
  74027. * Sets a sampler uniform on the effect.
  74028. * @param name Define the name of the sampler.
  74029. * @param texture Define the texture to set in the sampler
  74030. */
  74031. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74032. /**
  74033. * Directly updates the value of the uniform in the cache AND on the GPU.
  74034. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74035. * @param data Define the flattened data
  74036. */
  74037. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74038. /**
  74039. * Binds this uniform buffer to an effect.
  74040. * @param effect Define the effect to bind the buffer to
  74041. * @param name Name of the uniform block in the shader.
  74042. */
  74043. bindToEffect(effect: Effect, name: string): void;
  74044. /**
  74045. * Disposes the uniform buffer.
  74046. */
  74047. dispose(): void;
  74048. }
  74049. }
  74050. declare module BABYLON {
  74051. /**
  74052. * Enum that determines the text-wrapping mode to use.
  74053. */
  74054. export enum InspectableType {
  74055. /**
  74056. * Checkbox for booleans
  74057. */
  74058. Checkbox = 0,
  74059. /**
  74060. * Sliders for numbers
  74061. */
  74062. Slider = 1,
  74063. /**
  74064. * Vector3
  74065. */
  74066. Vector3 = 2,
  74067. /**
  74068. * Quaternions
  74069. */
  74070. Quaternion = 3,
  74071. /**
  74072. * Color3
  74073. */
  74074. Color3 = 4,
  74075. /**
  74076. * String
  74077. */
  74078. String = 5
  74079. }
  74080. /**
  74081. * Interface used to define custom inspectable properties.
  74082. * This interface is used by the inspector to display custom property grids
  74083. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74084. */
  74085. export interface IInspectable {
  74086. /**
  74087. * Gets the label to display
  74088. */
  74089. label: string;
  74090. /**
  74091. * Gets the name of the property to edit
  74092. */
  74093. propertyName: string;
  74094. /**
  74095. * Gets the type of the editor to use
  74096. */
  74097. type: InspectableType;
  74098. /**
  74099. * Gets the minimum value of the property when using in "slider" mode
  74100. */
  74101. min?: number;
  74102. /**
  74103. * Gets the maximum value of the property when using in "slider" mode
  74104. */
  74105. max?: number;
  74106. /**
  74107. * Gets the setp to use when using in "slider" mode
  74108. */
  74109. step?: number;
  74110. }
  74111. }
  74112. declare module BABYLON {
  74113. /**
  74114. * Class used to provide helper for timing
  74115. */
  74116. export class TimingTools {
  74117. /**
  74118. * Polyfill for setImmediate
  74119. * @param action defines the action to execute after the current execution block
  74120. */
  74121. static SetImmediate(action: () => void): void;
  74122. }
  74123. }
  74124. declare module BABYLON {
  74125. /**
  74126. * Class used to enable instatition of objects by class name
  74127. */
  74128. export class InstantiationTools {
  74129. /**
  74130. * Use this object to register external classes like custom textures or material
  74131. * to allow the laoders to instantiate them
  74132. */
  74133. static RegisteredExternalClasses: {
  74134. [key: string]: Object;
  74135. };
  74136. /**
  74137. * Tries to instantiate a new object from a given class name
  74138. * @param className defines the class name to instantiate
  74139. * @returns the new object or null if the system was not able to do the instantiation
  74140. */
  74141. static Instantiate(className: string): any;
  74142. }
  74143. }
  74144. declare module BABYLON {
  74145. /**
  74146. * Define options used to create a depth texture
  74147. */
  74148. export class DepthTextureCreationOptions {
  74149. /** Specifies whether or not a stencil should be allocated in the texture */
  74150. generateStencil?: boolean;
  74151. /** Specifies whether or not bilinear filtering is enable on the texture */
  74152. bilinearFiltering?: boolean;
  74153. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74154. comparisonFunction?: number;
  74155. /** Specifies if the created texture is a cube texture */
  74156. isCube?: boolean;
  74157. }
  74158. }
  74159. declare module BABYLON {
  74160. interface ThinEngine {
  74161. /**
  74162. * Creates a depth stencil cube texture.
  74163. * This is only available in WebGL 2.
  74164. * @param size The size of face edge in the cube texture.
  74165. * @param options The options defining the cube texture.
  74166. * @returns The cube texture
  74167. */
  74168. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74169. /**
  74170. * Creates a cube texture
  74171. * @param rootUrl defines the url where the files to load is located
  74172. * @param scene defines the current scene
  74173. * @param files defines the list of files to load (1 per face)
  74174. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74175. * @param onLoad defines an optional callback raised when the texture is loaded
  74176. * @param onError defines an optional callback raised if there is an issue to load the texture
  74177. * @param format defines the format of the data
  74178. * @param forcedExtension defines the extension to use to pick the right loader
  74179. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74180. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74181. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74182. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74183. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74184. * @returns the cube texture as an InternalTexture
  74185. */
  74186. 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;
  74187. /**
  74188. * Creates a cube texture
  74189. * @param rootUrl defines the url where the files to load is located
  74190. * @param scene defines the current scene
  74191. * @param files defines the list of files to load (1 per face)
  74192. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74193. * @param onLoad defines an optional callback raised when the texture is loaded
  74194. * @param onError defines an optional callback raised if there is an issue to load the texture
  74195. * @param format defines the format of the data
  74196. * @param forcedExtension defines the extension to use to pick the right loader
  74197. * @returns the cube texture as an InternalTexture
  74198. */
  74199. 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;
  74200. /**
  74201. * Creates a cube texture
  74202. * @param rootUrl defines the url where the files to load is located
  74203. * @param scene defines the current scene
  74204. * @param files defines the list of files to load (1 per face)
  74205. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74206. * @param onLoad defines an optional callback raised when the texture is loaded
  74207. * @param onError defines an optional callback raised if there is an issue to load the texture
  74208. * @param format defines the format of the data
  74209. * @param forcedExtension defines the extension to use to pick the right loader
  74210. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74211. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74212. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74213. * @returns the cube texture as an InternalTexture
  74214. */
  74215. 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;
  74216. /** @hidden */
  74217. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74218. /** @hidden */
  74219. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74220. /** @hidden */
  74221. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74222. /** @hidden */
  74223. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74224. }
  74225. }
  74226. declare module BABYLON {
  74227. /**
  74228. * Class for creating a cube texture
  74229. */
  74230. export class CubeTexture extends BaseTexture {
  74231. private _delayedOnLoad;
  74232. /**
  74233. * The url of the texture
  74234. */
  74235. url: string;
  74236. /**
  74237. * Gets or sets the center of the bounding box associated with the cube texture.
  74238. * It must define where the camera used to render the texture was set
  74239. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74240. */
  74241. boundingBoxPosition: Vector3;
  74242. private _boundingBoxSize;
  74243. /**
  74244. * Gets or sets the size of the bounding box associated with the cube texture
  74245. * When defined, the cubemap will switch to local mode
  74246. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74247. * @example https://www.babylonjs-playground.com/#RNASML
  74248. */
  74249. /**
  74250. * Returns the bounding box size
  74251. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74252. */
  74253. boundingBoxSize: Vector3;
  74254. protected _rotationY: number;
  74255. /**
  74256. * Sets texture matrix rotation angle around Y axis in radians.
  74257. */
  74258. /**
  74259. * Gets texture matrix rotation angle around Y axis radians.
  74260. */
  74261. rotationY: number;
  74262. /**
  74263. * Are mip maps generated for this texture or not.
  74264. */
  74265. readonly noMipmap: boolean;
  74266. private _noMipmap;
  74267. private _files;
  74268. private _extensions;
  74269. private _textureMatrix;
  74270. private _format;
  74271. private _createPolynomials;
  74272. /** @hidden */
  74273. _prefiltered: boolean;
  74274. /**
  74275. * Creates a cube texture from an array of image urls
  74276. * @param files defines an array of image urls
  74277. * @param scene defines the hosting scene
  74278. * @param noMipmap specifies if mip maps are not used
  74279. * @returns a cube texture
  74280. */
  74281. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74282. /**
  74283. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74284. * @param url defines the url of the prefiltered texture
  74285. * @param scene defines the scene the texture is attached to
  74286. * @param forcedExtension defines the extension of the file if different from the url
  74287. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74288. * @return the prefiltered texture
  74289. */
  74290. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74291. /**
  74292. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74293. * as prefiltered data.
  74294. * @param rootUrl defines the url of the texture or the root name of the six images
  74295. * @param scene defines the scene the texture is attached to
  74296. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74297. * @param noMipmap defines if mipmaps should be created or not
  74298. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74299. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74300. * @param onError defines a callback triggered in case of error during load
  74301. * @param format defines the internal format to use for the texture once loaded
  74302. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74303. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74304. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74305. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74306. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74307. * @return the cube texture
  74308. */
  74309. 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);
  74310. /**
  74311. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74312. */
  74313. readonly isPrefiltered: boolean;
  74314. /**
  74315. * Get the current class name of the texture useful for serialization or dynamic coding.
  74316. * @returns "CubeTexture"
  74317. */
  74318. getClassName(): string;
  74319. /**
  74320. * Update the url (and optional buffer) of this texture if url was null during construction.
  74321. * @param url the url of the texture
  74322. * @param forcedExtension defines the extension to use
  74323. * @param onLoad callback called when the texture is loaded (defaults to null)
  74324. */
  74325. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74326. /**
  74327. * Delays loading of the cube texture
  74328. * @param forcedExtension defines the extension to use
  74329. */
  74330. delayLoad(forcedExtension?: string): void;
  74331. /**
  74332. * Returns the reflection texture matrix
  74333. * @returns the reflection texture matrix
  74334. */
  74335. getReflectionTextureMatrix(): Matrix;
  74336. /**
  74337. * Sets the reflection texture matrix
  74338. * @param value Reflection texture matrix
  74339. */
  74340. setReflectionTextureMatrix(value: Matrix): void;
  74341. /**
  74342. * Parses text to create a cube texture
  74343. * @param parsedTexture define the serialized text to read from
  74344. * @param scene defines the hosting scene
  74345. * @param rootUrl defines the root url of the cube texture
  74346. * @returns a cube texture
  74347. */
  74348. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74349. /**
  74350. * Makes a clone, or deep copy, of the cube texture
  74351. * @returns a new cube texture
  74352. */
  74353. clone(): CubeTexture;
  74354. }
  74355. }
  74356. declare module BABYLON {
  74357. /**
  74358. * Manages the defines for the Material
  74359. */
  74360. export class MaterialDefines {
  74361. /** @hidden */
  74362. protected _keys: string[];
  74363. private _isDirty;
  74364. /** @hidden */
  74365. _renderId: number;
  74366. /** @hidden */
  74367. _areLightsDirty: boolean;
  74368. /** @hidden */
  74369. _areLightsDisposed: boolean;
  74370. /** @hidden */
  74371. _areAttributesDirty: boolean;
  74372. /** @hidden */
  74373. _areTexturesDirty: boolean;
  74374. /** @hidden */
  74375. _areFresnelDirty: boolean;
  74376. /** @hidden */
  74377. _areMiscDirty: boolean;
  74378. /** @hidden */
  74379. _areImageProcessingDirty: boolean;
  74380. /** @hidden */
  74381. _normals: boolean;
  74382. /** @hidden */
  74383. _uvs: boolean;
  74384. /** @hidden */
  74385. _needNormals: boolean;
  74386. /** @hidden */
  74387. _needUVs: boolean;
  74388. [id: string]: any;
  74389. /**
  74390. * Specifies if the material needs to be re-calculated
  74391. */
  74392. readonly isDirty: boolean;
  74393. /**
  74394. * Marks the material to indicate that it has been re-calculated
  74395. */
  74396. markAsProcessed(): void;
  74397. /**
  74398. * Marks the material to indicate that it needs to be re-calculated
  74399. */
  74400. markAsUnprocessed(): void;
  74401. /**
  74402. * Marks the material to indicate all of its defines need to be re-calculated
  74403. */
  74404. markAllAsDirty(): void;
  74405. /**
  74406. * Marks the material to indicate that image processing needs to be re-calculated
  74407. */
  74408. markAsImageProcessingDirty(): void;
  74409. /**
  74410. * Marks the material to indicate the lights need to be re-calculated
  74411. * @param disposed Defines whether the light is dirty due to dispose or not
  74412. */
  74413. markAsLightDirty(disposed?: boolean): void;
  74414. /**
  74415. * Marks the attribute state as changed
  74416. */
  74417. markAsAttributesDirty(): void;
  74418. /**
  74419. * Marks the texture state as changed
  74420. */
  74421. markAsTexturesDirty(): void;
  74422. /**
  74423. * Marks the fresnel state as changed
  74424. */
  74425. markAsFresnelDirty(): void;
  74426. /**
  74427. * Marks the misc state as changed
  74428. */
  74429. markAsMiscDirty(): void;
  74430. /**
  74431. * Rebuilds the material defines
  74432. */
  74433. rebuild(): void;
  74434. /**
  74435. * Specifies if two material defines are equal
  74436. * @param other - A material define instance to compare to
  74437. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74438. */
  74439. isEqual(other: MaterialDefines): boolean;
  74440. /**
  74441. * Clones this instance's defines to another instance
  74442. * @param other - material defines to clone values to
  74443. */
  74444. cloneTo(other: MaterialDefines): void;
  74445. /**
  74446. * Resets the material define values
  74447. */
  74448. reset(): void;
  74449. /**
  74450. * Converts the material define values to a string
  74451. * @returns - String of material define information
  74452. */
  74453. toString(): string;
  74454. }
  74455. }
  74456. declare module BABYLON {
  74457. /**
  74458. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74459. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74460. * 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;
  74461. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74462. */
  74463. export class ColorCurves {
  74464. private _dirty;
  74465. private _tempColor;
  74466. private _globalCurve;
  74467. private _highlightsCurve;
  74468. private _midtonesCurve;
  74469. private _shadowsCurve;
  74470. private _positiveCurve;
  74471. private _negativeCurve;
  74472. private _globalHue;
  74473. private _globalDensity;
  74474. private _globalSaturation;
  74475. private _globalExposure;
  74476. /**
  74477. * Gets the global Hue value.
  74478. * 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).
  74479. */
  74480. /**
  74481. * Sets the global Hue value.
  74482. * 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).
  74483. */
  74484. globalHue: number;
  74485. /**
  74486. * Gets the global Density value.
  74487. * 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.
  74488. * Values less than zero provide a filter of opposite hue.
  74489. */
  74490. /**
  74491. * Sets the global Density value.
  74492. * 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.
  74493. * Values less than zero provide a filter of opposite hue.
  74494. */
  74495. globalDensity: number;
  74496. /**
  74497. * Gets the global Saturation value.
  74498. * 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.
  74499. */
  74500. /**
  74501. * Sets the global Saturation value.
  74502. * 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.
  74503. */
  74504. globalSaturation: number;
  74505. /**
  74506. * Gets the global Exposure value.
  74507. * 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.
  74508. */
  74509. /**
  74510. * Sets the global Exposure value.
  74511. * 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.
  74512. */
  74513. globalExposure: number;
  74514. private _highlightsHue;
  74515. private _highlightsDensity;
  74516. private _highlightsSaturation;
  74517. private _highlightsExposure;
  74518. /**
  74519. * Gets the highlights Hue value.
  74520. * 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).
  74521. */
  74522. /**
  74523. * Sets the highlights Hue value.
  74524. * 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).
  74525. */
  74526. highlightsHue: number;
  74527. /**
  74528. * Gets the highlights Density value.
  74529. * 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.
  74530. * Values less than zero provide a filter of opposite hue.
  74531. */
  74532. /**
  74533. * Sets the highlights Density value.
  74534. * 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.
  74535. * Values less than zero provide a filter of opposite hue.
  74536. */
  74537. highlightsDensity: number;
  74538. /**
  74539. * Gets the highlights Saturation value.
  74540. * 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.
  74541. */
  74542. /**
  74543. * Sets the highlights Saturation value.
  74544. * 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.
  74545. */
  74546. highlightsSaturation: number;
  74547. /**
  74548. * Gets the highlights Exposure value.
  74549. * 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.
  74550. */
  74551. /**
  74552. * Sets the highlights Exposure value.
  74553. * 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.
  74554. */
  74555. highlightsExposure: number;
  74556. private _midtonesHue;
  74557. private _midtonesDensity;
  74558. private _midtonesSaturation;
  74559. private _midtonesExposure;
  74560. /**
  74561. * Gets the midtones Hue value.
  74562. * 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).
  74563. */
  74564. /**
  74565. * Sets the midtones Hue value.
  74566. * 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).
  74567. */
  74568. midtonesHue: number;
  74569. /**
  74570. * Gets the midtones Density value.
  74571. * 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.
  74572. * Values less than zero provide a filter of opposite hue.
  74573. */
  74574. /**
  74575. * Sets the midtones Density value.
  74576. * 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.
  74577. * Values less than zero provide a filter of opposite hue.
  74578. */
  74579. midtonesDensity: number;
  74580. /**
  74581. * Gets the midtones Saturation value.
  74582. * 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.
  74583. */
  74584. /**
  74585. * Sets the midtones Saturation value.
  74586. * 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.
  74587. */
  74588. midtonesSaturation: number;
  74589. /**
  74590. * Gets the midtones Exposure value.
  74591. * 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.
  74592. */
  74593. /**
  74594. * Sets the midtones Exposure value.
  74595. * 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.
  74596. */
  74597. midtonesExposure: number;
  74598. private _shadowsHue;
  74599. private _shadowsDensity;
  74600. private _shadowsSaturation;
  74601. private _shadowsExposure;
  74602. /**
  74603. * Gets the shadows Hue value.
  74604. * 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).
  74605. */
  74606. /**
  74607. * Sets the shadows Hue value.
  74608. * 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).
  74609. */
  74610. shadowsHue: number;
  74611. /**
  74612. * Gets the shadows Density value.
  74613. * 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.
  74614. * Values less than zero provide a filter of opposite hue.
  74615. */
  74616. /**
  74617. * Sets the shadows Density value.
  74618. * 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.
  74619. * Values less than zero provide a filter of opposite hue.
  74620. */
  74621. shadowsDensity: number;
  74622. /**
  74623. * Gets the shadows Saturation value.
  74624. * 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.
  74625. */
  74626. /**
  74627. * Sets the shadows Saturation value.
  74628. * 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.
  74629. */
  74630. shadowsSaturation: number;
  74631. /**
  74632. * Gets the shadows Exposure value.
  74633. * 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.
  74634. */
  74635. /**
  74636. * Sets the shadows Exposure value.
  74637. * 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.
  74638. */
  74639. shadowsExposure: number;
  74640. /**
  74641. * Returns the class name
  74642. * @returns The class name
  74643. */
  74644. getClassName(): string;
  74645. /**
  74646. * Binds the color curves to the shader.
  74647. * @param colorCurves The color curve to bind
  74648. * @param effect The effect to bind to
  74649. * @param positiveUniform The positive uniform shader parameter
  74650. * @param neutralUniform The neutral uniform shader parameter
  74651. * @param negativeUniform The negative uniform shader parameter
  74652. */
  74653. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74654. /**
  74655. * Prepare the list of uniforms associated with the ColorCurves effects.
  74656. * @param uniformsList The list of uniforms used in the effect
  74657. */
  74658. static PrepareUniforms(uniformsList: string[]): void;
  74659. /**
  74660. * Returns color grading data based on a hue, density, saturation and exposure value.
  74661. * @param filterHue The hue of the color filter.
  74662. * @param filterDensity The density of the color filter.
  74663. * @param saturation The saturation.
  74664. * @param exposure The exposure.
  74665. * @param result The result data container.
  74666. */
  74667. private getColorGradingDataToRef;
  74668. /**
  74669. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74670. * @param value The input slider value in range [-100,100].
  74671. * @returns Adjusted value.
  74672. */
  74673. private static applyColorGradingSliderNonlinear;
  74674. /**
  74675. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74676. * @param hue The hue (H) input.
  74677. * @param saturation The saturation (S) input.
  74678. * @param brightness The brightness (B) input.
  74679. * @result An RGBA color represented as Vector4.
  74680. */
  74681. private static fromHSBToRef;
  74682. /**
  74683. * Returns a value clamped between min and max
  74684. * @param value The value to clamp
  74685. * @param min The minimum of value
  74686. * @param max The maximum of value
  74687. * @returns The clamped value.
  74688. */
  74689. private static clamp;
  74690. /**
  74691. * Clones the current color curve instance.
  74692. * @return The cloned curves
  74693. */
  74694. clone(): ColorCurves;
  74695. /**
  74696. * Serializes the current color curve instance to a json representation.
  74697. * @return a JSON representation
  74698. */
  74699. serialize(): any;
  74700. /**
  74701. * Parses the color curve from a json representation.
  74702. * @param source the JSON source to parse
  74703. * @return The parsed curves
  74704. */
  74705. static Parse(source: any): ColorCurves;
  74706. }
  74707. }
  74708. declare module BABYLON {
  74709. /**
  74710. * Interface to follow in your material defines to integrate easily the
  74711. * Image proccessing functions.
  74712. * @hidden
  74713. */
  74714. export interface IImageProcessingConfigurationDefines {
  74715. IMAGEPROCESSING: boolean;
  74716. VIGNETTE: boolean;
  74717. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74718. VIGNETTEBLENDMODEOPAQUE: boolean;
  74719. TONEMAPPING: boolean;
  74720. TONEMAPPING_ACES: boolean;
  74721. CONTRAST: boolean;
  74722. EXPOSURE: boolean;
  74723. COLORCURVES: boolean;
  74724. COLORGRADING: boolean;
  74725. COLORGRADING3D: boolean;
  74726. SAMPLER3DGREENDEPTH: boolean;
  74727. SAMPLER3DBGRMAP: boolean;
  74728. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74729. }
  74730. /**
  74731. * @hidden
  74732. */
  74733. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74734. IMAGEPROCESSING: boolean;
  74735. VIGNETTE: boolean;
  74736. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74737. VIGNETTEBLENDMODEOPAQUE: boolean;
  74738. TONEMAPPING: boolean;
  74739. TONEMAPPING_ACES: boolean;
  74740. CONTRAST: boolean;
  74741. COLORCURVES: boolean;
  74742. COLORGRADING: boolean;
  74743. COLORGRADING3D: boolean;
  74744. SAMPLER3DGREENDEPTH: boolean;
  74745. SAMPLER3DBGRMAP: boolean;
  74746. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74747. EXPOSURE: boolean;
  74748. constructor();
  74749. }
  74750. /**
  74751. * This groups together the common properties used for image processing either in direct forward pass
  74752. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74753. * or not.
  74754. */
  74755. export class ImageProcessingConfiguration {
  74756. /**
  74757. * Default tone mapping applied in BabylonJS.
  74758. */
  74759. static readonly TONEMAPPING_STANDARD: number;
  74760. /**
  74761. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74762. * to other engines rendering to increase portability.
  74763. */
  74764. static readonly TONEMAPPING_ACES: number;
  74765. /**
  74766. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74767. */
  74768. colorCurves: Nullable<ColorCurves>;
  74769. private _colorCurvesEnabled;
  74770. /**
  74771. * Gets wether the color curves effect is enabled.
  74772. */
  74773. /**
  74774. * Sets wether the color curves effect is enabled.
  74775. */
  74776. colorCurvesEnabled: boolean;
  74777. private _colorGradingTexture;
  74778. /**
  74779. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74780. */
  74781. /**
  74782. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74783. */
  74784. colorGradingTexture: Nullable<BaseTexture>;
  74785. private _colorGradingEnabled;
  74786. /**
  74787. * Gets wether the color grading effect is enabled.
  74788. */
  74789. /**
  74790. * Sets wether the color grading effect is enabled.
  74791. */
  74792. colorGradingEnabled: boolean;
  74793. private _colorGradingWithGreenDepth;
  74794. /**
  74795. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74796. */
  74797. /**
  74798. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74799. */
  74800. colorGradingWithGreenDepth: boolean;
  74801. private _colorGradingBGR;
  74802. /**
  74803. * Gets wether the color grading texture contains BGR values.
  74804. */
  74805. /**
  74806. * Sets wether the color grading texture contains BGR values.
  74807. */
  74808. colorGradingBGR: boolean;
  74809. /** @hidden */
  74810. _exposure: number;
  74811. /**
  74812. * Gets the Exposure used in the effect.
  74813. */
  74814. /**
  74815. * Sets the Exposure used in the effect.
  74816. */
  74817. exposure: number;
  74818. private _toneMappingEnabled;
  74819. /**
  74820. * Gets wether the tone mapping effect is enabled.
  74821. */
  74822. /**
  74823. * Sets wether the tone mapping effect is enabled.
  74824. */
  74825. toneMappingEnabled: boolean;
  74826. private _toneMappingType;
  74827. /**
  74828. * Gets the type of tone mapping effect.
  74829. */
  74830. /**
  74831. * Sets the type of tone mapping effect used in BabylonJS.
  74832. */
  74833. toneMappingType: number;
  74834. protected _contrast: number;
  74835. /**
  74836. * Gets the contrast used in the effect.
  74837. */
  74838. /**
  74839. * Sets the contrast used in the effect.
  74840. */
  74841. contrast: number;
  74842. /**
  74843. * Vignette stretch size.
  74844. */
  74845. vignetteStretch: number;
  74846. /**
  74847. * Vignette centre X Offset.
  74848. */
  74849. vignetteCentreX: number;
  74850. /**
  74851. * Vignette centre Y Offset.
  74852. */
  74853. vignetteCentreY: number;
  74854. /**
  74855. * Vignette weight or intensity of the vignette effect.
  74856. */
  74857. vignetteWeight: number;
  74858. /**
  74859. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74860. * if vignetteEnabled is set to true.
  74861. */
  74862. vignetteColor: Color4;
  74863. /**
  74864. * Camera field of view used by the Vignette effect.
  74865. */
  74866. vignetteCameraFov: number;
  74867. private _vignetteBlendMode;
  74868. /**
  74869. * Gets the vignette blend mode allowing different kind of effect.
  74870. */
  74871. /**
  74872. * Sets the vignette blend mode allowing different kind of effect.
  74873. */
  74874. vignetteBlendMode: number;
  74875. private _vignetteEnabled;
  74876. /**
  74877. * Gets wether the vignette effect is enabled.
  74878. */
  74879. /**
  74880. * Sets wether the vignette effect is enabled.
  74881. */
  74882. vignetteEnabled: boolean;
  74883. private _applyByPostProcess;
  74884. /**
  74885. * Gets wether the image processing is applied through a post process or not.
  74886. */
  74887. /**
  74888. * Sets wether the image processing is applied through a post process or not.
  74889. */
  74890. applyByPostProcess: boolean;
  74891. private _isEnabled;
  74892. /**
  74893. * Gets wether the image processing is enabled or not.
  74894. */
  74895. /**
  74896. * Sets wether the image processing is enabled or not.
  74897. */
  74898. isEnabled: boolean;
  74899. /**
  74900. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74901. */
  74902. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74903. /**
  74904. * Method called each time the image processing information changes requires to recompile the effect.
  74905. */
  74906. protected _updateParameters(): void;
  74907. /**
  74908. * Gets the current class name.
  74909. * @return "ImageProcessingConfiguration"
  74910. */
  74911. getClassName(): string;
  74912. /**
  74913. * Prepare the list of uniforms associated with the Image Processing effects.
  74914. * @param uniforms The list of uniforms used in the effect
  74915. * @param defines the list of defines currently in use
  74916. */
  74917. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74918. /**
  74919. * Prepare the list of samplers associated with the Image Processing effects.
  74920. * @param samplersList The list of uniforms used in the effect
  74921. * @param defines the list of defines currently in use
  74922. */
  74923. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74924. /**
  74925. * Prepare the list of defines associated to the shader.
  74926. * @param defines the list of defines to complete
  74927. * @param forPostProcess Define if we are currently in post process mode or not
  74928. */
  74929. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74930. /**
  74931. * Returns true if all the image processing information are ready.
  74932. * @returns True if ready, otherwise, false
  74933. */
  74934. isReady(): boolean;
  74935. /**
  74936. * Binds the image processing to the shader.
  74937. * @param effect The effect to bind to
  74938. * @param aspectRatio Define the current aspect ratio of the effect
  74939. */
  74940. bind(effect: Effect, aspectRatio?: number): void;
  74941. /**
  74942. * Clones the current image processing instance.
  74943. * @return The cloned image processing
  74944. */
  74945. clone(): ImageProcessingConfiguration;
  74946. /**
  74947. * Serializes the current image processing instance to a json representation.
  74948. * @return a JSON representation
  74949. */
  74950. serialize(): any;
  74951. /**
  74952. * Parses the image processing from a json representation.
  74953. * @param source the JSON source to parse
  74954. * @return The parsed image processing
  74955. */
  74956. static Parse(source: any): ImageProcessingConfiguration;
  74957. private static _VIGNETTEMODE_MULTIPLY;
  74958. private static _VIGNETTEMODE_OPAQUE;
  74959. /**
  74960. * Used to apply the vignette as a mix with the pixel color.
  74961. */
  74962. static readonly VIGNETTEMODE_MULTIPLY: number;
  74963. /**
  74964. * Used to apply the vignette as a replacement of the pixel color.
  74965. */
  74966. static readonly VIGNETTEMODE_OPAQUE: number;
  74967. }
  74968. }
  74969. declare module BABYLON {
  74970. /** @hidden */
  74971. export var postprocessVertexShader: {
  74972. name: string;
  74973. shader: string;
  74974. };
  74975. }
  74976. declare module BABYLON {
  74977. /** Defines supported spaces */
  74978. export enum Space {
  74979. /** Local (object) space */
  74980. LOCAL = 0,
  74981. /** World space */
  74982. WORLD = 1,
  74983. /** Bone space */
  74984. BONE = 2
  74985. }
  74986. /** Defines the 3 main axes */
  74987. export class Axis {
  74988. /** X axis */
  74989. static X: Vector3;
  74990. /** Y axis */
  74991. static Y: Vector3;
  74992. /** Z axis */
  74993. static Z: Vector3;
  74994. }
  74995. }
  74996. declare module BABYLON {
  74997. /**
  74998. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74999. * This is the base of the follow, arc rotate cameras and Free camera
  75000. * @see http://doc.babylonjs.com/features/cameras
  75001. */
  75002. export class TargetCamera extends Camera {
  75003. private static _RigCamTransformMatrix;
  75004. private static _TargetTransformMatrix;
  75005. private static _TargetFocalPoint;
  75006. /**
  75007. * Define the current direction the camera is moving to
  75008. */
  75009. cameraDirection: Vector3;
  75010. /**
  75011. * Define the current rotation the camera is rotating to
  75012. */
  75013. cameraRotation: Vector2;
  75014. /**
  75015. * When set, the up vector of the camera will be updated by the rotation of the camera
  75016. */
  75017. updateUpVectorFromRotation: boolean;
  75018. private _tmpQuaternion;
  75019. /**
  75020. * Define the current rotation of the camera
  75021. */
  75022. rotation: Vector3;
  75023. /**
  75024. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75025. */
  75026. rotationQuaternion: Quaternion;
  75027. /**
  75028. * Define the current speed of the camera
  75029. */
  75030. speed: number;
  75031. /**
  75032. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75033. * around all axis.
  75034. */
  75035. noRotationConstraint: boolean;
  75036. /**
  75037. * Define the current target of the camera as an object or a position.
  75038. */
  75039. lockedTarget: any;
  75040. /** @hidden */
  75041. _currentTarget: Vector3;
  75042. /** @hidden */
  75043. _initialFocalDistance: number;
  75044. /** @hidden */
  75045. _viewMatrix: Matrix;
  75046. /** @hidden */
  75047. _camMatrix: Matrix;
  75048. /** @hidden */
  75049. _cameraTransformMatrix: Matrix;
  75050. /** @hidden */
  75051. _cameraRotationMatrix: Matrix;
  75052. /** @hidden */
  75053. _referencePoint: Vector3;
  75054. /** @hidden */
  75055. _transformedReferencePoint: Vector3;
  75056. protected _globalCurrentTarget: Vector3;
  75057. protected _globalCurrentUpVector: Vector3;
  75058. /** @hidden */
  75059. _reset: () => void;
  75060. private _defaultUp;
  75061. /**
  75062. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75063. * This is the base of the follow, arc rotate cameras and Free camera
  75064. * @see http://doc.babylonjs.com/features/cameras
  75065. * @param name Defines the name of the camera in the scene
  75066. * @param position Defines the start position of the camera in the scene
  75067. * @param scene Defines the scene the camera belongs to
  75068. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75069. */
  75070. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75071. /**
  75072. * Gets the position in front of the camera at a given distance.
  75073. * @param distance The distance from the camera we want the position to be
  75074. * @returns the position
  75075. */
  75076. getFrontPosition(distance: number): Vector3;
  75077. /** @hidden */
  75078. _getLockedTargetPosition(): Nullable<Vector3>;
  75079. private _storedPosition;
  75080. private _storedRotation;
  75081. private _storedRotationQuaternion;
  75082. /**
  75083. * Store current camera state of the camera (fov, position, rotation, etc..)
  75084. * @returns the camera
  75085. */
  75086. storeState(): Camera;
  75087. /**
  75088. * Restored camera state. You must call storeState() first
  75089. * @returns whether it was successful or not
  75090. * @hidden
  75091. */
  75092. _restoreStateValues(): boolean;
  75093. /** @hidden */
  75094. _initCache(): void;
  75095. /** @hidden */
  75096. _updateCache(ignoreParentClass?: boolean): void;
  75097. /** @hidden */
  75098. _isSynchronizedViewMatrix(): boolean;
  75099. /** @hidden */
  75100. _computeLocalCameraSpeed(): number;
  75101. /**
  75102. * Defines the target the camera should look at.
  75103. * @param target Defines the new target as a Vector or a mesh
  75104. */
  75105. setTarget(target: Vector3): void;
  75106. /**
  75107. * Return the current target position of the camera. This value is expressed in local space.
  75108. * @returns the target position
  75109. */
  75110. getTarget(): Vector3;
  75111. /** @hidden */
  75112. _decideIfNeedsToMove(): boolean;
  75113. /** @hidden */
  75114. _updatePosition(): void;
  75115. /** @hidden */
  75116. _checkInputs(): void;
  75117. protected _updateCameraRotationMatrix(): void;
  75118. /**
  75119. * 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)
  75120. * @returns the current camera
  75121. */
  75122. private _rotateUpVectorWithCameraRotationMatrix;
  75123. private _cachedRotationZ;
  75124. private _cachedQuaternionRotationZ;
  75125. /** @hidden */
  75126. _getViewMatrix(): Matrix;
  75127. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75128. /**
  75129. * @hidden
  75130. */
  75131. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75132. /**
  75133. * @hidden
  75134. */
  75135. _updateRigCameras(): void;
  75136. private _getRigCamPositionAndTarget;
  75137. /**
  75138. * Gets the current object class name.
  75139. * @return the class name
  75140. */
  75141. getClassName(): string;
  75142. }
  75143. }
  75144. declare module BABYLON {
  75145. /**
  75146. * Gather the list of keyboard event types as constants.
  75147. */
  75148. export class KeyboardEventTypes {
  75149. /**
  75150. * The keydown event is fired when a key becomes active (pressed).
  75151. */
  75152. static readonly KEYDOWN: number;
  75153. /**
  75154. * The keyup event is fired when a key has been released.
  75155. */
  75156. static readonly KEYUP: number;
  75157. }
  75158. /**
  75159. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75160. */
  75161. export class KeyboardInfo {
  75162. /**
  75163. * Defines the type of event (KeyboardEventTypes)
  75164. */
  75165. type: number;
  75166. /**
  75167. * Defines the related dom event
  75168. */
  75169. event: KeyboardEvent;
  75170. /**
  75171. * Instantiates a new keyboard info.
  75172. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75173. * @param type Defines the type of event (KeyboardEventTypes)
  75174. * @param event Defines the related dom event
  75175. */
  75176. constructor(
  75177. /**
  75178. * Defines the type of event (KeyboardEventTypes)
  75179. */
  75180. type: number,
  75181. /**
  75182. * Defines the related dom event
  75183. */
  75184. event: KeyboardEvent);
  75185. }
  75186. /**
  75187. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75188. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75189. */
  75190. export class KeyboardInfoPre extends KeyboardInfo {
  75191. /**
  75192. * Defines the type of event (KeyboardEventTypes)
  75193. */
  75194. type: number;
  75195. /**
  75196. * Defines the related dom event
  75197. */
  75198. event: KeyboardEvent;
  75199. /**
  75200. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75201. */
  75202. skipOnPointerObservable: boolean;
  75203. /**
  75204. * Instantiates a new keyboard pre info.
  75205. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75206. * @param type Defines the type of event (KeyboardEventTypes)
  75207. * @param event Defines the related dom event
  75208. */
  75209. constructor(
  75210. /**
  75211. * Defines the type of event (KeyboardEventTypes)
  75212. */
  75213. type: number,
  75214. /**
  75215. * Defines the related dom event
  75216. */
  75217. event: KeyboardEvent);
  75218. }
  75219. }
  75220. declare module BABYLON {
  75221. /**
  75222. * Manage the keyboard inputs to control the movement of a free camera.
  75223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75224. */
  75225. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75226. /**
  75227. * Defines the camera the input is attached to.
  75228. */
  75229. camera: FreeCamera;
  75230. /**
  75231. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75232. */
  75233. keysUp: number[];
  75234. /**
  75235. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75236. */
  75237. keysDown: number[];
  75238. /**
  75239. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75240. */
  75241. keysLeft: number[];
  75242. /**
  75243. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75244. */
  75245. keysRight: number[];
  75246. private _keys;
  75247. private _onCanvasBlurObserver;
  75248. private _onKeyboardObserver;
  75249. private _engine;
  75250. private _scene;
  75251. /**
  75252. * Attach the input controls to a specific dom element to get the input from.
  75253. * @param element Defines the element the controls should be listened from
  75254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75255. */
  75256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75257. /**
  75258. * Detach the current controls from the specified dom element.
  75259. * @param element Defines the element to stop listening the inputs from
  75260. */
  75261. detachControl(element: Nullable<HTMLElement>): void;
  75262. /**
  75263. * Update the current camera state depending on the inputs that have been used this frame.
  75264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75265. */
  75266. checkInputs(): void;
  75267. /**
  75268. * Gets the class name of the current intput.
  75269. * @returns the class name
  75270. */
  75271. getClassName(): string;
  75272. /** @hidden */
  75273. _onLostFocus(): void;
  75274. /**
  75275. * Get the friendly name associated with the input class.
  75276. * @returns the input friendly name
  75277. */
  75278. getSimpleName(): string;
  75279. }
  75280. }
  75281. declare module BABYLON {
  75282. /**
  75283. * Interface describing all the common properties and methods a shadow light needs to implement.
  75284. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75285. * as well as binding the different shadow properties to the effects.
  75286. */
  75287. export interface IShadowLight extends Light {
  75288. /**
  75289. * The light id in the scene (used in scene.findLighById for instance)
  75290. */
  75291. id: string;
  75292. /**
  75293. * The position the shdow will be casted from.
  75294. */
  75295. position: Vector3;
  75296. /**
  75297. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75298. */
  75299. direction: Vector3;
  75300. /**
  75301. * The transformed position. Position of the light in world space taking parenting in account.
  75302. */
  75303. transformedPosition: Vector3;
  75304. /**
  75305. * The transformed direction. Direction of the light in world space taking parenting in account.
  75306. */
  75307. transformedDirection: Vector3;
  75308. /**
  75309. * The friendly name of the light in the scene.
  75310. */
  75311. name: string;
  75312. /**
  75313. * Defines the shadow projection clipping minimum z value.
  75314. */
  75315. shadowMinZ: number;
  75316. /**
  75317. * Defines the shadow projection clipping maximum z value.
  75318. */
  75319. shadowMaxZ: number;
  75320. /**
  75321. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75322. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75323. */
  75324. computeTransformedInformation(): boolean;
  75325. /**
  75326. * Gets the scene the light belongs to.
  75327. * @returns The scene
  75328. */
  75329. getScene(): Scene;
  75330. /**
  75331. * Callback defining a custom Projection Matrix Builder.
  75332. * This can be used to override the default projection matrix computation.
  75333. */
  75334. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75335. /**
  75336. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75337. * @param matrix The materix to updated with the projection information
  75338. * @param viewMatrix The transform matrix of the light
  75339. * @param renderList The list of mesh to render in the map
  75340. * @returns The current light
  75341. */
  75342. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75343. /**
  75344. * Gets the current depth scale used in ESM.
  75345. * @returns The scale
  75346. */
  75347. getDepthScale(): number;
  75348. /**
  75349. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75350. * @returns true if a cube texture needs to be use
  75351. */
  75352. needCube(): boolean;
  75353. /**
  75354. * Detects if the projection matrix requires to be recomputed this frame.
  75355. * @returns true if it requires to be recomputed otherwise, false.
  75356. */
  75357. needProjectionMatrixCompute(): boolean;
  75358. /**
  75359. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75360. */
  75361. forceProjectionMatrixCompute(): void;
  75362. /**
  75363. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75364. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75365. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75366. */
  75367. getShadowDirection(faceIndex?: number): Vector3;
  75368. /**
  75369. * Gets the minZ used for shadow according to both the scene and the light.
  75370. * @param activeCamera The camera we are returning the min for
  75371. * @returns the depth min z
  75372. */
  75373. getDepthMinZ(activeCamera: Camera): number;
  75374. /**
  75375. * Gets the maxZ used for shadow according to both the scene and the light.
  75376. * @param activeCamera The camera we are returning the max for
  75377. * @returns the depth max z
  75378. */
  75379. getDepthMaxZ(activeCamera: Camera): number;
  75380. }
  75381. /**
  75382. * Base implementation IShadowLight
  75383. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75384. */
  75385. export abstract class ShadowLight extends Light implements IShadowLight {
  75386. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75387. protected _position: Vector3;
  75388. protected _setPosition(value: Vector3): void;
  75389. /**
  75390. * Sets the position the shadow will be casted from. Also use as the light position for both
  75391. * point and spot lights.
  75392. */
  75393. /**
  75394. * Sets the position the shadow will be casted from. Also use as the light position for both
  75395. * point and spot lights.
  75396. */
  75397. position: Vector3;
  75398. protected _direction: Vector3;
  75399. protected _setDirection(value: Vector3): void;
  75400. /**
  75401. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75402. * Also use as the light direction on spot and directional lights.
  75403. */
  75404. /**
  75405. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75406. * Also use as the light direction on spot and directional lights.
  75407. */
  75408. direction: Vector3;
  75409. private _shadowMinZ;
  75410. /**
  75411. * Gets the shadow projection clipping minimum z value.
  75412. */
  75413. /**
  75414. * Sets the shadow projection clipping minimum z value.
  75415. */
  75416. shadowMinZ: number;
  75417. private _shadowMaxZ;
  75418. /**
  75419. * Sets the shadow projection clipping maximum z value.
  75420. */
  75421. /**
  75422. * Gets the shadow projection clipping maximum z value.
  75423. */
  75424. shadowMaxZ: number;
  75425. /**
  75426. * Callback defining a custom Projection Matrix Builder.
  75427. * This can be used to override the default projection matrix computation.
  75428. */
  75429. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75430. /**
  75431. * The transformed position. Position of the light in world space taking parenting in account.
  75432. */
  75433. transformedPosition: Vector3;
  75434. /**
  75435. * The transformed direction. Direction of the light in world space taking parenting in account.
  75436. */
  75437. transformedDirection: Vector3;
  75438. private _needProjectionMatrixCompute;
  75439. /**
  75440. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75441. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75442. */
  75443. computeTransformedInformation(): boolean;
  75444. /**
  75445. * Return the depth scale used for the shadow map.
  75446. * @returns the depth scale.
  75447. */
  75448. getDepthScale(): number;
  75449. /**
  75450. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75451. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75452. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75453. */
  75454. getShadowDirection(faceIndex?: number): Vector3;
  75455. /**
  75456. * Returns the ShadowLight absolute position in the World.
  75457. * @returns the position vector in world space
  75458. */
  75459. getAbsolutePosition(): Vector3;
  75460. /**
  75461. * Sets the ShadowLight direction toward the passed target.
  75462. * @param target The point to target in local space
  75463. * @returns the updated ShadowLight direction
  75464. */
  75465. setDirectionToTarget(target: Vector3): Vector3;
  75466. /**
  75467. * Returns the light rotation in euler definition.
  75468. * @returns the x y z rotation in local space.
  75469. */
  75470. getRotation(): Vector3;
  75471. /**
  75472. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75473. * @returns true if a cube texture needs to be use
  75474. */
  75475. needCube(): boolean;
  75476. /**
  75477. * Detects if the projection matrix requires to be recomputed this frame.
  75478. * @returns true if it requires to be recomputed otherwise, false.
  75479. */
  75480. needProjectionMatrixCompute(): boolean;
  75481. /**
  75482. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75483. */
  75484. forceProjectionMatrixCompute(): void;
  75485. /** @hidden */
  75486. _initCache(): void;
  75487. /** @hidden */
  75488. _isSynchronized(): boolean;
  75489. /**
  75490. * Computes the world matrix of the node
  75491. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75492. * @returns the world matrix
  75493. */
  75494. computeWorldMatrix(force?: boolean): Matrix;
  75495. /**
  75496. * Gets the minZ used for shadow according to both the scene and the light.
  75497. * @param activeCamera The camera we are returning the min for
  75498. * @returns the depth min z
  75499. */
  75500. getDepthMinZ(activeCamera: Camera): number;
  75501. /**
  75502. * Gets the maxZ used for shadow according to both the scene and the light.
  75503. * @param activeCamera The camera we are returning the max for
  75504. * @returns the depth max z
  75505. */
  75506. getDepthMaxZ(activeCamera: Camera): number;
  75507. /**
  75508. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75509. * @param matrix The materix to updated with the projection information
  75510. * @param viewMatrix The transform matrix of the light
  75511. * @param renderList The list of mesh to render in the map
  75512. * @returns The current light
  75513. */
  75514. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75515. }
  75516. }
  75517. declare module BABYLON {
  75518. /**
  75519. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75520. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75521. */
  75522. export class EffectFallbacks implements IEffectFallbacks {
  75523. private _defines;
  75524. private _currentRank;
  75525. private _maxRank;
  75526. private _mesh;
  75527. /**
  75528. * Removes the fallback from the bound mesh.
  75529. */
  75530. unBindMesh(): void;
  75531. /**
  75532. * Adds a fallback on the specified property.
  75533. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75534. * @param define The name of the define in the shader
  75535. */
  75536. addFallback(rank: number, define: string): void;
  75537. /**
  75538. * Sets the mesh to use CPU skinning when needing to fallback.
  75539. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75540. * @param mesh The mesh to use the fallbacks.
  75541. */
  75542. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75543. /**
  75544. * Checks to see if more fallbacks are still availible.
  75545. */
  75546. readonly hasMoreFallbacks: boolean;
  75547. /**
  75548. * Removes the defines that should be removed when falling back.
  75549. * @param currentDefines defines the current define statements for the shader.
  75550. * @param effect defines the current effect we try to compile
  75551. * @returns The resulting defines with defines of the current rank removed.
  75552. */
  75553. reduce(currentDefines: string, effect: Effect): string;
  75554. }
  75555. }
  75556. declare module BABYLON {
  75557. /**
  75558. * "Static Class" containing the most commonly used helper while dealing with material for
  75559. * rendering purpose.
  75560. *
  75561. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75562. *
  75563. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75564. */
  75565. export class MaterialHelper {
  75566. /**
  75567. * Bind the current view position to an effect.
  75568. * @param effect The effect to be bound
  75569. * @param scene The scene the eyes position is used from
  75570. */
  75571. static BindEyePosition(effect: Effect, scene: Scene): void;
  75572. /**
  75573. * Helps preparing the defines values about the UVs in used in the effect.
  75574. * UVs are shared as much as we can accross channels in the shaders.
  75575. * @param texture The texture we are preparing the UVs for
  75576. * @param defines The defines to update
  75577. * @param key The channel key "diffuse", "specular"... used in the shader
  75578. */
  75579. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75580. /**
  75581. * Binds a texture matrix value to its corrsponding uniform
  75582. * @param texture The texture to bind the matrix for
  75583. * @param uniformBuffer The uniform buffer receivin the data
  75584. * @param key The channel key "diffuse", "specular"... used in the shader
  75585. */
  75586. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75587. /**
  75588. * Gets the current status of the fog (should it be enabled?)
  75589. * @param mesh defines the mesh to evaluate for fog support
  75590. * @param scene defines the hosting scene
  75591. * @returns true if fog must be enabled
  75592. */
  75593. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75594. /**
  75595. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75596. * @param mesh defines the current mesh
  75597. * @param scene defines the current scene
  75598. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75599. * @param pointsCloud defines if point cloud rendering has to be turned on
  75600. * @param fogEnabled defines if fog has to be turned on
  75601. * @param alphaTest defines if alpha testing has to be turned on
  75602. * @param defines defines the current list of defines
  75603. */
  75604. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75605. /**
  75606. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75607. * @param scene defines the current scene
  75608. * @param engine defines the current engine
  75609. * @param defines specifies the list of active defines
  75610. * @param useInstances defines if instances have to be turned on
  75611. * @param useClipPlane defines if clip plane have to be turned on
  75612. */
  75613. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75614. /**
  75615. * Prepares the defines for bones
  75616. * @param mesh The mesh containing the geometry data we will draw
  75617. * @param defines The defines to update
  75618. */
  75619. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75620. /**
  75621. * Prepares the defines for morph targets
  75622. * @param mesh The mesh containing the geometry data we will draw
  75623. * @param defines The defines to update
  75624. */
  75625. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75626. /**
  75627. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75628. * @param mesh The mesh containing the geometry data we will draw
  75629. * @param defines The defines to update
  75630. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75631. * @param useBones Precise whether bones should be used or not (override mesh info)
  75632. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75633. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75634. * @returns false if defines are considered not dirty and have not been checked
  75635. */
  75636. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75637. /**
  75638. * Prepares the defines related to multiview
  75639. * @param scene The scene we are intending to draw
  75640. * @param defines The defines to update
  75641. */
  75642. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75643. /**
  75644. * Prepares the defines related to the light information passed in parameter
  75645. * @param scene The scene we are intending to draw
  75646. * @param mesh The mesh the effect is compiling for
  75647. * @param light The light the effect is compiling for
  75648. * @param lightIndex The index of the light
  75649. * @param defines The defines to update
  75650. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75651. * @param state Defines the current state regarding what is needed (normals, etc...)
  75652. */
  75653. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75654. needNormals: boolean;
  75655. needRebuild: boolean;
  75656. shadowEnabled: boolean;
  75657. specularEnabled: boolean;
  75658. lightmapMode: boolean;
  75659. }): void;
  75660. /**
  75661. * Prepares the defines related to the light information passed in parameter
  75662. * @param scene The scene we are intending to draw
  75663. * @param mesh The mesh the effect is compiling for
  75664. * @param defines The defines to update
  75665. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75666. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75667. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75668. * @returns true if normals will be required for the rest of the effect
  75669. */
  75670. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75671. /**
  75672. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75673. * @param lightIndex defines the light index
  75674. * @param uniformsList The uniform list
  75675. * @param samplersList The sampler list
  75676. * @param projectedLightTexture defines if projected texture must be used
  75677. * @param uniformBuffersList defines an optional list of uniform buffers
  75678. */
  75679. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75680. /**
  75681. * Prepares the uniforms and samplers list to be used in the effect
  75682. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75683. * @param samplersList The sampler list
  75684. * @param defines The defines helping in the list generation
  75685. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75686. */
  75687. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75688. /**
  75689. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75690. * @param defines The defines to update while falling back
  75691. * @param fallbacks The authorized effect fallbacks
  75692. * @param maxSimultaneousLights The maximum number of lights allowed
  75693. * @param rank the current rank of the Effect
  75694. * @returns The newly affected rank
  75695. */
  75696. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75697. private static _TmpMorphInfluencers;
  75698. /**
  75699. * Prepares the list of attributes required for morph targets according to the effect defines.
  75700. * @param attribs The current list of supported attribs
  75701. * @param mesh The mesh to prepare the morph targets attributes for
  75702. * @param influencers The number of influencers
  75703. */
  75704. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75705. /**
  75706. * Prepares the list of attributes required for morph targets according to the effect defines.
  75707. * @param attribs The current list of supported attribs
  75708. * @param mesh The mesh to prepare the morph targets attributes for
  75709. * @param defines The current Defines of the effect
  75710. */
  75711. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75712. /**
  75713. * Prepares the list of attributes required for bones according to the effect defines.
  75714. * @param attribs The current list of supported attribs
  75715. * @param mesh The mesh to prepare the bones attributes for
  75716. * @param defines The current Defines of the effect
  75717. * @param fallbacks The current efffect fallback strategy
  75718. */
  75719. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75720. /**
  75721. * Check and prepare the list of attributes required for instances according to the effect defines.
  75722. * @param attribs The current list of supported attribs
  75723. * @param defines The current MaterialDefines of the effect
  75724. */
  75725. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75726. /**
  75727. * Add the list of attributes required for instances to the attribs array.
  75728. * @param attribs The current list of supported attribs
  75729. */
  75730. static PushAttributesForInstances(attribs: string[]): void;
  75731. /**
  75732. * Binds the light shadow information to the effect for the given mesh.
  75733. * @param light The light containing the generator
  75734. * @param scene The scene the lights belongs to
  75735. * @param mesh The mesh we are binding the information to render
  75736. * @param lightIndex The light index in the effect used to render the mesh
  75737. * @param effect The effect we are binding the data to
  75738. */
  75739. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75740. /**
  75741. * Binds the light information to the effect.
  75742. * @param light The light containing the generator
  75743. * @param effect The effect we are binding the data to
  75744. * @param lightIndex The light index in the effect used to render
  75745. */
  75746. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75747. /**
  75748. * Binds the lights information from the scene to the effect for the given mesh.
  75749. * @param light Light to bind
  75750. * @param lightIndex Light index
  75751. * @param scene The scene where the light belongs to
  75752. * @param mesh The mesh we are binding the information to render
  75753. * @param effect The effect we are binding the data to
  75754. * @param useSpecular Defines if specular is supported
  75755. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75756. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75757. */
  75758. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75759. /**
  75760. * Binds the lights information from the scene to the effect for the given mesh.
  75761. * @param scene The scene the lights belongs to
  75762. * @param mesh The mesh we are binding the information to render
  75763. * @param effect The effect we are binding the data to
  75764. * @param defines The generated defines for the effect
  75765. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75766. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75767. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75768. */
  75769. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75770. private static _tempFogColor;
  75771. /**
  75772. * Binds the fog information from the scene to the effect for the given mesh.
  75773. * @param scene The scene the lights belongs to
  75774. * @param mesh The mesh we are binding the information to render
  75775. * @param effect The effect we are binding the data to
  75776. * @param linearSpace Defines if the fog effect is applied in linear space
  75777. */
  75778. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75779. /**
  75780. * Binds the bones information from the mesh to the effect.
  75781. * @param mesh The mesh we are binding the information to render
  75782. * @param effect The effect we are binding the data to
  75783. */
  75784. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75785. /**
  75786. * Binds the morph targets information from the mesh to the effect.
  75787. * @param abstractMesh The mesh we are binding the information to render
  75788. * @param effect The effect we are binding the data to
  75789. */
  75790. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75791. /**
  75792. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75793. * @param defines The generated defines used in the effect
  75794. * @param effect The effect we are binding the data to
  75795. * @param scene The scene we are willing to render with logarithmic scale for
  75796. */
  75797. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75798. /**
  75799. * Binds the clip plane information from the scene to the effect.
  75800. * @param scene The scene the clip plane information are extracted from
  75801. * @param effect The effect we are binding the data to
  75802. */
  75803. static BindClipPlane(effect: Effect, scene: Scene): void;
  75804. }
  75805. }
  75806. declare module BABYLON {
  75807. /** @hidden */
  75808. export var packingFunctions: {
  75809. name: string;
  75810. shader: string;
  75811. };
  75812. }
  75813. declare module BABYLON {
  75814. /** @hidden */
  75815. export var shadowMapPixelShader: {
  75816. name: string;
  75817. shader: string;
  75818. };
  75819. }
  75820. declare module BABYLON {
  75821. /** @hidden */
  75822. export var bonesDeclaration: {
  75823. name: string;
  75824. shader: string;
  75825. };
  75826. }
  75827. declare module BABYLON {
  75828. /** @hidden */
  75829. export var morphTargetsVertexGlobalDeclaration: {
  75830. name: string;
  75831. shader: string;
  75832. };
  75833. }
  75834. declare module BABYLON {
  75835. /** @hidden */
  75836. export var morphTargetsVertexDeclaration: {
  75837. name: string;
  75838. shader: string;
  75839. };
  75840. }
  75841. declare module BABYLON {
  75842. /** @hidden */
  75843. export var instancesDeclaration: {
  75844. name: string;
  75845. shader: string;
  75846. };
  75847. }
  75848. declare module BABYLON {
  75849. /** @hidden */
  75850. export var helperFunctions: {
  75851. name: string;
  75852. shader: string;
  75853. };
  75854. }
  75855. declare module BABYLON {
  75856. /** @hidden */
  75857. export var morphTargetsVertex: {
  75858. name: string;
  75859. shader: string;
  75860. };
  75861. }
  75862. declare module BABYLON {
  75863. /** @hidden */
  75864. export var instancesVertex: {
  75865. name: string;
  75866. shader: string;
  75867. };
  75868. }
  75869. declare module BABYLON {
  75870. /** @hidden */
  75871. export var bonesVertex: {
  75872. name: string;
  75873. shader: string;
  75874. };
  75875. }
  75876. declare module BABYLON {
  75877. /** @hidden */
  75878. export var shadowMapVertexShader: {
  75879. name: string;
  75880. shader: string;
  75881. };
  75882. }
  75883. declare module BABYLON {
  75884. /** @hidden */
  75885. export var depthBoxBlurPixelShader: {
  75886. name: string;
  75887. shader: string;
  75888. };
  75889. }
  75890. declare module BABYLON {
  75891. /**
  75892. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75893. */
  75894. export interface ICustomShaderOptions {
  75895. /**
  75896. * Gets or sets the custom shader name to use
  75897. */
  75898. shaderName: string;
  75899. /**
  75900. * The list of attribute names used in the shader
  75901. */
  75902. attributes?: string[];
  75903. /**
  75904. * The list of unifrom names used in the shader
  75905. */
  75906. uniforms?: string[];
  75907. /**
  75908. * The list of sampler names used in the shader
  75909. */
  75910. samplers?: string[];
  75911. /**
  75912. * The list of defines used in the shader
  75913. */
  75914. defines?: string[];
  75915. }
  75916. /**
  75917. * Interface to implement to create a shadow generator compatible with BJS.
  75918. */
  75919. export interface IShadowGenerator {
  75920. /**
  75921. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75922. * @returns The render target texture if present otherwise, null
  75923. */
  75924. getShadowMap(): Nullable<RenderTargetTexture>;
  75925. /**
  75926. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75927. * @returns The render target texture if the shadow map is present otherwise, null
  75928. */
  75929. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75930. /**
  75931. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75932. * @param subMesh The submesh we want to render in the shadow map
  75933. * @param useInstances Defines wether will draw in the map using instances
  75934. * @returns true if ready otherwise, false
  75935. */
  75936. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75937. /**
  75938. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75939. * @param defines Defines of the material we want to update
  75940. * @param lightIndex Index of the light in the enabled light list of the material
  75941. */
  75942. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75943. /**
  75944. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75945. * defined in the generator but impacting the effect).
  75946. * It implies the unifroms available on the materials are the standard BJS ones.
  75947. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75948. * @param effect The effect we are binfing the information for
  75949. */
  75950. bindShadowLight(lightIndex: string, effect: Effect): void;
  75951. /**
  75952. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75953. * (eq to shadow prjection matrix * light transform matrix)
  75954. * @returns The transform matrix used to create the shadow map
  75955. */
  75956. getTransformMatrix(): Matrix;
  75957. /**
  75958. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75959. * Cube and 2D textures for instance.
  75960. */
  75961. recreateShadowMap(): void;
  75962. /**
  75963. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75964. * @param onCompiled Callback triggered at the and of the effects compilation
  75965. * @param options Sets of optional options forcing the compilation with different modes
  75966. */
  75967. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75968. useInstances: boolean;
  75969. }>): void;
  75970. /**
  75971. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75972. * @param options Sets of optional options forcing the compilation with different modes
  75973. * @returns A promise that resolves when the compilation completes
  75974. */
  75975. forceCompilationAsync(options?: Partial<{
  75976. useInstances: boolean;
  75977. }>): Promise<void>;
  75978. /**
  75979. * Serializes the shadow generator setup to a json object.
  75980. * @returns The serialized JSON object
  75981. */
  75982. serialize(): any;
  75983. /**
  75984. * Disposes the Shadow map and related Textures and effects.
  75985. */
  75986. dispose(): void;
  75987. }
  75988. /**
  75989. * Default implementation IShadowGenerator.
  75990. * This is the main object responsible of generating shadows in the framework.
  75991. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75992. */
  75993. export class ShadowGenerator implements IShadowGenerator {
  75994. /**
  75995. * Shadow generator mode None: no filtering applied.
  75996. */
  75997. static readonly FILTER_NONE: number;
  75998. /**
  75999. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76000. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76001. */
  76002. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76003. /**
  76004. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76005. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76006. */
  76007. static readonly FILTER_POISSONSAMPLING: number;
  76008. /**
  76009. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76010. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76011. */
  76012. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76013. /**
  76014. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76015. * edge artifacts on steep falloff.
  76016. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76017. */
  76018. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76019. /**
  76020. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76021. * edge artifacts on steep falloff.
  76022. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76023. */
  76024. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76025. /**
  76026. * Shadow generator mode PCF: Percentage Closer Filtering
  76027. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76028. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76029. */
  76030. static readonly FILTER_PCF: number;
  76031. /**
  76032. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76033. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76034. * Contact Hardening
  76035. */
  76036. static readonly FILTER_PCSS: number;
  76037. /**
  76038. * Reserved for PCF and PCSS
  76039. * Highest Quality.
  76040. *
  76041. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76042. *
  76043. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76044. */
  76045. static readonly QUALITY_HIGH: number;
  76046. /**
  76047. * Reserved for PCF and PCSS
  76048. * Good tradeoff for quality/perf cross devices
  76049. *
  76050. * Execute PCF on a 3*3 kernel.
  76051. *
  76052. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76053. */
  76054. static readonly QUALITY_MEDIUM: number;
  76055. /**
  76056. * Reserved for PCF and PCSS
  76057. * The lowest quality but the fastest.
  76058. *
  76059. * Execute PCF on a 1*1 kernel.
  76060. *
  76061. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76062. */
  76063. static readonly QUALITY_LOW: number;
  76064. /** Gets or sets the custom shader name to use */
  76065. customShaderOptions: ICustomShaderOptions;
  76066. /**
  76067. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76068. */
  76069. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76070. /**
  76071. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76072. */
  76073. onAfterShadowMapRenderObservable: Observable<Effect>;
  76074. /**
  76075. * Observable triggered before a mesh is rendered in the shadow map.
  76076. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76077. */
  76078. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76079. /**
  76080. * Observable triggered after a mesh is rendered in the shadow map.
  76081. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76082. */
  76083. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76084. private _bias;
  76085. /**
  76086. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76087. */
  76088. /**
  76089. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76090. */
  76091. bias: number;
  76092. private _normalBias;
  76093. /**
  76094. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76095. */
  76096. /**
  76097. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76098. */
  76099. normalBias: number;
  76100. private _blurBoxOffset;
  76101. /**
  76102. * Gets the blur box offset: offset applied during the blur pass.
  76103. * Only useful if useKernelBlur = false
  76104. */
  76105. /**
  76106. * Sets the blur box offset: offset applied during the blur pass.
  76107. * Only useful if useKernelBlur = false
  76108. */
  76109. blurBoxOffset: number;
  76110. private _blurScale;
  76111. /**
  76112. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76113. * 2 means half of the size.
  76114. */
  76115. /**
  76116. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76117. * 2 means half of the size.
  76118. */
  76119. blurScale: number;
  76120. private _blurKernel;
  76121. /**
  76122. * Gets the blur kernel: kernel size of the blur pass.
  76123. * Only useful if useKernelBlur = true
  76124. */
  76125. /**
  76126. * Sets the blur kernel: kernel size of the blur pass.
  76127. * Only useful if useKernelBlur = true
  76128. */
  76129. blurKernel: number;
  76130. private _useKernelBlur;
  76131. /**
  76132. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76133. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76134. */
  76135. /**
  76136. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76137. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76138. */
  76139. useKernelBlur: boolean;
  76140. private _depthScale;
  76141. /**
  76142. * Gets the depth scale used in ESM mode.
  76143. */
  76144. /**
  76145. * Sets the depth scale used in ESM mode.
  76146. * This can override the scale stored on the light.
  76147. */
  76148. depthScale: number;
  76149. private _filter;
  76150. /**
  76151. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76152. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76153. */
  76154. /**
  76155. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76156. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76157. */
  76158. filter: number;
  76159. /**
  76160. * Gets if the current filter is set to Poisson Sampling.
  76161. */
  76162. /**
  76163. * Sets the current filter to Poisson Sampling.
  76164. */
  76165. usePoissonSampling: boolean;
  76166. /**
  76167. * Gets if the current filter is set to ESM.
  76168. */
  76169. /**
  76170. * Sets the current filter is to ESM.
  76171. */
  76172. useExponentialShadowMap: boolean;
  76173. /**
  76174. * Gets if the current filter is set to filtered ESM.
  76175. */
  76176. /**
  76177. * Gets if the current filter is set to filtered ESM.
  76178. */
  76179. useBlurExponentialShadowMap: boolean;
  76180. /**
  76181. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76182. * exponential to prevent steep falloff artifacts).
  76183. */
  76184. /**
  76185. * Sets the current filter to "close ESM" (using the inverse of the
  76186. * exponential to prevent steep falloff artifacts).
  76187. */
  76188. useCloseExponentialShadowMap: boolean;
  76189. /**
  76190. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76191. * exponential to prevent steep falloff artifacts).
  76192. */
  76193. /**
  76194. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76195. * exponential to prevent steep falloff artifacts).
  76196. */
  76197. useBlurCloseExponentialShadowMap: boolean;
  76198. /**
  76199. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76200. */
  76201. /**
  76202. * Sets the current filter to "PCF" (percentage closer filtering).
  76203. */
  76204. usePercentageCloserFiltering: boolean;
  76205. private _filteringQuality;
  76206. /**
  76207. * Gets the PCF or PCSS Quality.
  76208. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76209. */
  76210. /**
  76211. * Sets the PCF or PCSS Quality.
  76212. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76213. */
  76214. filteringQuality: number;
  76215. /**
  76216. * Gets if the current filter is set to "PCSS" (contact hardening).
  76217. */
  76218. /**
  76219. * Sets the current filter to "PCSS" (contact hardening).
  76220. */
  76221. useContactHardeningShadow: boolean;
  76222. private _contactHardeningLightSizeUVRatio;
  76223. /**
  76224. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76225. * Using a ratio helps keeping shape stability independently of the map size.
  76226. *
  76227. * It does not account for the light projection as it was having too much
  76228. * instability during the light setup or during light position changes.
  76229. *
  76230. * Only valid if useContactHardeningShadow is true.
  76231. */
  76232. /**
  76233. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76234. * Using a ratio helps keeping shape stability independently of the map size.
  76235. *
  76236. * It does not account for the light projection as it was having too much
  76237. * instability during the light setup or during light position changes.
  76238. *
  76239. * Only valid if useContactHardeningShadow is true.
  76240. */
  76241. contactHardeningLightSizeUVRatio: number;
  76242. private _darkness;
  76243. /** Gets or sets the actual darkness of a shadow */
  76244. darkness: number;
  76245. /**
  76246. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76247. * 0 means strongest and 1 would means no shadow.
  76248. * @returns the darkness.
  76249. */
  76250. getDarkness(): number;
  76251. /**
  76252. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76253. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76254. * @returns the shadow generator allowing fluent coding.
  76255. */
  76256. setDarkness(darkness: number): ShadowGenerator;
  76257. private _transparencyShadow;
  76258. /** Gets or sets the ability to have transparent shadow */
  76259. transparencyShadow: boolean;
  76260. /**
  76261. * Sets the ability to have transparent shadow (boolean).
  76262. * @param transparent True if transparent else False
  76263. * @returns the shadow generator allowing fluent coding
  76264. */
  76265. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76266. private _shadowMap;
  76267. private _shadowMap2;
  76268. /**
  76269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76270. * @returns The render target texture if present otherwise, null
  76271. */
  76272. getShadowMap(): Nullable<RenderTargetTexture>;
  76273. /**
  76274. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76275. * @returns The render target texture if the shadow map is present otherwise, null
  76276. */
  76277. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76278. /**
  76279. * Gets the class name of that object
  76280. * @returns "ShadowGenerator"
  76281. */
  76282. getClassName(): string;
  76283. /**
  76284. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76285. * @param mesh Mesh to add
  76286. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76287. * @returns the Shadow Generator itself
  76288. */
  76289. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76290. /**
  76291. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76292. * @param mesh Mesh to remove
  76293. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76294. * @returns the Shadow Generator itself
  76295. */
  76296. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76297. /**
  76298. * Controls the extent to which the shadows fade out at the edge of the frustum
  76299. * Used only by directionals and spots
  76300. */
  76301. frustumEdgeFalloff: number;
  76302. private _light;
  76303. /**
  76304. * Returns the associated light object.
  76305. * @returns the light generating the shadow
  76306. */
  76307. getLight(): IShadowLight;
  76308. /**
  76309. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76310. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76311. * It might on the other hand introduce peter panning.
  76312. */
  76313. forceBackFacesOnly: boolean;
  76314. private _scene;
  76315. private _lightDirection;
  76316. private _effect;
  76317. private _viewMatrix;
  76318. private _projectionMatrix;
  76319. private _transformMatrix;
  76320. private _cachedPosition;
  76321. private _cachedDirection;
  76322. private _cachedDefines;
  76323. private _currentRenderID;
  76324. private _boxBlurPostprocess;
  76325. private _kernelBlurXPostprocess;
  76326. private _kernelBlurYPostprocess;
  76327. private _blurPostProcesses;
  76328. private _mapSize;
  76329. private _currentFaceIndex;
  76330. private _currentFaceIndexCache;
  76331. private _textureType;
  76332. private _defaultTextureMatrix;
  76333. /** @hidden */
  76334. static _SceneComponentInitialization: (scene: Scene) => void;
  76335. /**
  76336. * Creates a ShadowGenerator object.
  76337. * A ShadowGenerator is the required tool to use the shadows.
  76338. * Each light casting shadows needs to use its own ShadowGenerator.
  76339. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76340. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76341. * @param light The light object generating the shadows.
  76342. * @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.
  76343. */
  76344. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76345. private _initializeGenerator;
  76346. private _initializeShadowMap;
  76347. private _initializeBlurRTTAndPostProcesses;
  76348. private _renderForShadowMap;
  76349. private _renderSubMeshForShadowMap;
  76350. private _applyFilterValues;
  76351. /**
  76352. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76353. * @param onCompiled Callback triggered at the and of the effects compilation
  76354. * @param options Sets of optional options forcing the compilation with different modes
  76355. */
  76356. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76357. useInstances: boolean;
  76358. }>): void;
  76359. /**
  76360. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76361. * @param options Sets of optional options forcing the compilation with different modes
  76362. * @returns A promise that resolves when the compilation completes
  76363. */
  76364. forceCompilationAsync(options?: Partial<{
  76365. useInstances: boolean;
  76366. }>): Promise<void>;
  76367. /**
  76368. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76369. * @param subMesh The submesh we want to render in the shadow map
  76370. * @param useInstances Defines wether will draw in the map using instances
  76371. * @returns true if ready otherwise, false
  76372. */
  76373. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76374. /**
  76375. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76376. * @param defines Defines of the material we want to update
  76377. * @param lightIndex Index of the light in the enabled light list of the material
  76378. */
  76379. prepareDefines(defines: any, lightIndex: number): void;
  76380. /**
  76381. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76382. * defined in the generator but impacting the effect).
  76383. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76384. * @param effect The effect we are binfing the information for
  76385. */
  76386. bindShadowLight(lightIndex: string, effect: Effect): void;
  76387. /**
  76388. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76389. * (eq to shadow prjection matrix * light transform matrix)
  76390. * @returns The transform matrix used to create the shadow map
  76391. */
  76392. getTransformMatrix(): Matrix;
  76393. /**
  76394. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76395. * Cube and 2D textures for instance.
  76396. */
  76397. recreateShadowMap(): void;
  76398. private _disposeBlurPostProcesses;
  76399. private _disposeRTTandPostProcesses;
  76400. /**
  76401. * Disposes the ShadowGenerator.
  76402. * Returns nothing.
  76403. */
  76404. dispose(): void;
  76405. /**
  76406. * Serializes the shadow generator setup to a json object.
  76407. * @returns The serialized JSON object
  76408. */
  76409. serialize(): any;
  76410. /**
  76411. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76412. * @param parsedShadowGenerator The JSON object to parse
  76413. * @param scene The scene to create the shadow map for
  76414. * @returns The parsed shadow generator
  76415. */
  76416. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76417. }
  76418. }
  76419. declare module BABYLON {
  76420. /**
  76421. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76422. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76423. * 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.
  76424. */
  76425. export abstract class Light extends Node {
  76426. /**
  76427. * Falloff Default: light is falling off following the material specification:
  76428. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76429. */
  76430. static readonly FALLOFF_DEFAULT: number;
  76431. /**
  76432. * Falloff Physical: light is falling off following the inverse squared distance law.
  76433. */
  76434. static readonly FALLOFF_PHYSICAL: number;
  76435. /**
  76436. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76437. * to enhance interoperability with other engines.
  76438. */
  76439. static readonly FALLOFF_GLTF: number;
  76440. /**
  76441. * Falloff Standard: light is falling off like in the standard material
  76442. * to enhance interoperability with other materials.
  76443. */
  76444. static readonly FALLOFF_STANDARD: number;
  76445. /**
  76446. * If every light affecting the material is in this lightmapMode,
  76447. * material.lightmapTexture adds or multiplies
  76448. * (depends on material.useLightmapAsShadowmap)
  76449. * after every other light calculations.
  76450. */
  76451. static readonly LIGHTMAP_DEFAULT: number;
  76452. /**
  76453. * material.lightmapTexture as only diffuse lighting from this light
  76454. * adds only specular lighting from this light
  76455. * adds dynamic shadows
  76456. */
  76457. static readonly LIGHTMAP_SPECULAR: number;
  76458. /**
  76459. * material.lightmapTexture as only lighting
  76460. * no light calculation from this light
  76461. * only adds dynamic shadows from this light
  76462. */
  76463. static readonly LIGHTMAP_SHADOWSONLY: number;
  76464. /**
  76465. * Each light type uses the default quantity according to its type:
  76466. * point/spot lights use luminous intensity
  76467. * directional lights use illuminance
  76468. */
  76469. static readonly INTENSITYMODE_AUTOMATIC: number;
  76470. /**
  76471. * lumen (lm)
  76472. */
  76473. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76474. /**
  76475. * candela (lm/sr)
  76476. */
  76477. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76478. /**
  76479. * lux (lm/m^2)
  76480. */
  76481. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76482. /**
  76483. * nit (cd/m^2)
  76484. */
  76485. static readonly INTENSITYMODE_LUMINANCE: number;
  76486. /**
  76487. * Light type const id of the point light.
  76488. */
  76489. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76490. /**
  76491. * Light type const id of the directional light.
  76492. */
  76493. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76494. /**
  76495. * Light type const id of the spot light.
  76496. */
  76497. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76498. /**
  76499. * Light type const id of the hemispheric light.
  76500. */
  76501. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76502. /**
  76503. * Diffuse gives the basic color to an object.
  76504. */
  76505. diffuse: Color3;
  76506. /**
  76507. * Specular produces a highlight color on an object.
  76508. * Note: This is note affecting PBR materials.
  76509. */
  76510. specular: Color3;
  76511. /**
  76512. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76513. * falling off base on range or angle.
  76514. * This can be set to any values in Light.FALLOFF_x.
  76515. *
  76516. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76517. * other types of materials.
  76518. */
  76519. falloffType: number;
  76520. /**
  76521. * Strength of the light.
  76522. * Note: By default it is define in the framework own unit.
  76523. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76524. */
  76525. intensity: number;
  76526. private _range;
  76527. protected _inverseSquaredRange: number;
  76528. /**
  76529. * Defines how far from the source the light is impacting in scene units.
  76530. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76531. */
  76532. /**
  76533. * Defines how far from the source the light is impacting in scene units.
  76534. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76535. */
  76536. range: number;
  76537. /**
  76538. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76539. * of light.
  76540. */
  76541. private _photometricScale;
  76542. private _intensityMode;
  76543. /**
  76544. * Gets the photometric scale used to interpret the intensity.
  76545. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76546. */
  76547. /**
  76548. * Sets the photometric scale used to interpret the intensity.
  76549. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76550. */
  76551. intensityMode: number;
  76552. private _radius;
  76553. /**
  76554. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76555. */
  76556. /**
  76557. * sets the light radius used by PBR Materials to simulate soft area lights.
  76558. */
  76559. radius: number;
  76560. private _renderPriority;
  76561. /**
  76562. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76563. * exceeding the number allowed of the materials.
  76564. */
  76565. renderPriority: number;
  76566. private _shadowEnabled;
  76567. /**
  76568. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76569. * the current shadow generator.
  76570. */
  76571. /**
  76572. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76573. * the current shadow generator.
  76574. */
  76575. shadowEnabled: boolean;
  76576. private _includedOnlyMeshes;
  76577. /**
  76578. * Gets the only meshes impacted by this light.
  76579. */
  76580. /**
  76581. * Sets the only meshes impacted by this light.
  76582. */
  76583. includedOnlyMeshes: AbstractMesh[];
  76584. private _excludedMeshes;
  76585. /**
  76586. * Gets the meshes not impacted by this light.
  76587. */
  76588. /**
  76589. * Sets the meshes not impacted by this light.
  76590. */
  76591. excludedMeshes: AbstractMesh[];
  76592. private _excludeWithLayerMask;
  76593. /**
  76594. * Gets the layer id use to find what meshes are not impacted by the light.
  76595. * Inactive if 0
  76596. */
  76597. /**
  76598. * Sets the layer id use to find what meshes are not impacted by the light.
  76599. * Inactive if 0
  76600. */
  76601. excludeWithLayerMask: number;
  76602. private _includeOnlyWithLayerMask;
  76603. /**
  76604. * Gets the layer id use to find what meshes are impacted by the light.
  76605. * Inactive if 0
  76606. */
  76607. /**
  76608. * Sets the layer id use to find what meshes are impacted by the light.
  76609. * Inactive if 0
  76610. */
  76611. includeOnlyWithLayerMask: number;
  76612. private _lightmapMode;
  76613. /**
  76614. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76615. */
  76616. /**
  76617. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76618. */
  76619. lightmapMode: number;
  76620. /**
  76621. * Shadow generator associted to the light.
  76622. * @hidden Internal use only.
  76623. */
  76624. _shadowGenerator: Nullable<IShadowGenerator>;
  76625. /**
  76626. * @hidden Internal use only.
  76627. */
  76628. _excludedMeshesIds: string[];
  76629. /**
  76630. * @hidden Internal use only.
  76631. */
  76632. _includedOnlyMeshesIds: string[];
  76633. /**
  76634. * The current light unifom buffer.
  76635. * @hidden Internal use only.
  76636. */
  76637. _uniformBuffer: UniformBuffer;
  76638. /**
  76639. * Creates a Light object in the scene.
  76640. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76641. * @param name The firendly name of the light
  76642. * @param scene The scene the light belongs too
  76643. */
  76644. constructor(name: string, scene: Scene);
  76645. protected abstract _buildUniformLayout(): void;
  76646. /**
  76647. * Sets the passed Effect "effect" with the Light information.
  76648. * @param effect The effect to update
  76649. * @param lightIndex The index of the light in the effect to update
  76650. * @returns The light
  76651. */
  76652. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76653. /**
  76654. * Sets the passed Effect "effect" with the Light information.
  76655. * @param effect The effect to update
  76656. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76657. * @returns The light
  76658. */
  76659. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76660. /**
  76661. * Returns the string "Light".
  76662. * @returns the class name
  76663. */
  76664. getClassName(): string;
  76665. /** @hidden */
  76666. readonly _isLight: boolean;
  76667. /**
  76668. * Converts the light information to a readable string for debug purpose.
  76669. * @param fullDetails Supports for multiple levels of logging within scene loading
  76670. * @returns the human readable light info
  76671. */
  76672. toString(fullDetails?: boolean): string;
  76673. /** @hidden */
  76674. protected _syncParentEnabledState(): void;
  76675. /**
  76676. * Set the enabled state of this node.
  76677. * @param value - the new enabled state
  76678. */
  76679. setEnabled(value: boolean): void;
  76680. /**
  76681. * Returns the Light associated shadow generator if any.
  76682. * @return the associated shadow generator.
  76683. */
  76684. getShadowGenerator(): Nullable<IShadowGenerator>;
  76685. /**
  76686. * Returns a Vector3, the absolute light position in the World.
  76687. * @returns the world space position of the light
  76688. */
  76689. getAbsolutePosition(): Vector3;
  76690. /**
  76691. * Specifies if the light will affect the passed mesh.
  76692. * @param mesh The mesh to test against the light
  76693. * @return true the mesh is affected otherwise, false.
  76694. */
  76695. canAffectMesh(mesh: AbstractMesh): boolean;
  76696. /**
  76697. * Sort function to order lights for rendering.
  76698. * @param a First Light object to compare to second.
  76699. * @param b Second Light object to compare first.
  76700. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76701. */
  76702. static CompareLightsPriority(a: Light, b: Light): number;
  76703. /**
  76704. * Releases resources associated with this node.
  76705. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76706. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76707. */
  76708. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76709. /**
  76710. * Returns the light type ID (integer).
  76711. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76712. */
  76713. getTypeID(): number;
  76714. /**
  76715. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76716. * @returns the scaled intensity in intensity mode unit
  76717. */
  76718. getScaledIntensity(): number;
  76719. /**
  76720. * Returns a new Light object, named "name", from the current one.
  76721. * @param name The name of the cloned light
  76722. * @returns the new created light
  76723. */
  76724. clone(name: string): Nullable<Light>;
  76725. /**
  76726. * Serializes the current light into a Serialization object.
  76727. * @returns the serialized object.
  76728. */
  76729. serialize(): any;
  76730. /**
  76731. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76732. * This new light is named "name" and added to the passed scene.
  76733. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76734. * @param name The friendly name of the light
  76735. * @param scene The scene the new light will belong to
  76736. * @returns the constructor function
  76737. */
  76738. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76739. /**
  76740. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76741. * @param parsedLight The JSON representation of the light
  76742. * @param scene The scene to create the parsed light in
  76743. * @returns the created light after parsing
  76744. */
  76745. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76746. private _hookArrayForExcluded;
  76747. private _hookArrayForIncludedOnly;
  76748. private _resyncMeshes;
  76749. /**
  76750. * Forces the meshes to update their light related information in their rendering used effects
  76751. * @hidden Internal Use Only
  76752. */
  76753. _markMeshesAsLightDirty(): void;
  76754. /**
  76755. * Recomputes the cached photometric scale if needed.
  76756. */
  76757. private _computePhotometricScale;
  76758. /**
  76759. * Returns the Photometric Scale according to the light type and intensity mode.
  76760. */
  76761. private _getPhotometricScale;
  76762. /**
  76763. * Reorder the light in the scene according to their defined priority.
  76764. * @hidden Internal Use Only
  76765. */
  76766. _reorderLightsInScene(): void;
  76767. /**
  76768. * Prepares the list of defines specific to the light type.
  76769. * @param defines the list of defines
  76770. * @param lightIndex defines the index of the light for the effect
  76771. */
  76772. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76773. }
  76774. }
  76775. declare module BABYLON {
  76776. /**
  76777. * Interface used to define Action
  76778. */
  76779. export interface IAction {
  76780. /**
  76781. * Trigger for the action
  76782. */
  76783. trigger: number;
  76784. /** Options of the trigger */
  76785. triggerOptions: any;
  76786. /**
  76787. * Gets the trigger parameters
  76788. * @returns the trigger parameters
  76789. */
  76790. getTriggerParameter(): any;
  76791. /**
  76792. * Internal only - executes current action event
  76793. * @hidden
  76794. */
  76795. _executeCurrent(evt?: ActionEvent): void;
  76796. /**
  76797. * Serialize placeholder for child classes
  76798. * @param parent of child
  76799. * @returns the serialized object
  76800. */
  76801. serialize(parent: any): any;
  76802. /**
  76803. * Internal only
  76804. * @hidden
  76805. */
  76806. _prepare(): void;
  76807. /**
  76808. * Internal only - manager for action
  76809. * @hidden
  76810. */
  76811. _actionManager: AbstractActionManager;
  76812. /**
  76813. * Adds action to chain of actions, may be a DoNothingAction
  76814. * @param action defines the next action to execute
  76815. * @returns The action passed in
  76816. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76817. */
  76818. then(action: IAction): IAction;
  76819. }
  76820. /**
  76821. * The action to be carried out following a trigger
  76822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76823. */
  76824. export class Action implements IAction {
  76825. /** the trigger, with or without parameters, for the action */
  76826. triggerOptions: any;
  76827. /**
  76828. * Trigger for the action
  76829. */
  76830. trigger: number;
  76831. /**
  76832. * Internal only - manager for action
  76833. * @hidden
  76834. */
  76835. _actionManager: ActionManager;
  76836. private _nextActiveAction;
  76837. private _child;
  76838. private _condition?;
  76839. private _triggerParameter;
  76840. /**
  76841. * An event triggered prior to action being executed.
  76842. */
  76843. onBeforeExecuteObservable: Observable<Action>;
  76844. /**
  76845. * Creates a new Action
  76846. * @param triggerOptions the trigger, with or without parameters, for the action
  76847. * @param condition an optional determinant of action
  76848. */
  76849. constructor(
  76850. /** the trigger, with or without parameters, for the action */
  76851. triggerOptions: any, condition?: Condition);
  76852. /**
  76853. * Internal only
  76854. * @hidden
  76855. */
  76856. _prepare(): void;
  76857. /**
  76858. * Gets the trigger parameters
  76859. * @returns the trigger parameters
  76860. */
  76861. getTriggerParameter(): any;
  76862. /**
  76863. * Internal only - executes current action event
  76864. * @hidden
  76865. */
  76866. _executeCurrent(evt?: ActionEvent): void;
  76867. /**
  76868. * Execute placeholder for child classes
  76869. * @param evt optional action event
  76870. */
  76871. execute(evt?: ActionEvent): void;
  76872. /**
  76873. * Skips to next active action
  76874. */
  76875. skipToNextActiveAction(): void;
  76876. /**
  76877. * Adds action to chain of actions, may be a DoNothingAction
  76878. * @param action defines the next action to execute
  76879. * @returns The action passed in
  76880. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76881. */
  76882. then(action: Action): Action;
  76883. /**
  76884. * Internal only
  76885. * @hidden
  76886. */
  76887. _getProperty(propertyPath: string): string;
  76888. /**
  76889. * Internal only
  76890. * @hidden
  76891. */
  76892. _getEffectiveTarget(target: any, propertyPath: string): any;
  76893. /**
  76894. * Serialize placeholder for child classes
  76895. * @param parent of child
  76896. * @returns the serialized object
  76897. */
  76898. serialize(parent: any): any;
  76899. /**
  76900. * Internal only called by serialize
  76901. * @hidden
  76902. */
  76903. protected _serialize(serializedAction: any, parent?: any): any;
  76904. /**
  76905. * Internal only
  76906. * @hidden
  76907. */
  76908. static _SerializeValueAsString: (value: any) => string;
  76909. /**
  76910. * Internal only
  76911. * @hidden
  76912. */
  76913. static _GetTargetProperty: (target: Node | Scene) => {
  76914. name: string;
  76915. targetType: string;
  76916. value: string;
  76917. };
  76918. }
  76919. }
  76920. declare module BABYLON {
  76921. /**
  76922. * A Condition applied to an Action
  76923. */
  76924. export class Condition {
  76925. /**
  76926. * Internal only - manager for action
  76927. * @hidden
  76928. */
  76929. _actionManager: ActionManager;
  76930. /**
  76931. * Internal only
  76932. * @hidden
  76933. */
  76934. _evaluationId: number;
  76935. /**
  76936. * Internal only
  76937. * @hidden
  76938. */
  76939. _currentResult: boolean;
  76940. /**
  76941. * Creates a new Condition
  76942. * @param actionManager the manager of the action the condition is applied to
  76943. */
  76944. constructor(actionManager: ActionManager);
  76945. /**
  76946. * Check if the current condition is valid
  76947. * @returns a boolean
  76948. */
  76949. isValid(): boolean;
  76950. /**
  76951. * Internal only
  76952. * @hidden
  76953. */
  76954. _getProperty(propertyPath: string): string;
  76955. /**
  76956. * Internal only
  76957. * @hidden
  76958. */
  76959. _getEffectiveTarget(target: any, propertyPath: string): any;
  76960. /**
  76961. * Serialize placeholder for child classes
  76962. * @returns the serialized object
  76963. */
  76964. serialize(): any;
  76965. /**
  76966. * Internal only
  76967. * @hidden
  76968. */
  76969. protected _serialize(serializedCondition: any): any;
  76970. }
  76971. /**
  76972. * Defines specific conditional operators as extensions of Condition
  76973. */
  76974. export class ValueCondition extends Condition {
  76975. /** path to specify the property of the target the conditional operator uses */
  76976. propertyPath: string;
  76977. /** the value compared by the conditional operator against the current value of the property */
  76978. value: any;
  76979. /** the conditional operator, default ValueCondition.IsEqual */
  76980. operator: number;
  76981. /**
  76982. * Internal only
  76983. * @hidden
  76984. */
  76985. private static _IsEqual;
  76986. /**
  76987. * Internal only
  76988. * @hidden
  76989. */
  76990. private static _IsDifferent;
  76991. /**
  76992. * Internal only
  76993. * @hidden
  76994. */
  76995. private static _IsGreater;
  76996. /**
  76997. * Internal only
  76998. * @hidden
  76999. */
  77000. private static _IsLesser;
  77001. /**
  77002. * returns the number for IsEqual
  77003. */
  77004. static readonly IsEqual: number;
  77005. /**
  77006. * Returns the number for IsDifferent
  77007. */
  77008. static readonly IsDifferent: number;
  77009. /**
  77010. * Returns the number for IsGreater
  77011. */
  77012. static readonly IsGreater: number;
  77013. /**
  77014. * Returns the number for IsLesser
  77015. */
  77016. static readonly IsLesser: number;
  77017. /**
  77018. * Internal only The action manager for the condition
  77019. * @hidden
  77020. */
  77021. _actionManager: ActionManager;
  77022. /**
  77023. * Internal only
  77024. * @hidden
  77025. */
  77026. private _target;
  77027. /**
  77028. * Internal only
  77029. * @hidden
  77030. */
  77031. private _effectiveTarget;
  77032. /**
  77033. * Internal only
  77034. * @hidden
  77035. */
  77036. private _property;
  77037. /**
  77038. * Creates a new ValueCondition
  77039. * @param actionManager manager for the action the condition applies to
  77040. * @param target for the action
  77041. * @param propertyPath path to specify the property of the target the conditional operator uses
  77042. * @param value the value compared by the conditional operator against the current value of the property
  77043. * @param operator the conditional operator, default ValueCondition.IsEqual
  77044. */
  77045. constructor(actionManager: ActionManager, target: any,
  77046. /** path to specify the property of the target the conditional operator uses */
  77047. propertyPath: string,
  77048. /** the value compared by the conditional operator against the current value of the property */
  77049. value: any,
  77050. /** the conditional operator, default ValueCondition.IsEqual */
  77051. operator?: number);
  77052. /**
  77053. * Compares the given value with the property value for the specified conditional operator
  77054. * @returns the result of the comparison
  77055. */
  77056. isValid(): boolean;
  77057. /**
  77058. * Serialize the ValueCondition into a JSON compatible object
  77059. * @returns serialization object
  77060. */
  77061. serialize(): any;
  77062. /**
  77063. * Gets the name of the conditional operator for the ValueCondition
  77064. * @param operator the conditional operator
  77065. * @returns the name
  77066. */
  77067. static GetOperatorName(operator: number): string;
  77068. }
  77069. /**
  77070. * Defines a predicate condition as an extension of Condition
  77071. */
  77072. export class PredicateCondition extends Condition {
  77073. /** defines the predicate function used to validate the condition */
  77074. predicate: () => boolean;
  77075. /**
  77076. * Internal only - manager for action
  77077. * @hidden
  77078. */
  77079. _actionManager: ActionManager;
  77080. /**
  77081. * Creates a new PredicateCondition
  77082. * @param actionManager manager for the action the condition applies to
  77083. * @param predicate defines the predicate function used to validate the condition
  77084. */
  77085. constructor(actionManager: ActionManager,
  77086. /** defines the predicate function used to validate the condition */
  77087. predicate: () => boolean);
  77088. /**
  77089. * @returns the validity of the predicate condition
  77090. */
  77091. isValid(): boolean;
  77092. }
  77093. /**
  77094. * Defines a state condition as an extension of Condition
  77095. */
  77096. export class StateCondition extends Condition {
  77097. /** Value to compare with target state */
  77098. value: string;
  77099. /**
  77100. * Internal only - manager for action
  77101. * @hidden
  77102. */
  77103. _actionManager: ActionManager;
  77104. /**
  77105. * Internal only
  77106. * @hidden
  77107. */
  77108. private _target;
  77109. /**
  77110. * Creates a new StateCondition
  77111. * @param actionManager manager for the action the condition applies to
  77112. * @param target of the condition
  77113. * @param value to compare with target state
  77114. */
  77115. constructor(actionManager: ActionManager, target: any,
  77116. /** Value to compare with target state */
  77117. value: string);
  77118. /**
  77119. * Gets a boolean indicating if the current condition is met
  77120. * @returns the validity of the state
  77121. */
  77122. isValid(): boolean;
  77123. /**
  77124. * Serialize the StateCondition into a JSON compatible object
  77125. * @returns serialization object
  77126. */
  77127. serialize(): any;
  77128. }
  77129. }
  77130. declare module BABYLON {
  77131. /**
  77132. * This defines an action responsible to toggle a boolean once triggered.
  77133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77134. */
  77135. export class SwitchBooleanAction extends Action {
  77136. /**
  77137. * The path to the boolean property in the target object
  77138. */
  77139. propertyPath: string;
  77140. private _target;
  77141. private _effectiveTarget;
  77142. private _property;
  77143. /**
  77144. * Instantiate the action
  77145. * @param triggerOptions defines the trigger options
  77146. * @param target defines the object containing the boolean
  77147. * @param propertyPath defines the path to the boolean property in the target object
  77148. * @param condition defines the trigger related conditions
  77149. */
  77150. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77151. /** @hidden */
  77152. _prepare(): void;
  77153. /**
  77154. * Execute the action toggle the boolean value.
  77155. */
  77156. execute(): void;
  77157. /**
  77158. * Serializes the actions and its related information.
  77159. * @param parent defines the object to serialize in
  77160. * @returns the serialized object
  77161. */
  77162. serialize(parent: any): any;
  77163. }
  77164. /**
  77165. * This defines an action responsible to set a the state field of the target
  77166. * to a desired value once triggered.
  77167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77168. */
  77169. export class SetStateAction extends Action {
  77170. /**
  77171. * The value to store in the state field.
  77172. */
  77173. value: string;
  77174. private _target;
  77175. /**
  77176. * Instantiate the action
  77177. * @param triggerOptions defines the trigger options
  77178. * @param target defines the object containing the state property
  77179. * @param value defines the value to store in the state field
  77180. * @param condition defines the trigger related conditions
  77181. */
  77182. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77183. /**
  77184. * Execute the action and store the value on the target state property.
  77185. */
  77186. execute(): void;
  77187. /**
  77188. * Serializes the actions and its related information.
  77189. * @param parent defines the object to serialize in
  77190. * @returns the serialized object
  77191. */
  77192. serialize(parent: any): any;
  77193. }
  77194. /**
  77195. * This defines an action responsible to set a property of the target
  77196. * to a desired value once triggered.
  77197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77198. */
  77199. export class SetValueAction extends Action {
  77200. /**
  77201. * The path of the property to set in the target.
  77202. */
  77203. propertyPath: string;
  77204. /**
  77205. * The value to set in the property
  77206. */
  77207. value: any;
  77208. private _target;
  77209. private _effectiveTarget;
  77210. private _property;
  77211. /**
  77212. * Instantiate the action
  77213. * @param triggerOptions defines the trigger options
  77214. * @param target defines the object containing the property
  77215. * @param propertyPath defines the path of the property to set in the target
  77216. * @param value defines the value to set in the property
  77217. * @param condition defines the trigger related conditions
  77218. */
  77219. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77220. /** @hidden */
  77221. _prepare(): void;
  77222. /**
  77223. * Execute the action and set the targetted property to the desired value.
  77224. */
  77225. execute(): void;
  77226. /**
  77227. * Serializes the actions and its related information.
  77228. * @param parent defines the object to serialize in
  77229. * @returns the serialized object
  77230. */
  77231. serialize(parent: any): any;
  77232. }
  77233. /**
  77234. * This defines an action responsible to increment the target value
  77235. * to a desired value once triggered.
  77236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77237. */
  77238. export class IncrementValueAction extends Action {
  77239. /**
  77240. * The path of the property to increment in the target.
  77241. */
  77242. propertyPath: string;
  77243. /**
  77244. * The value we should increment the property by.
  77245. */
  77246. value: any;
  77247. private _target;
  77248. private _effectiveTarget;
  77249. private _property;
  77250. /**
  77251. * Instantiate the action
  77252. * @param triggerOptions defines the trigger options
  77253. * @param target defines the object containing the property
  77254. * @param propertyPath defines the path of the property to increment in the target
  77255. * @param value defines the value value we should increment the property by
  77256. * @param condition defines the trigger related conditions
  77257. */
  77258. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77259. /** @hidden */
  77260. _prepare(): void;
  77261. /**
  77262. * Execute the action and increment the target of the value amount.
  77263. */
  77264. execute(): void;
  77265. /**
  77266. * Serializes the actions and its related information.
  77267. * @param parent defines the object to serialize in
  77268. * @returns the serialized object
  77269. */
  77270. serialize(parent: any): any;
  77271. }
  77272. /**
  77273. * This defines an action responsible to start an animation once triggered.
  77274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77275. */
  77276. export class PlayAnimationAction extends Action {
  77277. /**
  77278. * Where the animation should start (animation frame)
  77279. */
  77280. from: number;
  77281. /**
  77282. * Where the animation should stop (animation frame)
  77283. */
  77284. to: number;
  77285. /**
  77286. * Define if the animation should loop or stop after the first play.
  77287. */
  77288. loop?: boolean;
  77289. private _target;
  77290. /**
  77291. * Instantiate the action
  77292. * @param triggerOptions defines the trigger options
  77293. * @param target defines the target animation or animation name
  77294. * @param from defines from where the animation should start (animation frame)
  77295. * @param end defines where the animation should stop (animation frame)
  77296. * @param loop defines if the animation should loop or stop after the first play
  77297. * @param condition defines the trigger related conditions
  77298. */
  77299. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77300. /** @hidden */
  77301. _prepare(): void;
  77302. /**
  77303. * Execute the action and play the animation.
  77304. */
  77305. execute(): void;
  77306. /**
  77307. * Serializes the actions and its related information.
  77308. * @param parent defines the object to serialize in
  77309. * @returns the serialized object
  77310. */
  77311. serialize(parent: any): any;
  77312. }
  77313. /**
  77314. * This defines an action responsible to stop an animation once triggered.
  77315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77316. */
  77317. export class StopAnimationAction extends Action {
  77318. private _target;
  77319. /**
  77320. * Instantiate the action
  77321. * @param triggerOptions defines the trigger options
  77322. * @param target defines the target animation or animation name
  77323. * @param condition defines the trigger related conditions
  77324. */
  77325. constructor(triggerOptions: any, target: any, condition?: Condition);
  77326. /** @hidden */
  77327. _prepare(): void;
  77328. /**
  77329. * Execute the action and stop the animation.
  77330. */
  77331. execute(): void;
  77332. /**
  77333. * Serializes the actions and its related information.
  77334. * @param parent defines the object to serialize in
  77335. * @returns the serialized object
  77336. */
  77337. serialize(parent: any): any;
  77338. }
  77339. /**
  77340. * This defines an action responsible that does nothing once triggered.
  77341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77342. */
  77343. export class DoNothingAction extends Action {
  77344. /**
  77345. * Instantiate the action
  77346. * @param triggerOptions defines the trigger options
  77347. * @param condition defines the trigger related conditions
  77348. */
  77349. constructor(triggerOptions?: any, condition?: Condition);
  77350. /**
  77351. * Execute the action and do nothing.
  77352. */
  77353. execute(): void;
  77354. /**
  77355. * Serializes the actions and its related information.
  77356. * @param parent defines the object to serialize in
  77357. * @returns the serialized object
  77358. */
  77359. serialize(parent: any): any;
  77360. }
  77361. /**
  77362. * This defines an action responsible to trigger several actions once triggered.
  77363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77364. */
  77365. export class CombineAction extends Action {
  77366. /**
  77367. * The list of aggregated animations to run.
  77368. */
  77369. children: Action[];
  77370. /**
  77371. * Instantiate the action
  77372. * @param triggerOptions defines the trigger options
  77373. * @param children defines the list of aggregated animations to run
  77374. * @param condition defines the trigger related conditions
  77375. */
  77376. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77377. /** @hidden */
  77378. _prepare(): void;
  77379. /**
  77380. * Execute the action and executes all the aggregated actions.
  77381. */
  77382. execute(evt: ActionEvent): void;
  77383. /**
  77384. * Serializes the actions and its related information.
  77385. * @param parent defines the object to serialize in
  77386. * @returns the serialized object
  77387. */
  77388. serialize(parent: any): any;
  77389. }
  77390. /**
  77391. * This defines an action responsible to run code (external event) once triggered.
  77392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77393. */
  77394. export class ExecuteCodeAction extends Action {
  77395. /**
  77396. * The callback function to run.
  77397. */
  77398. func: (evt: ActionEvent) => void;
  77399. /**
  77400. * Instantiate the action
  77401. * @param triggerOptions defines the trigger options
  77402. * @param func defines the callback function to run
  77403. * @param condition defines the trigger related conditions
  77404. */
  77405. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77406. /**
  77407. * Execute the action and run the attached code.
  77408. */
  77409. execute(evt: ActionEvent): void;
  77410. }
  77411. /**
  77412. * This defines an action responsible to set the parent property of the target once triggered.
  77413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77414. */
  77415. export class SetParentAction extends Action {
  77416. private _parent;
  77417. private _target;
  77418. /**
  77419. * Instantiate the action
  77420. * @param triggerOptions defines the trigger options
  77421. * @param target defines the target containing the parent property
  77422. * @param parent defines from where the animation should start (animation frame)
  77423. * @param condition defines the trigger related conditions
  77424. */
  77425. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77426. /** @hidden */
  77427. _prepare(): void;
  77428. /**
  77429. * Execute the action and set the parent property.
  77430. */
  77431. execute(): void;
  77432. /**
  77433. * Serializes the actions and its related information.
  77434. * @param parent defines the object to serialize in
  77435. * @returns the serialized object
  77436. */
  77437. serialize(parent: any): any;
  77438. }
  77439. }
  77440. declare module BABYLON {
  77441. /**
  77442. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77443. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77445. */
  77446. export class ActionManager extends AbstractActionManager {
  77447. /**
  77448. * Nothing
  77449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77450. */
  77451. static readonly NothingTrigger: number;
  77452. /**
  77453. * On pick
  77454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77455. */
  77456. static readonly OnPickTrigger: number;
  77457. /**
  77458. * On left pick
  77459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77460. */
  77461. static readonly OnLeftPickTrigger: number;
  77462. /**
  77463. * On right pick
  77464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77465. */
  77466. static readonly OnRightPickTrigger: number;
  77467. /**
  77468. * On center pick
  77469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77470. */
  77471. static readonly OnCenterPickTrigger: number;
  77472. /**
  77473. * On pick down
  77474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77475. */
  77476. static readonly OnPickDownTrigger: number;
  77477. /**
  77478. * On double pick
  77479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77480. */
  77481. static readonly OnDoublePickTrigger: number;
  77482. /**
  77483. * On pick up
  77484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77485. */
  77486. static readonly OnPickUpTrigger: number;
  77487. /**
  77488. * On pick out.
  77489. * This trigger will only be raised if you also declared a OnPickDown
  77490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77491. */
  77492. static readonly OnPickOutTrigger: number;
  77493. /**
  77494. * On long press
  77495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77496. */
  77497. static readonly OnLongPressTrigger: number;
  77498. /**
  77499. * On pointer over
  77500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77501. */
  77502. static readonly OnPointerOverTrigger: number;
  77503. /**
  77504. * On pointer out
  77505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77506. */
  77507. static readonly OnPointerOutTrigger: number;
  77508. /**
  77509. * On every frame
  77510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77511. */
  77512. static readonly OnEveryFrameTrigger: number;
  77513. /**
  77514. * On intersection enter
  77515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77516. */
  77517. static readonly OnIntersectionEnterTrigger: number;
  77518. /**
  77519. * On intersection exit
  77520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77521. */
  77522. static readonly OnIntersectionExitTrigger: number;
  77523. /**
  77524. * On key down
  77525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77526. */
  77527. static readonly OnKeyDownTrigger: number;
  77528. /**
  77529. * On key up
  77530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77531. */
  77532. static readonly OnKeyUpTrigger: number;
  77533. private _scene;
  77534. /**
  77535. * Creates a new action manager
  77536. * @param scene defines the hosting scene
  77537. */
  77538. constructor(scene: Scene);
  77539. /**
  77540. * Releases all associated resources
  77541. */
  77542. dispose(): void;
  77543. /**
  77544. * Gets hosting scene
  77545. * @returns the hosting scene
  77546. */
  77547. getScene(): Scene;
  77548. /**
  77549. * Does this action manager handles actions of any of the given triggers
  77550. * @param triggers defines the triggers to be tested
  77551. * @return a boolean indicating whether one (or more) of the triggers is handled
  77552. */
  77553. hasSpecificTriggers(triggers: number[]): boolean;
  77554. /**
  77555. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77556. * speed.
  77557. * @param triggerA defines the trigger to be tested
  77558. * @param triggerB defines the trigger to be tested
  77559. * @return a boolean indicating whether one (or more) of the triggers is handled
  77560. */
  77561. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77562. /**
  77563. * Does this action manager handles actions of a given trigger
  77564. * @param trigger defines the trigger to be tested
  77565. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77566. * @return whether the trigger is handled
  77567. */
  77568. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77569. /**
  77570. * Does this action manager has pointer triggers
  77571. */
  77572. readonly hasPointerTriggers: boolean;
  77573. /**
  77574. * Does this action manager has pick triggers
  77575. */
  77576. readonly hasPickTriggers: boolean;
  77577. /**
  77578. * Registers an action to this action manager
  77579. * @param action defines the action to be registered
  77580. * @return the action amended (prepared) after registration
  77581. */
  77582. registerAction(action: IAction): Nullable<IAction>;
  77583. /**
  77584. * Unregisters an action to this action manager
  77585. * @param action defines the action to be unregistered
  77586. * @return a boolean indicating whether the action has been unregistered
  77587. */
  77588. unregisterAction(action: IAction): Boolean;
  77589. /**
  77590. * Process a specific trigger
  77591. * @param trigger defines the trigger to process
  77592. * @param evt defines the event details to be processed
  77593. */
  77594. processTrigger(trigger: number, evt?: IActionEvent): void;
  77595. /** @hidden */
  77596. _getEffectiveTarget(target: any, propertyPath: string): any;
  77597. /** @hidden */
  77598. _getProperty(propertyPath: string): string;
  77599. /**
  77600. * Serialize this manager to a JSON object
  77601. * @param name defines the property name to store this manager
  77602. * @returns a JSON representation of this manager
  77603. */
  77604. serialize(name: string): any;
  77605. /**
  77606. * Creates a new ActionManager from a JSON data
  77607. * @param parsedActions defines the JSON data to read from
  77608. * @param object defines the hosting mesh
  77609. * @param scene defines the hosting scene
  77610. */
  77611. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77612. /**
  77613. * Get a trigger name by index
  77614. * @param trigger defines the trigger index
  77615. * @returns a trigger name
  77616. */
  77617. static GetTriggerName(trigger: number): string;
  77618. }
  77619. }
  77620. declare module BABYLON {
  77621. /**
  77622. * Class representing a ray with position and direction
  77623. */
  77624. export class Ray {
  77625. /** origin point */
  77626. origin: Vector3;
  77627. /** direction */
  77628. direction: Vector3;
  77629. /** length of the ray */
  77630. length: number;
  77631. private static readonly TmpVector3;
  77632. private _tmpRay;
  77633. /**
  77634. * Creates a new ray
  77635. * @param origin origin point
  77636. * @param direction direction
  77637. * @param length length of the ray
  77638. */
  77639. constructor(
  77640. /** origin point */
  77641. origin: Vector3,
  77642. /** direction */
  77643. direction: Vector3,
  77644. /** length of the ray */
  77645. length?: number);
  77646. /**
  77647. * Checks if the ray intersects a box
  77648. * @param minimum bound of the box
  77649. * @param maximum bound of the box
  77650. * @param intersectionTreshold extra extend to be added to the box in all direction
  77651. * @returns if the box was hit
  77652. */
  77653. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77654. /**
  77655. * Checks if the ray intersects a box
  77656. * @param box the bounding box to check
  77657. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77658. * @returns if the box was hit
  77659. */
  77660. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77661. /**
  77662. * If the ray hits a sphere
  77663. * @param sphere the bounding sphere to check
  77664. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77665. * @returns true if it hits the sphere
  77666. */
  77667. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77668. /**
  77669. * If the ray hits a triange
  77670. * @param vertex0 triangle vertex
  77671. * @param vertex1 triangle vertex
  77672. * @param vertex2 triangle vertex
  77673. * @returns intersection information if hit
  77674. */
  77675. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77676. /**
  77677. * Checks if ray intersects a plane
  77678. * @param plane the plane to check
  77679. * @returns the distance away it was hit
  77680. */
  77681. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77682. /**
  77683. * Calculate the intercept of a ray on a given axis
  77684. * @param axis to check 'x' | 'y' | 'z'
  77685. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77686. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77687. */
  77688. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77689. /**
  77690. * Checks if ray intersects a mesh
  77691. * @param mesh the mesh to check
  77692. * @param fastCheck if only the bounding box should checked
  77693. * @returns picking info of the intersecton
  77694. */
  77695. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77696. /**
  77697. * Checks if ray intersects a mesh
  77698. * @param meshes the meshes to check
  77699. * @param fastCheck if only the bounding box should checked
  77700. * @param results array to store result in
  77701. * @returns Array of picking infos
  77702. */
  77703. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77704. private _comparePickingInfo;
  77705. private static smallnum;
  77706. private static rayl;
  77707. /**
  77708. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77709. * @param sega the first point of the segment to test the intersection against
  77710. * @param segb the second point of the segment to test the intersection against
  77711. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77712. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77713. */
  77714. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77715. /**
  77716. * Update the ray from viewport position
  77717. * @param x position
  77718. * @param y y position
  77719. * @param viewportWidth viewport width
  77720. * @param viewportHeight viewport height
  77721. * @param world world matrix
  77722. * @param view view matrix
  77723. * @param projection projection matrix
  77724. * @returns this ray updated
  77725. */
  77726. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77727. /**
  77728. * Creates a ray with origin and direction of 0,0,0
  77729. * @returns the new ray
  77730. */
  77731. static Zero(): Ray;
  77732. /**
  77733. * Creates a new ray from screen space and viewport
  77734. * @param x position
  77735. * @param y y position
  77736. * @param viewportWidth viewport width
  77737. * @param viewportHeight viewport height
  77738. * @param world world matrix
  77739. * @param view view matrix
  77740. * @param projection projection matrix
  77741. * @returns new ray
  77742. */
  77743. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77744. /**
  77745. * 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
  77746. * transformed to the given world matrix.
  77747. * @param origin The origin point
  77748. * @param end The end point
  77749. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77750. * @returns the new ray
  77751. */
  77752. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77753. /**
  77754. * Transforms a ray by a matrix
  77755. * @param ray ray to transform
  77756. * @param matrix matrix to apply
  77757. * @returns the resulting new ray
  77758. */
  77759. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77760. /**
  77761. * Transforms a ray by a matrix
  77762. * @param ray ray to transform
  77763. * @param matrix matrix to apply
  77764. * @param result ray to store result in
  77765. */
  77766. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77767. /**
  77768. * Unproject a ray from screen space to object space
  77769. * @param sourceX defines the screen space x coordinate to use
  77770. * @param sourceY defines the screen space y coordinate to use
  77771. * @param viewportWidth defines the current width of the viewport
  77772. * @param viewportHeight defines the current height of the viewport
  77773. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77774. * @param view defines the view matrix to use
  77775. * @param projection defines the projection matrix to use
  77776. */
  77777. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77778. }
  77779. /**
  77780. * Type used to define predicate used to select faces when a mesh intersection is detected
  77781. */
  77782. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77783. interface Scene {
  77784. /** @hidden */
  77785. _tempPickingRay: Nullable<Ray>;
  77786. /** @hidden */
  77787. _cachedRayForTransform: Ray;
  77788. /** @hidden */
  77789. _pickWithRayInverseMatrix: Matrix;
  77790. /** @hidden */
  77791. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77792. /** @hidden */
  77793. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77794. }
  77795. }
  77796. declare module BABYLON {
  77797. /**
  77798. * Groups all the scene component constants in one place to ease maintenance.
  77799. * @hidden
  77800. */
  77801. export class SceneComponentConstants {
  77802. static readonly NAME_EFFECTLAYER: string;
  77803. static readonly NAME_LAYER: string;
  77804. static readonly NAME_LENSFLARESYSTEM: string;
  77805. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77806. static readonly NAME_PARTICLESYSTEM: string;
  77807. static readonly NAME_GAMEPAD: string;
  77808. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77809. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77810. static readonly NAME_DEPTHRENDERER: string;
  77811. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77812. static readonly NAME_SPRITE: string;
  77813. static readonly NAME_OUTLINERENDERER: string;
  77814. static readonly NAME_PROCEDURALTEXTURE: string;
  77815. static readonly NAME_SHADOWGENERATOR: string;
  77816. static readonly NAME_OCTREE: string;
  77817. static readonly NAME_PHYSICSENGINE: string;
  77818. static readonly NAME_AUDIO: string;
  77819. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77820. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77821. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77822. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77823. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77824. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77825. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77826. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77827. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77828. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77829. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77830. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77831. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77832. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77833. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77834. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77835. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77836. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77837. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77838. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77839. static readonly STEP_AFTERRENDER_AUDIO: number;
  77840. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77841. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77842. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77843. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77844. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77845. static readonly STEP_POINTERMOVE_SPRITE: number;
  77846. static readonly STEP_POINTERDOWN_SPRITE: number;
  77847. static readonly STEP_POINTERUP_SPRITE: number;
  77848. }
  77849. /**
  77850. * This represents a scene component.
  77851. *
  77852. * This is used to decouple the dependency the scene is having on the different workloads like
  77853. * layers, post processes...
  77854. */
  77855. export interface ISceneComponent {
  77856. /**
  77857. * The name of the component. Each component must have a unique name.
  77858. */
  77859. name: string;
  77860. /**
  77861. * The scene the component belongs to.
  77862. */
  77863. scene: Scene;
  77864. /**
  77865. * Register the component to one instance of a scene.
  77866. */
  77867. register(): void;
  77868. /**
  77869. * Rebuilds the elements related to this component in case of
  77870. * context lost for instance.
  77871. */
  77872. rebuild(): void;
  77873. /**
  77874. * Disposes the component and the associated ressources.
  77875. */
  77876. dispose(): void;
  77877. }
  77878. /**
  77879. * This represents a SERIALIZABLE scene component.
  77880. *
  77881. * This extends Scene Component to add Serialization methods on top.
  77882. */
  77883. export interface ISceneSerializableComponent extends ISceneComponent {
  77884. /**
  77885. * Adds all the elements from the container to the scene
  77886. * @param container the container holding the elements
  77887. */
  77888. addFromContainer(container: AbstractScene): void;
  77889. /**
  77890. * Removes all the elements in the container from the scene
  77891. * @param container contains the elements to remove
  77892. * @param dispose if the removed element should be disposed (default: false)
  77893. */
  77894. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77895. /**
  77896. * Serializes the component data to the specified json object
  77897. * @param serializationObject The object to serialize to
  77898. */
  77899. serialize(serializationObject: any): void;
  77900. }
  77901. /**
  77902. * Strong typing of a Mesh related stage step action
  77903. */
  77904. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77905. /**
  77906. * Strong typing of a Evaluate Sub Mesh related stage step action
  77907. */
  77908. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77909. /**
  77910. * Strong typing of a Active Mesh related stage step action
  77911. */
  77912. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77913. /**
  77914. * Strong typing of a Camera related stage step action
  77915. */
  77916. export type CameraStageAction = (camera: Camera) => void;
  77917. /**
  77918. * Strong typing of a Camera Frame buffer related stage step action
  77919. */
  77920. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77921. /**
  77922. * Strong typing of a Render Target related stage step action
  77923. */
  77924. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77925. /**
  77926. * Strong typing of a RenderingGroup related stage step action
  77927. */
  77928. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77929. /**
  77930. * Strong typing of a Mesh Render related stage step action
  77931. */
  77932. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77933. /**
  77934. * Strong typing of a simple stage step action
  77935. */
  77936. export type SimpleStageAction = () => void;
  77937. /**
  77938. * Strong typing of a render target action.
  77939. */
  77940. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77941. /**
  77942. * Strong typing of a pointer move action.
  77943. */
  77944. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77945. /**
  77946. * Strong typing of a pointer up/down action.
  77947. */
  77948. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77949. /**
  77950. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  77951. * @hidden
  77952. */
  77953. export class Stage<T extends Function> extends Array<{
  77954. index: number;
  77955. component: ISceneComponent;
  77956. action: T;
  77957. }> {
  77958. /**
  77959. * Hide ctor from the rest of the world.
  77960. * @param items The items to add.
  77961. */
  77962. private constructor();
  77963. /**
  77964. * Creates a new Stage.
  77965. * @returns A new instance of a Stage
  77966. */
  77967. static Create<T extends Function>(): Stage<T>;
  77968. /**
  77969. * Registers a step in an ordered way in the targeted stage.
  77970. * @param index Defines the position to register the step in
  77971. * @param component Defines the component attached to the step
  77972. * @param action Defines the action to launch during the step
  77973. */
  77974. registerStep(index: number, component: ISceneComponent, action: T): void;
  77975. /**
  77976. * Clears all the steps from the stage.
  77977. */
  77978. clear(): void;
  77979. }
  77980. }
  77981. declare module BABYLON {
  77982. interface Scene {
  77983. /** @hidden */
  77984. _pointerOverSprite: Nullable<Sprite>;
  77985. /** @hidden */
  77986. _pickedDownSprite: Nullable<Sprite>;
  77987. /** @hidden */
  77988. _tempSpritePickingRay: Nullable<Ray>;
  77989. /**
  77990. * All of the sprite managers added to this scene
  77991. * @see http://doc.babylonjs.com/babylon101/sprites
  77992. */
  77993. spriteManagers: Array<ISpriteManager>;
  77994. /**
  77995. * An event triggered when sprites rendering is about to start
  77996. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77997. */
  77998. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77999. /**
  78000. * An event triggered when sprites rendering is done
  78001. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78002. */
  78003. onAfterSpritesRenderingObservable: Observable<Scene>;
  78004. /** @hidden */
  78005. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78006. /** Launch a ray to try to pick a sprite in the scene
  78007. * @param x position on screen
  78008. * @param y position on screen
  78009. * @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
  78010. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78011. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78012. * @returns a PickingInfo
  78013. */
  78014. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78015. /** Use the given ray to pick a sprite in the scene
  78016. * @param ray The ray (in world space) to use to pick meshes
  78017. * @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
  78018. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78019. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78020. * @returns a PickingInfo
  78021. */
  78022. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78023. /** @hidden */
  78024. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78025. /** Launch a ray to try to pick sprites in the scene
  78026. * @param x position on screen
  78027. * @param y position on screen
  78028. * @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
  78029. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78030. * @returns a PickingInfo array
  78031. */
  78032. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78033. /** Use the given ray to pick sprites in the scene
  78034. * @param ray The ray (in world space) to use to pick meshes
  78035. * @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
  78036. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78037. * @returns a PickingInfo array
  78038. */
  78039. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78040. /**
  78041. * Force the sprite under the pointer
  78042. * @param sprite defines the sprite to use
  78043. */
  78044. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78045. /**
  78046. * Gets the sprite under the pointer
  78047. * @returns a Sprite or null if no sprite is under the pointer
  78048. */
  78049. getPointerOverSprite(): Nullable<Sprite>;
  78050. }
  78051. /**
  78052. * Defines the sprite scene component responsible to manage sprites
  78053. * in a given scene.
  78054. */
  78055. export class SpriteSceneComponent implements ISceneComponent {
  78056. /**
  78057. * The component name helpfull to identify the component in the list of scene components.
  78058. */
  78059. readonly name: string;
  78060. /**
  78061. * The scene the component belongs to.
  78062. */
  78063. scene: Scene;
  78064. /** @hidden */
  78065. private _spritePredicate;
  78066. /**
  78067. * Creates a new instance of the component for the given scene
  78068. * @param scene Defines the scene to register the component in
  78069. */
  78070. constructor(scene: Scene);
  78071. /**
  78072. * Registers the component in a given scene
  78073. */
  78074. register(): void;
  78075. /**
  78076. * Rebuilds the elements related to this component in case of
  78077. * context lost for instance.
  78078. */
  78079. rebuild(): void;
  78080. /**
  78081. * Disposes the component and the associated ressources.
  78082. */
  78083. dispose(): void;
  78084. private _pickSpriteButKeepRay;
  78085. private _pointerMove;
  78086. private _pointerDown;
  78087. private _pointerUp;
  78088. }
  78089. }
  78090. declare module BABYLON {
  78091. /** @hidden */
  78092. export var fogFragmentDeclaration: {
  78093. name: string;
  78094. shader: string;
  78095. };
  78096. }
  78097. declare module BABYLON {
  78098. /** @hidden */
  78099. export var fogFragment: {
  78100. name: string;
  78101. shader: string;
  78102. };
  78103. }
  78104. declare module BABYLON {
  78105. /** @hidden */
  78106. export var spritesPixelShader: {
  78107. name: string;
  78108. shader: string;
  78109. };
  78110. }
  78111. declare module BABYLON {
  78112. /** @hidden */
  78113. export var fogVertexDeclaration: {
  78114. name: string;
  78115. shader: string;
  78116. };
  78117. }
  78118. declare module BABYLON {
  78119. /** @hidden */
  78120. export var spritesVertexShader: {
  78121. name: string;
  78122. shader: string;
  78123. };
  78124. }
  78125. declare module BABYLON {
  78126. /**
  78127. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78128. */
  78129. export interface ISpriteManager extends IDisposable {
  78130. /**
  78131. * Restricts the camera to viewing objects with the same layerMask.
  78132. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78133. */
  78134. layerMask: number;
  78135. /**
  78136. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78137. */
  78138. isPickable: boolean;
  78139. /**
  78140. * Specifies the rendering group id for this mesh (0 by default)
  78141. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78142. */
  78143. renderingGroupId: number;
  78144. /**
  78145. * Defines the list of sprites managed by the manager.
  78146. */
  78147. sprites: Array<Sprite>;
  78148. /**
  78149. * Tests the intersection of a sprite with a specific ray.
  78150. * @param ray The ray we are sending to test the collision
  78151. * @param camera The camera space we are sending rays in
  78152. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78153. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78154. * @returns picking info or null.
  78155. */
  78156. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78157. /**
  78158. * Intersects the sprites with a ray
  78159. * @param ray defines the ray to intersect with
  78160. * @param camera defines the current active camera
  78161. * @param predicate defines a predicate used to select candidate sprites
  78162. * @returns null if no hit or a PickingInfo array
  78163. */
  78164. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78165. /**
  78166. * Renders the list of sprites on screen.
  78167. */
  78168. render(): void;
  78169. }
  78170. /**
  78171. * Class used to manage multiple sprites on the same spritesheet
  78172. * @see http://doc.babylonjs.com/babylon101/sprites
  78173. */
  78174. export class SpriteManager implements ISpriteManager {
  78175. /** defines the manager's name */
  78176. name: string;
  78177. /** Gets the list of sprites */
  78178. sprites: Sprite[];
  78179. /** Gets or sets the rendering group id (0 by default) */
  78180. renderingGroupId: number;
  78181. /** Gets or sets camera layer mask */
  78182. layerMask: number;
  78183. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78184. fogEnabled: boolean;
  78185. /** Gets or sets a boolean indicating if the sprites are pickable */
  78186. isPickable: boolean;
  78187. /** Defines the default width of a cell in the spritesheet */
  78188. cellWidth: number;
  78189. /** Defines the default height of a cell in the spritesheet */
  78190. cellHeight: number;
  78191. /** Associative array from JSON sprite data file */
  78192. private _cellData;
  78193. /** Array of sprite names from JSON sprite data file */
  78194. private _spriteMap;
  78195. /** True when packed cell data from JSON file is ready*/
  78196. private _packedAndReady;
  78197. /**
  78198. * An event triggered when the manager is disposed.
  78199. */
  78200. onDisposeObservable: Observable<SpriteManager>;
  78201. private _onDisposeObserver;
  78202. /**
  78203. * Callback called when the manager is disposed
  78204. */
  78205. onDispose: () => void;
  78206. private _capacity;
  78207. private _fromPacked;
  78208. private _spriteTexture;
  78209. private _epsilon;
  78210. private _scene;
  78211. private _vertexData;
  78212. private _buffer;
  78213. private _vertexBuffers;
  78214. private _indexBuffer;
  78215. private _effectBase;
  78216. private _effectFog;
  78217. /**
  78218. * Gets or sets the spritesheet texture
  78219. */
  78220. texture: Texture;
  78221. /**
  78222. * Creates a new sprite manager
  78223. * @param name defines the manager's name
  78224. * @param imgUrl defines the sprite sheet url
  78225. * @param capacity defines the maximum allowed number of sprites
  78226. * @param cellSize defines the size of a sprite cell
  78227. * @param scene defines the hosting scene
  78228. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78229. * @param samplingMode defines the smapling mode to use with spritesheet
  78230. * @param fromPacked set to false; do not alter
  78231. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78232. */
  78233. constructor(
  78234. /** defines the manager's name */
  78235. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78236. private _makePacked;
  78237. private _appendSpriteVertex;
  78238. /**
  78239. * Intersects the sprites with a ray
  78240. * @param ray defines the ray to intersect with
  78241. * @param camera defines the current active camera
  78242. * @param predicate defines a predicate used to select candidate sprites
  78243. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78244. * @returns null if no hit or a PickingInfo
  78245. */
  78246. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78247. /**
  78248. * Intersects the sprites with a ray
  78249. * @param ray defines the ray to intersect with
  78250. * @param camera defines the current active camera
  78251. * @param predicate defines a predicate used to select candidate sprites
  78252. * @returns null if no hit or a PickingInfo array
  78253. */
  78254. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78255. /**
  78256. * Render all child sprites
  78257. */
  78258. render(): void;
  78259. /**
  78260. * Release associated resources
  78261. */
  78262. dispose(): void;
  78263. }
  78264. }
  78265. declare module BABYLON {
  78266. /**
  78267. * Class used to represent a sprite
  78268. * @see http://doc.babylonjs.com/babylon101/sprites
  78269. */
  78270. export class Sprite {
  78271. /** defines the name */
  78272. name: string;
  78273. /** Gets or sets the current world position */
  78274. position: Vector3;
  78275. /** Gets or sets the main color */
  78276. color: Color4;
  78277. /** Gets or sets the width */
  78278. width: number;
  78279. /** Gets or sets the height */
  78280. height: number;
  78281. /** Gets or sets rotation angle */
  78282. angle: number;
  78283. /** Gets or sets the cell index in the sprite sheet */
  78284. cellIndex: number;
  78285. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78286. cellRef: string;
  78287. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78288. invertU: number;
  78289. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78290. invertV: number;
  78291. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78292. disposeWhenFinishedAnimating: boolean;
  78293. /** Gets the list of attached animations */
  78294. animations: Animation[];
  78295. /** Gets or sets a boolean indicating if the sprite can be picked */
  78296. isPickable: boolean;
  78297. /**
  78298. * Gets or sets the associated action manager
  78299. */
  78300. actionManager: Nullable<ActionManager>;
  78301. private _animationStarted;
  78302. private _loopAnimation;
  78303. private _fromIndex;
  78304. private _toIndex;
  78305. private _delay;
  78306. private _direction;
  78307. private _manager;
  78308. private _time;
  78309. private _onAnimationEnd;
  78310. /**
  78311. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78312. */
  78313. isVisible: boolean;
  78314. /**
  78315. * Gets or sets the sprite size
  78316. */
  78317. size: number;
  78318. /**
  78319. * Creates a new Sprite
  78320. * @param name defines the name
  78321. * @param manager defines the manager
  78322. */
  78323. constructor(
  78324. /** defines the name */
  78325. name: string, manager: ISpriteManager);
  78326. /**
  78327. * Starts an animation
  78328. * @param from defines the initial key
  78329. * @param to defines the end key
  78330. * @param loop defines if the animation must loop
  78331. * @param delay defines the start delay (in ms)
  78332. * @param onAnimationEnd defines a callback to call when animation ends
  78333. */
  78334. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78335. /** Stops current animation (if any) */
  78336. stopAnimation(): void;
  78337. /** @hidden */
  78338. _animate(deltaTime: number): void;
  78339. /** Release associated resources */
  78340. dispose(): void;
  78341. }
  78342. }
  78343. declare module BABYLON {
  78344. /**
  78345. * Information about the result of picking within a scene
  78346. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78347. */
  78348. export class PickingInfo {
  78349. /** @hidden */
  78350. _pickingUnavailable: boolean;
  78351. /**
  78352. * If the pick collided with an object
  78353. */
  78354. hit: boolean;
  78355. /**
  78356. * Distance away where the pick collided
  78357. */
  78358. distance: number;
  78359. /**
  78360. * The location of pick collision
  78361. */
  78362. pickedPoint: Nullable<Vector3>;
  78363. /**
  78364. * The mesh corresponding the the pick collision
  78365. */
  78366. pickedMesh: Nullable<AbstractMesh>;
  78367. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78368. bu: number;
  78369. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78370. bv: number;
  78371. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78372. faceId: number;
  78373. /** Id of the the submesh that was picked */
  78374. subMeshId: number;
  78375. /** If a sprite was picked, this will be the sprite the pick collided with */
  78376. pickedSprite: Nullable<Sprite>;
  78377. /**
  78378. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78379. */
  78380. originMesh: Nullable<AbstractMesh>;
  78381. /**
  78382. * The ray that was used to perform the picking.
  78383. */
  78384. ray: Nullable<Ray>;
  78385. /**
  78386. * Gets the normal correspodning to the face the pick collided with
  78387. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78388. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78389. * @returns The normal correspodning to the face the pick collided with
  78390. */
  78391. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78392. /**
  78393. * Gets the texture coordinates of where the pick occured
  78394. * @returns the vector containing the coordnates of the texture
  78395. */
  78396. getTextureCoordinates(): Nullable<Vector2>;
  78397. }
  78398. }
  78399. declare module BABYLON {
  78400. /**
  78401. * Gather the list of pointer event types as constants.
  78402. */
  78403. export class PointerEventTypes {
  78404. /**
  78405. * 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.
  78406. */
  78407. static readonly POINTERDOWN: number;
  78408. /**
  78409. * The pointerup event is fired when a pointer is no longer active.
  78410. */
  78411. static readonly POINTERUP: number;
  78412. /**
  78413. * The pointermove event is fired when a pointer changes coordinates.
  78414. */
  78415. static readonly POINTERMOVE: number;
  78416. /**
  78417. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78418. */
  78419. static readonly POINTERWHEEL: number;
  78420. /**
  78421. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78422. */
  78423. static readonly POINTERPICK: number;
  78424. /**
  78425. * The pointertap event is fired when a the object has been touched and released without drag.
  78426. */
  78427. static readonly POINTERTAP: number;
  78428. /**
  78429. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78430. */
  78431. static readonly POINTERDOUBLETAP: number;
  78432. }
  78433. /**
  78434. * Base class of pointer info types.
  78435. */
  78436. export class PointerInfoBase {
  78437. /**
  78438. * Defines the type of event (PointerEventTypes)
  78439. */
  78440. type: number;
  78441. /**
  78442. * Defines the related dom event
  78443. */
  78444. event: PointerEvent | MouseWheelEvent;
  78445. /**
  78446. * Instantiates the base class of pointers info.
  78447. * @param type Defines the type of event (PointerEventTypes)
  78448. * @param event Defines the related dom event
  78449. */
  78450. constructor(
  78451. /**
  78452. * Defines the type of event (PointerEventTypes)
  78453. */
  78454. type: number,
  78455. /**
  78456. * Defines the related dom event
  78457. */
  78458. event: PointerEvent | MouseWheelEvent);
  78459. }
  78460. /**
  78461. * This class is used to store pointer related info for the onPrePointerObservable event.
  78462. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78463. */
  78464. export class PointerInfoPre extends PointerInfoBase {
  78465. /**
  78466. * Ray from a pointer if availible (eg. 6dof controller)
  78467. */
  78468. ray: Nullable<Ray>;
  78469. /**
  78470. * Defines the local position of the pointer on the canvas.
  78471. */
  78472. localPosition: Vector2;
  78473. /**
  78474. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78475. */
  78476. skipOnPointerObservable: boolean;
  78477. /**
  78478. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78479. * @param type Defines the type of event (PointerEventTypes)
  78480. * @param event Defines the related dom event
  78481. * @param localX Defines the local x coordinates of the pointer when the event occured
  78482. * @param localY Defines the local y coordinates of the pointer when the event occured
  78483. */
  78484. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78485. }
  78486. /**
  78487. * This type contains all the data related to a pointer event in Babylon.js.
  78488. * 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.
  78489. */
  78490. export class PointerInfo extends PointerInfoBase {
  78491. /**
  78492. * Defines the picking info associated to the info (if any)\
  78493. */
  78494. pickInfo: Nullable<PickingInfo>;
  78495. /**
  78496. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78497. * @param type Defines the type of event (PointerEventTypes)
  78498. * @param event Defines the related dom event
  78499. * @param pickInfo Defines the picking info associated to the info (if any)\
  78500. */
  78501. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78502. /**
  78503. * Defines the picking info associated to the info (if any)\
  78504. */
  78505. pickInfo: Nullable<PickingInfo>);
  78506. }
  78507. /**
  78508. * Data relating to a touch event on the screen.
  78509. */
  78510. export interface PointerTouch {
  78511. /**
  78512. * X coordinate of touch.
  78513. */
  78514. x: number;
  78515. /**
  78516. * Y coordinate of touch.
  78517. */
  78518. y: number;
  78519. /**
  78520. * Id of touch. Unique for each finger.
  78521. */
  78522. pointerId: number;
  78523. /**
  78524. * Event type passed from DOM.
  78525. */
  78526. type: any;
  78527. }
  78528. }
  78529. declare module BABYLON {
  78530. /**
  78531. * Manage the mouse inputs to control the movement of a free camera.
  78532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78533. */
  78534. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78535. /**
  78536. * Define if touch is enabled in the mouse input
  78537. */
  78538. touchEnabled: boolean;
  78539. /**
  78540. * Defines the camera the input is attached to.
  78541. */
  78542. camera: FreeCamera;
  78543. /**
  78544. * Defines the buttons associated with the input to handle camera move.
  78545. */
  78546. buttons: number[];
  78547. /**
  78548. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78549. */
  78550. angularSensibility: number;
  78551. private _pointerInput;
  78552. private _onMouseMove;
  78553. private _observer;
  78554. private previousPosition;
  78555. /**
  78556. * Observable for when a pointer move event occurs containing the move offset
  78557. */
  78558. onPointerMovedObservable: Observable<{
  78559. offsetX: number;
  78560. offsetY: number;
  78561. }>;
  78562. /**
  78563. * @hidden
  78564. * If the camera should be rotated automatically based on pointer movement
  78565. */
  78566. _allowCameraRotation: boolean;
  78567. /**
  78568. * Manage the mouse inputs to control the movement of a free camera.
  78569. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78570. * @param touchEnabled Defines if touch is enabled or not
  78571. */
  78572. constructor(
  78573. /**
  78574. * Define if touch is enabled in the mouse input
  78575. */
  78576. touchEnabled?: boolean);
  78577. /**
  78578. * Attach the input controls to a specific dom element to get the input from.
  78579. * @param element Defines the element the controls should be listened from
  78580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78581. */
  78582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78583. /**
  78584. * Called on JS contextmenu event.
  78585. * Override this method to provide functionality.
  78586. */
  78587. protected onContextMenu(evt: PointerEvent): void;
  78588. /**
  78589. * Detach the current controls from the specified dom element.
  78590. * @param element Defines the element to stop listening the inputs from
  78591. */
  78592. detachControl(element: Nullable<HTMLElement>): void;
  78593. /**
  78594. * Gets the class name of the current intput.
  78595. * @returns the class name
  78596. */
  78597. getClassName(): string;
  78598. /**
  78599. * Get the friendly name associated with the input class.
  78600. * @returns the input friendly name
  78601. */
  78602. getSimpleName(): string;
  78603. }
  78604. }
  78605. declare module BABYLON {
  78606. /**
  78607. * Manage the touch inputs to control the movement of a free camera.
  78608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78609. */
  78610. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78611. /**
  78612. * Defines the camera the input is attached to.
  78613. */
  78614. camera: FreeCamera;
  78615. /**
  78616. * Defines the touch sensibility for rotation.
  78617. * The higher the faster.
  78618. */
  78619. touchAngularSensibility: number;
  78620. /**
  78621. * Defines the touch sensibility for move.
  78622. * The higher the faster.
  78623. */
  78624. touchMoveSensibility: number;
  78625. private _offsetX;
  78626. private _offsetY;
  78627. private _pointerPressed;
  78628. private _pointerInput;
  78629. private _observer;
  78630. private _onLostFocus;
  78631. /**
  78632. * Attach the input controls to a specific dom element to get the input from.
  78633. * @param element Defines the element the controls should be listened from
  78634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78635. */
  78636. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78637. /**
  78638. * Detach the current controls from the specified dom element.
  78639. * @param element Defines the element to stop listening the inputs from
  78640. */
  78641. detachControl(element: Nullable<HTMLElement>): void;
  78642. /**
  78643. * Update the current camera state depending on the inputs that have been used this frame.
  78644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78645. */
  78646. checkInputs(): void;
  78647. /**
  78648. * Gets the class name of the current intput.
  78649. * @returns the class name
  78650. */
  78651. getClassName(): string;
  78652. /**
  78653. * Get the friendly name associated with the input class.
  78654. * @returns the input friendly name
  78655. */
  78656. getSimpleName(): string;
  78657. }
  78658. }
  78659. declare module BABYLON {
  78660. /**
  78661. * Default Inputs manager for the FreeCamera.
  78662. * It groups all the default supported inputs for ease of use.
  78663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78664. */
  78665. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78666. /**
  78667. * @hidden
  78668. */
  78669. _mouseInput: Nullable<FreeCameraMouseInput>;
  78670. /**
  78671. * Instantiates a new FreeCameraInputsManager.
  78672. * @param camera Defines the camera the inputs belong to
  78673. */
  78674. constructor(camera: FreeCamera);
  78675. /**
  78676. * Add keyboard input support to the input manager.
  78677. * @returns the current input manager
  78678. */
  78679. addKeyboard(): FreeCameraInputsManager;
  78680. /**
  78681. * Add mouse input support to the input manager.
  78682. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78683. * @returns the current input manager
  78684. */
  78685. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78686. /**
  78687. * Removes the mouse input support from the manager
  78688. * @returns the current input manager
  78689. */
  78690. removeMouse(): FreeCameraInputsManager;
  78691. /**
  78692. * Add touch input support to the input manager.
  78693. * @returns the current input manager
  78694. */
  78695. addTouch(): FreeCameraInputsManager;
  78696. /**
  78697. * Remove all attached input methods from a camera
  78698. */
  78699. clear(): void;
  78700. }
  78701. }
  78702. declare module BABYLON {
  78703. /**
  78704. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78705. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78706. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78707. */
  78708. export class FreeCamera extends TargetCamera {
  78709. /**
  78710. * Define the collision ellipsoid of the camera.
  78711. * This is helpful to simulate a camera body like the player body around the camera
  78712. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78713. */
  78714. ellipsoid: Vector3;
  78715. /**
  78716. * Define an offset for the position of the ellipsoid around the camera.
  78717. * This can be helpful to determine the center of the body near the gravity center of the body
  78718. * instead of its head.
  78719. */
  78720. ellipsoidOffset: Vector3;
  78721. /**
  78722. * Enable or disable collisions of the camera with the rest of the scene objects.
  78723. */
  78724. checkCollisions: boolean;
  78725. /**
  78726. * Enable or disable gravity on the camera.
  78727. */
  78728. applyGravity: boolean;
  78729. /**
  78730. * Define the input manager associated to the camera.
  78731. */
  78732. inputs: FreeCameraInputsManager;
  78733. /**
  78734. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78735. * Higher values reduce sensitivity.
  78736. */
  78737. /**
  78738. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78739. * Higher values reduce sensitivity.
  78740. */
  78741. angularSensibility: number;
  78742. /**
  78743. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78744. */
  78745. keysUp: number[];
  78746. /**
  78747. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78748. */
  78749. keysDown: number[];
  78750. /**
  78751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78752. */
  78753. keysLeft: number[];
  78754. /**
  78755. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78756. */
  78757. keysRight: number[];
  78758. /**
  78759. * Event raised when the camera collide with a mesh in the scene.
  78760. */
  78761. onCollide: (collidedMesh: AbstractMesh) => void;
  78762. private _collider;
  78763. private _needMoveForGravity;
  78764. private _oldPosition;
  78765. private _diffPosition;
  78766. private _newPosition;
  78767. /** @hidden */
  78768. _localDirection: Vector3;
  78769. /** @hidden */
  78770. _transformedDirection: Vector3;
  78771. /**
  78772. * Instantiates a Free Camera.
  78773. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78774. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78775. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78776. * @param name Define the name of the camera in the scene
  78777. * @param position Define the start position of the camera in the scene
  78778. * @param scene Define the scene the camera belongs to
  78779. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78780. */
  78781. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78782. /**
  78783. * Attached controls to the current camera.
  78784. * @param element Defines the element the controls should be listened from
  78785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78786. */
  78787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78788. /**
  78789. * Detach the current controls from the camera.
  78790. * The camera will stop reacting to inputs.
  78791. * @param element Defines the element to stop listening the inputs from
  78792. */
  78793. detachControl(element: HTMLElement): void;
  78794. private _collisionMask;
  78795. /**
  78796. * Define a collision mask to limit the list of object the camera can collide with
  78797. */
  78798. collisionMask: number;
  78799. /** @hidden */
  78800. _collideWithWorld(displacement: Vector3): void;
  78801. private _onCollisionPositionChange;
  78802. /** @hidden */
  78803. _checkInputs(): void;
  78804. /** @hidden */
  78805. _decideIfNeedsToMove(): boolean;
  78806. /** @hidden */
  78807. _updatePosition(): void;
  78808. /**
  78809. * Destroy the camera and release the current resources hold by it.
  78810. */
  78811. dispose(): void;
  78812. /**
  78813. * Gets the current object class name.
  78814. * @return the class name
  78815. */
  78816. getClassName(): string;
  78817. }
  78818. }
  78819. declare module BABYLON {
  78820. /**
  78821. * Represents a gamepad control stick position
  78822. */
  78823. export class StickValues {
  78824. /**
  78825. * The x component of the control stick
  78826. */
  78827. x: number;
  78828. /**
  78829. * The y component of the control stick
  78830. */
  78831. y: number;
  78832. /**
  78833. * Initializes the gamepad x and y control stick values
  78834. * @param x The x component of the gamepad control stick value
  78835. * @param y The y component of the gamepad control stick value
  78836. */
  78837. constructor(
  78838. /**
  78839. * The x component of the control stick
  78840. */
  78841. x: number,
  78842. /**
  78843. * The y component of the control stick
  78844. */
  78845. y: number);
  78846. }
  78847. /**
  78848. * An interface which manages callbacks for gamepad button changes
  78849. */
  78850. export interface GamepadButtonChanges {
  78851. /**
  78852. * Called when a gamepad has been changed
  78853. */
  78854. changed: boolean;
  78855. /**
  78856. * Called when a gamepad press event has been triggered
  78857. */
  78858. pressChanged: boolean;
  78859. /**
  78860. * Called when a touch event has been triggered
  78861. */
  78862. touchChanged: boolean;
  78863. /**
  78864. * Called when a value has changed
  78865. */
  78866. valueChanged: boolean;
  78867. }
  78868. /**
  78869. * Represents a gamepad
  78870. */
  78871. export class Gamepad {
  78872. /**
  78873. * The id of the gamepad
  78874. */
  78875. id: string;
  78876. /**
  78877. * The index of the gamepad
  78878. */
  78879. index: number;
  78880. /**
  78881. * The browser gamepad
  78882. */
  78883. browserGamepad: any;
  78884. /**
  78885. * Specifies what type of gamepad this represents
  78886. */
  78887. type: number;
  78888. private _leftStick;
  78889. private _rightStick;
  78890. /** @hidden */
  78891. _isConnected: boolean;
  78892. private _leftStickAxisX;
  78893. private _leftStickAxisY;
  78894. private _rightStickAxisX;
  78895. private _rightStickAxisY;
  78896. /**
  78897. * Triggered when the left control stick has been changed
  78898. */
  78899. private _onleftstickchanged;
  78900. /**
  78901. * Triggered when the right control stick has been changed
  78902. */
  78903. private _onrightstickchanged;
  78904. /**
  78905. * Represents a gamepad controller
  78906. */
  78907. static GAMEPAD: number;
  78908. /**
  78909. * Represents a generic controller
  78910. */
  78911. static GENERIC: number;
  78912. /**
  78913. * Represents an XBox controller
  78914. */
  78915. static XBOX: number;
  78916. /**
  78917. * Represents a pose-enabled controller
  78918. */
  78919. static POSE_ENABLED: number;
  78920. /**
  78921. * Represents an Dual Shock controller
  78922. */
  78923. static DUALSHOCK: number;
  78924. /**
  78925. * Specifies whether the left control stick should be Y-inverted
  78926. */
  78927. protected _invertLeftStickY: boolean;
  78928. /**
  78929. * Specifies if the gamepad has been connected
  78930. */
  78931. readonly isConnected: boolean;
  78932. /**
  78933. * Initializes the gamepad
  78934. * @param id The id of the gamepad
  78935. * @param index The index of the gamepad
  78936. * @param browserGamepad The browser gamepad
  78937. * @param leftStickX The x component of the left joystick
  78938. * @param leftStickY The y component of the left joystick
  78939. * @param rightStickX The x component of the right joystick
  78940. * @param rightStickY The y component of the right joystick
  78941. */
  78942. constructor(
  78943. /**
  78944. * The id of the gamepad
  78945. */
  78946. id: string,
  78947. /**
  78948. * The index of the gamepad
  78949. */
  78950. index: number,
  78951. /**
  78952. * The browser gamepad
  78953. */
  78954. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  78955. /**
  78956. * Callback triggered when the left joystick has changed
  78957. * @param callback
  78958. */
  78959. onleftstickchanged(callback: (values: StickValues) => void): void;
  78960. /**
  78961. * Callback triggered when the right joystick has changed
  78962. * @param callback
  78963. */
  78964. onrightstickchanged(callback: (values: StickValues) => void): void;
  78965. /**
  78966. * Gets the left joystick
  78967. */
  78968. /**
  78969. * Sets the left joystick values
  78970. */
  78971. leftStick: StickValues;
  78972. /**
  78973. * Gets the right joystick
  78974. */
  78975. /**
  78976. * Sets the right joystick value
  78977. */
  78978. rightStick: StickValues;
  78979. /**
  78980. * Updates the gamepad joystick positions
  78981. */
  78982. update(): void;
  78983. /**
  78984. * Disposes the gamepad
  78985. */
  78986. dispose(): void;
  78987. }
  78988. /**
  78989. * Represents a generic gamepad
  78990. */
  78991. export class GenericPad extends Gamepad {
  78992. private _buttons;
  78993. private _onbuttondown;
  78994. private _onbuttonup;
  78995. /**
  78996. * Observable triggered when a button has been pressed
  78997. */
  78998. onButtonDownObservable: Observable<number>;
  78999. /**
  79000. * Observable triggered when a button has been released
  79001. */
  79002. onButtonUpObservable: Observable<number>;
  79003. /**
  79004. * Callback triggered when a button has been pressed
  79005. * @param callback Called when a button has been pressed
  79006. */
  79007. onbuttondown(callback: (buttonPressed: number) => void): void;
  79008. /**
  79009. * Callback triggered when a button has been released
  79010. * @param callback Called when a button has been released
  79011. */
  79012. onbuttonup(callback: (buttonReleased: number) => void): void;
  79013. /**
  79014. * Initializes the generic gamepad
  79015. * @param id The id of the generic gamepad
  79016. * @param index The index of the generic gamepad
  79017. * @param browserGamepad The browser gamepad
  79018. */
  79019. constructor(id: string, index: number, browserGamepad: any);
  79020. private _setButtonValue;
  79021. /**
  79022. * Updates the generic gamepad
  79023. */
  79024. update(): void;
  79025. /**
  79026. * Disposes the generic gamepad
  79027. */
  79028. dispose(): void;
  79029. }
  79030. }
  79031. declare module BABYLON {
  79032. interface Engine {
  79033. /**
  79034. * Creates a raw texture
  79035. * @param data defines the data to store in the texture
  79036. * @param width defines the width of the texture
  79037. * @param height defines the height of the texture
  79038. * @param format defines the format of the data
  79039. * @param generateMipMaps defines if the engine should generate the mip levels
  79040. * @param invertY defines if data must be stored with Y axis inverted
  79041. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79042. * @param compression defines the compression used (null by default)
  79043. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79044. * @returns the raw texture inside an InternalTexture
  79045. */
  79046. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79047. /**
  79048. * Update a raw texture
  79049. * @param texture defines the texture to update
  79050. * @param data defines the data to store in the texture
  79051. * @param format defines the format of the data
  79052. * @param invertY defines if data must be stored with Y axis inverted
  79053. */
  79054. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79055. /**
  79056. * Update a raw texture
  79057. * @param texture defines the texture to update
  79058. * @param data defines the data to store in the texture
  79059. * @param format defines the format of the data
  79060. * @param invertY defines if data must be stored with Y axis inverted
  79061. * @param compression defines the compression used (null by default)
  79062. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79063. */
  79064. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79065. /**
  79066. * Creates a new raw cube texture
  79067. * @param data defines the array of data to use to create each face
  79068. * @param size defines the size of the textures
  79069. * @param format defines the format of the data
  79070. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79071. * @param generateMipMaps defines if the engine should generate the mip levels
  79072. * @param invertY defines if data must be stored with Y axis inverted
  79073. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79074. * @param compression defines the compression used (null by default)
  79075. * @returns the cube texture as an InternalTexture
  79076. */
  79077. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79078. /**
  79079. * Update a raw cube texture
  79080. * @param texture defines the texture to udpdate
  79081. * @param data defines the data to store
  79082. * @param format defines the data format
  79083. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79084. * @param invertY defines if data must be stored with Y axis inverted
  79085. */
  79086. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79087. /**
  79088. * Update a raw cube texture
  79089. * @param texture defines the texture to udpdate
  79090. * @param data defines the data to store
  79091. * @param format defines the data format
  79092. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79093. * @param invertY defines if data must be stored with Y axis inverted
  79094. * @param compression defines the compression used (null by default)
  79095. */
  79096. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79097. /**
  79098. * Update a raw cube texture
  79099. * @param texture defines the texture to udpdate
  79100. * @param data defines the data to store
  79101. * @param format defines the data format
  79102. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79103. * @param invertY defines if data must be stored with Y axis inverted
  79104. * @param compression defines the compression used (null by default)
  79105. * @param level defines which level of the texture to update
  79106. */
  79107. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79108. /**
  79109. * Creates a new raw cube texture from a specified url
  79110. * @param url defines the url where the data is located
  79111. * @param scene defines the current scene
  79112. * @param size defines the size of the textures
  79113. * @param format defines the format of the data
  79114. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79115. * @param noMipmap defines if the engine should avoid generating the mip levels
  79116. * @param callback defines a callback used to extract texture data from loaded data
  79117. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79118. * @param onLoad defines a callback called when texture is loaded
  79119. * @param onError defines a callback called if there is an error
  79120. * @returns the cube texture as an InternalTexture
  79121. */
  79122. 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;
  79123. /**
  79124. * Creates a new raw cube texture from a specified url
  79125. * @param url defines the url where the data is located
  79126. * @param scene defines the current scene
  79127. * @param size defines the size of the textures
  79128. * @param format defines the format of the data
  79129. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79130. * @param noMipmap defines if the engine should avoid generating the mip levels
  79131. * @param callback defines a callback used to extract texture data from loaded data
  79132. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79133. * @param onLoad defines a callback called when texture is loaded
  79134. * @param onError defines a callback called if there is an error
  79135. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79136. * @param invertY defines if data must be stored with Y axis inverted
  79137. * @returns the cube texture as an InternalTexture
  79138. */
  79139. 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;
  79140. /**
  79141. * Creates a new raw 3D texture
  79142. * @param data defines the data used to create the texture
  79143. * @param width defines the width of the texture
  79144. * @param height defines the height of the texture
  79145. * @param depth defines the depth of the texture
  79146. * @param format defines the format of the texture
  79147. * @param generateMipMaps defines if the engine must generate mip levels
  79148. * @param invertY defines if data must be stored with Y axis inverted
  79149. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79150. * @param compression defines the compressed used (can be null)
  79151. * @param textureType defines the compressed used (can be null)
  79152. * @returns a new raw 3D texture (stored in an InternalTexture)
  79153. */
  79154. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79155. /**
  79156. * Update a raw 3D texture
  79157. * @param texture defines the texture to update
  79158. * @param data defines the data to store
  79159. * @param format defines the data format
  79160. * @param invertY defines if data must be stored with Y axis inverted
  79161. */
  79162. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79163. /**
  79164. * Update a raw 3D texture
  79165. * @param texture defines the texture to update
  79166. * @param data defines the data to store
  79167. * @param format defines the data format
  79168. * @param invertY defines if data must be stored with Y axis inverted
  79169. * @param compression defines the used compression (can be null)
  79170. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79171. */
  79172. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79173. }
  79174. }
  79175. declare module BABYLON {
  79176. /**
  79177. * Raw texture can help creating a texture directly from an array of data.
  79178. * This can be super useful if you either get the data from an uncompressed source or
  79179. * if you wish to create your texture pixel by pixel.
  79180. */
  79181. export class RawTexture extends Texture {
  79182. /**
  79183. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79184. */
  79185. format: number;
  79186. private _engine;
  79187. /**
  79188. * Instantiates a new RawTexture.
  79189. * Raw texture can help creating a texture directly from an array of data.
  79190. * This can be super useful if you either get the data from an uncompressed source or
  79191. * if you wish to create your texture pixel by pixel.
  79192. * @param data define the array of data to use to create the texture
  79193. * @param width define the width of the texture
  79194. * @param height define the height of the texture
  79195. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79196. * @param scene define the scene the texture belongs to
  79197. * @param generateMipMaps define whether mip maps should be generated or not
  79198. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79199. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79200. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79201. */
  79202. constructor(data: ArrayBufferView, width: number, height: number,
  79203. /**
  79204. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79205. */
  79206. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79207. /**
  79208. * Updates the texture underlying data.
  79209. * @param data Define the new data of the texture
  79210. */
  79211. update(data: ArrayBufferView): void;
  79212. /**
  79213. * Creates a luminance texture from some data.
  79214. * @param data Define the texture data
  79215. * @param width Define the width of the texture
  79216. * @param height Define the height of the texture
  79217. * @param scene Define the scene the texture belongs to
  79218. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79219. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79220. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79221. * @returns the luminance texture
  79222. */
  79223. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79224. /**
  79225. * Creates a luminance alpha texture from some data.
  79226. * @param data Define the texture data
  79227. * @param width Define the width of the texture
  79228. * @param height Define the height of the texture
  79229. * @param scene Define the scene the texture belongs to
  79230. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79231. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79232. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79233. * @returns the luminance alpha texture
  79234. */
  79235. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79236. /**
  79237. * Creates an alpha texture from some data.
  79238. * @param data Define the texture data
  79239. * @param width Define the width of the texture
  79240. * @param height Define the height of the texture
  79241. * @param scene Define the scene the texture belongs to
  79242. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79243. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79244. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79245. * @returns the alpha texture
  79246. */
  79247. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79248. /**
  79249. * Creates a RGB texture from some data.
  79250. * @param data Define the texture data
  79251. * @param width Define the width of the texture
  79252. * @param height Define the height of the texture
  79253. * @param scene Define the scene the texture belongs to
  79254. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79255. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79256. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79257. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79258. * @returns the RGB alpha texture
  79259. */
  79260. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79261. /**
  79262. * Creates a RGBA texture from some data.
  79263. * @param data Define the texture data
  79264. * @param width Define the width of the texture
  79265. * @param height Define the height of the texture
  79266. * @param scene Define the scene the texture belongs to
  79267. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79268. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79269. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79270. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79271. * @returns the RGBA texture
  79272. */
  79273. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79274. /**
  79275. * Creates a R texture from some data.
  79276. * @param data Define the texture data
  79277. * @param width Define the width of the texture
  79278. * @param height Define the height of the texture
  79279. * @param scene Define the scene the texture belongs to
  79280. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79281. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79282. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79283. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79284. * @returns the R texture
  79285. */
  79286. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79287. }
  79288. }
  79289. declare module BABYLON {
  79290. /**
  79291. * Interface for the size containing width and height
  79292. */
  79293. export interface ISize {
  79294. /**
  79295. * Width
  79296. */
  79297. width: number;
  79298. /**
  79299. * Heighht
  79300. */
  79301. height: number;
  79302. }
  79303. /**
  79304. * Size containing widht and height
  79305. */
  79306. export class Size implements ISize {
  79307. /**
  79308. * Width
  79309. */
  79310. width: number;
  79311. /**
  79312. * Height
  79313. */
  79314. height: number;
  79315. /**
  79316. * Creates a Size object from the given width and height (floats).
  79317. * @param width width of the new size
  79318. * @param height height of the new size
  79319. */
  79320. constructor(width: number, height: number);
  79321. /**
  79322. * Returns a string with the Size width and height
  79323. * @returns a string with the Size width and height
  79324. */
  79325. toString(): string;
  79326. /**
  79327. * "Size"
  79328. * @returns the string "Size"
  79329. */
  79330. getClassName(): string;
  79331. /**
  79332. * Returns the Size hash code.
  79333. * @returns a hash code for a unique width and height
  79334. */
  79335. getHashCode(): number;
  79336. /**
  79337. * Updates the current size from the given one.
  79338. * @param src the given size
  79339. */
  79340. copyFrom(src: Size): void;
  79341. /**
  79342. * Updates in place the current Size from the given floats.
  79343. * @param width width of the new size
  79344. * @param height height of the new size
  79345. * @returns the updated Size.
  79346. */
  79347. copyFromFloats(width: number, height: number): Size;
  79348. /**
  79349. * Updates in place the current Size from the given floats.
  79350. * @param width width to set
  79351. * @param height height to set
  79352. * @returns the updated Size.
  79353. */
  79354. set(width: number, height: number): Size;
  79355. /**
  79356. * Multiplies the width and height by numbers
  79357. * @param w factor to multiple the width by
  79358. * @param h factor to multiple the height by
  79359. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79360. */
  79361. multiplyByFloats(w: number, h: number): Size;
  79362. /**
  79363. * Clones the size
  79364. * @returns a new Size copied from the given one.
  79365. */
  79366. clone(): Size;
  79367. /**
  79368. * True if the current Size and the given one width and height are strictly equal.
  79369. * @param other the other size to compare against
  79370. * @returns True if the current Size and the given one width and height are strictly equal.
  79371. */
  79372. equals(other: Size): boolean;
  79373. /**
  79374. * The surface of the Size : width * height (float).
  79375. */
  79376. readonly surface: number;
  79377. /**
  79378. * Create a new size of zero
  79379. * @returns a new Size set to (0.0, 0.0)
  79380. */
  79381. static Zero(): Size;
  79382. /**
  79383. * Sums the width and height of two sizes
  79384. * @param otherSize size to add to this size
  79385. * @returns a new Size set as the addition result of the current Size and the given one.
  79386. */
  79387. add(otherSize: Size): Size;
  79388. /**
  79389. * Subtracts the width and height of two
  79390. * @param otherSize size to subtract to this size
  79391. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79392. */
  79393. subtract(otherSize: Size): Size;
  79394. /**
  79395. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79396. * @param start starting size to lerp between
  79397. * @param end end size to lerp between
  79398. * @param amount amount to lerp between the start and end values
  79399. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79400. */
  79401. static Lerp(start: Size, end: Size, amount: number): Size;
  79402. }
  79403. }
  79404. declare module BABYLON {
  79405. /**
  79406. * Defines a runtime animation
  79407. */
  79408. export class RuntimeAnimation {
  79409. private _events;
  79410. /**
  79411. * The current frame of the runtime animation
  79412. */
  79413. private _currentFrame;
  79414. /**
  79415. * The animation used by the runtime animation
  79416. */
  79417. private _animation;
  79418. /**
  79419. * The target of the runtime animation
  79420. */
  79421. private _target;
  79422. /**
  79423. * The initiating animatable
  79424. */
  79425. private _host;
  79426. /**
  79427. * The original value of the runtime animation
  79428. */
  79429. private _originalValue;
  79430. /**
  79431. * The original blend value of the runtime animation
  79432. */
  79433. private _originalBlendValue;
  79434. /**
  79435. * The offsets cache of the runtime animation
  79436. */
  79437. private _offsetsCache;
  79438. /**
  79439. * The high limits cache of the runtime animation
  79440. */
  79441. private _highLimitsCache;
  79442. /**
  79443. * Specifies if the runtime animation has been stopped
  79444. */
  79445. private _stopped;
  79446. /**
  79447. * The blending factor of the runtime animation
  79448. */
  79449. private _blendingFactor;
  79450. /**
  79451. * The BabylonJS scene
  79452. */
  79453. private _scene;
  79454. /**
  79455. * The current value of the runtime animation
  79456. */
  79457. private _currentValue;
  79458. /** @hidden */
  79459. _animationState: _IAnimationState;
  79460. /**
  79461. * The active target of the runtime animation
  79462. */
  79463. private _activeTargets;
  79464. private _currentActiveTarget;
  79465. private _directTarget;
  79466. /**
  79467. * The target path of the runtime animation
  79468. */
  79469. private _targetPath;
  79470. /**
  79471. * The weight of the runtime animation
  79472. */
  79473. private _weight;
  79474. /**
  79475. * The ratio offset of the runtime animation
  79476. */
  79477. private _ratioOffset;
  79478. /**
  79479. * The previous delay of the runtime animation
  79480. */
  79481. private _previousDelay;
  79482. /**
  79483. * The previous ratio of the runtime animation
  79484. */
  79485. private _previousRatio;
  79486. private _enableBlending;
  79487. private _keys;
  79488. private _minFrame;
  79489. private _maxFrame;
  79490. private _minValue;
  79491. private _maxValue;
  79492. private _targetIsArray;
  79493. /**
  79494. * Gets the current frame of the runtime animation
  79495. */
  79496. readonly currentFrame: number;
  79497. /**
  79498. * Gets the weight of the runtime animation
  79499. */
  79500. readonly weight: number;
  79501. /**
  79502. * Gets the current value of the runtime animation
  79503. */
  79504. readonly currentValue: any;
  79505. /**
  79506. * Gets the target path of the runtime animation
  79507. */
  79508. readonly targetPath: string;
  79509. /**
  79510. * Gets the actual target of the runtime animation
  79511. */
  79512. readonly target: any;
  79513. /** @hidden */
  79514. _onLoop: () => void;
  79515. /**
  79516. * Create a new RuntimeAnimation object
  79517. * @param target defines the target of the animation
  79518. * @param animation defines the source animation object
  79519. * @param scene defines the hosting scene
  79520. * @param host defines the initiating Animatable
  79521. */
  79522. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79523. private _preparePath;
  79524. /**
  79525. * Gets the animation from the runtime animation
  79526. */
  79527. readonly animation: Animation;
  79528. /**
  79529. * Resets the runtime animation to the beginning
  79530. * @param restoreOriginal defines whether to restore the target property to the original value
  79531. */
  79532. reset(restoreOriginal?: boolean): void;
  79533. /**
  79534. * Specifies if the runtime animation is stopped
  79535. * @returns Boolean specifying if the runtime animation is stopped
  79536. */
  79537. isStopped(): boolean;
  79538. /**
  79539. * Disposes of the runtime animation
  79540. */
  79541. dispose(): void;
  79542. /**
  79543. * Apply the interpolated value to the target
  79544. * @param currentValue defines the value computed by the animation
  79545. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79546. */
  79547. setValue(currentValue: any, weight: number): void;
  79548. private _getOriginalValues;
  79549. private _setValue;
  79550. /**
  79551. * Gets the loop pmode of the runtime animation
  79552. * @returns Loop Mode
  79553. */
  79554. private _getCorrectLoopMode;
  79555. /**
  79556. * Move the current animation to a given frame
  79557. * @param frame defines the frame to move to
  79558. */
  79559. goToFrame(frame: number): void;
  79560. /**
  79561. * @hidden Internal use only
  79562. */
  79563. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79564. /**
  79565. * Execute the current animation
  79566. * @param delay defines the delay to add to the current frame
  79567. * @param from defines the lower bound of the animation range
  79568. * @param to defines the upper bound of the animation range
  79569. * @param loop defines if the current animation must loop
  79570. * @param speedRatio defines the current speed ratio
  79571. * @param weight defines the weight of the animation (default is -1 so no weight)
  79572. * @param onLoop optional callback called when animation loops
  79573. * @returns a boolean indicating if the animation is running
  79574. */
  79575. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79576. }
  79577. }
  79578. declare module BABYLON {
  79579. /**
  79580. * Class used to store an actual running animation
  79581. */
  79582. export class Animatable {
  79583. /** defines the target object */
  79584. target: any;
  79585. /** defines the starting frame number (default is 0) */
  79586. fromFrame: number;
  79587. /** defines the ending frame number (default is 100) */
  79588. toFrame: number;
  79589. /** defines if the animation must loop (default is false) */
  79590. loopAnimation: boolean;
  79591. /** defines a callback to call when animation ends if it is not looping */
  79592. onAnimationEnd?: (() => void) | null | undefined;
  79593. /** defines a callback to call when animation loops */
  79594. onAnimationLoop?: (() => void) | null | undefined;
  79595. private _localDelayOffset;
  79596. private _pausedDelay;
  79597. private _runtimeAnimations;
  79598. private _paused;
  79599. private _scene;
  79600. private _speedRatio;
  79601. private _weight;
  79602. private _syncRoot;
  79603. /**
  79604. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79605. * This will only apply for non looping animation (default is true)
  79606. */
  79607. disposeOnEnd: boolean;
  79608. /**
  79609. * Gets a boolean indicating if the animation has started
  79610. */
  79611. animationStarted: boolean;
  79612. /**
  79613. * Observer raised when the animation ends
  79614. */
  79615. onAnimationEndObservable: Observable<Animatable>;
  79616. /**
  79617. * Observer raised when the animation loops
  79618. */
  79619. onAnimationLoopObservable: Observable<Animatable>;
  79620. /**
  79621. * Gets the root Animatable used to synchronize and normalize animations
  79622. */
  79623. readonly syncRoot: Nullable<Animatable>;
  79624. /**
  79625. * Gets the current frame of the first RuntimeAnimation
  79626. * Used to synchronize Animatables
  79627. */
  79628. readonly masterFrame: number;
  79629. /**
  79630. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79631. */
  79632. weight: number;
  79633. /**
  79634. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79635. */
  79636. speedRatio: number;
  79637. /**
  79638. * Creates a new Animatable
  79639. * @param scene defines the hosting scene
  79640. * @param target defines the target object
  79641. * @param fromFrame defines the starting frame number (default is 0)
  79642. * @param toFrame defines the ending frame number (default is 100)
  79643. * @param loopAnimation defines if the animation must loop (default is false)
  79644. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79645. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79646. * @param animations defines a group of animation to add to the new Animatable
  79647. * @param onAnimationLoop defines a callback to call when animation loops
  79648. */
  79649. constructor(scene: Scene,
  79650. /** defines the target object */
  79651. target: any,
  79652. /** defines the starting frame number (default is 0) */
  79653. fromFrame?: number,
  79654. /** defines the ending frame number (default is 100) */
  79655. toFrame?: number,
  79656. /** defines if the animation must loop (default is false) */
  79657. loopAnimation?: boolean, speedRatio?: number,
  79658. /** defines a callback to call when animation ends if it is not looping */
  79659. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79660. /** defines a callback to call when animation loops */
  79661. onAnimationLoop?: (() => void) | null | undefined);
  79662. /**
  79663. * Synchronize and normalize current Animatable with a source Animatable
  79664. * This is useful when using animation weights and when animations are not of the same length
  79665. * @param root defines the root Animatable to synchronize with
  79666. * @returns the current Animatable
  79667. */
  79668. syncWith(root: Animatable): Animatable;
  79669. /**
  79670. * Gets the list of runtime animations
  79671. * @returns an array of RuntimeAnimation
  79672. */
  79673. getAnimations(): RuntimeAnimation[];
  79674. /**
  79675. * Adds more animations to the current animatable
  79676. * @param target defines the target of the animations
  79677. * @param animations defines the new animations to add
  79678. */
  79679. appendAnimations(target: any, animations: Animation[]): void;
  79680. /**
  79681. * Gets the source animation for a specific property
  79682. * @param property defines the propertyu to look for
  79683. * @returns null or the source animation for the given property
  79684. */
  79685. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79686. /**
  79687. * Gets the runtime animation for a specific property
  79688. * @param property defines the propertyu to look for
  79689. * @returns null or the runtime animation for the given property
  79690. */
  79691. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79692. /**
  79693. * Resets the animatable to its original state
  79694. */
  79695. reset(): void;
  79696. /**
  79697. * Allows the animatable to blend with current running animations
  79698. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79699. * @param blendingSpeed defines the blending speed to use
  79700. */
  79701. enableBlending(blendingSpeed: number): void;
  79702. /**
  79703. * Disable animation blending
  79704. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79705. */
  79706. disableBlending(): void;
  79707. /**
  79708. * Jump directly to a given frame
  79709. * @param frame defines the frame to jump to
  79710. */
  79711. goToFrame(frame: number): void;
  79712. /**
  79713. * Pause the animation
  79714. */
  79715. pause(): void;
  79716. /**
  79717. * Restart the animation
  79718. */
  79719. restart(): void;
  79720. private _raiseOnAnimationEnd;
  79721. /**
  79722. * Stop and delete the current animation
  79723. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79724. * @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)
  79725. */
  79726. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79727. /**
  79728. * Wait asynchronously for the animation to end
  79729. * @returns a promise which will be fullfilled when the animation ends
  79730. */
  79731. waitAsync(): Promise<Animatable>;
  79732. /** @hidden */
  79733. _animate(delay: number): boolean;
  79734. }
  79735. interface Scene {
  79736. /** @hidden */
  79737. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79738. /** @hidden */
  79739. _processLateAnimationBindingsForMatrices(holder: {
  79740. totalWeight: number;
  79741. animations: RuntimeAnimation[];
  79742. originalValue: Matrix;
  79743. }): any;
  79744. /** @hidden */
  79745. _processLateAnimationBindingsForQuaternions(holder: {
  79746. totalWeight: number;
  79747. animations: RuntimeAnimation[];
  79748. originalValue: Quaternion;
  79749. }, refQuaternion: Quaternion): Quaternion;
  79750. /** @hidden */
  79751. _processLateAnimationBindings(): void;
  79752. /**
  79753. * Will start the animation sequence of a given target
  79754. * @param target defines the target
  79755. * @param from defines from which frame should animation start
  79756. * @param to defines until which frame should animation run.
  79757. * @param weight defines the weight to apply to the animation (1.0 by default)
  79758. * @param loop defines if the animation loops
  79759. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79760. * @param onAnimationEnd defines the function to be executed when the animation ends
  79761. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79762. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79763. * @param onAnimationLoop defines the callback to call when an animation loops
  79764. * @returns the animatable object created for this animation
  79765. */
  79766. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79767. /**
  79768. * Will start the animation sequence of a given target
  79769. * @param target defines the target
  79770. * @param from defines from which frame should animation start
  79771. * @param to defines until which frame should animation run.
  79772. * @param loop defines if the animation loops
  79773. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79774. * @param onAnimationEnd defines the function to be executed when the animation ends
  79775. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79776. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79777. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79778. * @param onAnimationLoop defines the callback to call when an animation loops
  79779. * @returns the animatable object created for this animation
  79780. */
  79781. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79782. /**
  79783. * Will start the animation sequence of a given target and its hierarchy
  79784. * @param target defines the target
  79785. * @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.
  79786. * @param from defines from which frame should animation start
  79787. * @param to defines until which frame should animation run.
  79788. * @param loop defines if the animation loops
  79789. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79790. * @param onAnimationEnd defines the function to be executed when the animation ends
  79791. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79792. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79793. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79794. * @param onAnimationLoop defines the callback to call when an animation loops
  79795. * @returns the list of created animatables
  79796. */
  79797. 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[];
  79798. /**
  79799. * Begin a new animation on a given node
  79800. * @param target defines the target where the animation will take place
  79801. * @param animations defines the list of animations to start
  79802. * @param from defines the initial value
  79803. * @param to defines the final value
  79804. * @param loop defines if you want animation to loop (off by default)
  79805. * @param speedRatio defines the speed ratio to apply to all animations
  79806. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79807. * @param onAnimationLoop defines the callback to call when an animation loops
  79808. * @returns the list of created animatables
  79809. */
  79810. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79811. /**
  79812. * Begin a new animation on a given node and its hierarchy
  79813. * @param target defines the root node where the animation will take place
  79814. * @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.
  79815. * @param animations defines the list of animations to start
  79816. * @param from defines the initial value
  79817. * @param to defines the final value
  79818. * @param loop defines if you want animation to loop (off by default)
  79819. * @param speedRatio defines the speed ratio to apply to all animations
  79820. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79821. * @param onAnimationLoop defines the callback to call when an animation loops
  79822. * @returns the list of animatables created for all nodes
  79823. */
  79824. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79825. /**
  79826. * Gets the animatable associated with a specific target
  79827. * @param target defines the target of the animatable
  79828. * @returns the required animatable if found
  79829. */
  79830. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79831. /**
  79832. * Gets all animatables associated with a given target
  79833. * @param target defines the target to look animatables for
  79834. * @returns an array of Animatables
  79835. */
  79836. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79837. /**
  79838. * Stops and removes all animations that have been applied to the scene
  79839. */
  79840. stopAllAnimations(): void;
  79841. /**
  79842. * Gets the current delta time used by animation engine
  79843. */
  79844. deltaTime: number;
  79845. }
  79846. interface Bone {
  79847. /**
  79848. * Copy an animation range from another bone
  79849. * @param source defines the source bone
  79850. * @param rangeName defines the range name to copy
  79851. * @param frameOffset defines the frame offset
  79852. * @param rescaleAsRequired defines if rescaling must be applied if required
  79853. * @param skelDimensionsRatio defines the scaling ratio
  79854. * @returns true if operation was successful
  79855. */
  79856. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79857. }
  79858. }
  79859. declare module BABYLON {
  79860. /**
  79861. * Class used to override all child animations of a given target
  79862. */
  79863. export class AnimationPropertiesOverride {
  79864. /**
  79865. * Gets or sets a value indicating if animation blending must be used
  79866. */
  79867. enableBlending: boolean;
  79868. /**
  79869. * Gets or sets the blending speed to use when enableBlending is true
  79870. */
  79871. blendingSpeed: number;
  79872. /**
  79873. * Gets or sets the default loop mode to use
  79874. */
  79875. loopMode: number;
  79876. }
  79877. }
  79878. declare module BABYLON {
  79879. /**
  79880. * Class used to handle skinning animations
  79881. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79882. */
  79883. export class Skeleton implements IAnimatable {
  79884. /** defines the skeleton name */
  79885. name: string;
  79886. /** defines the skeleton Id */
  79887. id: string;
  79888. /**
  79889. * Defines the list of child bones
  79890. */
  79891. bones: Bone[];
  79892. /**
  79893. * Defines an estimate of the dimension of the skeleton at rest
  79894. */
  79895. dimensionsAtRest: Vector3;
  79896. /**
  79897. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79898. */
  79899. needInitialSkinMatrix: boolean;
  79900. /**
  79901. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79902. */
  79903. overrideMesh: Nullable<AbstractMesh>;
  79904. /**
  79905. * Gets the list of animations attached to this skeleton
  79906. */
  79907. animations: Array<Animation>;
  79908. private _scene;
  79909. private _isDirty;
  79910. private _transformMatrices;
  79911. private _transformMatrixTexture;
  79912. private _meshesWithPoseMatrix;
  79913. private _animatables;
  79914. private _identity;
  79915. private _synchronizedWithMesh;
  79916. private _ranges;
  79917. private _lastAbsoluteTransformsUpdateId;
  79918. private _canUseTextureForBones;
  79919. private _uniqueId;
  79920. /** @hidden */
  79921. _numBonesWithLinkedTransformNode: number;
  79922. /** @hidden */
  79923. _hasWaitingData: Nullable<boolean>;
  79924. /**
  79925. * Specifies if the skeleton should be serialized
  79926. */
  79927. doNotSerialize: boolean;
  79928. private _useTextureToStoreBoneMatrices;
  79929. /**
  79930. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79931. * Please note that this option is not available if the hardware does not support it
  79932. */
  79933. useTextureToStoreBoneMatrices: boolean;
  79934. private _animationPropertiesOverride;
  79935. /**
  79936. * Gets or sets the animation properties override
  79937. */
  79938. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79939. /**
  79940. * List of inspectable custom properties (used by the Inspector)
  79941. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79942. */
  79943. inspectableCustomProperties: IInspectable[];
  79944. /**
  79945. * An observable triggered before computing the skeleton's matrices
  79946. */
  79947. onBeforeComputeObservable: Observable<Skeleton>;
  79948. /**
  79949. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79950. */
  79951. readonly isUsingTextureForMatrices: boolean;
  79952. /**
  79953. * Gets the unique ID of this skeleton
  79954. */
  79955. readonly uniqueId: number;
  79956. /**
  79957. * Creates a new skeleton
  79958. * @param name defines the skeleton name
  79959. * @param id defines the skeleton Id
  79960. * @param scene defines the hosting scene
  79961. */
  79962. constructor(
  79963. /** defines the skeleton name */
  79964. name: string,
  79965. /** defines the skeleton Id */
  79966. id: string, scene: Scene);
  79967. /**
  79968. * Gets the current object class name.
  79969. * @return the class name
  79970. */
  79971. getClassName(): string;
  79972. /**
  79973. * Returns an array containing the root bones
  79974. * @returns an array containing the root bones
  79975. */
  79976. getChildren(): Array<Bone>;
  79977. /**
  79978. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79979. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79980. * @returns a Float32Array containing matrices data
  79981. */
  79982. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79983. /**
  79984. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79985. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79986. * @returns a raw texture containing the data
  79987. */
  79988. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79989. /**
  79990. * Gets the current hosting scene
  79991. * @returns a scene object
  79992. */
  79993. getScene(): Scene;
  79994. /**
  79995. * Gets a string representing the current skeleton data
  79996. * @param fullDetails defines a boolean indicating if we want a verbose version
  79997. * @returns a string representing the current skeleton data
  79998. */
  79999. toString(fullDetails?: boolean): string;
  80000. /**
  80001. * Get bone's index searching by name
  80002. * @param name defines bone's name to search for
  80003. * @return the indice of the bone. Returns -1 if not found
  80004. */
  80005. getBoneIndexByName(name: string): number;
  80006. /**
  80007. * Creater a new animation range
  80008. * @param name defines the name of the range
  80009. * @param from defines the start key
  80010. * @param to defines the end key
  80011. */
  80012. createAnimationRange(name: string, from: number, to: number): void;
  80013. /**
  80014. * Delete a specific animation range
  80015. * @param name defines the name of the range
  80016. * @param deleteFrames defines if frames must be removed as well
  80017. */
  80018. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80019. /**
  80020. * Gets a specific animation range
  80021. * @param name defines the name of the range to look for
  80022. * @returns the requested animation range or null if not found
  80023. */
  80024. getAnimationRange(name: string): Nullable<AnimationRange>;
  80025. /**
  80026. * Gets the list of all animation ranges defined on this skeleton
  80027. * @returns an array
  80028. */
  80029. getAnimationRanges(): Nullable<AnimationRange>[];
  80030. /**
  80031. * Copy animation range from a source skeleton.
  80032. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80033. * @param source defines the source skeleton
  80034. * @param name defines the name of the range to copy
  80035. * @param rescaleAsRequired defines if rescaling must be applied if required
  80036. * @returns true if operation was successful
  80037. */
  80038. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80039. /**
  80040. * Forces the skeleton to go to rest pose
  80041. */
  80042. returnToRest(): void;
  80043. private _getHighestAnimationFrame;
  80044. /**
  80045. * Begin a specific animation range
  80046. * @param name defines the name of the range to start
  80047. * @param loop defines if looping must be turned on (false by default)
  80048. * @param speedRatio defines the speed ratio to apply (1 by default)
  80049. * @param onAnimationEnd defines a callback which will be called when animation will end
  80050. * @returns a new animatable
  80051. */
  80052. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80053. /** @hidden */
  80054. _markAsDirty(): void;
  80055. /** @hidden */
  80056. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80057. /** @hidden */
  80058. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80059. private _computeTransformMatrices;
  80060. /**
  80061. * Build all resources required to render a skeleton
  80062. */
  80063. prepare(): void;
  80064. /**
  80065. * Gets the list of animatables currently running for this skeleton
  80066. * @returns an array of animatables
  80067. */
  80068. getAnimatables(): IAnimatable[];
  80069. /**
  80070. * Clone the current skeleton
  80071. * @param name defines the name of the new skeleton
  80072. * @param id defines the id of the new skeleton
  80073. * @returns the new skeleton
  80074. */
  80075. clone(name: string, id: string): Skeleton;
  80076. /**
  80077. * Enable animation blending for this skeleton
  80078. * @param blendingSpeed defines the blending speed to apply
  80079. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80080. */
  80081. enableBlending(blendingSpeed?: number): void;
  80082. /**
  80083. * Releases all resources associated with the current skeleton
  80084. */
  80085. dispose(): void;
  80086. /**
  80087. * Serialize the skeleton in a JSON object
  80088. * @returns a JSON object
  80089. */
  80090. serialize(): any;
  80091. /**
  80092. * Creates a new skeleton from serialized data
  80093. * @param parsedSkeleton defines the serialized data
  80094. * @param scene defines the hosting scene
  80095. * @returns a new skeleton
  80096. */
  80097. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80098. /**
  80099. * Compute all node absolute transforms
  80100. * @param forceUpdate defines if computation must be done even if cache is up to date
  80101. */
  80102. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80103. /**
  80104. * Gets the root pose matrix
  80105. * @returns a matrix
  80106. */
  80107. getPoseMatrix(): Nullable<Matrix>;
  80108. /**
  80109. * Sorts bones per internal index
  80110. */
  80111. sortBones(): void;
  80112. private _sortBones;
  80113. }
  80114. }
  80115. declare module BABYLON {
  80116. /**
  80117. * Class used to store bone information
  80118. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80119. */
  80120. export class Bone extends Node {
  80121. /**
  80122. * defines the bone name
  80123. */
  80124. name: string;
  80125. private static _tmpVecs;
  80126. private static _tmpQuat;
  80127. private static _tmpMats;
  80128. /**
  80129. * Gets the list of child bones
  80130. */
  80131. children: Bone[];
  80132. /** Gets the animations associated with this bone */
  80133. animations: Animation[];
  80134. /**
  80135. * Gets or sets bone length
  80136. */
  80137. length: number;
  80138. /**
  80139. * @hidden Internal only
  80140. * Set this value to map this bone to a different index in the transform matrices
  80141. * Set this value to -1 to exclude the bone from the transform matrices
  80142. */
  80143. _index: Nullable<number>;
  80144. private _skeleton;
  80145. private _localMatrix;
  80146. private _restPose;
  80147. private _baseMatrix;
  80148. private _absoluteTransform;
  80149. private _invertedAbsoluteTransform;
  80150. private _parent;
  80151. private _scalingDeterminant;
  80152. private _worldTransform;
  80153. private _localScaling;
  80154. private _localRotation;
  80155. private _localPosition;
  80156. private _needToDecompose;
  80157. private _needToCompose;
  80158. /** @hidden */
  80159. _linkedTransformNode: Nullable<TransformNode>;
  80160. /** @hidden */
  80161. _waitingTransformNodeId: Nullable<string>;
  80162. /** @hidden */
  80163. /** @hidden */
  80164. _matrix: Matrix;
  80165. /**
  80166. * Create a new bone
  80167. * @param name defines the bone name
  80168. * @param skeleton defines the parent skeleton
  80169. * @param parentBone defines the parent (can be null if the bone is the root)
  80170. * @param localMatrix defines the local matrix
  80171. * @param restPose defines the rest pose matrix
  80172. * @param baseMatrix defines the base matrix
  80173. * @param index defines index of the bone in the hiearchy
  80174. */
  80175. constructor(
  80176. /**
  80177. * defines the bone name
  80178. */
  80179. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80180. /**
  80181. * Gets the current object class name.
  80182. * @return the class name
  80183. */
  80184. getClassName(): string;
  80185. /**
  80186. * Gets the parent skeleton
  80187. * @returns a skeleton
  80188. */
  80189. getSkeleton(): Skeleton;
  80190. /**
  80191. * Gets parent bone
  80192. * @returns a bone or null if the bone is the root of the bone hierarchy
  80193. */
  80194. getParent(): Nullable<Bone>;
  80195. /**
  80196. * Returns an array containing the root bones
  80197. * @returns an array containing the root bones
  80198. */
  80199. getChildren(): Array<Bone>;
  80200. /**
  80201. * Sets the parent bone
  80202. * @param parent defines the parent (can be null if the bone is the root)
  80203. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80204. */
  80205. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80206. /**
  80207. * Gets the local matrix
  80208. * @returns a matrix
  80209. */
  80210. getLocalMatrix(): Matrix;
  80211. /**
  80212. * Gets the base matrix (initial matrix which remains unchanged)
  80213. * @returns a matrix
  80214. */
  80215. getBaseMatrix(): Matrix;
  80216. /**
  80217. * Gets the rest pose matrix
  80218. * @returns a matrix
  80219. */
  80220. getRestPose(): Matrix;
  80221. /**
  80222. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80223. */
  80224. getWorldMatrix(): Matrix;
  80225. /**
  80226. * Sets the local matrix to rest pose matrix
  80227. */
  80228. returnToRest(): void;
  80229. /**
  80230. * Gets the inverse of the absolute transform matrix.
  80231. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80232. * @returns a matrix
  80233. */
  80234. getInvertedAbsoluteTransform(): Matrix;
  80235. /**
  80236. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80237. * @returns a matrix
  80238. */
  80239. getAbsoluteTransform(): Matrix;
  80240. /**
  80241. * Links with the given transform node.
  80242. * The local matrix of this bone is copied from the transform node every frame.
  80243. * @param transformNode defines the transform node to link to
  80244. */
  80245. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80246. /**
  80247. * Gets the node used to drive the bone's transformation
  80248. * @returns a transform node or null
  80249. */
  80250. getTransformNode(): Nullable<TransformNode>;
  80251. /** Gets or sets current position (in local space) */
  80252. position: Vector3;
  80253. /** Gets or sets current rotation (in local space) */
  80254. rotation: Vector3;
  80255. /** Gets or sets current rotation quaternion (in local space) */
  80256. rotationQuaternion: Quaternion;
  80257. /** Gets or sets current scaling (in local space) */
  80258. scaling: Vector3;
  80259. /**
  80260. * Gets the animation properties override
  80261. */
  80262. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80263. private _decompose;
  80264. private _compose;
  80265. /**
  80266. * Update the base and local matrices
  80267. * @param matrix defines the new base or local matrix
  80268. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80269. * @param updateLocalMatrix defines if the local matrix should be updated
  80270. */
  80271. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80272. /** @hidden */
  80273. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80274. /**
  80275. * Flag the bone as dirty (Forcing it to update everything)
  80276. */
  80277. markAsDirty(): void;
  80278. /** @hidden */
  80279. _markAsDirtyAndCompose(): void;
  80280. private _markAsDirtyAndDecompose;
  80281. /**
  80282. * Translate the bone in local or world space
  80283. * @param vec The amount to translate the bone
  80284. * @param space The space that the translation is in
  80285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80286. */
  80287. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80288. /**
  80289. * Set the postion of the bone in local or world space
  80290. * @param position The position to set the bone
  80291. * @param space The space that the position is in
  80292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80293. */
  80294. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80295. /**
  80296. * Set the absolute position of the bone (world space)
  80297. * @param position The position to set the bone
  80298. * @param mesh The mesh that this bone is attached to
  80299. */
  80300. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80301. /**
  80302. * Scale the bone on the x, y and z axes (in local space)
  80303. * @param x The amount to scale the bone on the x axis
  80304. * @param y The amount to scale the bone on the y axis
  80305. * @param z The amount to scale the bone on the z axis
  80306. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80307. */
  80308. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80309. /**
  80310. * Set the bone scaling in local space
  80311. * @param scale defines the scaling vector
  80312. */
  80313. setScale(scale: Vector3): void;
  80314. /**
  80315. * Gets the current scaling in local space
  80316. * @returns the current scaling vector
  80317. */
  80318. getScale(): Vector3;
  80319. /**
  80320. * Gets the current scaling in local space and stores it in a target vector
  80321. * @param result defines the target vector
  80322. */
  80323. getScaleToRef(result: Vector3): void;
  80324. /**
  80325. * Set the yaw, pitch, and roll of the bone in local or world space
  80326. * @param yaw The rotation of the bone on the y axis
  80327. * @param pitch The rotation of the bone on the x axis
  80328. * @param roll The rotation of the bone on the z axis
  80329. * @param space The space that the axes of rotation are in
  80330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80331. */
  80332. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80333. /**
  80334. * Add a rotation to the bone on an axis in local or world space
  80335. * @param axis The axis to rotate the bone on
  80336. * @param amount The amount to rotate the bone
  80337. * @param space The space that the axis is in
  80338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80339. */
  80340. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80341. /**
  80342. * Set the rotation of the bone to a particular axis angle in local or world space
  80343. * @param axis The axis to rotate the bone on
  80344. * @param angle The angle that the bone should be rotated to
  80345. * @param space The space that the axis is in
  80346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80347. */
  80348. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80349. /**
  80350. * Set the euler rotation of the bone in local of world space
  80351. * @param rotation The euler rotation that the bone should be set to
  80352. * @param space The space that the rotation is in
  80353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80354. */
  80355. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80356. /**
  80357. * Set the quaternion rotation of the bone in local of world space
  80358. * @param quat The quaternion rotation that the bone should be set to
  80359. * @param space The space that the rotation is in
  80360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80361. */
  80362. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80363. /**
  80364. * Set the rotation matrix of the bone in local of world space
  80365. * @param rotMat The rotation matrix that the bone should be set to
  80366. * @param space The space that the rotation is in
  80367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80368. */
  80369. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80370. private _rotateWithMatrix;
  80371. private _getNegativeRotationToRef;
  80372. /**
  80373. * Get the position of the bone in local or world space
  80374. * @param space The space that the returned position is in
  80375. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80376. * @returns The position of the bone
  80377. */
  80378. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80379. /**
  80380. * Copy the position of the bone to a vector3 in local or world space
  80381. * @param space The space that the returned position is in
  80382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80383. * @param result The vector3 to copy the position to
  80384. */
  80385. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80386. /**
  80387. * Get the absolute position of the bone (world space)
  80388. * @param mesh The mesh that this bone is attached to
  80389. * @returns The absolute position of the bone
  80390. */
  80391. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80392. /**
  80393. * Copy the absolute position of the bone (world space) to the result param
  80394. * @param mesh The mesh that this bone is attached to
  80395. * @param result The vector3 to copy the absolute position to
  80396. */
  80397. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80398. /**
  80399. * Compute the absolute transforms of this bone and its children
  80400. */
  80401. computeAbsoluteTransforms(): void;
  80402. /**
  80403. * Get the world direction from an axis that is in the local space of the bone
  80404. * @param localAxis The local direction that is used to compute the world direction
  80405. * @param mesh The mesh that this bone is attached to
  80406. * @returns The world direction
  80407. */
  80408. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80409. /**
  80410. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80411. * @param localAxis The local direction that is used to compute the world direction
  80412. * @param mesh The mesh that this bone is attached to
  80413. * @param result The vector3 that the world direction will be copied to
  80414. */
  80415. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80416. /**
  80417. * Get the euler rotation of the bone in local or world space
  80418. * @param space The space that the rotation should be in
  80419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80420. * @returns The euler rotation
  80421. */
  80422. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80423. /**
  80424. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80425. * @param space The space that the rotation should be in
  80426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80427. * @param result The vector3 that the rotation should be copied to
  80428. */
  80429. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80430. /**
  80431. * Get the quaternion rotation of the bone in either local or world space
  80432. * @param space The space that the rotation should be in
  80433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80434. * @returns The quaternion rotation
  80435. */
  80436. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80437. /**
  80438. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80439. * @param space The space that the rotation should be in
  80440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80441. * @param result The quaternion that the rotation should be copied to
  80442. */
  80443. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80444. /**
  80445. * Get the rotation matrix of the bone in local or world space
  80446. * @param space The space that the rotation should be in
  80447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80448. * @returns The rotation matrix
  80449. */
  80450. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80451. /**
  80452. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80453. * @param space The space that the rotation should be in
  80454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80455. * @param result The quaternion that the rotation should be copied to
  80456. */
  80457. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80458. /**
  80459. * Get the world position of a point that is in the local space of the bone
  80460. * @param position The local position
  80461. * @param mesh The mesh that this bone is attached to
  80462. * @returns The world position
  80463. */
  80464. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80465. /**
  80466. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80467. * @param position The local position
  80468. * @param mesh The mesh that this bone is attached to
  80469. * @param result The vector3 that the world position should be copied to
  80470. */
  80471. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80472. /**
  80473. * Get the local position of a point that is in world space
  80474. * @param position The world position
  80475. * @param mesh The mesh that this bone is attached to
  80476. * @returns The local position
  80477. */
  80478. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80479. /**
  80480. * Get the local position of a point that is in world space and copy it to the result param
  80481. * @param position The world position
  80482. * @param mesh The mesh that this bone is attached to
  80483. * @param result The vector3 that the local position should be copied to
  80484. */
  80485. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80486. }
  80487. }
  80488. declare module BABYLON {
  80489. /**
  80490. * 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.
  80491. * @see https://doc.babylonjs.com/how_to/transformnode
  80492. */
  80493. export class TransformNode extends Node {
  80494. /**
  80495. * Object will not rotate to face the camera
  80496. */
  80497. static BILLBOARDMODE_NONE: number;
  80498. /**
  80499. * Object will rotate to face the camera but only on the x axis
  80500. */
  80501. static BILLBOARDMODE_X: number;
  80502. /**
  80503. * Object will rotate to face the camera but only on the y axis
  80504. */
  80505. static BILLBOARDMODE_Y: number;
  80506. /**
  80507. * Object will rotate to face the camera but only on the z axis
  80508. */
  80509. static BILLBOARDMODE_Z: number;
  80510. /**
  80511. * Object will rotate to face the camera
  80512. */
  80513. static BILLBOARDMODE_ALL: number;
  80514. /**
  80515. * Object will rotate to face the camera's position instead of orientation
  80516. */
  80517. static BILLBOARDMODE_USE_POSITION: number;
  80518. private _forward;
  80519. private _forwardInverted;
  80520. private _up;
  80521. private _right;
  80522. private _rightInverted;
  80523. private _position;
  80524. private _rotation;
  80525. private _rotationQuaternion;
  80526. protected _scaling: Vector3;
  80527. protected _isDirty: boolean;
  80528. private _transformToBoneReferal;
  80529. private _isAbsoluteSynced;
  80530. private _billboardMode;
  80531. /**
  80532. * Gets or sets the billboard mode. Default is 0.
  80533. *
  80534. * | Value | Type | Description |
  80535. * | --- | --- | --- |
  80536. * | 0 | BILLBOARDMODE_NONE | |
  80537. * | 1 | BILLBOARDMODE_X | |
  80538. * | 2 | BILLBOARDMODE_Y | |
  80539. * | 4 | BILLBOARDMODE_Z | |
  80540. * | 7 | BILLBOARDMODE_ALL | |
  80541. *
  80542. */
  80543. billboardMode: number;
  80544. private _preserveParentRotationForBillboard;
  80545. /**
  80546. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80547. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80548. */
  80549. preserveParentRotationForBillboard: boolean;
  80550. /**
  80551. * 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
  80552. */
  80553. scalingDeterminant: number;
  80554. private _infiniteDistance;
  80555. /**
  80556. * Gets or sets the distance of the object to max, often used by skybox
  80557. */
  80558. infiniteDistance: boolean;
  80559. /**
  80560. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80561. * By default the system will update normals to compensate
  80562. */
  80563. ignoreNonUniformScaling: boolean;
  80564. /**
  80565. * 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
  80566. */
  80567. reIntegrateRotationIntoRotationQuaternion: boolean;
  80568. /** @hidden */
  80569. _poseMatrix: Nullable<Matrix>;
  80570. /** @hidden */
  80571. _localMatrix: Matrix;
  80572. private _usePivotMatrix;
  80573. private _absolutePosition;
  80574. private _absoluteScaling;
  80575. private _absoluteRotationQuaternion;
  80576. private _pivotMatrix;
  80577. private _pivotMatrixInverse;
  80578. protected _postMultiplyPivotMatrix: boolean;
  80579. protected _isWorldMatrixFrozen: boolean;
  80580. /** @hidden */
  80581. _indexInSceneTransformNodesArray: number;
  80582. /**
  80583. * An event triggered after the world matrix is updated
  80584. */
  80585. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80586. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80587. /**
  80588. * Gets a string identifying the name of the class
  80589. * @returns "TransformNode" string
  80590. */
  80591. getClassName(): string;
  80592. /**
  80593. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80594. */
  80595. position: Vector3;
  80596. /**
  80597. * 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)).
  80598. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80599. */
  80600. rotation: Vector3;
  80601. /**
  80602. * 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)).
  80603. */
  80604. scaling: Vector3;
  80605. /**
  80606. * 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).
  80607. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80608. */
  80609. rotationQuaternion: Nullable<Quaternion>;
  80610. /**
  80611. * The forward direction of that transform in world space.
  80612. */
  80613. readonly forward: Vector3;
  80614. /**
  80615. * The up direction of that transform in world space.
  80616. */
  80617. readonly up: Vector3;
  80618. /**
  80619. * The right direction of that transform in world space.
  80620. */
  80621. readonly right: Vector3;
  80622. /**
  80623. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80624. * @param matrix the matrix to copy the pose from
  80625. * @returns this TransformNode.
  80626. */
  80627. updatePoseMatrix(matrix: Matrix): TransformNode;
  80628. /**
  80629. * Returns the mesh Pose matrix.
  80630. * @returns the pose matrix
  80631. */
  80632. getPoseMatrix(): Matrix;
  80633. /** @hidden */
  80634. _isSynchronized(): boolean;
  80635. /** @hidden */
  80636. _initCache(): void;
  80637. /**
  80638. * Flag the transform node as dirty (Forcing it to update everything)
  80639. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80640. * @returns this transform node
  80641. */
  80642. markAsDirty(property: string): TransformNode;
  80643. /**
  80644. * Returns the current mesh absolute position.
  80645. * Returns a Vector3.
  80646. */
  80647. readonly absolutePosition: Vector3;
  80648. /**
  80649. * Returns the current mesh absolute scaling.
  80650. * Returns a Vector3.
  80651. */
  80652. readonly absoluteScaling: Vector3;
  80653. /**
  80654. * Returns the current mesh absolute rotation.
  80655. * Returns a Quaternion.
  80656. */
  80657. readonly absoluteRotationQuaternion: Quaternion;
  80658. /**
  80659. * Sets a new matrix to apply before all other transformation
  80660. * @param matrix defines the transform matrix
  80661. * @returns the current TransformNode
  80662. */
  80663. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80664. /**
  80665. * Sets a new pivot matrix to the current node
  80666. * @param matrix defines the new pivot matrix to use
  80667. * @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
  80668. * @returns the current TransformNode
  80669. */
  80670. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80671. /**
  80672. * Returns the mesh pivot matrix.
  80673. * Default : Identity.
  80674. * @returns the matrix
  80675. */
  80676. getPivotMatrix(): Matrix;
  80677. /**
  80678. * Instantiate (when possible) or clone that node with its hierarchy
  80679. * @param newParent defines the new parent to use for the instance (or clone)
  80680. * @returns an instance (or a clone) of the current node with its hiearchy
  80681. */
  80682. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80683. /**
  80684. * Prevents the World matrix to be computed any longer
  80685. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80686. * @returns the TransformNode.
  80687. */
  80688. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80689. /**
  80690. * Allows back the World matrix computation.
  80691. * @returns the TransformNode.
  80692. */
  80693. unfreezeWorldMatrix(): this;
  80694. /**
  80695. * True if the World matrix has been frozen.
  80696. */
  80697. readonly isWorldMatrixFrozen: boolean;
  80698. /**
  80699. * Retuns the mesh absolute position in the World.
  80700. * @returns a Vector3.
  80701. */
  80702. getAbsolutePosition(): Vector3;
  80703. /**
  80704. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80705. * @param absolutePosition the absolute position to set
  80706. * @returns the TransformNode.
  80707. */
  80708. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80709. /**
  80710. * Sets the mesh position in its local space.
  80711. * @param vector3 the position to set in localspace
  80712. * @returns the TransformNode.
  80713. */
  80714. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80715. /**
  80716. * Returns the mesh position in the local space from the current World matrix values.
  80717. * @returns a new Vector3.
  80718. */
  80719. getPositionExpressedInLocalSpace(): Vector3;
  80720. /**
  80721. * Translates the mesh along the passed Vector3 in its local space.
  80722. * @param vector3 the distance to translate in localspace
  80723. * @returns the TransformNode.
  80724. */
  80725. locallyTranslate(vector3: Vector3): TransformNode;
  80726. private static _lookAtVectorCache;
  80727. /**
  80728. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80729. * @param targetPoint the position (must be in same space as current mesh) to look at
  80730. * @param yawCor optional yaw (y-axis) correction in radians
  80731. * @param pitchCor optional pitch (x-axis) correction in radians
  80732. * @param rollCor optional roll (z-axis) correction in radians
  80733. * @param space the choosen space of the target
  80734. * @returns the TransformNode.
  80735. */
  80736. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80737. /**
  80738. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80739. * This Vector3 is expressed in the World space.
  80740. * @param localAxis axis to rotate
  80741. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80742. */
  80743. getDirection(localAxis: Vector3): Vector3;
  80744. /**
  80745. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80746. * localAxis is expressed in the mesh local space.
  80747. * result is computed in the Wordl space from the mesh World matrix.
  80748. * @param localAxis axis to rotate
  80749. * @param result the resulting transformnode
  80750. * @returns this TransformNode.
  80751. */
  80752. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80753. /**
  80754. * Sets this transform node rotation to the given local axis.
  80755. * @param localAxis the axis in local space
  80756. * @param yawCor optional yaw (y-axis) correction in radians
  80757. * @param pitchCor optional pitch (x-axis) correction in radians
  80758. * @param rollCor optional roll (z-axis) correction in radians
  80759. * @returns this TransformNode
  80760. */
  80761. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80762. /**
  80763. * Sets a new pivot point to the current node
  80764. * @param point defines the new pivot point to use
  80765. * @param space defines if the point is in world or local space (local by default)
  80766. * @returns the current TransformNode
  80767. */
  80768. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80769. /**
  80770. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80771. * @returns the pivot point
  80772. */
  80773. getPivotPoint(): Vector3;
  80774. /**
  80775. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80776. * @param result the vector3 to store the result
  80777. * @returns this TransformNode.
  80778. */
  80779. getPivotPointToRef(result: Vector3): TransformNode;
  80780. /**
  80781. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80782. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80783. */
  80784. getAbsolutePivotPoint(): Vector3;
  80785. /**
  80786. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80787. * @param result vector3 to store the result
  80788. * @returns this TransformNode.
  80789. */
  80790. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80791. /**
  80792. * Defines the passed node as the parent of the current node.
  80793. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80794. * @see https://doc.babylonjs.com/how_to/parenting
  80795. * @param node the node ot set as the parent
  80796. * @returns this TransformNode.
  80797. */
  80798. setParent(node: Nullable<Node>): TransformNode;
  80799. private _nonUniformScaling;
  80800. /**
  80801. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80802. */
  80803. readonly nonUniformScaling: boolean;
  80804. /** @hidden */
  80805. _updateNonUniformScalingState(value: boolean): boolean;
  80806. /**
  80807. * Attach the current TransformNode to another TransformNode associated with a bone
  80808. * @param bone Bone affecting the TransformNode
  80809. * @param affectedTransformNode TransformNode associated with the bone
  80810. * @returns this object
  80811. */
  80812. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80813. /**
  80814. * Detach the transform node if its associated with a bone
  80815. * @returns this object
  80816. */
  80817. detachFromBone(): TransformNode;
  80818. private static _rotationAxisCache;
  80819. /**
  80820. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80821. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80822. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80823. * The passed axis is also normalized.
  80824. * @param axis the axis to rotate around
  80825. * @param amount the amount to rotate in radians
  80826. * @param space Space to rotate in (Default: local)
  80827. * @returns the TransformNode.
  80828. */
  80829. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80830. /**
  80831. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80832. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80833. * The passed axis is also normalized. .
  80834. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80835. * @param point the point to rotate around
  80836. * @param axis the axis to rotate around
  80837. * @param amount the amount to rotate in radians
  80838. * @returns the TransformNode
  80839. */
  80840. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80841. /**
  80842. * Translates the mesh along the axis vector for the passed distance in the given space.
  80843. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80844. * @param axis the axis to translate in
  80845. * @param distance the distance to translate
  80846. * @param space Space to rotate in (Default: local)
  80847. * @returns the TransformNode.
  80848. */
  80849. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80850. /**
  80851. * Adds a rotation step to the mesh current rotation.
  80852. * x, y, z are Euler angles expressed in radians.
  80853. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80854. * This means this rotation is made in the mesh local space only.
  80855. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80856. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80857. * ```javascript
  80858. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80859. * ```
  80860. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80861. * 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.
  80862. * @param x Rotation to add
  80863. * @param y Rotation to add
  80864. * @param z Rotation to add
  80865. * @returns the TransformNode.
  80866. */
  80867. addRotation(x: number, y: number, z: number): TransformNode;
  80868. /**
  80869. * @hidden
  80870. */
  80871. protected _getEffectiveParent(): Nullable<Node>;
  80872. /**
  80873. * Computes the world matrix of the node
  80874. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80875. * @returns the world matrix
  80876. */
  80877. computeWorldMatrix(force?: boolean): Matrix;
  80878. protected _afterComputeWorldMatrix(): void;
  80879. /**
  80880. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80881. * @param func callback function to add
  80882. *
  80883. * @returns the TransformNode.
  80884. */
  80885. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80886. /**
  80887. * Removes a registered callback function.
  80888. * @param func callback function to remove
  80889. * @returns the TransformNode.
  80890. */
  80891. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80892. /**
  80893. * Gets the position of the current mesh in camera space
  80894. * @param camera defines the camera to use
  80895. * @returns a position
  80896. */
  80897. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80898. /**
  80899. * Returns the distance from the mesh to the active camera
  80900. * @param camera defines the camera to use
  80901. * @returns the distance
  80902. */
  80903. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80904. /**
  80905. * Clone the current transform node
  80906. * @param name Name of the new clone
  80907. * @param newParent New parent for the clone
  80908. * @param doNotCloneChildren Do not clone children hierarchy
  80909. * @returns the new transform node
  80910. */
  80911. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80912. /**
  80913. * Serializes the objects information.
  80914. * @param currentSerializationObject defines the object to serialize in
  80915. * @returns the serialized object
  80916. */
  80917. serialize(currentSerializationObject?: any): any;
  80918. /**
  80919. * Returns a new TransformNode object parsed from the source provided.
  80920. * @param parsedTransformNode is the source.
  80921. * @param scene the scne the object belongs to
  80922. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80923. * @returns a new TransformNode object parsed from the source provided.
  80924. */
  80925. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80926. /**
  80927. * Get all child-transformNodes of this node
  80928. * @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
  80929. * @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
  80930. * @returns an array of TransformNode
  80931. */
  80932. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80933. /**
  80934. * Releases resources associated with this transform node.
  80935. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80936. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80937. */
  80938. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80939. /**
  80940. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80941. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80942. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80943. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80944. * @returns the current mesh
  80945. */
  80946. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80947. private _syncAbsoluteScalingAndRotation;
  80948. }
  80949. }
  80950. declare module BABYLON {
  80951. /**
  80952. * Defines the types of pose enabled controllers that are supported
  80953. */
  80954. export enum PoseEnabledControllerType {
  80955. /**
  80956. * HTC Vive
  80957. */
  80958. VIVE = 0,
  80959. /**
  80960. * Oculus Rift
  80961. */
  80962. OCULUS = 1,
  80963. /**
  80964. * Windows mixed reality
  80965. */
  80966. WINDOWS = 2,
  80967. /**
  80968. * Samsung gear VR
  80969. */
  80970. GEAR_VR = 3,
  80971. /**
  80972. * Google Daydream
  80973. */
  80974. DAYDREAM = 4,
  80975. /**
  80976. * Generic
  80977. */
  80978. GENERIC = 5
  80979. }
  80980. /**
  80981. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80982. */
  80983. export interface MutableGamepadButton {
  80984. /**
  80985. * Value of the button/trigger
  80986. */
  80987. value: number;
  80988. /**
  80989. * If the button/trigger is currently touched
  80990. */
  80991. touched: boolean;
  80992. /**
  80993. * If the button/trigger is currently pressed
  80994. */
  80995. pressed: boolean;
  80996. }
  80997. /**
  80998. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80999. * @hidden
  81000. */
  81001. export interface ExtendedGamepadButton extends GamepadButton {
  81002. /**
  81003. * If the button/trigger is currently pressed
  81004. */
  81005. readonly pressed: boolean;
  81006. /**
  81007. * If the button/trigger is currently touched
  81008. */
  81009. readonly touched: boolean;
  81010. /**
  81011. * Value of the button/trigger
  81012. */
  81013. readonly value: number;
  81014. }
  81015. /** @hidden */
  81016. export interface _GamePadFactory {
  81017. /**
  81018. * Returns wether or not the current gamepad can be created for this type of controller.
  81019. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81020. * @returns true if it can be created, otherwise false
  81021. */
  81022. canCreate(gamepadInfo: any): boolean;
  81023. /**
  81024. * Creates a new instance of the Gamepad.
  81025. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81026. * @returns the new gamepad instance
  81027. */
  81028. create(gamepadInfo: any): Gamepad;
  81029. }
  81030. /**
  81031. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81032. */
  81033. export class PoseEnabledControllerHelper {
  81034. /** @hidden */
  81035. static _ControllerFactories: _GamePadFactory[];
  81036. /** @hidden */
  81037. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81038. /**
  81039. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81040. * @param vrGamepad the gamepad to initialized
  81041. * @returns a vr controller of the type the gamepad identified as
  81042. */
  81043. static InitiateController(vrGamepad: any): Gamepad;
  81044. }
  81045. /**
  81046. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81047. */
  81048. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81049. /**
  81050. * If the controller is used in a webXR session
  81051. */
  81052. isXR: boolean;
  81053. private _deviceRoomPosition;
  81054. private _deviceRoomRotationQuaternion;
  81055. /**
  81056. * The device position in babylon space
  81057. */
  81058. devicePosition: Vector3;
  81059. /**
  81060. * The device rotation in babylon space
  81061. */
  81062. deviceRotationQuaternion: Quaternion;
  81063. /**
  81064. * The scale factor of the device in babylon space
  81065. */
  81066. deviceScaleFactor: number;
  81067. /**
  81068. * (Likely devicePosition should be used instead) The device position in its room space
  81069. */
  81070. position: Vector3;
  81071. /**
  81072. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81073. */
  81074. rotationQuaternion: Quaternion;
  81075. /**
  81076. * The type of controller (Eg. Windows mixed reality)
  81077. */
  81078. controllerType: PoseEnabledControllerType;
  81079. protected _calculatedPosition: Vector3;
  81080. private _calculatedRotation;
  81081. /**
  81082. * The raw pose from the device
  81083. */
  81084. rawPose: DevicePose;
  81085. private _trackPosition;
  81086. private _maxRotationDistFromHeadset;
  81087. private _draggedRoomRotation;
  81088. /**
  81089. * @hidden
  81090. */
  81091. _disableTrackPosition(fixedPosition: Vector3): void;
  81092. /**
  81093. * Internal, the mesh attached to the controller
  81094. * @hidden
  81095. */
  81096. _mesh: Nullable<AbstractMesh>;
  81097. private _poseControlledCamera;
  81098. private _leftHandSystemQuaternion;
  81099. /**
  81100. * Internal, matrix used to convert room space to babylon space
  81101. * @hidden
  81102. */
  81103. _deviceToWorld: Matrix;
  81104. /**
  81105. * Node to be used when casting a ray from the controller
  81106. * @hidden
  81107. */
  81108. _pointingPoseNode: Nullable<TransformNode>;
  81109. /**
  81110. * Name of the child mesh that can be used to cast a ray from the controller
  81111. */
  81112. static readonly POINTING_POSE: string;
  81113. /**
  81114. * Creates a new PoseEnabledController from a gamepad
  81115. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81116. */
  81117. constructor(browserGamepad: any);
  81118. private _workingMatrix;
  81119. /**
  81120. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81121. */
  81122. update(): void;
  81123. /**
  81124. * Updates only the pose device and mesh without doing any button event checking
  81125. */
  81126. protected _updatePoseAndMesh(): void;
  81127. /**
  81128. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81129. * @param poseData raw pose fromthe device
  81130. */
  81131. updateFromDevice(poseData: DevicePose): void;
  81132. /**
  81133. * @hidden
  81134. */
  81135. _meshAttachedObservable: Observable<AbstractMesh>;
  81136. /**
  81137. * Attaches a mesh to the controller
  81138. * @param mesh the mesh to be attached
  81139. */
  81140. attachToMesh(mesh: AbstractMesh): void;
  81141. /**
  81142. * Attaches the controllers mesh to a camera
  81143. * @param camera the camera the mesh should be attached to
  81144. */
  81145. attachToPoseControlledCamera(camera: TargetCamera): void;
  81146. /**
  81147. * Disposes of the controller
  81148. */
  81149. dispose(): void;
  81150. /**
  81151. * The mesh that is attached to the controller
  81152. */
  81153. readonly mesh: Nullable<AbstractMesh>;
  81154. /**
  81155. * Gets the ray of the controller in the direction the controller is pointing
  81156. * @param length the length the resulting ray should be
  81157. * @returns a ray in the direction the controller is pointing
  81158. */
  81159. getForwardRay(length?: number): Ray;
  81160. }
  81161. }
  81162. declare module BABYLON {
  81163. /**
  81164. * Defines the WebVRController object that represents controllers tracked in 3D space
  81165. */
  81166. export abstract class WebVRController extends PoseEnabledController {
  81167. /**
  81168. * Internal, the default controller model for the controller
  81169. */
  81170. protected _defaultModel: Nullable<AbstractMesh>;
  81171. /**
  81172. * Fired when the trigger state has changed
  81173. */
  81174. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81175. /**
  81176. * Fired when the main button state has changed
  81177. */
  81178. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81179. /**
  81180. * Fired when the secondary button state has changed
  81181. */
  81182. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81183. /**
  81184. * Fired when the pad state has changed
  81185. */
  81186. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81187. /**
  81188. * Fired when controllers stick values have changed
  81189. */
  81190. onPadValuesChangedObservable: Observable<StickValues>;
  81191. /**
  81192. * Array of button availible on the controller
  81193. */
  81194. protected _buttons: Array<MutableGamepadButton>;
  81195. private _onButtonStateChange;
  81196. /**
  81197. * Fired when a controller button's state has changed
  81198. * @param callback the callback containing the button that was modified
  81199. */
  81200. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81201. /**
  81202. * X and Y axis corresponding to the controllers joystick
  81203. */
  81204. pad: StickValues;
  81205. /**
  81206. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81207. */
  81208. hand: string;
  81209. /**
  81210. * The default controller model for the controller
  81211. */
  81212. readonly defaultModel: Nullable<AbstractMesh>;
  81213. /**
  81214. * Creates a new WebVRController from a gamepad
  81215. * @param vrGamepad the gamepad that the WebVRController should be created from
  81216. */
  81217. constructor(vrGamepad: any);
  81218. /**
  81219. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81220. */
  81221. update(): void;
  81222. /**
  81223. * Function to be called when a button is modified
  81224. */
  81225. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81226. /**
  81227. * Loads a mesh and attaches it to the controller
  81228. * @param scene the scene the mesh should be added to
  81229. * @param meshLoaded callback for when the mesh has been loaded
  81230. */
  81231. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81232. private _setButtonValue;
  81233. private _changes;
  81234. private _checkChanges;
  81235. /**
  81236. * Disposes of th webVRCOntroller
  81237. */
  81238. dispose(): void;
  81239. }
  81240. }
  81241. declare module BABYLON {
  81242. /**
  81243. * The HemisphericLight simulates the ambient environment light,
  81244. * so the passed direction is the light reflection direction, not the incoming direction.
  81245. */
  81246. export class HemisphericLight extends Light {
  81247. /**
  81248. * The groundColor is the light in the opposite direction to the one specified during creation.
  81249. * 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.
  81250. */
  81251. groundColor: Color3;
  81252. /**
  81253. * The light reflection direction, not the incoming direction.
  81254. */
  81255. direction: Vector3;
  81256. /**
  81257. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81258. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81259. * The HemisphericLight can't cast shadows.
  81260. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81261. * @param name The friendly name of the light
  81262. * @param direction The direction of the light reflection
  81263. * @param scene The scene the light belongs to
  81264. */
  81265. constructor(name: string, direction: Vector3, scene: Scene);
  81266. protected _buildUniformLayout(): void;
  81267. /**
  81268. * Returns the string "HemisphericLight".
  81269. * @return The class name
  81270. */
  81271. getClassName(): string;
  81272. /**
  81273. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81274. * Returns the updated direction.
  81275. * @param target The target the direction should point to
  81276. * @return The computed direction
  81277. */
  81278. setDirectionToTarget(target: Vector3): Vector3;
  81279. /**
  81280. * Returns the shadow generator associated to the light.
  81281. * @returns Always null for hemispheric lights because it does not support shadows.
  81282. */
  81283. getShadowGenerator(): Nullable<IShadowGenerator>;
  81284. /**
  81285. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81286. * @param effect The effect to update
  81287. * @param lightIndex The index of the light in the effect to update
  81288. * @returns The hemispheric light
  81289. */
  81290. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81291. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81292. /**
  81293. * Computes the world matrix of the node
  81294. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81295. * @param useWasUpdatedFlag defines a reserved property
  81296. * @returns the world matrix
  81297. */
  81298. computeWorldMatrix(): Matrix;
  81299. /**
  81300. * Returns the integer 3.
  81301. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81302. */
  81303. getTypeID(): number;
  81304. /**
  81305. * Prepares the list of defines specific to the light type.
  81306. * @param defines the list of defines
  81307. * @param lightIndex defines the index of the light for the effect
  81308. */
  81309. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81310. }
  81311. }
  81312. declare module BABYLON {
  81313. /** @hidden */
  81314. export var vrMultiviewToSingleviewPixelShader: {
  81315. name: string;
  81316. shader: string;
  81317. };
  81318. }
  81319. declare module BABYLON {
  81320. /**
  81321. * Renders to multiple views with a single draw call
  81322. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81323. */
  81324. export class MultiviewRenderTarget extends RenderTargetTexture {
  81325. /**
  81326. * Creates a multiview render target
  81327. * @param scene scene used with the render target
  81328. * @param size the size of the render target (used for each view)
  81329. */
  81330. constructor(scene: Scene, size?: number | {
  81331. width: number;
  81332. height: number;
  81333. } | {
  81334. ratio: number;
  81335. });
  81336. /**
  81337. * @hidden
  81338. * @param faceIndex the face index, if its a cube texture
  81339. */
  81340. _bindFrameBuffer(faceIndex?: number): void;
  81341. /**
  81342. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81343. * @returns the view count
  81344. */
  81345. getViewCount(): number;
  81346. }
  81347. }
  81348. declare module BABYLON {
  81349. /**
  81350. * Represents a camera frustum
  81351. */
  81352. export class Frustum {
  81353. /**
  81354. * Gets the planes representing the frustum
  81355. * @param transform matrix to be applied to the returned planes
  81356. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81357. */
  81358. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81359. /**
  81360. * Gets the near frustum plane transformed by the transform matrix
  81361. * @param transform transformation matrix to be applied to the resulting frustum plane
  81362. * @param frustumPlane the resuling frustum plane
  81363. */
  81364. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81365. /**
  81366. * Gets the far frustum plane transformed by the transform matrix
  81367. * @param transform transformation matrix to be applied to the resulting frustum plane
  81368. * @param frustumPlane the resuling frustum plane
  81369. */
  81370. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81371. /**
  81372. * Gets the left frustum plane transformed by the transform matrix
  81373. * @param transform transformation matrix to be applied to the resulting frustum plane
  81374. * @param frustumPlane the resuling frustum plane
  81375. */
  81376. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81377. /**
  81378. * Gets the right frustum plane transformed by the transform matrix
  81379. * @param transform transformation matrix to be applied to the resulting frustum plane
  81380. * @param frustumPlane the resuling frustum plane
  81381. */
  81382. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81383. /**
  81384. * Gets the top frustum plane transformed by the transform matrix
  81385. * @param transform transformation matrix to be applied to the resulting frustum plane
  81386. * @param frustumPlane the resuling frustum plane
  81387. */
  81388. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81389. /**
  81390. * Gets the bottom frustum plane transformed by the transform matrix
  81391. * @param transform transformation matrix to be applied to the resulting frustum plane
  81392. * @param frustumPlane the resuling frustum plane
  81393. */
  81394. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81395. /**
  81396. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81397. * @param transform transformation matrix to be applied to the resulting frustum planes
  81398. * @param frustumPlanes the resuling frustum planes
  81399. */
  81400. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81401. }
  81402. }
  81403. declare module BABYLON {
  81404. interface Engine {
  81405. /**
  81406. * Creates a new multiview render target
  81407. * @param width defines the width of the texture
  81408. * @param height defines the height of the texture
  81409. * @returns the created multiview texture
  81410. */
  81411. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81412. /**
  81413. * Binds a multiview framebuffer to be drawn to
  81414. * @param multiviewTexture texture to bind
  81415. */
  81416. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81417. }
  81418. interface Camera {
  81419. /**
  81420. * @hidden
  81421. * 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)
  81422. */
  81423. _useMultiviewToSingleView: boolean;
  81424. /**
  81425. * @hidden
  81426. * 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)
  81427. */
  81428. _multiviewTexture: Nullable<RenderTargetTexture>;
  81429. /**
  81430. * @hidden
  81431. * ensures the multiview texture of the camera exists and has the specified width/height
  81432. * @param width height to set on the multiview texture
  81433. * @param height width to set on the multiview texture
  81434. */
  81435. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81436. }
  81437. interface Scene {
  81438. /** @hidden */
  81439. _transformMatrixR: Matrix;
  81440. /** @hidden */
  81441. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81442. /** @hidden */
  81443. _createMultiviewUbo(): void;
  81444. /** @hidden */
  81445. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81446. /** @hidden */
  81447. _renderMultiviewToSingleView(camera: Camera): void;
  81448. }
  81449. }
  81450. declare module BABYLON {
  81451. /**
  81452. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81453. * This will not be used for webXR as it supports displaying texture arrays directly
  81454. */
  81455. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81456. /**
  81457. * Initializes a VRMultiviewToSingleview
  81458. * @param name name of the post process
  81459. * @param camera camera to be applied to
  81460. * @param scaleFactor scaling factor to the size of the output texture
  81461. */
  81462. constructor(name: string, camera: Camera, scaleFactor: number);
  81463. }
  81464. }
  81465. declare module BABYLON {
  81466. interface Engine {
  81467. /** @hidden */
  81468. _vrDisplay: any;
  81469. /** @hidden */
  81470. _vrSupported: boolean;
  81471. /** @hidden */
  81472. _oldSize: Size;
  81473. /** @hidden */
  81474. _oldHardwareScaleFactor: number;
  81475. /** @hidden */
  81476. _vrExclusivePointerMode: boolean;
  81477. /** @hidden */
  81478. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81479. /** @hidden */
  81480. _onVRDisplayPointerRestricted: () => void;
  81481. /** @hidden */
  81482. _onVRDisplayPointerUnrestricted: () => void;
  81483. /** @hidden */
  81484. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81485. /** @hidden */
  81486. _onVrDisplayDisconnect: Nullable<() => void>;
  81487. /** @hidden */
  81488. _onVrDisplayPresentChange: Nullable<() => void>;
  81489. /**
  81490. * Observable signaled when VR display mode changes
  81491. */
  81492. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81493. /**
  81494. * Observable signaled when VR request present is complete
  81495. */
  81496. onVRRequestPresentComplete: Observable<boolean>;
  81497. /**
  81498. * Observable signaled when VR request present starts
  81499. */
  81500. onVRRequestPresentStart: Observable<Engine>;
  81501. /**
  81502. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81503. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81504. */
  81505. isInVRExclusivePointerMode: boolean;
  81506. /**
  81507. * Gets a boolean indicating if a webVR device was detected
  81508. * @returns true if a webVR device was detected
  81509. */
  81510. isVRDevicePresent(): boolean;
  81511. /**
  81512. * Gets the current webVR device
  81513. * @returns the current webVR device (or null)
  81514. */
  81515. getVRDevice(): any;
  81516. /**
  81517. * Initializes a webVR display and starts listening to display change events
  81518. * The onVRDisplayChangedObservable will be notified upon these changes
  81519. * @returns A promise containing a VRDisplay and if vr is supported
  81520. */
  81521. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81522. /** @hidden */
  81523. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81524. /**
  81525. * Call this function to switch to webVR mode
  81526. * Will do nothing if webVR is not supported or if there is no webVR device
  81527. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81528. */
  81529. enableVR(): void;
  81530. /** @hidden */
  81531. _onVRFullScreenTriggered(): void;
  81532. }
  81533. }
  81534. declare module BABYLON {
  81535. /**
  81536. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81537. * IMPORTANT!! The data is right-hand data.
  81538. * @export
  81539. * @interface DevicePose
  81540. */
  81541. export interface DevicePose {
  81542. /**
  81543. * The position of the device, values in array are [x,y,z].
  81544. */
  81545. readonly position: Nullable<Float32Array>;
  81546. /**
  81547. * The linearVelocity of the device, values in array are [x,y,z].
  81548. */
  81549. readonly linearVelocity: Nullable<Float32Array>;
  81550. /**
  81551. * The linearAcceleration of the device, values in array are [x,y,z].
  81552. */
  81553. readonly linearAcceleration: Nullable<Float32Array>;
  81554. /**
  81555. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81556. */
  81557. readonly orientation: Nullable<Float32Array>;
  81558. /**
  81559. * The angularVelocity of the device, values in array are [x,y,z].
  81560. */
  81561. readonly angularVelocity: Nullable<Float32Array>;
  81562. /**
  81563. * The angularAcceleration of the device, values in array are [x,y,z].
  81564. */
  81565. readonly angularAcceleration: Nullable<Float32Array>;
  81566. }
  81567. /**
  81568. * Interface representing a pose controlled object in Babylon.
  81569. * A pose controlled object has both regular pose values as well as pose values
  81570. * from an external device such as a VR head mounted display
  81571. */
  81572. export interface PoseControlled {
  81573. /**
  81574. * The position of the object in babylon space.
  81575. */
  81576. position: Vector3;
  81577. /**
  81578. * The rotation quaternion of the object in babylon space.
  81579. */
  81580. rotationQuaternion: Quaternion;
  81581. /**
  81582. * The position of the device in babylon space.
  81583. */
  81584. devicePosition?: Vector3;
  81585. /**
  81586. * The rotation quaternion of the device in babylon space.
  81587. */
  81588. deviceRotationQuaternion: Quaternion;
  81589. /**
  81590. * The raw pose coming from the device.
  81591. */
  81592. rawPose: Nullable<DevicePose>;
  81593. /**
  81594. * The scale of the device to be used when translating from device space to babylon space.
  81595. */
  81596. deviceScaleFactor: number;
  81597. /**
  81598. * Updates the poseControlled values based on the input device pose.
  81599. * @param poseData the pose data to update the object with
  81600. */
  81601. updateFromDevice(poseData: DevicePose): void;
  81602. }
  81603. /**
  81604. * Set of options to customize the webVRCamera
  81605. */
  81606. export interface WebVROptions {
  81607. /**
  81608. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81609. */
  81610. trackPosition?: boolean;
  81611. /**
  81612. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81613. */
  81614. positionScale?: number;
  81615. /**
  81616. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81617. */
  81618. displayName?: string;
  81619. /**
  81620. * Should the native controller meshes be initialized. (default: true)
  81621. */
  81622. controllerMeshes?: boolean;
  81623. /**
  81624. * Creating a default HemiLight only on controllers. (default: true)
  81625. */
  81626. defaultLightingOnControllers?: boolean;
  81627. /**
  81628. * If you don't want to use the default VR button of the helper. (default: false)
  81629. */
  81630. useCustomVRButton?: boolean;
  81631. /**
  81632. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81633. */
  81634. customVRButton?: HTMLButtonElement;
  81635. /**
  81636. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81637. */
  81638. rayLength?: number;
  81639. /**
  81640. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81641. */
  81642. defaultHeight?: number;
  81643. /**
  81644. * If multiview should be used if availible (default: false)
  81645. */
  81646. useMultiview?: boolean;
  81647. }
  81648. /**
  81649. * This represents a WebVR camera.
  81650. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81651. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81652. */
  81653. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81654. private webVROptions;
  81655. /**
  81656. * @hidden
  81657. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81658. */
  81659. _vrDevice: any;
  81660. /**
  81661. * The rawPose of the vrDevice.
  81662. */
  81663. rawPose: Nullable<DevicePose>;
  81664. private _onVREnabled;
  81665. private _specsVersion;
  81666. private _attached;
  81667. private _frameData;
  81668. protected _descendants: Array<Node>;
  81669. private _deviceRoomPosition;
  81670. /** @hidden */
  81671. _deviceRoomRotationQuaternion: Quaternion;
  81672. private _standingMatrix;
  81673. /**
  81674. * Represents device position in babylon space.
  81675. */
  81676. devicePosition: Vector3;
  81677. /**
  81678. * Represents device rotation in babylon space.
  81679. */
  81680. deviceRotationQuaternion: Quaternion;
  81681. /**
  81682. * The scale of the device to be used when translating from device space to babylon space.
  81683. */
  81684. deviceScaleFactor: number;
  81685. private _deviceToWorld;
  81686. private _worldToDevice;
  81687. /**
  81688. * References to the webVR controllers for the vrDevice.
  81689. */
  81690. controllers: Array<WebVRController>;
  81691. /**
  81692. * Emits an event when a controller is attached.
  81693. */
  81694. onControllersAttachedObservable: Observable<WebVRController[]>;
  81695. /**
  81696. * Emits an event when a controller's mesh has been loaded;
  81697. */
  81698. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81699. /**
  81700. * Emits an event when the HMD's pose has been updated.
  81701. */
  81702. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81703. private _poseSet;
  81704. /**
  81705. * If the rig cameras be used as parent instead of this camera.
  81706. */
  81707. rigParenting: boolean;
  81708. private _lightOnControllers;
  81709. private _defaultHeight?;
  81710. /**
  81711. * Instantiates a WebVRFreeCamera.
  81712. * @param name The name of the WebVRFreeCamera
  81713. * @param position The starting anchor position for the camera
  81714. * @param scene The scene the camera belongs to
  81715. * @param webVROptions a set of customizable options for the webVRCamera
  81716. */
  81717. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81718. /**
  81719. * Gets the device distance from the ground in meters.
  81720. * @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.
  81721. */
  81722. deviceDistanceToRoomGround(): number;
  81723. /**
  81724. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81725. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81726. */
  81727. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81728. /**
  81729. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81730. * @returns A promise with a boolean set to if the standing matrix is supported.
  81731. */
  81732. useStandingMatrixAsync(): Promise<boolean>;
  81733. /**
  81734. * Disposes the camera
  81735. */
  81736. dispose(): void;
  81737. /**
  81738. * Gets a vrController by name.
  81739. * @param name The name of the controller to retreive
  81740. * @returns the controller matching the name specified or null if not found
  81741. */
  81742. getControllerByName(name: string): Nullable<WebVRController>;
  81743. private _leftController;
  81744. /**
  81745. * The controller corresponding to the users left hand.
  81746. */
  81747. readonly leftController: Nullable<WebVRController>;
  81748. private _rightController;
  81749. /**
  81750. * The controller corresponding to the users right hand.
  81751. */
  81752. readonly rightController: Nullable<WebVRController>;
  81753. /**
  81754. * Casts a ray forward from the vrCamera's gaze.
  81755. * @param length Length of the ray (default: 100)
  81756. * @returns the ray corresponding to the gaze
  81757. */
  81758. getForwardRay(length?: number): Ray;
  81759. /**
  81760. * @hidden
  81761. * Updates the camera based on device's frame data
  81762. */
  81763. _checkInputs(): void;
  81764. /**
  81765. * Updates the poseControlled values based on the input device pose.
  81766. * @param poseData Pose coming from the device
  81767. */
  81768. updateFromDevice(poseData: DevicePose): void;
  81769. private _htmlElementAttached;
  81770. private _detachIfAttached;
  81771. /**
  81772. * WebVR's attach control will start broadcasting frames to the device.
  81773. * Note that in certain browsers (chrome for example) this function must be called
  81774. * within a user-interaction callback. Example:
  81775. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81776. *
  81777. * @param element html element to attach the vrDevice to
  81778. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81779. */
  81780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81781. /**
  81782. * Detaches the camera from the html element and disables VR
  81783. *
  81784. * @param element html element to detach from
  81785. */
  81786. detachControl(element: HTMLElement): void;
  81787. /**
  81788. * @returns the name of this class
  81789. */
  81790. getClassName(): string;
  81791. /**
  81792. * Calls resetPose on the vrDisplay
  81793. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81794. */
  81795. resetToCurrentRotation(): void;
  81796. /**
  81797. * @hidden
  81798. * Updates the rig cameras (left and right eye)
  81799. */
  81800. _updateRigCameras(): void;
  81801. private _workingVector;
  81802. private _oneVector;
  81803. private _workingMatrix;
  81804. private updateCacheCalled;
  81805. private _correctPositionIfNotTrackPosition;
  81806. /**
  81807. * @hidden
  81808. * Updates the cached values of the camera
  81809. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81810. */
  81811. _updateCache(ignoreParentClass?: boolean): void;
  81812. /**
  81813. * @hidden
  81814. * Get current device position in babylon world
  81815. */
  81816. _computeDevicePosition(): void;
  81817. /**
  81818. * Updates the current device position and rotation in the babylon world
  81819. */
  81820. update(): void;
  81821. /**
  81822. * @hidden
  81823. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81824. * @returns an identity matrix
  81825. */
  81826. _getViewMatrix(): Matrix;
  81827. private _tmpMatrix;
  81828. /**
  81829. * This function is called by the two RIG cameras.
  81830. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81831. * @hidden
  81832. */
  81833. _getWebVRViewMatrix(): Matrix;
  81834. /** @hidden */
  81835. _getWebVRProjectionMatrix(): Matrix;
  81836. private _onGamepadConnectedObserver;
  81837. private _onGamepadDisconnectedObserver;
  81838. private _updateCacheWhenTrackingDisabledObserver;
  81839. /**
  81840. * Initializes the controllers and their meshes
  81841. */
  81842. initControllers(): void;
  81843. }
  81844. }
  81845. declare module BABYLON {
  81846. /**
  81847. * Size options for a post process
  81848. */
  81849. export type PostProcessOptions = {
  81850. width: number;
  81851. height: number;
  81852. };
  81853. /**
  81854. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81855. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81856. */
  81857. export class PostProcess {
  81858. /** Name of the PostProcess. */
  81859. name: string;
  81860. /**
  81861. * Gets or sets the unique id of the post process
  81862. */
  81863. uniqueId: number;
  81864. /**
  81865. * Width of the texture to apply the post process on
  81866. */
  81867. width: number;
  81868. /**
  81869. * Height of the texture to apply the post process on
  81870. */
  81871. height: number;
  81872. /**
  81873. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81874. * @hidden
  81875. */
  81876. _outputTexture: Nullable<InternalTexture>;
  81877. /**
  81878. * Sampling mode used by the shader
  81879. * See https://doc.babylonjs.com/classes/3.1/texture
  81880. */
  81881. renderTargetSamplingMode: number;
  81882. /**
  81883. * Clear color to use when screen clearing
  81884. */
  81885. clearColor: Color4;
  81886. /**
  81887. * If the buffer needs to be cleared before applying the post process. (default: true)
  81888. * Should be set to false if shader will overwrite all previous pixels.
  81889. */
  81890. autoClear: boolean;
  81891. /**
  81892. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81893. */
  81894. alphaMode: number;
  81895. /**
  81896. * Sets the setAlphaBlendConstants of the babylon engine
  81897. */
  81898. alphaConstants: Color4;
  81899. /**
  81900. * Animations to be used for the post processing
  81901. */
  81902. animations: Animation[];
  81903. /**
  81904. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81905. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81906. */
  81907. enablePixelPerfectMode: boolean;
  81908. /**
  81909. * Force the postprocess to be applied without taking in account viewport
  81910. */
  81911. forceFullscreenViewport: boolean;
  81912. /**
  81913. * List of inspectable custom properties (used by the Inspector)
  81914. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81915. */
  81916. inspectableCustomProperties: IInspectable[];
  81917. /**
  81918. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81919. *
  81920. * | Value | Type | Description |
  81921. * | ----- | ----------------------------------- | ----------- |
  81922. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81923. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81924. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81925. *
  81926. */
  81927. scaleMode: number;
  81928. /**
  81929. * Force textures to be a power of two (default: false)
  81930. */
  81931. alwaysForcePOT: boolean;
  81932. private _samples;
  81933. /**
  81934. * Number of sample textures (default: 1)
  81935. */
  81936. samples: number;
  81937. /**
  81938. * Modify the scale of the post process to be the same as the viewport (default: false)
  81939. */
  81940. adaptScaleToCurrentViewport: boolean;
  81941. private _camera;
  81942. private _scene;
  81943. private _engine;
  81944. private _options;
  81945. private _reusable;
  81946. private _textureType;
  81947. /**
  81948. * Smart array of input and output textures for the post process.
  81949. * @hidden
  81950. */
  81951. _textures: SmartArray<InternalTexture>;
  81952. /**
  81953. * The index in _textures that corresponds to the output texture.
  81954. * @hidden
  81955. */
  81956. _currentRenderTextureInd: number;
  81957. private _effect;
  81958. private _samplers;
  81959. private _fragmentUrl;
  81960. private _vertexUrl;
  81961. private _parameters;
  81962. private _scaleRatio;
  81963. protected _indexParameters: any;
  81964. private _shareOutputWithPostProcess;
  81965. private _texelSize;
  81966. private _forcedOutputTexture;
  81967. /**
  81968. * Returns the fragment url or shader name used in the post process.
  81969. * @returns the fragment url or name in the shader store.
  81970. */
  81971. getEffectName(): string;
  81972. /**
  81973. * An event triggered when the postprocess is activated.
  81974. */
  81975. onActivateObservable: Observable<Camera>;
  81976. private _onActivateObserver;
  81977. /**
  81978. * A function that is added to the onActivateObservable
  81979. */
  81980. onActivate: Nullable<(camera: Camera) => void>;
  81981. /**
  81982. * An event triggered when the postprocess changes its size.
  81983. */
  81984. onSizeChangedObservable: Observable<PostProcess>;
  81985. private _onSizeChangedObserver;
  81986. /**
  81987. * A function that is added to the onSizeChangedObservable
  81988. */
  81989. onSizeChanged: (postProcess: PostProcess) => void;
  81990. /**
  81991. * An event triggered when the postprocess applies its effect.
  81992. */
  81993. onApplyObservable: Observable<Effect>;
  81994. private _onApplyObserver;
  81995. /**
  81996. * A function that is added to the onApplyObservable
  81997. */
  81998. onApply: (effect: Effect) => void;
  81999. /**
  82000. * An event triggered before rendering the postprocess
  82001. */
  82002. onBeforeRenderObservable: Observable<Effect>;
  82003. private _onBeforeRenderObserver;
  82004. /**
  82005. * A function that is added to the onBeforeRenderObservable
  82006. */
  82007. onBeforeRender: (effect: Effect) => void;
  82008. /**
  82009. * An event triggered after rendering the postprocess
  82010. */
  82011. onAfterRenderObservable: Observable<Effect>;
  82012. private _onAfterRenderObserver;
  82013. /**
  82014. * A function that is added to the onAfterRenderObservable
  82015. */
  82016. onAfterRender: (efect: Effect) => void;
  82017. /**
  82018. * 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
  82019. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82020. */
  82021. inputTexture: InternalTexture;
  82022. /**
  82023. * Gets the camera which post process is applied to.
  82024. * @returns The camera the post process is applied to.
  82025. */
  82026. getCamera(): Camera;
  82027. /**
  82028. * Gets the texel size of the postprocess.
  82029. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82030. */
  82031. readonly texelSize: Vector2;
  82032. /**
  82033. * Creates a new instance PostProcess
  82034. * @param name The name of the PostProcess.
  82035. * @param fragmentUrl The url of the fragment shader to be used.
  82036. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82037. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82038. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82039. * @param camera The camera to apply the render pass to.
  82040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82041. * @param engine The engine which the post process will be applied. (default: current engine)
  82042. * @param reusable If the post process can be reused on the same frame. (default: false)
  82043. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82044. * @param textureType Type of textures used when performing the post process. (default: 0)
  82045. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82046. * @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
  82047. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82048. */
  82049. constructor(
  82050. /** Name of the PostProcess. */
  82051. 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);
  82052. /**
  82053. * Gets a string idenfifying the name of the class
  82054. * @returns "PostProcess" string
  82055. */
  82056. getClassName(): string;
  82057. /**
  82058. * Gets the engine which this post process belongs to.
  82059. * @returns The engine the post process was enabled with.
  82060. */
  82061. getEngine(): Engine;
  82062. /**
  82063. * The effect that is created when initializing the post process.
  82064. * @returns The created effect corresponding the the postprocess.
  82065. */
  82066. getEffect(): Effect;
  82067. /**
  82068. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82069. * @param postProcess The post process to share the output with.
  82070. * @returns This post process.
  82071. */
  82072. shareOutputWith(postProcess: PostProcess): PostProcess;
  82073. /**
  82074. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82075. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82076. */
  82077. useOwnOutput(): void;
  82078. /**
  82079. * Updates the effect with the current post process compile time values and recompiles the shader.
  82080. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82081. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82082. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82083. * @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
  82084. * @param onCompiled Called when the shader has been compiled.
  82085. * @param onError Called if there is an error when compiling a shader.
  82086. */
  82087. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82088. /**
  82089. * The post process is reusable if it can be used multiple times within one frame.
  82090. * @returns If the post process is reusable
  82091. */
  82092. isReusable(): boolean;
  82093. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82094. markTextureDirty(): void;
  82095. /**
  82096. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82097. * 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.
  82098. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82099. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82100. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82101. * @returns The target texture that was bound to be written to.
  82102. */
  82103. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82104. /**
  82105. * If the post process is supported.
  82106. */
  82107. readonly isSupported: boolean;
  82108. /**
  82109. * The aspect ratio of the output texture.
  82110. */
  82111. readonly aspectRatio: number;
  82112. /**
  82113. * Get a value indicating if the post-process is ready to be used
  82114. * @returns true if the post-process is ready (shader is compiled)
  82115. */
  82116. isReady(): boolean;
  82117. /**
  82118. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82119. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82120. */
  82121. apply(): Nullable<Effect>;
  82122. private _disposeTextures;
  82123. /**
  82124. * Disposes the post process.
  82125. * @param camera The camera to dispose the post process on.
  82126. */
  82127. dispose(camera?: Camera): void;
  82128. }
  82129. }
  82130. declare module BABYLON {
  82131. /** @hidden */
  82132. export var kernelBlurVaryingDeclaration: {
  82133. name: string;
  82134. shader: string;
  82135. };
  82136. }
  82137. declare module BABYLON {
  82138. /** @hidden */
  82139. export var kernelBlurFragment: {
  82140. name: string;
  82141. shader: string;
  82142. };
  82143. }
  82144. declare module BABYLON {
  82145. /** @hidden */
  82146. export var kernelBlurFragment2: {
  82147. name: string;
  82148. shader: string;
  82149. };
  82150. }
  82151. declare module BABYLON {
  82152. /** @hidden */
  82153. export var kernelBlurPixelShader: {
  82154. name: string;
  82155. shader: string;
  82156. };
  82157. }
  82158. declare module BABYLON {
  82159. /** @hidden */
  82160. export var kernelBlurVertex: {
  82161. name: string;
  82162. shader: string;
  82163. };
  82164. }
  82165. declare module BABYLON {
  82166. /** @hidden */
  82167. export var kernelBlurVertexShader: {
  82168. name: string;
  82169. shader: string;
  82170. };
  82171. }
  82172. declare module BABYLON {
  82173. /**
  82174. * The Blur Post Process which blurs an image based on a kernel and direction.
  82175. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82176. */
  82177. export class BlurPostProcess extends PostProcess {
  82178. /** The direction in which to blur the image. */
  82179. direction: Vector2;
  82180. private blockCompilation;
  82181. protected _kernel: number;
  82182. protected _idealKernel: number;
  82183. protected _packedFloat: boolean;
  82184. private _staticDefines;
  82185. /**
  82186. * Sets the length in pixels of the blur sample region
  82187. */
  82188. /**
  82189. * Gets the length in pixels of the blur sample region
  82190. */
  82191. kernel: number;
  82192. /**
  82193. * Sets wether or not the blur needs to unpack/repack floats
  82194. */
  82195. /**
  82196. * Gets wether or not the blur is unpacking/repacking floats
  82197. */
  82198. packedFloat: boolean;
  82199. /**
  82200. * Creates a new instance BlurPostProcess
  82201. * @param name The name of the effect.
  82202. * @param direction The direction in which to blur the image.
  82203. * @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.
  82204. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82205. * @param camera The camera to apply the render pass to.
  82206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82207. * @param engine The engine which the post process will be applied. (default: current engine)
  82208. * @param reusable If the post process can be reused on the same frame. (default: false)
  82209. * @param textureType Type of textures used when performing the post process. (default: 0)
  82210. * @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)
  82211. */
  82212. constructor(name: string,
  82213. /** The direction in which to blur the image. */
  82214. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82215. /**
  82216. * Updates the effect with the current post process compile time values and recompiles the shader.
  82217. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82218. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82219. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82220. * @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
  82221. * @param onCompiled Called when the shader has been compiled.
  82222. * @param onError Called if there is an error when compiling a shader.
  82223. */
  82224. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82225. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82226. /**
  82227. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82228. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82229. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82230. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82231. * The gaps between physical kernels are compensated for in the weighting of the samples
  82232. * @param idealKernel Ideal blur kernel.
  82233. * @return Nearest best kernel.
  82234. */
  82235. protected _nearestBestKernel(idealKernel: number): number;
  82236. /**
  82237. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82238. * @param x The point on the Gaussian distribution to sample.
  82239. * @return the value of the Gaussian function at x.
  82240. */
  82241. protected _gaussianWeight(x: number): number;
  82242. /**
  82243. * Generates a string that can be used as a floating point number in GLSL.
  82244. * @param x Value to print.
  82245. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82246. * @return GLSL float string.
  82247. */
  82248. protected _glslFloat(x: number, decimalFigures?: number): string;
  82249. }
  82250. }
  82251. declare module BABYLON {
  82252. /**
  82253. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82254. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82255. * You can then easily use it as a reflectionTexture on a flat surface.
  82256. * In case the surface is not a plane, please consider relying on reflection probes.
  82257. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82258. */
  82259. export class MirrorTexture extends RenderTargetTexture {
  82260. private scene;
  82261. /**
  82262. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82263. * 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.
  82264. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82265. */
  82266. mirrorPlane: Plane;
  82267. /**
  82268. * Define the blur ratio used to blur the reflection if needed.
  82269. */
  82270. blurRatio: number;
  82271. /**
  82272. * Define the adaptive blur kernel used to blur the reflection if needed.
  82273. * This will autocompute the closest best match for the `blurKernel`
  82274. */
  82275. adaptiveBlurKernel: number;
  82276. /**
  82277. * Define the blur kernel used to blur the reflection if needed.
  82278. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82279. */
  82280. blurKernel: number;
  82281. /**
  82282. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82283. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82284. */
  82285. blurKernelX: number;
  82286. /**
  82287. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82288. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82289. */
  82290. blurKernelY: number;
  82291. private _autoComputeBlurKernel;
  82292. protected _onRatioRescale(): void;
  82293. private _updateGammaSpace;
  82294. private _imageProcessingConfigChangeObserver;
  82295. private _transformMatrix;
  82296. private _mirrorMatrix;
  82297. private _savedViewMatrix;
  82298. private _blurX;
  82299. private _blurY;
  82300. private _adaptiveBlurKernel;
  82301. private _blurKernelX;
  82302. private _blurKernelY;
  82303. private _blurRatio;
  82304. /**
  82305. * Instantiates a Mirror Texture.
  82306. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82307. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82308. * You can then easily use it as a reflectionTexture on a flat surface.
  82309. * In case the surface is not a plane, please consider relying on reflection probes.
  82310. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82311. * @param name
  82312. * @param size
  82313. * @param scene
  82314. * @param generateMipMaps
  82315. * @param type
  82316. * @param samplingMode
  82317. * @param generateDepthBuffer
  82318. */
  82319. constructor(name: string, size: number | {
  82320. width: number;
  82321. height: number;
  82322. } | {
  82323. ratio: number;
  82324. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82325. private _preparePostProcesses;
  82326. /**
  82327. * Clone the mirror texture.
  82328. * @returns the cloned texture
  82329. */
  82330. clone(): MirrorTexture;
  82331. /**
  82332. * Serialize the texture to a JSON representation you could use in Parse later on
  82333. * @returns the serialized JSON representation
  82334. */
  82335. serialize(): any;
  82336. /**
  82337. * Dispose the texture and release its associated resources.
  82338. */
  82339. dispose(): void;
  82340. }
  82341. }
  82342. declare module BABYLON {
  82343. /**
  82344. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82345. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82346. */
  82347. export class Texture extends BaseTexture {
  82348. /**
  82349. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82350. */
  82351. static SerializeBuffers: boolean;
  82352. /** @hidden */
  82353. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82354. /** @hidden */
  82355. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82356. /** @hidden */
  82357. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82358. /** nearest is mag = nearest and min = nearest and mip = linear */
  82359. static readonly NEAREST_SAMPLINGMODE: number;
  82360. /** nearest is mag = nearest and min = nearest and mip = linear */
  82361. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82362. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82363. static readonly BILINEAR_SAMPLINGMODE: number;
  82364. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82365. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82366. /** Trilinear is mag = linear and min = linear and mip = linear */
  82367. static readonly TRILINEAR_SAMPLINGMODE: number;
  82368. /** Trilinear is mag = linear and min = linear and mip = linear */
  82369. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82370. /** mag = nearest and min = nearest and mip = nearest */
  82371. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82372. /** mag = nearest and min = linear and mip = nearest */
  82373. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82374. /** mag = nearest and min = linear and mip = linear */
  82375. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82376. /** mag = nearest and min = linear and mip = none */
  82377. static readonly NEAREST_LINEAR: number;
  82378. /** mag = nearest and min = nearest and mip = none */
  82379. static readonly NEAREST_NEAREST: number;
  82380. /** mag = linear and min = nearest and mip = nearest */
  82381. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82382. /** mag = linear and min = nearest and mip = linear */
  82383. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82384. /** mag = linear and min = linear and mip = none */
  82385. static readonly LINEAR_LINEAR: number;
  82386. /** mag = linear and min = nearest and mip = none */
  82387. static readonly LINEAR_NEAREST: number;
  82388. /** Explicit coordinates mode */
  82389. static readonly EXPLICIT_MODE: number;
  82390. /** Spherical coordinates mode */
  82391. static readonly SPHERICAL_MODE: number;
  82392. /** Planar coordinates mode */
  82393. static readonly PLANAR_MODE: number;
  82394. /** Cubic coordinates mode */
  82395. static readonly CUBIC_MODE: number;
  82396. /** Projection coordinates mode */
  82397. static readonly PROJECTION_MODE: number;
  82398. /** Inverse Cubic coordinates mode */
  82399. static readonly SKYBOX_MODE: number;
  82400. /** Inverse Cubic coordinates mode */
  82401. static readonly INVCUBIC_MODE: number;
  82402. /** Equirectangular coordinates mode */
  82403. static readonly EQUIRECTANGULAR_MODE: number;
  82404. /** Equirectangular Fixed coordinates mode */
  82405. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82406. /** Equirectangular Fixed Mirrored coordinates mode */
  82407. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82408. /** Texture is not repeating outside of 0..1 UVs */
  82409. static readonly CLAMP_ADDRESSMODE: number;
  82410. /** Texture is repeating outside of 0..1 UVs */
  82411. static readonly WRAP_ADDRESSMODE: number;
  82412. /** Texture is repeating and mirrored */
  82413. static readonly MIRROR_ADDRESSMODE: number;
  82414. /**
  82415. * 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
  82416. */
  82417. static UseSerializedUrlIfAny: boolean;
  82418. /**
  82419. * Define the url of the texture.
  82420. */
  82421. url: Nullable<string>;
  82422. /**
  82423. * Define an offset on the texture to offset the u coordinates of the UVs
  82424. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82425. */
  82426. uOffset: number;
  82427. /**
  82428. * Define an offset on the texture to offset the v coordinates of the UVs
  82429. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82430. */
  82431. vOffset: number;
  82432. /**
  82433. * Define an offset on the texture to scale the u coordinates of the UVs
  82434. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82435. */
  82436. uScale: number;
  82437. /**
  82438. * Define an offset on the texture to scale the v coordinates of the UVs
  82439. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82440. */
  82441. vScale: number;
  82442. /**
  82443. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82444. * @see http://doc.babylonjs.com/how_to/more_materials
  82445. */
  82446. uAng: number;
  82447. /**
  82448. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82449. * @see http://doc.babylonjs.com/how_to/more_materials
  82450. */
  82451. vAng: number;
  82452. /**
  82453. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82454. * @see http://doc.babylonjs.com/how_to/more_materials
  82455. */
  82456. wAng: number;
  82457. /**
  82458. * Defines the center of rotation (U)
  82459. */
  82460. uRotationCenter: number;
  82461. /**
  82462. * Defines the center of rotation (V)
  82463. */
  82464. vRotationCenter: number;
  82465. /**
  82466. * Defines the center of rotation (W)
  82467. */
  82468. wRotationCenter: number;
  82469. /**
  82470. * Are mip maps generated for this texture or not.
  82471. */
  82472. readonly noMipmap: boolean;
  82473. /**
  82474. * List of inspectable custom properties (used by the Inspector)
  82475. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82476. */
  82477. inspectableCustomProperties: Nullable<IInspectable[]>;
  82478. private _noMipmap;
  82479. /** @hidden */
  82480. _invertY: boolean;
  82481. private _rowGenerationMatrix;
  82482. private _cachedTextureMatrix;
  82483. private _projectionModeMatrix;
  82484. private _t0;
  82485. private _t1;
  82486. private _t2;
  82487. private _cachedUOffset;
  82488. private _cachedVOffset;
  82489. private _cachedUScale;
  82490. private _cachedVScale;
  82491. private _cachedUAng;
  82492. private _cachedVAng;
  82493. private _cachedWAng;
  82494. private _cachedProjectionMatrixId;
  82495. private _cachedCoordinatesMode;
  82496. /** @hidden */
  82497. protected _initialSamplingMode: number;
  82498. /** @hidden */
  82499. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82500. private _deleteBuffer;
  82501. protected _format: Nullable<number>;
  82502. private _delayedOnLoad;
  82503. private _delayedOnError;
  82504. /**
  82505. * Observable triggered once the texture has been loaded.
  82506. */
  82507. onLoadObservable: Observable<Texture>;
  82508. protected _isBlocking: boolean;
  82509. /**
  82510. * Is the texture preventing material to render while loading.
  82511. * If false, a default texture will be used instead of the loading one during the preparation step.
  82512. */
  82513. isBlocking: boolean;
  82514. /**
  82515. * Get the current sampling mode associated with the texture.
  82516. */
  82517. readonly samplingMode: number;
  82518. /**
  82519. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82520. */
  82521. readonly invertY: boolean;
  82522. /**
  82523. * Instantiates a new texture.
  82524. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82525. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82526. * @param url define the url of the picture to load as a texture
  82527. * @param scene define the scene or engine the texture will belong to
  82528. * @param noMipmap define if the texture will require mip maps or not
  82529. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82530. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82531. * @param onLoad define a callback triggered when the texture has been loaded
  82532. * @param onError define a callback triggered when an error occurred during the loading session
  82533. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82534. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82535. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82536. */
  82537. 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);
  82538. /**
  82539. * Update the url (and optional buffer) of this texture if url was null during construction.
  82540. * @param url the url of the texture
  82541. * @param buffer the buffer of the texture (defaults to null)
  82542. * @param onLoad callback called when the texture is loaded (defaults to null)
  82543. */
  82544. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82545. /**
  82546. * Finish the loading sequence of a texture flagged as delayed load.
  82547. * @hidden
  82548. */
  82549. delayLoad(): void;
  82550. private _prepareRowForTextureGeneration;
  82551. /**
  82552. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82553. * @returns the transform matrix of the texture.
  82554. */
  82555. getTextureMatrix(): Matrix;
  82556. /**
  82557. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82558. * @returns The reflection texture transform
  82559. */
  82560. getReflectionTextureMatrix(): Matrix;
  82561. /**
  82562. * Clones the texture.
  82563. * @returns the cloned texture
  82564. */
  82565. clone(): Texture;
  82566. /**
  82567. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82568. * @returns The JSON representation of the texture
  82569. */
  82570. serialize(): any;
  82571. /**
  82572. * Get the current class name of the texture useful for serialization or dynamic coding.
  82573. * @returns "Texture"
  82574. */
  82575. getClassName(): string;
  82576. /**
  82577. * Dispose the texture and release its associated resources.
  82578. */
  82579. dispose(): void;
  82580. /**
  82581. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82582. * @param parsedTexture Define the JSON representation of the texture
  82583. * @param scene Define the scene the parsed texture should be instantiated in
  82584. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82585. * @returns The parsed texture if successful
  82586. */
  82587. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82588. /**
  82589. * Creates a texture from its base 64 representation.
  82590. * @param data Define the base64 payload without the data: prefix
  82591. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82592. * @param scene Define the scene the texture should belong to
  82593. * @param noMipmap Forces the texture to not create mip map information if true
  82594. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82595. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82596. * @param onLoad define a callback triggered when the texture has been loaded
  82597. * @param onError define a callback triggered when an error occurred during the loading session
  82598. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82599. * @returns the created texture
  82600. */
  82601. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82602. /**
  82603. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82604. * @param data Define the base64 payload without the data: prefix
  82605. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82606. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82607. * @param scene Define the scene the texture should belong to
  82608. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82609. * @param noMipmap Forces the texture to not create mip map information if true
  82610. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82611. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82612. * @param onLoad define a callback triggered when the texture has been loaded
  82613. * @param onError define a callback triggered when an error occurred during the loading session
  82614. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82615. * @returns the created texture
  82616. */
  82617. 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;
  82618. }
  82619. }
  82620. declare module BABYLON {
  82621. /**
  82622. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82623. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82624. */
  82625. export class PostProcessManager {
  82626. private _scene;
  82627. private _indexBuffer;
  82628. private _vertexBuffers;
  82629. /**
  82630. * Creates a new instance PostProcess
  82631. * @param scene The scene that the post process is associated with.
  82632. */
  82633. constructor(scene: Scene);
  82634. private _prepareBuffers;
  82635. private _buildIndexBuffer;
  82636. /**
  82637. * Rebuilds the vertex buffers of the manager.
  82638. * @hidden
  82639. */
  82640. _rebuild(): void;
  82641. /**
  82642. * Prepares a frame to be run through a post process.
  82643. * @param sourceTexture The input texture to the post procesess. (default: null)
  82644. * @param postProcesses An array of post processes to be run. (default: null)
  82645. * @returns True if the post processes were able to be run.
  82646. * @hidden
  82647. */
  82648. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82649. /**
  82650. * Manually render a set of post processes to a texture.
  82651. * @param postProcesses An array of post processes to be run.
  82652. * @param targetTexture The target texture to render to.
  82653. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82654. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82655. * @param lodLevel defines which lod of the texture to render to
  82656. */
  82657. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82658. /**
  82659. * Finalize the result of the output of the postprocesses.
  82660. * @param doNotPresent If true the result will not be displayed to the screen.
  82661. * @param targetTexture The target texture to render to.
  82662. * @param faceIndex The index of the face to bind the target texture to.
  82663. * @param postProcesses The array of post processes to render.
  82664. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82665. * @hidden
  82666. */
  82667. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82668. /**
  82669. * Disposes of the post process manager.
  82670. */
  82671. dispose(): void;
  82672. }
  82673. }
  82674. declare module BABYLON {
  82675. /** Interface used by value gradients (color, factor, ...) */
  82676. export interface IValueGradient {
  82677. /**
  82678. * Gets or sets the gradient value (between 0 and 1)
  82679. */
  82680. gradient: number;
  82681. }
  82682. /** Class used to store color4 gradient */
  82683. export class ColorGradient implements IValueGradient {
  82684. /**
  82685. * Gets or sets the gradient value (between 0 and 1)
  82686. */
  82687. gradient: number;
  82688. /**
  82689. * Gets or sets first associated color
  82690. */
  82691. color1: Color4;
  82692. /**
  82693. * Gets or sets second associated color
  82694. */
  82695. color2?: Color4;
  82696. /**
  82697. * Will get a color picked randomly between color1 and color2.
  82698. * If color2 is undefined then color1 will be used
  82699. * @param result defines the target Color4 to store the result in
  82700. */
  82701. getColorToRef(result: Color4): void;
  82702. }
  82703. /** Class used to store color 3 gradient */
  82704. export class Color3Gradient implements IValueGradient {
  82705. /**
  82706. * Gets or sets the gradient value (between 0 and 1)
  82707. */
  82708. gradient: number;
  82709. /**
  82710. * Gets or sets the associated color
  82711. */
  82712. color: Color3;
  82713. }
  82714. /** Class used to store factor gradient */
  82715. export class FactorGradient implements IValueGradient {
  82716. /**
  82717. * Gets or sets the gradient value (between 0 and 1)
  82718. */
  82719. gradient: number;
  82720. /**
  82721. * Gets or sets first associated factor
  82722. */
  82723. factor1: number;
  82724. /**
  82725. * Gets or sets second associated factor
  82726. */
  82727. factor2?: number;
  82728. /**
  82729. * Will get a number picked randomly between factor1 and factor2.
  82730. * If factor2 is undefined then factor1 will be used
  82731. * @returns the picked number
  82732. */
  82733. getFactor(): number;
  82734. }
  82735. /**
  82736. * Helper used to simplify some generic gradient tasks
  82737. */
  82738. export class GradientHelper {
  82739. /**
  82740. * Gets the current gradient from an array of IValueGradient
  82741. * @param ratio defines the current ratio to get
  82742. * @param gradients defines the array of IValueGradient
  82743. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82744. */
  82745. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82746. }
  82747. }
  82748. declare module BABYLON {
  82749. interface ThinEngine {
  82750. /**
  82751. * Creates a dynamic texture
  82752. * @param width defines the width of the texture
  82753. * @param height defines the height of the texture
  82754. * @param generateMipMaps defines if the engine should generate the mip levels
  82755. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82756. * @returns the dynamic texture inside an InternalTexture
  82757. */
  82758. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82759. /**
  82760. * Update the content of a dynamic texture
  82761. * @param texture defines the texture to update
  82762. * @param canvas defines the canvas containing the source
  82763. * @param invertY defines if data must be stored with Y axis inverted
  82764. * @param premulAlpha defines if alpha is stored as premultiplied
  82765. * @param format defines the format of the data
  82766. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82767. */
  82768. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82769. }
  82770. }
  82771. declare module BABYLON {
  82772. /**
  82773. * A class extending Texture allowing drawing on a texture
  82774. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82775. */
  82776. export class DynamicTexture extends Texture {
  82777. private _generateMipMaps;
  82778. private _canvas;
  82779. private _context;
  82780. private _engine;
  82781. /**
  82782. * Creates a DynamicTexture
  82783. * @param name defines the name of the texture
  82784. * @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
  82785. * @param scene defines the scene where you want the texture
  82786. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82787. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82788. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82789. */
  82790. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82791. /**
  82792. * Get the current class name of the texture useful for serialization or dynamic coding.
  82793. * @returns "DynamicTexture"
  82794. */
  82795. getClassName(): string;
  82796. /**
  82797. * Gets the current state of canRescale
  82798. */
  82799. readonly canRescale: boolean;
  82800. private _recreate;
  82801. /**
  82802. * Scales the texture
  82803. * @param ratio the scale factor to apply to both width and height
  82804. */
  82805. scale(ratio: number): void;
  82806. /**
  82807. * Resizes the texture
  82808. * @param width the new width
  82809. * @param height the new height
  82810. */
  82811. scaleTo(width: number, height: number): void;
  82812. /**
  82813. * Gets the context of the canvas used by the texture
  82814. * @returns the canvas context of the dynamic texture
  82815. */
  82816. getContext(): CanvasRenderingContext2D;
  82817. /**
  82818. * Clears the texture
  82819. */
  82820. clear(): void;
  82821. /**
  82822. * Updates the texture
  82823. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82824. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82825. */
  82826. update(invertY?: boolean, premulAlpha?: boolean): void;
  82827. /**
  82828. * Draws text onto the texture
  82829. * @param text defines the text to be drawn
  82830. * @param x defines the placement of the text from the left
  82831. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82832. * @param font defines the font to be used with font-style, font-size, font-name
  82833. * @param color defines the color used for the text
  82834. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82835. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82836. * @param update defines whether texture is immediately update (default is true)
  82837. */
  82838. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82839. /**
  82840. * Clones the texture
  82841. * @returns the clone of the texture.
  82842. */
  82843. clone(): DynamicTexture;
  82844. /**
  82845. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82846. * @returns a serialized dynamic texture object
  82847. */
  82848. serialize(): any;
  82849. /** @hidden */
  82850. _rebuild(): void;
  82851. }
  82852. }
  82853. declare module BABYLON {
  82854. interface AbstractScene {
  82855. /**
  82856. * The list of procedural textures added to the scene
  82857. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82858. */
  82859. proceduralTextures: Array<ProceduralTexture>;
  82860. }
  82861. /**
  82862. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82863. * in a given scene.
  82864. */
  82865. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82866. /**
  82867. * The component name helpfull to identify the component in the list of scene components.
  82868. */
  82869. readonly name: string;
  82870. /**
  82871. * The scene the component belongs to.
  82872. */
  82873. scene: Scene;
  82874. /**
  82875. * Creates a new instance of the component for the given scene
  82876. * @param scene Defines the scene to register the component in
  82877. */
  82878. constructor(scene: Scene);
  82879. /**
  82880. * Registers the component in a given scene
  82881. */
  82882. register(): void;
  82883. /**
  82884. * Rebuilds the elements related to this component in case of
  82885. * context lost for instance.
  82886. */
  82887. rebuild(): void;
  82888. /**
  82889. * Disposes the component and the associated ressources.
  82890. */
  82891. dispose(): void;
  82892. private _beforeClear;
  82893. }
  82894. }
  82895. declare module BABYLON {
  82896. interface ThinEngine {
  82897. /**
  82898. * Creates a new render target cube texture
  82899. * @param size defines the size of the texture
  82900. * @param options defines the options used to create the texture
  82901. * @returns a new render target cube texture stored in an InternalTexture
  82902. */
  82903. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82904. }
  82905. }
  82906. declare module BABYLON {
  82907. /** @hidden */
  82908. export var proceduralVertexShader: {
  82909. name: string;
  82910. shader: string;
  82911. };
  82912. }
  82913. declare module BABYLON {
  82914. /**
  82915. * 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.
  82916. * This is the base class of any Procedural texture and contains most of the shareable code.
  82917. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82918. */
  82919. export class ProceduralTexture extends Texture {
  82920. isCube: boolean;
  82921. /**
  82922. * Define if the texture is enabled or not (disabled texture will not render)
  82923. */
  82924. isEnabled: boolean;
  82925. /**
  82926. * Define if the texture must be cleared before rendering (default is true)
  82927. */
  82928. autoClear: boolean;
  82929. /**
  82930. * Callback called when the texture is generated
  82931. */
  82932. onGenerated: () => void;
  82933. /**
  82934. * Event raised when the texture is generated
  82935. */
  82936. onGeneratedObservable: Observable<ProceduralTexture>;
  82937. /** @hidden */
  82938. _generateMipMaps: boolean;
  82939. /** @hidden **/
  82940. _effect: Effect;
  82941. /** @hidden */
  82942. _textures: {
  82943. [key: string]: Texture;
  82944. };
  82945. private _size;
  82946. private _currentRefreshId;
  82947. private _refreshRate;
  82948. private _vertexBuffers;
  82949. private _indexBuffer;
  82950. private _uniforms;
  82951. private _samplers;
  82952. private _fragment;
  82953. private _floats;
  82954. private _ints;
  82955. private _floatsArrays;
  82956. private _colors3;
  82957. private _colors4;
  82958. private _vectors2;
  82959. private _vectors3;
  82960. private _matrices;
  82961. private _fallbackTexture;
  82962. private _fallbackTextureUsed;
  82963. private _engine;
  82964. private _cachedDefines;
  82965. private _contentUpdateId;
  82966. private _contentData;
  82967. /**
  82968. * Instantiates a new procedural texture.
  82969. * 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.
  82970. * This is the base class of any Procedural texture and contains most of the shareable code.
  82971. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82972. * @param name Define the name of the texture
  82973. * @param size Define the size of the texture to create
  82974. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  82975. * @param scene Define the scene the texture belongs to
  82976. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  82977. * @param generateMipMaps Define if the texture should creates mip maps or not
  82978. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  82979. */
  82980. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  82981. /**
  82982. * The effect that is created when initializing the post process.
  82983. * @returns The created effect corresponding the the postprocess.
  82984. */
  82985. getEffect(): Effect;
  82986. /**
  82987. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  82988. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  82989. */
  82990. getContent(): Nullable<ArrayBufferView>;
  82991. private _createIndexBuffer;
  82992. /** @hidden */
  82993. _rebuild(): void;
  82994. /**
  82995. * Resets the texture in order to recreate its associated resources.
  82996. * This can be called in case of context loss
  82997. */
  82998. reset(): void;
  82999. protected _getDefines(): string;
  83000. /**
  83001. * Is the texture ready to be used ? (rendered at least once)
  83002. * @returns true if ready, otherwise, false.
  83003. */
  83004. isReady(): boolean;
  83005. /**
  83006. * Resets the refresh counter of the texture and start bak from scratch.
  83007. * Could be useful to regenerate the texture if it is setup to render only once.
  83008. */
  83009. resetRefreshCounter(): void;
  83010. /**
  83011. * Set the fragment shader to use in order to render the texture.
  83012. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83013. */
  83014. setFragment(fragment: any): void;
  83015. /**
  83016. * Define the refresh rate of the texture or the rendering frequency.
  83017. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83018. */
  83019. refreshRate: number;
  83020. /** @hidden */
  83021. _shouldRender(): boolean;
  83022. /**
  83023. * Get the size the texture is rendering at.
  83024. * @returns the size (texture is always squared)
  83025. */
  83026. getRenderSize(): number;
  83027. /**
  83028. * Resize the texture to new value.
  83029. * @param size Define the new size the texture should have
  83030. * @param generateMipMaps Define whether the new texture should create mip maps
  83031. */
  83032. resize(size: number, generateMipMaps: boolean): void;
  83033. private _checkUniform;
  83034. /**
  83035. * Set a texture in the shader program used to render.
  83036. * @param name Define the name of the uniform samplers as defined in the shader
  83037. * @param texture Define the texture to bind to this sampler
  83038. * @return the texture itself allowing "fluent" like uniform updates
  83039. */
  83040. setTexture(name: string, texture: Texture): ProceduralTexture;
  83041. /**
  83042. * Set a float in the shader.
  83043. * @param name Define the name of the uniform as defined in the shader
  83044. * @param value Define the value to give to the uniform
  83045. * @return the texture itself allowing "fluent" like uniform updates
  83046. */
  83047. setFloat(name: string, value: number): ProceduralTexture;
  83048. /**
  83049. * Set a int in the shader.
  83050. * @param name Define the name of the uniform as defined in the shader
  83051. * @param value Define the value to give to the uniform
  83052. * @return the texture itself allowing "fluent" like uniform updates
  83053. */
  83054. setInt(name: string, value: number): ProceduralTexture;
  83055. /**
  83056. * Set an array of floats in the shader.
  83057. * @param name Define the name of the uniform as defined in the shader
  83058. * @param value Define the value to give to the uniform
  83059. * @return the texture itself allowing "fluent" like uniform updates
  83060. */
  83061. setFloats(name: string, value: number[]): ProceduralTexture;
  83062. /**
  83063. * Set a vec3 in the shader from a Color3.
  83064. * @param name Define the name of the uniform as defined in the shader
  83065. * @param value Define the value to give to the uniform
  83066. * @return the texture itself allowing "fluent" like uniform updates
  83067. */
  83068. setColor3(name: string, value: Color3): ProceduralTexture;
  83069. /**
  83070. * Set a vec4 in the shader from a Color4.
  83071. * @param name Define the name of the uniform as defined in the shader
  83072. * @param value Define the value to give to the uniform
  83073. * @return the texture itself allowing "fluent" like uniform updates
  83074. */
  83075. setColor4(name: string, value: Color4): ProceduralTexture;
  83076. /**
  83077. * Set a vec2 in the shader from a Vector2.
  83078. * @param name Define the name of the uniform as defined in the shader
  83079. * @param value Define the value to give to the uniform
  83080. * @return the texture itself allowing "fluent" like uniform updates
  83081. */
  83082. setVector2(name: string, value: Vector2): ProceduralTexture;
  83083. /**
  83084. * Set a vec3 in the shader from a Vector3.
  83085. * @param name Define the name of the uniform as defined in the shader
  83086. * @param value Define the value to give to the uniform
  83087. * @return the texture itself allowing "fluent" like uniform updates
  83088. */
  83089. setVector3(name: string, value: Vector3): ProceduralTexture;
  83090. /**
  83091. * Set a mat4 in the shader from a MAtrix.
  83092. * @param name Define the name of the uniform as defined in the shader
  83093. * @param value Define the value to give to the uniform
  83094. * @return the texture itself allowing "fluent" like uniform updates
  83095. */
  83096. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83097. /**
  83098. * Render the texture to its associated render target.
  83099. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83100. */
  83101. render(useCameraPostProcess?: boolean): void;
  83102. /**
  83103. * Clone the texture.
  83104. * @returns the cloned texture
  83105. */
  83106. clone(): ProceduralTexture;
  83107. /**
  83108. * Dispose the texture and release its asoociated resources.
  83109. */
  83110. dispose(): void;
  83111. }
  83112. }
  83113. declare module BABYLON {
  83114. /**
  83115. * This represents the base class for particle system in Babylon.
  83116. * 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.
  83117. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83118. * @example https://doc.babylonjs.com/babylon101/particles
  83119. */
  83120. export class BaseParticleSystem {
  83121. /**
  83122. * Source color is added to the destination color without alpha affecting the result
  83123. */
  83124. static BLENDMODE_ONEONE: number;
  83125. /**
  83126. * Blend current color and particle color using particle’s alpha
  83127. */
  83128. static BLENDMODE_STANDARD: number;
  83129. /**
  83130. * Add current color and particle color multiplied by particle’s alpha
  83131. */
  83132. static BLENDMODE_ADD: number;
  83133. /**
  83134. * Multiply current color with particle color
  83135. */
  83136. static BLENDMODE_MULTIPLY: number;
  83137. /**
  83138. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83139. */
  83140. static BLENDMODE_MULTIPLYADD: number;
  83141. /**
  83142. * List of animations used by the particle system.
  83143. */
  83144. animations: Animation[];
  83145. /**
  83146. * The id of the Particle system.
  83147. */
  83148. id: string;
  83149. /**
  83150. * The friendly name of the Particle system.
  83151. */
  83152. name: string;
  83153. /**
  83154. * The rendering group used by the Particle system to chose when to render.
  83155. */
  83156. renderingGroupId: number;
  83157. /**
  83158. * The emitter represents the Mesh or position we are attaching the particle system to.
  83159. */
  83160. emitter: Nullable<AbstractMesh | Vector3>;
  83161. /**
  83162. * The maximum number of particles to emit per frame
  83163. */
  83164. emitRate: number;
  83165. /**
  83166. * If you want to launch only a few particles at once, that can be done, as well.
  83167. */
  83168. manualEmitCount: number;
  83169. /**
  83170. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83171. */
  83172. updateSpeed: number;
  83173. /**
  83174. * The amount of time the particle system is running (depends of the overall update speed).
  83175. */
  83176. targetStopDuration: number;
  83177. /**
  83178. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83179. */
  83180. disposeOnStop: boolean;
  83181. /**
  83182. * Minimum power of emitting particles.
  83183. */
  83184. minEmitPower: number;
  83185. /**
  83186. * Maximum power of emitting particles.
  83187. */
  83188. maxEmitPower: number;
  83189. /**
  83190. * Minimum life time of emitting particles.
  83191. */
  83192. minLifeTime: number;
  83193. /**
  83194. * Maximum life time of emitting particles.
  83195. */
  83196. maxLifeTime: number;
  83197. /**
  83198. * Minimum Size of emitting particles.
  83199. */
  83200. minSize: number;
  83201. /**
  83202. * Maximum Size of emitting particles.
  83203. */
  83204. maxSize: number;
  83205. /**
  83206. * Minimum scale of emitting particles on X axis.
  83207. */
  83208. minScaleX: number;
  83209. /**
  83210. * Maximum scale of emitting particles on X axis.
  83211. */
  83212. maxScaleX: number;
  83213. /**
  83214. * Minimum scale of emitting particles on Y axis.
  83215. */
  83216. minScaleY: number;
  83217. /**
  83218. * Maximum scale of emitting particles on Y axis.
  83219. */
  83220. maxScaleY: number;
  83221. /**
  83222. * Gets or sets the minimal initial rotation in radians.
  83223. */
  83224. minInitialRotation: number;
  83225. /**
  83226. * Gets or sets the maximal initial rotation in radians.
  83227. */
  83228. maxInitialRotation: number;
  83229. /**
  83230. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83231. */
  83232. minAngularSpeed: number;
  83233. /**
  83234. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83235. */
  83236. maxAngularSpeed: number;
  83237. /**
  83238. * The texture used to render each particle. (this can be a spritesheet)
  83239. */
  83240. particleTexture: Nullable<Texture>;
  83241. /**
  83242. * The layer mask we are rendering the particles through.
  83243. */
  83244. layerMask: number;
  83245. /**
  83246. * This can help using your own shader to render the particle system.
  83247. * The according effect will be created
  83248. */
  83249. customShader: any;
  83250. /**
  83251. * By default particle system starts as soon as they are created. This prevents the
  83252. * automatic start to happen and let you decide when to start emitting particles.
  83253. */
  83254. preventAutoStart: boolean;
  83255. private _noiseTexture;
  83256. /**
  83257. * Gets or sets a texture used to add random noise to particle positions
  83258. */
  83259. noiseTexture: Nullable<ProceduralTexture>;
  83260. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83261. noiseStrength: Vector3;
  83262. /**
  83263. * Callback triggered when the particle animation is ending.
  83264. */
  83265. onAnimationEnd: Nullable<() => void>;
  83266. /**
  83267. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83268. */
  83269. blendMode: number;
  83270. /**
  83271. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83272. * to override the particles.
  83273. */
  83274. forceDepthWrite: boolean;
  83275. /** 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 */
  83276. preWarmCycles: number;
  83277. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83278. preWarmStepOffset: number;
  83279. /**
  83280. * 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)
  83281. */
  83282. spriteCellChangeSpeed: number;
  83283. /**
  83284. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83285. */
  83286. startSpriteCellID: number;
  83287. /**
  83288. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83289. */
  83290. endSpriteCellID: number;
  83291. /**
  83292. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83293. */
  83294. spriteCellWidth: number;
  83295. /**
  83296. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83297. */
  83298. spriteCellHeight: number;
  83299. /**
  83300. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83301. */
  83302. spriteRandomStartCell: boolean;
  83303. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83304. translationPivot: Vector2;
  83305. /** @hidden */
  83306. protected _isAnimationSheetEnabled: boolean;
  83307. /**
  83308. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83309. */
  83310. beginAnimationOnStart: boolean;
  83311. /**
  83312. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83313. */
  83314. beginAnimationFrom: number;
  83315. /**
  83316. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83317. */
  83318. beginAnimationTo: number;
  83319. /**
  83320. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83321. */
  83322. beginAnimationLoop: boolean;
  83323. /**
  83324. * Gets or sets a world offset applied to all particles
  83325. */
  83326. worldOffset: Vector3;
  83327. /**
  83328. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83329. */
  83330. isAnimationSheetEnabled: boolean;
  83331. /**
  83332. * Get hosting scene
  83333. * @returns the scene
  83334. */
  83335. getScene(): Scene;
  83336. /**
  83337. * You can use gravity if you want to give an orientation to your particles.
  83338. */
  83339. gravity: Vector3;
  83340. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83341. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83342. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83343. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83344. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83345. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83346. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83347. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83348. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83349. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83350. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83351. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83352. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83353. /**
  83354. * Defines the delay in milliseconds before starting the system (0 by default)
  83355. */
  83356. startDelay: number;
  83357. /**
  83358. * Gets the current list of drag gradients.
  83359. * You must use addDragGradient and removeDragGradient to udpate this list
  83360. * @returns the list of drag gradients
  83361. */
  83362. getDragGradients(): Nullable<Array<FactorGradient>>;
  83363. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83364. limitVelocityDamping: number;
  83365. /**
  83366. * Gets the current list of limit velocity gradients.
  83367. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83368. * @returns the list of limit velocity gradients
  83369. */
  83370. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83371. /**
  83372. * Gets the current list of color gradients.
  83373. * You must use addColorGradient and removeColorGradient to udpate this list
  83374. * @returns the list of color gradients
  83375. */
  83376. getColorGradients(): Nullable<Array<ColorGradient>>;
  83377. /**
  83378. * Gets the current list of size gradients.
  83379. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83380. * @returns the list of size gradients
  83381. */
  83382. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83383. /**
  83384. * Gets the current list of color remap gradients.
  83385. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83386. * @returns the list of color remap gradients
  83387. */
  83388. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83389. /**
  83390. * Gets the current list of alpha remap gradients.
  83391. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83392. * @returns the list of alpha remap gradients
  83393. */
  83394. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83395. /**
  83396. * Gets the current list of life time gradients.
  83397. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83398. * @returns the list of life time gradients
  83399. */
  83400. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83401. /**
  83402. * Gets the current list of angular speed gradients.
  83403. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83404. * @returns the list of angular speed gradients
  83405. */
  83406. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83407. /**
  83408. * Gets the current list of velocity gradients.
  83409. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83410. * @returns the list of velocity gradients
  83411. */
  83412. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83413. /**
  83414. * Gets the current list of start size gradients.
  83415. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83416. * @returns the list of start size gradients
  83417. */
  83418. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83419. /**
  83420. * Gets the current list of emit rate gradients.
  83421. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83422. * @returns the list of emit rate gradients
  83423. */
  83424. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83425. /**
  83426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83428. */
  83429. direction1: Vector3;
  83430. /**
  83431. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83432. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83433. */
  83434. direction2: Vector3;
  83435. /**
  83436. * 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.
  83437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83438. */
  83439. minEmitBox: Vector3;
  83440. /**
  83441. * 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.
  83442. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83443. */
  83444. maxEmitBox: Vector3;
  83445. /**
  83446. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83447. */
  83448. color1: Color4;
  83449. /**
  83450. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83451. */
  83452. color2: Color4;
  83453. /**
  83454. * Color the particle will have at the end of its lifetime
  83455. */
  83456. colorDead: Color4;
  83457. /**
  83458. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83459. */
  83460. textureMask: Color4;
  83461. /**
  83462. * The particle emitter type defines the emitter used by the particle system.
  83463. * It can be for example box, sphere, or cone...
  83464. */
  83465. particleEmitterType: IParticleEmitterType;
  83466. /** @hidden */
  83467. _isSubEmitter: boolean;
  83468. /**
  83469. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83470. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83471. */
  83472. billboardMode: number;
  83473. protected _isBillboardBased: boolean;
  83474. /**
  83475. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83476. */
  83477. isBillboardBased: boolean;
  83478. /**
  83479. * The scene the particle system belongs to.
  83480. */
  83481. protected _scene: Scene;
  83482. /**
  83483. * Local cache of defines for image processing.
  83484. */
  83485. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83486. /**
  83487. * Default configuration related to image processing available in the standard Material.
  83488. */
  83489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83490. /**
  83491. * Gets the image processing configuration used either in this material.
  83492. */
  83493. /**
  83494. * Sets the Default image processing configuration used either in the this material.
  83495. *
  83496. * If sets to null, the scene one is in use.
  83497. */
  83498. imageProcessingConfiguration: ImageProcessingConfiguration;
  83499. /**
  83500. * Attaches a new image processing configuration to the Standard Material.
  83501. * @param configuration
  83502. */
  83503. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83504. /** @hidden */
  83505. protected _reset(): void;
  83506. /** @hidden */
  83507. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83508. /**
  83509. * Instantiates a particle system.
  83510. * 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.
  83511. * @param name The name of the particle system
  83512. */
  83513. constructor(name: string);
  83514. /**
  83515. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83516. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83517. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83518. * @returns the emitter
  83519. */
  83520. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83521. /**
  83522. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83523. * @param radius The radius of the hemisphere to emit from
  83524. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83525. * @returns the emitter
  83526. */
  83527. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83528. /**
  83529. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83530. * @param radius The radius of the sphere to emit from
  83531. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83532. * @returns the emitter
  83533. */
  83534. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83535. /**
  83536. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83537. * @param radius The radius of the sphere to emit from
  83538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83540. * @returns the emitter
  83541. */
  83542. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83543. /**
  83544. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83545. * @param radius The radius of the emission cylinder
  83546. * @param height The height of the emission cylinder
  83547. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83548. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83549. * @returns the emitter
  83550. */
  83551. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83552. /**
  83553. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83554. * @param radius The radius of the cylinder to emit from
  83555. * @param height The height of the emission cylinder
  83556. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83559. * @returns the emitter
  83560. */
  83561. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83562. /**
  83563. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83564. * @param radius The radius of the cone to emit from
  83565. * @param angle The base angle of the cone
  83566. * @returns the emitter
  83567. */
  83568. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83569. /**
  83570. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83573. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83574. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83575. * @returns the emitter
  83576. */
  83577. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83578. }
  83579. }
  83580. declare module BABYLON {
  83581. /**
  83582. * Type of sub emitter
  83583. */
  83584. export enum SubEmitterType {
  83585. /**
  83586. * Attached to the particle over it's lifetime
  83587. */
  83588. ATTACHED = 0,
  83589. /**
  83590. * Created when the particle dies
  83591. */
  83592. END = 1
  83593. }
  83594. /**
  83595. * Sub emitter class used to emit particles from an existing particle
  83596. */
  83597. export class SubEmitter {
  83598. /**
  83599. * the particle system to be used by the sub emitter
  83600. */
  83601. particleSystem: ParticleSystem;
  83602. /**
  83603. * Type of the submitter (Default: END)
  83604. */
  83605. type: SubEmitterType;
  83606. /**
  83607. * 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)
  83608. * Note: This only is supported when using an emitter of type Mesh
  83609. */
  83610. inheritDirection: boolean;
  83611. /**
  83612. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83613. */
  83614. inheritedVelocityAmount: number;
  83615. /**
  83616. * Creates a sub emitter
  83617. * @param particleSystem the particle system to be used by the sub emitter
  83618. */
  83619. constructor(
  83620. /**
  83621. * the particle system to be used by the sub emitter
  83622. */
  83623. particleSystem: ParticleSystem);
  83624. /**
  83625. * Clones the sub emitter
  83626. * @returns the cloned sub emitter
  83627. */
  83628. clone(): SubEmitter;
  83629. /**
  83630. * Serialize current object to a JSON object
  83631. * @returns the serialized object
  83632. */
  83633. serialize(): any;
  83634. /** @hidden */
  83635. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83636. /**
  83637. * Creates a new SubEmitter from a serialized JSON version
  83638. * @param serializationObject defines the JSON object to read from
  83639. * @param scene defines the hosting scene
  83640. * @param rootUrl defines the rootUrl for data loading
  83641. * @returns a new SubEmitter
  83642. */
  83643. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83644. /** Release associated resources */
  83645. dispose(): void;
  83646. }
  83647. }
  83648. declare module BABYLON {
  83649. /** @hidden */
  83650. export var clipPlaneFragmentDeclaration: {
  83651. name: string;
  83652. shader: string;
  83653. };
  83654. }
  83655. declare module BABYLON {
  83656. /** @hidden */
  83657. export var imageProcessingDeclaration: {
  83658. name: string;
  83659. shader: string;
  83660. };
  83661. }
  83662. declare module BABYLON {
  83663. /** @hidden */
  83664. export var imageProcessingFunctions: {
  83665. name: string;
  83666. shader: string;
  83667. };
  83668. }
  83669. declare module BABYLON {
  83670. /** @hidden */
  83671. export var clipPlaneFragment: {
  83672. name: string;
  83673. shader: string;
  83674. };
  83675. }
  83676. declare module BABYLON {
  83677. /** @hidden */
  83678. export var particlesPixelShader: {
  83679. name: string;
  83680. shader: string;
  83681. };
  83682. }
  83683. declare module BABYLON {
  83684. /** @hidden */
  83685. export var clipPlaneVertexDeclaration: {
  83686. name: string;
  83687. shader: string;
  83688. };
  83689. }
  83690. declare module BABYLON {
  83691. /** @hidden */
  83692. export var clipPlaneVertex: {
  83693. name: string;
  83694. shader: string;
  83695. };
  83696. }
  83697. declare module BABYLON {
  83698. /** @hidden */
  83699. export var particlesVertexShader: {
  83700. name: string;
  83701. shader: string;
  83702. };
  83703. }
  83704. declare module BABYLON {
  83705. /**
  83706. * This represents a particle system in Babylon.
  83707. * 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.
  83708. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83709. * @example https://doc.babylonjs.com/babylon101/particles
  83710. */
  83711. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83712. /**
  83713. * Billboard mode will only apply to Y axis
  83714. */
  83715. static readonly BILLBOARDMODE_Y: number;
  83716. /**
  83717. * Billboard mode will apply to all axes
  83718. */
  83719. static readonly BILLBOARDMODE_ALL: number;
  83720. /**
  83721. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83722. */
  83723. static readonly BILLBOARDMODE_STRETCHED: number;
  83724. /**
  83725. * This function can be defined to provide custom update for active particles.
  83726. * This function will be called instead of regular update (age, position, color, etc.).
  83727. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83728. */
  83729. updateFunction: (particles: Particle[]) => void;
  83730. private _emitterWorldMatrix;
  83731. /**
  83732. * This function can be defined to specify initial direction for every new particle.
  83733. * It by default use the emitterType defined function
  83734. */
  83735. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83736. /**
  83737. * This function can be defined to specify initial position for every new particle.
  83738. * It by default use the emitterType defined function
  83739. */
  83740. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83741. /**
  83742. * @hidden
  83743. */
  83744. _inheritedVelocityOffset: Vector3;
  83745. /**
  83746. * An event triggered when the system is disposed
  83747. */
  83748. onDisposeObservable: Observable<ParticleSystem>;
  83749. private _onDisposeObserver;
  83750. /**
  83751. * Sets a callback that will be triggered when the system is disposed
  83752. */
  83753. onDispose: () => void;
  83754. private _particles;
  83755. private _epsilon;
  83756. private _capacity;
  83757. private _stockParticles;
  83758. private _newPartsExcess;
  83759. private _vertexData;
  83760. private _vertexBuffer;
  83761. private _vertexBuffers;
  83762. private _spriteBuffer;
  83763. private _indexBuffer;
  83764. private _effect;
  83765. private _customEffect;
  83766. private _cachedDefines;
  83767. private _scaledColorStep;
  83768. private _colorDiff;
  83769. private _scaledDirection;
  83770. private _scaledGravity;
  83771. private _currentRenderId;
  83772. private _alive;
  83773. private _useInstancing;
  83774. private _started;
  83775. private _stopped;
  83776. private _actualFrame;
  83777. private _scaledUpdateSpeed;
  83778. private _vertexBufferSize;
  83779. /** @hidden */
  83780. _currentEmitRateGradient: Nullable<FactorGradient>;
  83781. /** @hidden */
  83782. _currentEmitRate1: number;
  83783. /** @hidden */
  83784. _currentEmitRate2: number;
  83785. /** @hidden */
  83786. _currentStartSizeGradient: Nullable<FactorGradient>;
  83787. /** @hidden */
  83788. _currentStartSize1: number;
  83789. /** @hidden */
  83790. _currentStartSize2: number;
  83791. private readonly _rawTextureWidth;
  83792. private _rampGradientsTexture;
  83793. private _useRampGradients;
  83794. /** Gets or sets a boolean indicating that ramp gradients must be used
  83795. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83796. */
  83797. useRampGradients: boolean;
  83798. /**
  83799. * 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.
  83800. * 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: [])
  83801. */
  83802. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83803. private _subEmitters;
  83804. /**
  83805. * @hidden
  83806. * If the particle systems emitter should be disposed when the particle system is disposed
  83807. */
  83808. _disposeEmitterOnDispose: boolean;
  83809. /**
  83810. * The current active Sub-systems, this property is used by the root particle system only.
  83811. */
  83812. activeSubSystems: Array<ParticleSystem>;
  83813. private _rootParticleSystem;
  83814. /**
  83815. * Gets the current list of active particles
  83816. */
  83817. readonly particles: Particle[];
  83818. /**
  83819. * Returns the string "ParticleSystem"
  83820. * @returns a string containing the class name
  83821. */
  83822. getClassName(): string;
  83823. /**
  83824. * Instantiates a particle system.
  83825. * 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.
  83826. * @param name The name of the particle system
  83827. * @param capacity The max number of particles alive at the same time
  83828. * @param scene The scene the particle system belongs to
  83829. * @param customEffect a custom effect used to change the way particles are rendered by default
  83830. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83831. * @param epsilon Offset used to render the particles
  83832. */
  83833. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83834. private _addFactorGradient;
  83835. private _removeFactorGradient;
  83836. /**
  83837. * Adds a new life time gradient
  83838. * @param gradient defines the gradient to use (between 0 and 1)
  83839. * @param factor defines the life time factor to affect to the specified gradient
  83840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83841. * @returns the current particle system
  83842. */
  83843. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83844. /**
  83845. * Remove a specific life time gradient
  83846. * @param gradient defines the gradient to remove
  83847. * @returns the current particle system
  83848. */
  83849. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83850. /**
  83851. * Adds a new size gradient
  83852. * @param gradient defines the gradient to use (between 0 and 1)
  83853. * @param factor defines the size factor to affect to the specified gradient
  83854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83855. * @returns the current particle system
  83856. */
  83857. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83858. /**
  83859. * Remove a specific size gradient
  83860. * @param gradient defines the gradient to remove
  83861. * @returns the current particle system
  83862. */
  83863. removeSizeGradient(gradient: number): IParticleSystem;
  83864. /**
  83865. * Adds a new color remap gradient
  83866. * @param gradient defines the gradient to use (between 0 and 1)
  83867. * @param min defines the color remap minimal range
  83868. * @param max defines the color remap maximal range
  83869. * @returns the current particle system
  83870. */
  83871. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83872. /**
  83873. * Remove a specific color remap gradient
  83874. * @param gradient defines the gradient to remove
  83875. * @returns the current particle system
  83876. */
  83877. removeColorRemapGradient(gradient: number): IParticleSystem;
  83878. /**
  83879. * Adds a new alpha remap gradient
  83880. * @param gradient defines the gradient to use (between 0 and 1)
  83881. * @param min defines the alpha remap minimal range
  83882. * @param max defines the alpha remap maximal range
  83883. * @returns the current particle system
  83884. */
  83885. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83886. /**
  83887. * Remove a specific alpha remap gradient
  83888. * @param gradient defines the gradient to remove
  83889. * @returns the current particle system
  83890. */
  83891. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83892. /**
  83893. * Adds a new angular speed gradient
  83894. * @param gradient defines the gradient to use (between 0 and 1)
  83895. * @param factor defines the angular speed to affect to the specified gradient
  83896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83897. * @returns the current particle system
  83898. */
  83899. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83900. /**
  83901. * Remove a specific angular speed gradient
  83902. * @param gradient defines the gradient to remove
  83903. * @returns the current particle system
  83904. */
  83905. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83906. /**
  83907. * Adds a new velocity gradient
  83908. * @param gradient defines the gradient to use (between 0 and 1)
  83909. * @param factor defines the velocity to affect to the specified gradient
  83910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83911. * @returns the current particle system
  83912. */
  83913. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83914. /**
  83915. * Remove a specific velocity gradient
  83916. * @param gradient defines the gradient to remove
  83917. * @returns the current particle system
  83918. */
  83919. removeVelocityGradient(gradient: number): IParticleSystem;
  83920. /**
  83921. * Adds a new limit velocity gradient
  83922. * @param gradient defines the gradient to use (between 0 and 1)
  83923. * @param factor defines the limit velocity value to affect to the specified gradient
  83924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83925. * @returns the current particle system
  83926. */
  83927. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83928. /**
  83929. * Remove a specific limit velocity gradient
  83930. * @param gradient defines the gradient to remove
  83931. * @returns the current particle system
  83932. */
  83933. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83934. /**
  83935. * Adds a new drag gradient
  83936. * @param gradient defines the gradient to use (between 0 and 1)
  83937. * @param factor defines the drag value to affect to the specified gradient
  83938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83939. * @returns the current particle system
  83940. */
  83941. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83942. /**
  83943. * Remove a specific drag gradient
  83944. * @param gradient defines the gradient to remove
  83945. * @returns the current particle system
  83946. */
  83947. removeDragGradient(gradient: number): IParticleSystem;
  83948. /**
  83949. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83950. * @param gradient defines the gradient to use (between 0 and 1)
  83951. * @param factor defines the emit rate value to affect to the specified gradient
  83952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83953. * @returns the current particle system
  83954. */
  83955. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83956. /**
  83957. * Remove a specific emit rate gradient
  83958. * @param gradient defines the gradient to remove
  83959. * @returns the current particle system
  83960. */
  83961. removeEmitRateGradient(gradient: number): IParticleSystem;
  83962. /**
  83963. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83964. * @param gradient defines the gradient to use (between 0 and 1)
  83965. * @param factor defines the start size value to affect to the specified gradient
  83966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83967. * @returns the current particle system
  83968. */
  83969. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83970. /**
  83971. * Remove a specific start size gradient
  83972. * @param gradient defines the gradient to remove
  83973. * @returns the current particle system
  83974. */
  83975. removeStartSizeGradient(gradient: number): IParticleSystem;
  83976. private _createRampGradientTexture;
  83977. /**
  83978. * Gets the current list of ramp gradients.
  83979. * You must use addRampGradient and removeRampGradient to udpate this list
  83980. * @returns the list of ramp gradients
  83981. */
  83982. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83983. /**
  83984. * Adds a new ramp gradient used to remap particle colors
  83985. * @param gradient defines the gradient to use (between 0 and 1)
  83986. * @param color defines the color to affect to the specified gradient
  83987. * @returns the current particle system
  83988. */
  83989. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  83990. /**
  83991. * Remove a specific ramp gradient
  83992. * @param gradient defines the gradient to remove
  83993. * @returns the current particle system
  83994. */
  83995. removeRampGradient(gradient: number): ParticleSystem;
  83996. /**
  83997. * Adds a new color gradient
  83998. * @param gradient defines the gradient to use (between 0 and 1)
  83999. * @param color1 defines the color to affect to the specified gradient
  84000. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84001. * @returns this particle system
  84002. */
  84003. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84004. /**
  84005. * Remove a specific color gradient
  84006. * @param gradient defines the gradient to remove
  84007. * @returns this particle system
  84008. */
  84009. removeColorGradient(gradient: number): IParticleSystem;
  84010. private _fetchR;
  84011. protected _reset(): void;
  84012. private _resetEffect;
  84013. private _createVertexBuffers;
  84014. private _createIndexBuffer;
  84015. /**
  84016. * Gets the maximum number of particles active at the same time.
  84017. * @returns The max number of active particles.
  84018. */
  84019. getCapacity(): number;
  84020. /**
  84021. * Gets whether there are still active particles in the system.
  84022. * @returns True if it is alive, otherwise false.
  84023. */
  84024. isAlive(): boolean;
  84025. /**
  84026. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84027. * @returns True if it has been started, otherwise false.
  84028. */
  84029. isStarted(): boolean;
  84030. private _prepareSubEmitterInternalArray;
  84031. /**
  84032. * Starts the particle system and begins to emit
  84033. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84034. */
  84035. start(delay?: number): void;
  84036. /**
  84037. * Stops the particle system.
  84038. * @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.
  84039. */
  84040. stop(stopSubEmitters?: boolean): void;
  84041. /**
  84042. * Remove all active particles
  84043. */
  84044. reset(): void;
  84045. /**
  84046. * @hidden (for internal use only)
  84047. */
  84048. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84049. /**
  84050. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84051. * Its lifetime will start back at 0.
  84052. */
  84053. recycleParticle: (particle: Particle) => void;
  84054. private _stopSubEmitters;
  84055. private _createParticle;
  84056. private _removeFromRoot;
  84057. private _emitFromParticle;
  84058. private _update;
  84059. /** @hidden */
  84060. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84061. /** @hidden */
  84062. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84063. /** @hidden */
  84064. private _getEffect;
  84065. /**
  84066. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84067. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84068. */
  84069. animate(preWarmOnly?: boolean): void;
  84070. private _appendParticleVertices;
  84071. /**
  84072. * Rebuilds the particle system.
  84073. */
  84074. rebuild(): void;
  84075. /**
  84076. * Is this system ready to be used/rendered
  84077. * @return true if the system is ready
  84078. */
  84079. isReady(): boolean;
  84080. private _render;
  84081. /**
  84082. * Renders the particle system in its current state.
  84083. * @returns the current number of particles
  84084. */
  84085. render(): number;
  84086. /**
  84087. * Disposes the particle system and free the associated resources
  84088. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84089. */
  84090. dispose(disposeTexture?: boolean): void;
  84091. /**
  84092. * Clones the particle system.
  84093. * @param name The name of the cloned object
  84094. * @param newEmitter The new emitter to use
  84095. * @returns the cloned particle system
  84096. */
  84097. clone(name: string, newEmitter: any): ParticleSystem;
  84098. /**
  84099. * Serializes the particle system to a JSON object.
  84100. * @returns the JSON object
  84101. */
  84102. serialize(): any;
  84103. /** @hidden */
  84104. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84105. /** @hidden */
  84106. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84107. /**
  84108. * Parses a JSON object to create a particle system.
  84109. * @param parsedParticleSystem The JSON object to parse
  84110. * @param scene The scene to create the particle system in
  84111. * @param rootUrl The root url to use to load external dependencies like texture
  84112. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84113. * @returns the Parsed particle system
  84114. */
  84115. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84116. }
  84117. }
  84118. declare module BABYLON {
  84119. /**
  84120. * A particle represents one of the element emitted by a particle system.
  84121. * This is mainly define by its coordinates, direction, velocity and age.
  84122. */
  84123. export class Particle {
  84124. /**
  84125. * The particle system the particle belongs to.
  84126. */
  84127. particleSystem: ParticleSystem;
  84128. private static _Count;
  84129. /**
  84130. * Unique ID of the particle
  84131. */
  84132. id: number;
  84133. /**
  84134. * The world position of the particle in the scene.
  84135. */
  84136. position: Vector3;
  84137. /**
  84138. * The world direction of the particle in the scene.
  84139. */
  84140. direction: Vector3;
  84141. /**
  84142. * The color of the particle.
  84143. */
  84144. color: Color4;
  84145. /**
  84146. * The color change of the particle per step.
  84147. */
  84148. colorStep: Color4;
  84149. /**
  84150. * Defines how long will the life of the particle be.
  84151. */
  84152. lifeTime: number;
  84153. /**
  84154. * The current age of the particle.
  84155. */
  84156. age: number;
  84157. /**
  84158. * The current size of the particle.
  84159. */
  84160. size: number;
  84161. /**
  84162. * The current scale of the particle.
  84163. */
  84164. scale: Vector2;
  84165. /**
  84166. * The current angle of the particle.
  84167. */
  84168. angle: number;
  84169. /**
  84170. * Defines how fast is the angle changing.
  84171. */
  84172. angularSpeed: number;
  84173. /**
  84174. * Defines the cell index used by the particle to be rendered from a sprite.
  84175. */
  84176. cellIndex: number;
  84177. /**
  84178. * The information required to support color remapping
  84179. */
  84180. remapData: Vector4;
  84181. /** @hidden */
  84182. _randomCellOffset?: number;
  84183. /** @hidden */
  84184. _initialDirection: Nullable<Vector3>;
  84185. /** @hidden */
  84186. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84187. /** @hidden */
  84188. _initialStartSpriteCellID: number;
  84189. /** @hidden */
  84190. _initialEndSpriteCellID: number;
  84191. /** @hidden */
  84192. _currentColorGradient: Nullable<ColorGradient>;
  84193. /** @hidden */
  84194. _currentColor1: Color4;
  84195. /** @hidden */
  84196. _currentColor2: Color4;
  84197. /** @hidden */
  84198. _currentSizeGradient: Nullable<FactorGradient>;
  84199. /** @hidden */
  84200. _currentSize1: number;
  84201. /** @hidden */
  84202. _currentSize2: number;
  84203. /** @hidden */
  84204. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84205. /** @hidden */
  84206. _currentAngularSpeed1: number;
  84207. /** @hidden */
  84208. _currentAngularSpeed2: number;
  84209. /** @hidden */
  84210. _currentVelocityGradient: Nullable<FactorGradient>;
  84211. /** @hidden */
  84212. _currentVelocity1: number;
  84213. /** @hidden */
  84214. _currentVelocity2: number;
  84215. /** @hidden */
  84216. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84217. /** @hidden */
  84218. _currentLimitVelocity1: number;
  84219. /** @hidden */
  84220. _currentLimitVelocity2: number;
  84221. /** @hidden */
  84222. _currentDragGradient: Nullable<FactorGradient>;
  84223. /** @hidden */
  84224. _currentDrag1: number;
  84225. /** @hidden */
  84226. _currentDrag2: number;
  84227. /** @hidden */
  84228. _randomNoiseCoordinates1: Vector3;
  84229. /** @hidden */
  84230. _randomNoiseCoordinates2: Vector3;
  84231. /**
  84232. * Creates a new instance Particle
  84233. * @param particleSystem the particle system the particle belongs to
  84234. */
  84235. constructor(
  84236. /**
  84237. * The particle system the particle belongs to.
  84238. */
  84239. particleSystem: ParticleSystem);
  84240. private updateCellInfoFromSystem;
  84241. /**
  84242. * Defines how the sprite cell index is updated for the particle
  84243. */
  84244. updateCellIndex(): void;
  84245. /** @hidden */
  84246. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84247. /** @hidden */
  84248. _inheritParticleInfoToSubEmitters(): void;
  84249. /** @hidden */
  84250. _reset(): void;
  84251. /**
  84252. * Copy the properties of particle to another one.
  84253. * @param other the particle to copy the information to.
  84254. */
  84255. copyTo(other: Particle): void;
  84256. }
  84257. }
  84258. declare module BABYLON {
  84259. /**
  84260. * Particle emitter represents a volume emitting particles.
  84261. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84262. */
  84263. export interface IParticleEmitterType {
  84264. /**
  84265. * Called by the particle System when the direction is computed for the created particle.
  84266. * @param worldMatrix is the world matrix of the particle system
  84267. * @param directionToUpdate is the direction vector to update with the result
  84268. * @param particle is the particle we are computed the direction for
  84269. */
  84270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84271. /**
  84272. * Called by the particle System when the position is computed for the created particle.
  84273. * @param worldMatrix is the world matrix of the particle system
  84274. * @param positionToUpdate is the position vector to update with the result
  84275. * @param particle is the particle we are computed the position for
  84276. */
  84277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84278. /**
  84279. * Clones the current emitter and returns a copy of it
  84280. * @returns the new emitter
  84281. */
  84282. clone(): IParticleEmitterType;
  84283. /**
  84284. * Called by the GPUParticleSystem to setup the update shader
  84285. * @param effect defines the update shader
  84286. */
  84287. applyToShader(effect: Effect): void;
  84288. /**
  84289. * Returns a string to use to update the GPU particles update shader
  84290. * @returns the effect defines string
  84291. */
  84292. getEffectDefines(): string;
  84293. /**
  84294. * Returns a string representing the class name
  84295. * @returns a string containing the class name
  84296. */
  84297. getClassName(): string;
  84298. /**
  84299. * Serializes the particle system to a JSON object.
  84300. * @returns the JSON object
  84301. */
  84302. serialize(): any;
  84303. /**
  84304. * Parse properties from a JSON object
  84305. * @param serializationObject defines the JSON object
  84306. */
  84307. parse(serializationObject: any): void;
  84308. }
  84309. }
  84310. declare module BABYLON {
  84311. /**
  84312. * Particle emitter emitting particles from the inside of a box.
  84313. * It emits the particles randomly between 2 given directions.
  84314. */
  84315. export class BoxParticleEmitter implements IParticleEmitterType {
  84316. /**
  84317. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84318. */
  84319. direction1: Vector3;
  84320. /**
  84321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84322. */
  84323. direction2: Vector3;
  84324. /**
  84325. * 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.
  84326. */
  84327. minEmitBox: Vector3;
  84328. /**
  84329. * 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.
  84330. */
  84331. maxEmitBox: Vector3;
  84332. /**
  84333. * Creates a new instance BoxParticleEmitter
  84334. */
  84335. constructor();
  84336. /**
  84337. * Called by the particle System when the direction is computed for the created particle.
  84338. * @param worldMatrix is the world matrix of the particle system
  84339. * @param directionToUpdate is the direction vector to update with the result
  84340. * @param particle is the particle we are computed the direction for
  84341. */
  84342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84343. /**
  84344. * Called by the particle System when the position is computed for the created particle.
  84345. * @param worldMatrix is the world matrix of the particle system
  84346. * @param positionToUpdate is the position vector to update with the result
  84347. * @param particle is the particle we are computed the position for
  84348. */
  84349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84350. /**
  84351. * Clones the current emitter and returns a copy of it
  84352. * @returns the new emitter
  84353. */
  84354. clone(): BoxParticleEmitter;
  84355. /**
  84356. * Called by the GPUParticleSystem to setup the update shader
  84357. * @param effect defines the update shader
  84358. */
  84359. applyToShader(effect: Effect): void;
  84360. /**
  84361. * Returns a string to use to update the GPU particles update shader
  84362. * @returns a string containng the defines string
  84363. */
  84364. getEffectDefines(): string;
  84365. /**
  84366. * Returns the string "BoxParticleEmitter"
  84367. * @returns a string containing the class name
  84368. */
  84369. getClassName(): string;
  84370. /**
  84371. * Serializes the particle system to a JSON object.
  84372. * @returns the JSON object
  84373. */
  84374. serialize(): any;
  84375. /**
  84376. * Parse properties from a JSON object
  84377. * @param serializationObject defines the JSON object
  84378. */
  84379. parse(serializationObject: any): void;
  84380. }
  84381. }
  84382. declare module BABYLON {
  84383. /**
  84384. * Particle emitter emitting particles from the inside of a cone.
  84385. * It emits the particles alongside the cone volume from the base to the particle.
  84386. * The emission direction might be randomized.
  84387. */
  84388. export class ConeParticleEmitter implements IParticleEmitterType {
  84389. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84390. directionRandomizer: number;
  84391. private _radius;
  84392. private _angle;
  84393. private _height;
  84394. /**
  84395. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84396. */
  84397. radiusRange: number;
  84398. /**
  84399. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84400. */
  84401. heightRange: number;
  84402. /**
  84403. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84404. */
  84405. emitFromSpawnPointOnly: boolean;
  84406. /**
  84407. * Gets or sets the radius of the emission cone
  84408. */
  84409. radius: number;
  84410. /**
  84411. * Gets or sets the angle of the emission cone
  84412. */
  84413. angle: number;
  84414. private _buildHeight;
  84415. /**
  84416. * Creates a new instance ConeParticleEmitter
  84417. * @param radius the radius of the emission cone (1 by default)
  84418. * @param angle the cone base angle (PI by default)
  84419. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84420. */
  84421. constructor(radius?: number, angle?: number,
  84422. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84423. directionRandomizer?: number);
  84424. /**
  84425. * Called by the particle System when the direction is computed for the created particle.
  84426. * @param worldMatrix is the world matrix of the particle system
  84427. * @param directionToUpdate is the direction vector to update with the result
  84428. * @param particle is the particle we are computed the direction for
  84429. */
  84430. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84431. /**
  84432. * Called by the particle System when the position is computed for the created particle.
  84433. * @param worldMatrix is the world matrix of the particle system
  84434. * @param positionToUpdate is the position vector to update with the result
  84435. * @param particle is the particle we are computed the position for
  84436. */
  84437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84438. /**
  84439. * Clones the current emitter and returns a copy of it
  84440. * @returns the new emitter
  84441. */
  84442. clone(): ConeParticleEmitter;
  84443. /**
  84444. * Called by the GPUParticleSystem to setup the update shader
  84445. * @param effect defines the update shader
  84446. */
  84447. applyToShader(effect: Effect): void;
  84448. /**
  84449. * Returns a string to use to update the GPU particles update shader
  84450. * @returns a string containng the defines string
  84451. */
  84452. getEffectDefines(): string;
  84453. /**
  84454. * Returns the string "ConeParticleEmitter"
  84455. * @returns a string containing the class name
  84456. */
  84457. getClassName(): string;
  84458. /**
  84459. * Serializes the particle system to a JSON object.
  84460. * @returns the JSON object
  84461. */
  84462. serialize(): any;
  84463. /**
  84464. * Parse properties from a JSON object
  84465. * @param serializationObject defines the JSON object
  84466. */
  84467. parse(serializationObject: any): void;
  84468. }
  84469. }
  84470. declare module BABYLON {
  84471. /**
  84472. * Particle emitter emitting particles from the inside of a cylinder.
  84473. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84474. */
  84475. export class CylinderParticleEmitter implements IParticleEmitterType {
  84476. /**
  84477. * The radius of the emission cylinder.
  84478. */
  84479. radius: number;
  84480. /**
  84481. * The height of the emission cylinder.
  84482. */
  84483. height: number;
  84484. /**
  84485. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84486. */
  84487. radiusRange: number;
  84488. /**
  84489. * How much to randomize the particle direction [0-1].
  84490. */
  84491. directionRandomizer: number;
  84492. /**
  84493. * Creates a new instance CylinderParticleEmitter
  84494. * @param radius the radius of the emission cylinder (1 by default)
  84495. * @param height the height of the emission cylinder (1 by default)
  84496. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84498. */
  84499. constructor(
  84500. /**
  84501. * The radius of the emission cylinder.
  84502. */
  84503. radius?: number,
  84504. /**
  84505. * The height of the emission cylinder.
  84506. */
  84507. height?: number,
  84508. /**
  84509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84510. */
  84511. radiusRange?: number,
  84512. /**
  84513. * How much to randomize the particle direction [0-1].
  84514. */
  84515. directionRandomizer?: number);
  84516. /**
  84517. * Called by the particle System when the direction is computed for the created particle.
  84518. * @param worldMatrix is the world matrix of the particle system
  84519. * @param directionToUpdate is the direction vector to update with the result
  84520. * @param particle is the particle we are computed the direction for
  84521. */
  84522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84523. /**
  84524. * Called by the particle System when the position is computed for the created particle.
  84525. * @param worldMatrix is the world matrix of the particle system
  84526. * @param positionToUpdate is the position vector to update with the result
  84527. * @param particle is the particle we are computed the position for
  84528. */
  84529. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84530. /**
  84531. * Clones the current emitter and returns a copy of it
  84532. * @returns the new emitter
  84533. */
  84534. clone(): CylinderParticleEmitter;
  84535. /**
  84536. * Called by the GPUParticleSystem to setup the update shader
  84537. * @param effect defines the update shader
  84538. */
  84539. applyToShader(effect: Effect): void;
  84540. /**
  84541. * Returns a string to use to update the GPU particles update shader
  84542. * @returns a string containng the defines string
  84543. */
  84544. getEffectDefines(): string;
  84545. /**
  84546. * Returns the string "CylinderParticleEmitter"
  84547. * @returns a string containing the class name
  84548. */
  84549. getClassName(): string;
  84550. /**
  84551. * Serializes the particle system to a JSON object.
  84552. * @returns the JSON object
  84553. */
  84554. serialize(): any;
  84555. /**
  84556. * Parse properties from a JSON object
  84557. * @param serializationObject defines the JSON object
  84558. */
  84559. parse(serializationObject: any): void;
  84560. }
  84561. /**
  84562. * Particle emitter emitting particles from the inside of a cylinder.
  84563. * It emits the particles randomly between two vectors.
  84564. */
  84565. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84566. /**
  84567. * The min limit of the emission direction.
  84568. */
  84569. direction1: Vector3;
  84570. /**
  84571. * The max limit of the emission direction.
  84572. */
  84573. direction2: Vector3;
  84574. /**
  84575. * Creates a new instance CylinderDirectedParticleEmitter
  84576. * @param radius the radius of the emission cylinder (1 by default)
  84577. * @param height the height of the emission cylinder (1 by default)
  84578. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84579. * @param direction1 the min limit of the emission direction (up vector by default)
  84580. * @param direction2 the max limit of the emission direction (up vector by default)
  84581. */
  84582. constructor(radius?: number, height?: number, radiusRange?: number,
  84583. /**
  84584. * The min limit of the emission direction.
  84585. */
  84586. direction1?: Vector3,
  84587. /**
  84588. * The max limit of the emission direction.
  84589. */
  84590. direction2?: Vector3);
  84591. /**
  84592. * Called by the particle System when the direction is computed for the created particle.
  84593. * @param worldMatrix is the world matrix of the particle system
  84594. * @param directionToUpdate is the direction vector to update with the result
  84595. * @param particle is the particle we are computed the direction for
  84596. */
  84597. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84598. /**
  84599. * Clones the current emitter and returns a copy of it
  84600. * @returns the new emitter
  84601. */
  84602. clone(): CylinderDirectedParticleEmitter;
  84603. /**
  84604. * Called by the GPUParticleSystem to setup the update shader
  84605. * @param effect defines the update shader
  84606. */
  84607. applyToShader(effect: Effect): void;
  84608. /**
  84609. * Returns a string to use to update the GPU particles update shader
  84610. * @returns a string containng the defines string
  84611. */
  84612. getEffectDefines(): string;
  84613. /**
  84614. * Returns the string "CylinderDirectedParticleEmitter"
  84615. * @returns a string containing the class name
  84616. */
  84617. getClassName(): string;
  84618. /**
  84619. * Serializes the particle system to a JSON object.
  84620. * @returns the JSON object
  84621. */
  84622. serialize(): any;
  84623. /**
  84624. * Parse properties from a JSON object
  84625. * @param serializationObject defines the JSON object
  84626. */
  84627. parse(serializationObject: any): void;
  84628. }
  84629. }
  84630. declare module BABYLON {
  84631. /**
  84632. * Particle emitter emitting particles from the inside of a hemisphere.
  84633. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84634. */
  84635. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84636. /**
  84637. * The radius of the emission hemisphere.
  84638. */
  84639. radius: number;
  84640. /**
  84641. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84642. */
  84643. radiusRange: number;
  84644. /**
  84645. * How much to randomize the particle direction [0-1].
  84646. */
  84647. directionRandomizer: number;
  84648. /**
  84649. * Creates a new instance HemisphericParticleEmitter
  84650. * @param radius the radius of the emission hemisphere (1 by default)
  84651. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84652. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84653. */
  84654. constructor(
  84655. /**
  84656. * The radius of the emission hemisphere.
  84657. */
  84658. radius?: number,
  84659. /**
  84660. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84661. */
  84662. radiusRange?: number,
  84663. /**
  84664. * How much to randomize the particle direction [0-1].
  84665. */
  84666. directionRandomizer?: number);
  84667. /**
  84668. * Called by the particle System when the direction is computed for the created particle.
  84669. * @param worldMatrix is the world matrix of the particle system
  84670. * @param directionToUpdate is the direction vector to update with the result
  84671. * @param particle is the particle we are computed the direction for
  84672. */
  84673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84674. /**
  84675. * Called by the particle System when the position is computed for the created particle.
  84676. * @param worldMatrix is the world matrix of the particle system
  84677. * @param positionToUpdate is the position vector to update with the result
  84678. * @param particle is the particle we are computed the position for
  84679. */
  84680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84681. /**
  84682. * Clones the current emitter and returns a copy of it
  84683. * @returns the new emitter
  84684. */
  84685. clone(): HemisphericParticleEmitter;
  84686. /**
  84687. * Called by the GPUParticleSystem to setup the update shader
  84688. * @param effect defines the update shader
  84689. */
  84690. applyToShader(effect: Effect): void;
  84691. /**
  84692. * Returns a string to use to update the GPU particles update shader
  84693. * @returns a string containng the defines string
  84694. */
  84695. getEffectDefines(): string;
  84696. /**
  84697. * Returns the string "HemisphericParticleEmitter"
  84698. * @returns a string containing the class name
  84699. */
  84700. getClassName(): string;
  84701. /**
  84702. * Serializes the particle system to a JSON object.
  84703. * @returns the JSON object
  84704. */
  84705. serialize(): any;
  84706. /**
  84707. * Parse properties from a JSON object
  84708. * @param serializationObject defines the JSON object
  84709. */
  84710. parse(serializationObject: any): void;
  84711. }
  84712. }
  84713. declare module BABYLON {
  84714. /**
  84715. * Particle emitter emitting particles from a point.
  84716. * It emits the particles randomly between 2 given directions.
  84717. */
  84718. export class PointParticleEmitter implements IParticleEmitterType {
  84719. /**
  84720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84721. */
  84722. direction1: Vector3;
  84723. /**
  84724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84725. */
  84726. direction2: Vector3;
  84727. /**
  84728. * Creates a new instance PointParticleEmitter
  84729. */
  84730. constructor();
  84731. /**
  84732. * Called by the particle System when the direction is computed for the created particle.
  84733. * @param worldMatrix is the world matrix of the particle system
  84734. * @param directionToUpdate is the direction vector to update with the result
  84735. * @param particle is the particle we are computed the direction for
  84736. */
  84737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84738. /**
  84739. * Called by the particle System when the position is computed for the created particle.
  84740. * @param worldMatrix is the world matrix of the particle system
  84741. * @param positionToUpdate is the position vector to update with the result
  84742. * @param particle is the particle we are computed the position for
  84743. */
  84744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84745. /**
  84746. * Clones the current emitter and returns a copy of it
  84747. * @returns the new emitter
  84748. */
  84749. clone(): PointParticleEmitter;
  84750. /**
  84751. * Called by the GPUParticleSystem to setup the update shader
  84752. * @param effect defines the update shader
  84753. */
  84754. applyToShader(effect: Effect): void;
  84755. /**
  84756. * Returns a string to use to update the GPU particles update shader
  84757. * @returns a string containng the defines string
  84758. */
  84759. getEffectDefines(): string;
  84760. /**
  84761. * Returns the string "PointParticleEmitter"
  84762. * @returns a string containing the class name
  84763. */
  84764. getClassName(): string;
  84765. /**
  84766. * Serializes the particle system to a JSON object.
  84767. * @returns the JSON object
  84768. */
  84769. serialize(): any;
  84770. /**
  84771. * Parse properties from a JSON object
  84772. * @param serializationObject defines the JSON object
  84773. */
  84774. parse(serializationObject: any): void;
  84775. }
  84776. }
  84777. declare module BABYLON {
  84778. /**
  84779. * Particle emitter emitting particles from the inside of a sphere.
  84780. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84781. */
  84782. export class SphereParticleEmitter implements IParticleEmitterType {
  84783. /**
  84784. * The radius of the emission sphere.
  84785. */
  84786. radius: number;
  84787. /**
  84788. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84789. */
  84790. radiusRange: number;
  84791. /**
  84792. * How much to randomize the particle direction [0-1].
  84793. */
  84794. directionRandomizer: number;
  84795. /**
  84796. * Creates a new instance SphereParticleEmitter
  84797. * @param radius the radius of the emission sphere (1 by default)
  84798. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84799. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84800. */
  84801. constructor(
  84802. /**
  84803. * The radius of the emission sphere.
  84804. */
  84805. radius?: number,
  84806. /**
  84807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84808. */
  84809. radiusRange?: number,
  84810. /**
  84811. * How much to randomize the particle direction [0-1].
  84812. */
  84813. directionRandomizer?: number);
  84814. /**
  84815. * Called by the particle System when the direction is computed for the created particle.
  84816. * @param worldMatrix is the world matrix of the particle system
  84817. * @param directionToUpdate is the direction vector to update with the result
  84818. * @param particle is the particle we are computed the direction for
  84819. */
  84820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84821. /**
  84822. * Called by the particle System when the position is computed for the created particle.
  84823. * @param worldMatrix is the world matrix of the particle system
  84824. * @param positionToUpdate is the position vector to update with the result
  84825. * @param particle is the particle we are computed the position for
  84826. */
  84827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84828. /**
  84829. * Clones the current emitter and returns a copy of it
  84830. * @returns the new emitter
  84831. */
  84832. clone(): SphereParticleEmitter;
  84833. /**
  84834. * Called by the GPUParticleSystem to setup the update shader
  84835. * @param effect defines the update shader
  84836. */
  84837. applyToShader(effect: Effect): void;
  84838. /**
  84839. * Returns a string to use to update the GPU particles update shader
  84840. * @returns a string containng the defines string
  84841. */
  84842. getEffectDefines(): string;
  84843. /**
  84844. * Returns the string "SphereParticleEmitter"
  84845. * @returns a string containing the class name
  84846. */
  84847. getClassName(): string;
  84848. /**
  84849. * Serializes the particle system to a JSON object.
  84850. * @returns the JSON object
  84851. */
  84852. serialize(): any;
  84853. /**
  84854. * Parse properties from a JSON object
  84855. * @param serializationObject defines the JSON object
  84856. */
  84857. parse(serializationObject: any): void;
  84858. }
  84859. /**
  84860. * Particle emitter emitting particles from the inside of a sphere.
  84861. * It emits the particles randomly between two vectors.
  84862. */
  84863. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84864. /**
  84865. * The min limit of the emission direction.
  84866. */
  84867. direction1: Vector3;
  84868. /**
  84869. * The max limit of the emission direction.
  84870. */
  84871. direction2: Vector3;
  84872. /**
  84873. * Creates a new instance SphereDirectedParticleEmitter
  84874. * @param radius the radius of the emission sphere (1 by default)
  84875. * @param direction1 the min limit of the emission direction (up vector by default)
  84876. * @param direction2 the max limit of the emission direction (up vector by default)
  84877. */
  84878. constructor(radius?: number,
  84879. /**
  84880. * The min limit of the emission direction.
  84881. */
  84882. direction1?: Vector3,
  84883. /**
  84884. * The max limit of the emission direction.
  84885. */
  84886. direction2?: Vector3);
  84887. /**
  84888. * Called by the particle System when the direction is computed for the created particle.
  84889. * @param worldMatrix is the world matrix of the particle system
  84890. * @param directionToUpdate is the direction vector to update with the result
  84891. * @param particle is the particle we are computed the direction for
  84892. */
  84893. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84894. /**
  84895. * Clones the current emitter and returns a copy of it
  84896. * @returns the new emitter
  84897. */
  84898. clone(): SphereDirectedParticleEmitter;
  84899. /**
  84900. * Called by the GPUParticleSystem to setup the update shader
  84901. * @param effect defines the update shader
  84902. */
  84903. applyToShader(effect: Effect): void;
  84904. /**
  84905. * Returns a string to use to update the GPU particles update shader
  84906. * @returns a string containng the defines string
  84907. */
  84908. getEffectDefines(): string;
  84909. /**
  84910. * Returns the string "SphereDirectedParticleEmitter"
  84911. * @returns a string containing the class name
  84912. */
  84913. getClassName(): string;
  84914. /**
  84915. * Serializes the particle system to a JSON object.
  84916. * @returns the JSON object
  84917. */
  84918. serialize(): any;
  84919. /**
  84920. * Parse properties from a JSON object
  84921. * @param serializationObject defines the JSON object
  84922. */
  84923. parse(serializationObject: any): void;
  84924. }
  84925. }
  84926. declare module BABYLON {
  84927. /**
  84928. * Interface representing a particle system in Babylon.js.
  84929. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84930. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84931. */
  84932. export interface IParticleSystem {
  84933. /**
  84934. * List of animations used by the particle system.
  84935. */
  84936. animations: Animation[];
  84937. /**
  84938. * The id of the Particle system.
  84939. */
  84940. id: string;
  84941. /**
  84942. * The name of the Particle system.
  84943. */
  84944. name: string;
  84945. /**
  84946. * The emitter represents the Mesh or position we are attaching the particle system to.
  84947. */
  84948. emitter: Nullable<AbstractMesh | Vector3>;
  84949. /**
  84950. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84951. */
  84952. isBillboardBased: boolean;
  84953. /**
  84954. * The rendering group used by the Particle system to chose when to render.
  84955. */
  84956. renderingGroupId: number;
  84957. /**
  84958. * The layer mask we are rendering the particles through.
  84959. */
  84960. layerMask: number;
  84961. /**
  84962. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84963. */
  84964. updateSpeed: number;
  84965. /**
  84966. * The amount of time the particle system is running (depends of the overall update speed).
  84967. */
  84968. targetStopDuration: number;
  84969. /**
  84970. * The texture used to render each particle. (this can be a spritesheet)
  84971. */
  84972. particleTexture: Nullable<Texture>;
  84973. /**
  84974. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  84975. */
  84976. blendMode: number;
  84977. /**
  84978. * Minimum life time of emitting particles.
  84979. */
  84980. minLifeTime: number;
  84981. /**
  84982. * Maximum life time of emitting particles.
  84983. */
  84984. maxLifeTime: number;
  84985. /**
  84986. * Minimum Size of emitting particles.
  84987. */
  84988. minSize: number;
  84989. /**
  84990. * Maximum Size of emitting particles.
  84991. */
  84992. maxSize: number;
  84993. /**
  84994. * Minimum scale of emitting particles on X axis.
  84995. */
  84996. minScaleX: number;
  84997. /**
  84998. * Maximum scale of emitting particles on X axis.
  84999. */
  85000. maxScaleX: number;
  85001. /**
  85002. * Minimum scale of emitting particles on Y axis.
  85003. */
  85004. minScaleY: number;
  85005. /**
  85006. * Maximum scale of emitting particles on Y axis.
  85007. */
  85008. maxScaleY: number;
  85009. /**
  85010. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85011. */
  85012. color1: Color4;
  85013. /**
  85014. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85015. */
  85016. color2: Color4;
  85017. /**
  85018. * Color the particle will have at the end of its lifetime.
  85019. */
  85020. colorDead: Color4;
  85021. /**
  85022. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85023. */
  85024. emitRate: number;
  85025. /**
  85026. * You can use gravity if you want to give an orientation to your particles.
  85027. */
  85028. gravity: Vector3;
  85029. /**
  85030. * Minimum power of emitting particles.
  85031. */
  85032. minEmitPower: number;
  85033. /**
  85034. * Maximum power of emitting particles.
  85035. */
  85036. maxEmitPower: number;
  85037. /**
  85038. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85039. */
  85040. minAngularSpeed: number;
  85041. /**
  85042. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85043. */
  85044. maxAngularSpeed: number;
  85045. /**
  85046. * Gets or sets the minimal initial rotation in radians.
  85047. */
  85048. minInitialRotation: number;
  85049. /**
  85050. * Gets or sets the maximal initial rotation in radians.
  85051. */
  85052. maxInitialRotation: number;
  85053. /**
  85054. * The particle emitter type defines the emitter used by the particle system.
  85055. * It can be for example box, sphere, or cone...
  85056. */
  85057. particleEmitterType: Nullable<IParticleEmitterType>;
  85058. /**
  85059. * Defines the delay in milliseconds before starting the system (0 by default)
  85060. */
  85061. startDelay: number;
  85062. /**
  85063. * 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
  85064. */
  85065. preWarmCycles: number;
  85066. /**
  85067. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85068. */
  85069. preWarmStepOffset: number;
  85070. /**
  85071. * 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)
  85072. */
  85073. spriteCellChangeSpeed: number;
  85074. /**
  85075. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85076. */
  85077. startSpriteCellID: number;
  85078. /**
  85079. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85080. */
  85081. endSpriteCellID: number;
  85082. /**
  85083. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85084. */
  85085. spriteCellWidth: number;
  85086. /**
  85087. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85088. */
  85089. spriteCellHeight: number;
  85090. /**
  85091. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85092. */
  85093. spriteRandomStartCell: boolean;
  85094. /**
  85095. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85096. */
  85097. isAnimationSheetEnabled: boolean;
  85098. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85099. translationPivot: Vector2;
  85100. /**
  85101. * Gets or sets a texture used to add random noise to particle positions
  85102. */
  85103. noiseTexture: Nullable<BaseTexture>;
  85104. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85105. noiseStrength: Vector3;
  85106. /**
  85107. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85108. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85109. */
  85110. billboardMode: number;
  85111. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85112. limitVelocityDamping: number;
  85113. /**
  85114. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85115. */
  85116. beginAnimationOnStart: boolean;
  85117. /**
  85118. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85119. */
  85120. beginAnimationFrom: number;
  85121. /**
  85122. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85123. */
  85124. beginAnimationTo: number;
  85125. /**
  85126. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85127. */
  85128. beginAnimationLoop: boolean;
  85129. /**
  85130. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85131. */
  85132. disposeOnStop: boolean;
  85133. /**
  85134. * Gets the maximum number of particles active at the same time.
  85135. * @returns The max number of active particles.
  85136. */
  85137. getCapacity(): number;
  85138. /**
  85139. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85140. * @returns True if it has been started, otherwise false.
  85141. */
  85142. isStarted(): boolean;
  85143. /**
  85144. * Animates the particle system for this frame.
  85145. */
  85146. animate(): void;
  85147. /**
  85148. * Renders the particle system in its current state.
  85149. * @returns the current number of particles
  85150. */
  85151. render(): number;
  85152. /**
  85153. * Dispose the particle system and frees its associated resources.
  85154. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85155. */
  85156. dispose(disposeTexture?: boolean): void;
  85157. /**
  85158. * Clones the particle system.
  85159. * @param name The name of the cloned object
  85160. * @param newEmitter The new emitter to use
  85161. * @returns the cloned particle system
  85162. */
  85163. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85164. /**
  85165. * Serializes the particle system to a JSON object.
  85166. * @returns the JSON object
  85167. */
  85168. serialize(): any;
  85169. /**
  85170. * Rebuild the particle system
  85171. */
  85172. rebuild(): void;
  85173. /**
  85174. * Starts the particle system and begins to emit
  85175. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85176. */
  85177. start(delay?: number): void;
  85178. /**
  85179. * Stops the particle system.
  85180. */
  85181. stop(): void;
  85182. /**
  85183. * Remove all active particles
  85184. */
  85185. reset(): void;
  85186. /**
  85187. * Is this system ready to be used/rendered
  85188. * @return true if the system is ready
  85189. */
  85190. isReady(): boolean;
  85191. /**
  85192. * Adds a new color gradient
  85193. * @param gradient defines the gradient to use (between 0 and 1)
  85194. * @param color1 defines the color to affect to the specified gradient
  85195. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85196. * @returns the current particle system
  85197. */
  85198. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85199. /**
  85200. * Remove a specific color gradient
  85201. * @param gradient defines the gradient to remove
  85202. * @returns the current particle system
  85203. */
  85204. removeColorGradient(gradient: number): IParticleSystem;
  85205. /**
  85206. * Adds a new size gradient
  85207. * @param gradient defines the gradient to use (between 0 and 1)
  85208. * @param factor defines the size factor to affect to the specified gradient
  85209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85210. * @returns the current particle system
  85211. */
  85212. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85213. /**
  85214. * Remove a specific size gradient
  85215. * @param gradient defines the gradient to remove
  85216. * @returns the current particle system
  85217. */
  85218. removeSizeGradient(gradient: number): IParticleSystem;
  85219. /**
  85220. * Gets the current list of color gradients.
  85221. * You must use addColorGradient and removeColorGradient to udpate this list
  85222. * @returns the list of color gradients
  85223. */
  85224. getColorGradients(): Nullable<Array<ColorGradient>>;
  85225. /**
  85226. * Gets the current list of size gradients.
  85227. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85228. * @returns the list of size gradients
  85229. */
  85230. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85231. /**
  85232. * Gets the current list of angular speed gradients.
  85233. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85234. * @returns the list of angular speed gradients
  85235. */
  85236. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85237. /**
  85238. * Adds a new angular speed gradient
  85239. * @param gradient defines the gradient to use (between 0 and 1)
  85240. * @param factor defines the angular speed to affect to the specified gradient
  85241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85242. * @returns the current particle system
  85243. */
  85244. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85245. /**
  85246. * Remove a specific angular speed gradient
  85247. * @param gradient defines the gradient to remove
  85248. * @returns the current particle system
  85249. */
  85250. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85251. /**
  85252. * Gets the current list of velocity gradients.
  85253. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85254. * @returns the list of velocity gradients
  85255. */
  85256. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85257. /**
  85258. * Adds a new velocity gradient
  85259. * @param gradient defines the gradient to use (between 0 and 1)
  85260. * @param factor defines the velocity to affect to the specified gradient
  85261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85262. * @returns the current particle system
  85263. */
  85264. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85265. /**
  85266. * Remove a specific velocity gradient
  85267. * @param gradient defines the gradient to remove
  85268. * @returns the current particle system
  85269. */
  85270. removeVelocityGradient(gradient: number): IParticleSystem;
  85271. /**
  85272. * Gets the current list of limit velocity gradients.
  85273. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85274. * @returns the list of limit velocity gradients
  85275. */
  85276. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85277. /**
  85278. * Adds a new limit velocity gradient
  85279. * @param gradient defines the gradient to use (between 0 and 1)
  85280. * @param factor defines the limit velocity to affect to the specified gradient
  85281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85282. * @returns the current particle system
  85283. */
  85284. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85285. /**
  85286. * Remove a specific limit velocity gradient
  85287. * @param gradient defines the gradient to remove
  85288. * @returns the current particle system
  85289. */
  85290. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85291. /**
  85292. * Adds a new drag gradient
  85293. * @param gradient defines the gradient to use (between 0 and 1)
  85294. * @param factor defines the drag to affect to the specified gradient
  85295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85296. * @returns the current particle system
  85297. */
  85298. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85299. /**
  85300. * Remove a specific drag gradient
  85301. * @param gradient defines the gradient to remove
  85302. * @returns the current particle system
  85303. */
  85304. removeDragGradient(gradient: number): IParticleSystem;
  85305. /**
  85306. * Gets the current list of drag gradients.
  85307. * You must use addDragGradient and removeDragGradient to udpate this list
  85308. * @returns the list of drag gradients
  85309. */
  85310. getDragGradients(): Nullable<Array<FactorGradient>>;
  85311. /**
  85312. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85313. * @param gradient defines the gradient to use (between 0 and 1)
  85314. * @param factor defines the emit rate to affect to the specified gradient
  85315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85316. * @returns the current particle system
  85317. */
  85318. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85319. /**
  85320. * Remove a specific emit rate gradient
  85321. * @param gradient defines the gradient to remove
  85322. * @returns the current particle system
  85323. */
  85324. removeEmitRateGradient(gradient: number): IParticleSystem;
  85325. /**
  85326. * Gets the current list of emit rate gradients.
  85327. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85328. * @returns the list of emit rate gradients
  85329. */
  85330. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85331. /**
  85332. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85333. * @param gradient defines the gradient to use (between 0 and 1)
  85334. * @param factor defines the start size to affect to the specified gradient
  85335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85336. * @returns the current particle system
  85337. */
  85338. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85339. /**
  85340. * Remove a specific start size gradient
  85341. * @param gradient defines the gradient to remove
  85342. * @returns the current particle system
  85343. */
  85344. removeStartSizeGradient(gradient: number): IParticleSystem;
  85345. /**
  85346. * Gets the current list of start size gradients.
  85347. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85348. * @returns the list of start size gradients
  85349. */
  85350. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85351. /**
  85352. * Adds a new life time gradient
  85353. * @param gradient defines the gradient to use (between 0 and 1)
  85354. * @param factor defines the life time factor to affect to the specified gradient
  85355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85356. * @returns the current particle system
  85357. */
  85358. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85359. /**
  85360. * Remove a specific life time gradient
  85361. * @param gradient defines the gradient to remove
  85362. * @returns the current particle system
  85363. */
  85364. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85365. /**
  85366. * Gets the current list of life time gradients.
  85367. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85368. * @returns the list of life time gradients
  85369. */
  85370. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85371. /**
  85372. * Gets the current list of color gradients.
  85373. * You must use addColorGradient and removeColorGradient to udpate this list
  85374. * @returns the list of color gradients
  85375. */
  85376. getColorGradients(): Nullable<Array<ColorGradient>>;
  85377. /**
  85378. * Adds a new ramp gradient used to remap particle colors
  85379. * @param gradient defines the gradient to use (between 0 and 1)
  85380. * @param color defines the color to affect to the specified gradient
  85381. * @returns the current particle system
  85382. */
  85383. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85384. /**
  85385. * Gets the current list of ramp gradients.
  85386. * You must use addRampGradient and removeRampGradient to udpate this list
  85387. * @returns the list of ramp gradients
  85388. */
  85389. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85390. /** Gets or sets a boolean indicating that ramp gradients must be used
  85391. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85392. */
  85393. useRampGradients: boolean;
  85394. /**
  85395. * Adds a new color remap gradient
  85396. * @param gradient defines the gradient to use (between 0 and 1)
  85397. * @param min defines the color remap minimal range
  85398. * @param max defines the color remap maximal range
  85399. * @returns the current particle system
  85400. */
  85401. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85402. /**
  85403. * Gets the current list of color remap gradients.
  85404. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85405. * @returns the list of color remap gradients
  85406. */
  85407. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85408. /**
  85409. * Adds a new alpha remap gradient
  85410. * @param gradient defines the gradient to use (between 0 and 1)
  85411. * @param min defines the alpha remap minimal range
  85412. * @param max defines the alpha remap maximal range
  85413. * @returns the current particle system
  85414. */
  85415. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85416. /**
  85417. * Gets the current list of alpha remap gradients.
  85418. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85419. * @returns the list of alpha remap gradients
  85420. */
  85421. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85422. /**
  85423. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85424. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85425. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85426. * @returns the emitter
  85427. */
  85428. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85429. /**
  85430. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85431. * @param radius The radius of the hemisphere to emit from
  85432. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85433. * @returns the emitter
  85434. */
  85435. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85436. /**
  85437. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85438. * @param radius The radius of the sphere to emit from
  85439. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85440. * @returns the emitter
  85441. */
  85442. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85443. /**
  85444. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85445. * @param radius The radius of the sphere to emit from
  85446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85448. * @returns the emitter
  85449. */
  85450. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85451. /**
  85452. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85453. * @param radius The radius of the emission cylinder
  85454. * @param height The height of the emission cylinder
  85455. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85456. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85457. * @returns the emitter
  85458. */
  85459. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85460. /**
  85461. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85462. * @param radius The radius of the cylinder to emit from
  85463. * @param height The height of the emission cylinder
  85464. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85467. * @returns the emitter
  85468. */
  85469. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85470. /**
  85471. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85472. * @param radius The radius of the cone to emit from
  85473. * @param angle The base angle of the cone
  85474. * @returns the emitter
  85475. */
  85476. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85477. /**
  85478. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85481. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85482. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85483. * @returns the emitter
  85484. */
  85485. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85486. /**
  85487. * Get hosting scene
  85488. * @returns the scene
  85489. */
  85490. getScene(): Scene;
  85491. }
  85492. }
  85493. declare module BABYLON {
  85494. /**
  85495. * Creates an instance based on a source mesh.
  85496. */
  85497. export class InstancedMesh extends AbstractMesh {
  85498. private _sourceMesh;
  85499. private _currentLOD;
  85500. /** @hidden */
  85501. _indexInSourceMeshInstanceArray: number;
  85502. constructor(name: string, source: Mesh);
  85503. /**
  85504. * Returns the string "InstancedMesh".
  85505. */
  85506. getClassName(): string;
  85507. /** Gets the list of lights affecting that mesh */
  85508. readonly lightSources: Light[];
  85509. _resyncLightSources(): void;
  85510. _resyncLighSource(light: Light): void;
  85511. _removeLightSource(light: Light, dispose: boolean): void;
  85512. /**
  85513. * If the source mesh receives shadows
  85514. */
  85515. readonly receiveShadows: boolean;
  85516. /**
  85517. * The material of the source mesh
  85518. */
  85519. readonly material: Nullable<Material>;
  85520. /**
  85521. * Visibility of the source mesh
  85522. */
  85523. readonly visibility: number;
  85524. /**
  85525. * Skeleton of the source mesh
  85526. */
  85527. readonly skeleton: Nullable<Skeleton>;
  85528. /**
  85529. * Rendering ground id of the source mesh
  85530. */
  85531. renderingGroupId: number;
  85532. /**
  85533. * Returns the total number of vertices (integer).
  85534. */
  85535. getTotalVertices(): number;
  85536. /**
  85537. * Returns a positive integer : the total number of indices in this mesh geometry.
  85538. * @returns the numner of indices or zero if the mesh has no geometry.
  85539. */
  85540. getTotalIndices(): number;
  85541. /**
  85542. * The source mesh of the instance
  85543. */
  85544. readonly sourceMesh: Mesh;
  85545. /**
  85546. * Is this node ready to be used/rendered
  85547. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85548. * @return {boolean} is it ready
  85549. */
  85550. isReady(completeCheck?: boolean): boolean;
  85551. /**
  85552. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85553. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85554. * @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.
  85555. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85556. */
  85557. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85558. /**
  85559. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85560. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85561. * The `data` are either a numeric array either a Float32Array.
  85562. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85563. * 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).
  85564. * Note that a new underlying VertexBuffer object is created each call.
  85565. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85566. *
  85567. * Possible `kind` values :
  85568. * - VertexBuffer.PositionKind
  85569. * - VertexBuffer.UVKind
  85570. * - VertexBuffer.UV2Kind
  85571. * - VertexBuffer.UV3Kind
  85572. * - VertexBuffer.UV4Kind
  85573. * - VertexBuffer.UV5Kind
  85574. * - VertexBuffer.UV6Kind
  85575. * - VertexBuffer.ColorKind
  85576. * - VertexBuffer.MatricesIndicesKind
  85577. * - VertexBuffer.MatricesIndicesExtraKind
  85578. * - VertexBuffer.MatricesWeightsKind
  85579. * - VertexBuffer.MatricesWeightsExtraKind
  85580. *
  85581. * Returns the Mesh.
  85582. */
  85583. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85584. /**
  85585. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85586. * If the mesh has no geometry, it is simply returned as it is.
  85587. * The `data` are either a numeric array either a Float32Array.
  85588. * No new underlying VertexBuffer object is created.
  85589. * 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.
  85590. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85591. *
  85592. * Possible `kind` values :
  85593. * - VertexBuffer.PositionKind
  85594. * - VertexBuffer.UVKind
  85595. * - VertexBuffer.UV2Kind
  85596. * - VertexBuffer.UV3Kind
  85597. * - VertexBuffer.UV4Kind
  85598. * - VertexBuffer.UV5Kind
  85599. * - VertexBuffer.UV6Kind
  85600. * - VertexBuffer.ColorKind
  85601. * - VertexBuffer.MatricesIndicesKind
  85602. * - VertexBuffer.MatricesIndicesExtraKind
  85603. * - VertexBuffer.MatricesWeightsKind
  85604. * - VertexBuffer.MatricesWeightsExtraKind
  85605. *
  85606. * Returns the Mesh.
  85607. */
  85608. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85609. /**
  85610. * Sets the mesh indices.
  85611. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85612. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85613. * This method creates a new index buffer each call.
  85614. * Returns the Mesh.
  85615. */
  85616. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85617. /**
  85618. * Boolean : True if the mesh owns the requested kind of data.
  85619. */
  85620. isVerticesDataPresent(kind: string): boolean;
  85621. /**
  85622. * Returns an array of indices (IndicesArray).
  85623. */
  85624. getIndices(): Nullable<IndicesArray>;
  85625. readonly _positions: Nullable<Vector3[]>;
  85626. /**
  85627. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85628. * This means the mesh underlying bounding box and sphere are recomputed.
  85629. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85630. * @returns the current mesh
  85631. */
  85632. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85633. /** @hidden */
  85634. _preActivate(): InstancedMesh;
  85635. /** @hidden */
  85636. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85637. /** @hidden */
  85638. _postActivate(): void;
  85639. getWorldMatrix(): Matrix;
  85640. readonly isAnInstance: boolean;
  85641. /**
  85642. * Returns the current associated LOD AbstractMesh.
  85643. */
  85644. getLOD(camera: Camera): AbstractMesh;
  85645. /** @hidden */
  85646. _syncSubMeshes(): InstancedMesh;
  85647. /** @hidden */
  85648. _generatePointsArray(): boolean;
  85649. /**
  85650. * Creates a new InstancedMesh from the current mesh.
  85651. * - name (string) : the cloned mesh name
  85652. * - newParent (optional Node) : the optional Node to parent the clone to.
  85653. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85654. *
  85655. * Returns the clone.
  85656. */
  85657. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85658. /**
  85659. * Disposes the InstancedMesh.
  85660. * Returns nothing.
  85661. */
  85662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85663. }
  85664. }
  85665. declare module BABYLON {
  85666. /**
  85667. * Defines the options associated with the creation of a shader material.
  85668. */
  85669. export interface IShaderMaterialOptions {
  85670. /**
  85671. * Does the material work in alpha blend mode
  85672. */
  85673. needAlphaBlending: boolean;
  85674. /**
  85675. * Does the material work in alpha test mode
  85676. */
  85677. needAlphaTesting: boolean;
  85678. /**
  85679. * The list of attribute names used in the shader
  85680. */
  85681. attributes: string[];
  85682. /**
  85683. * The list of unifrom names used in the shader
  85684. */
  85685. uniforms: string[];
  85686. /**
  85687. * The list of UBO names used in the shader
  85688. */
  85689. uniformBuffers: string[];
  85690. /**
  85691. * The list of sampler names used in the shader
  85692. */
  85693. samplers: string[];
  85694. /**
  85695. * The list of defines used in the shader
  85696. */
  85697. defines: string[];
  85698. }
  85699. /**
  85700. * 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.
  85701. *
  85702. * This returned material effects how the mesh will look based on the code in the shaders.
  85703. *
  85704. * @see http://doc.babylonjs.com/how_to/shader_material
  85705. */
  85706. export class ShaderMaterial extends Material {
  85707. private _shaderPath;
  85708. private _options;
  85709. private _textures;
  85710. private _textureArrays;
  85711. private _floats;
  85712. private _ints;
  85713. private _floatsArrays;
  85714. private _colors3;
  85715. private _colors3Arrays;
  85716. private _colors4;
  85717. private _colors4Arrays;
  85718. private _vectors2;
  85719. private _vectors3;
  85720. private _vectors4;
  85721. private _matrices;
  85722. private _matrices3x3;
  85723. private _matrices2x2;
  85724. private _vectors2Arrays;
  85725. private _vectors3Arrays;
  85726. private _vectors4Arrays;
  85727. private _cachedWorldViewMatrix;
  85728. private _cachedWorldViewProjectionMatrix;
  85729. private _renderId;
  85730. /**
  85731. * Instantiate a new shader material.
  85732. * 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.
  85733. * This returned material effects how the mesh will look based on the code in the shaders.
  85734. * @see http://doc.babylonjs.com/how_to/shader_material
  85735. * @param name Define the name of the material in the scene
  85736. * @param scene Define the scene the material belongs to
  85737. * @param shaderPath Defines the route to the shader code in one of three ways:
  85738. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85739. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85740. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85741. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85742. * @param options Define the options used to create the shader
  85743. */
  85744. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85745. /**
  85746. * Gets the options used to compile the shader.
  85747. * They can be modified to trigger a new compilation
  85748. */
  85749. readonly options: IShaderMaterialOptions;
  85750. /**
  85751. * Gets the current class name of the material e.g. "ShaderMaterial"
  85752. * Mainly use in serialization.
  85753. * @returns the class name
  85754. */
  85755. getClassName(): string;
  85756. /**
  85757. * Specifies if the material will require alpha blending
  85758. * @returns a boolean specifying if alpha blending is needed
  85759. */
  85760. needAlphaBlending(): boolean;
  85761. /**
  85762. * Specifies if this material should be rendered in alpha test mode
  85763. * @returns a boolean specifying if an alpha test is needed.
  85764. */
  85765. needAlphaTesting(): boolean;
  85766. private _checkUniform;
  85767. /**
  85768. * Set a texture in the shader.
  85769. * @param name Define the name of the uniform samplers as defined in the shader
  85770. * @param texture Define the texture to bind to this sampler
  85771. * @return the material itself allowing "fluent" like uniform updates
  85772. */
  85773. setTexture(name: string, texture: Texture): ShaderMaterial;
  85774. /**
  85775. * Set a texture array in the shader.
  85776. * @param name Define the name of the uniform sampler array as defined in the shader
  85777. * @param textures Define the list of textures to bind to this sampler
  85778. * @return the material itself allowing "fluent" like uniform updates
  85779. */
  85780. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85781. /**
  85782. * Set a float in the shader.
  85783. * @param name Define the name of the uniform as defined in the shader
  85784. * @param value Define the value to give to the uniform
  85785. * @return the material itself allowing "fluent" like uniform updates
  85786. */
  85787. setFloat(name: string, value: number): ShaderMaterial;
  85788. /**
  85789. * Set a int in the shader.
  85790. * @param name Define the name of the uniform as defined in the shader
  85791. * @param value Define the value to give to the uniform
  85792. * @return the material itself allowing "fluent" like uniform updates
  85793. */
  85794. setInt(name: string, value: number): ShaderMaterial;
  85795. /**
  85796. * Set an array of floats in the shader.
  85797. * @param name Define the name of the uniform as defined in the shader
  85798. * @param value Define the value to give to the uniform
  85799. * @return the material itself allowing "fluent" like uniform updates
  85800. */
  85801. setFloats(name: string, value: number[]): ShaderMaterial;
  85802. /**
  85803. * Set a vec3 in the shader from a Color3.
  85804. * @param name Define the name of the uniform as defined in the shader
  85805. * @param value Define the value to give to the uniform
  85806. * @return the material itself allowing "fluent" like uniform updates
  85807. */
  85808. setColor3(name: string, value: Color3): ShaderMaterial;
  85809. /**
  85810. * Set a vec3 array in the shader from a Color3 array.
  85811. * @param name Define the name of the uniform as defined in the shader
  85812. * @param value Define the value to give to the uniform
  85813. * @return the material itself allowing "fluent" like uniform updates
  85814. */
  85815. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85816. /**
  85817. * Set a vec4 in the shader from a Color4.
  85818. * @param name Define the name of the uniform as defined in the shader
  85819. * @param value Define the value to give to the uniform
  85820. * @return the material itself allowing "fluent" like uniform updates
  85821. */
  85822. setColor4(name: string, value: Color4): ShaderMaterial;
  85823. /**
  85824. * Set a vec4 array in the shader from a Color4 array.
  85825. * @param name Define the name of the uniform as defined in the shader
  85826. * @param value Define the value to give to the uniform
  85827. * @return the material itself allowing "fluent" like uniform updates
  85828. */
  85829. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85830. /**
  85831. * Set a vec2 in the shader from a Vector2.
  85832. * @param name Define the name of the uniform as defined in the shader
  85833. * @param value Define the value to give to the uniform
  85834. * @return the material itself allowing "fluent" like uniform updates
  85835. */
  85836. setVector2(name: string, value: Vector2): ShaderMaterial;
  85837. /**
  85838. * Set a vec3 in the shader from a Vector3.
  85839. * @param name Define the name of the uniform as defined in the shader
  85840. * @param value Define the value to give to the uniform
  85841. * @return the material itself allowing "fluent" like uniform updates
  85842. */
  85843. setVector3(name: string, value: Vector3): ShaderMaterial;
  85844. /**
  85845. * Set a vec4 in the shader from a Vector4.
  85846. * @param name Define the name of the uniform as defined in the shader
  85847. * @param value Define the value to give to the uniform
  85848. * @return the material itself allowing "fluent" like uniform updates
  85849. */
  85850. setVector4(name: string, value: Vector4): ShaderMaterial;
  85851. /**
  85852. * Set a mat4 in the shader from a Matrix.
  85853. * @param name Define the name of the uniform as defined in the shader
  85854. * @param value Define the value to give to the uniform
  85855. * @return the material itself allowing "fluent" like uniform updates
  85856. */
  85857. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85858. /**
  85859. * Set a mat3 in the shader from a Float32Array.
  85860. * @param name Define the name of the uniform as defined in the shader
  85861. * @param value Define the value to give to the uniform
  85862. * @return the material itself allowing "fluent" like uniform updates
  85863. */
  85864. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85865. /**
  85866. * Set a mat2 in the shader from a Float32Array.
  85867. * @param name Define the name of the uniform as defined in the shader
  85868. * @param value Define the value to give to the uniform
  85869. * @return the material itself allowing "fluent" like uniform updates
  85870. */
  85871. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85872. /**
  85873. * Set a vec2 array in the shader from a number array.
  85874. * @param name Define the name of the uniform as defined in the shader
  85875. * @param value Define the value to give to the uniform
  85876. * @return the material itself allowing "fluent" like uniform updates
  85877. */
  85878. setArray2(name: string, value: number[]): ShaderMaterial;
  85879. /**
  85880. * Set a vec3 array in the shader from a number array.
  85881. * @param name Define the name of the uniform as defined in the shader
  85882. * @param value Define the value to give to the uniform
  85883. * @return the material itself allowing "fluent" like uniform updates
  85884. */
  85885. setArray3(name: string, value: number[]): ShaderMaterial;
  85886. /**
  85887. * Set a vec4 array in the shader from a number array.
  85888. * @param name Define the name of the uniform as defined in the shader
  85889. * @param value Define the value to give to the uniform
  85890. * @return the material itself allowing "fluent" like uniform updates
  85891. */
  85892. setArray4(name: string, value: number[]): ShaderMaterial;
  85893. private _checkCache;
  85894. /**
  85895. * Specifies that the submesh is ready to be used
  85896. * @param mesh defines the mesh to check
  85897. * @param subMesh defines which submesh to check
  85898. * @param useInstances specifies that instances should be used
  85899. * @returns a boolean indicating that the submesh is ready or not
  85900. */
  85901. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85902. /**
  85903. * Checks if the material is ready to render the requested mesh
  85904. * @param mesh Define the mesh to render
  85905. * @param useInstances Define whether or not the material is used with instances
  85906. * @returns true if ready, otherwise false
  85907. */
  85908. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85909. /**
  85910. * Binds the world matrix to the material
  85911. * @param world defines the world transformation matrix
  85912. */
  85913. bindOnlyWorldMatrix(world: Matrix): void;
  85914. /**
  85915. * Binds the material to the mesh
  85916. * @param world defines the world transformation matrix
  85917. * @param mesh defines the mesh to bind the material to
  85918. */
  85919. bind(world: Matrix, mesh?: Mesh): void;
  85920. /**
  85921. * Gets the active textures from the material
  85922. * @returns an array of textures
  85923. */
  85924. getActiveTextures(): BaseTexture[];
  85925. /**
  85926. * Specifies if the material uses a texture
  85927. * @param texture defines the texture to check against the material
  85928. * @returns a boolean specifying if the material uses the texture
  85929. */
  85930. hasTexture(texture: BaseTexture): boolean;
  85931. /**
  85932. * Makes a duplicate of the material, and gives it a new name
  85933. * @param name defines the new name for the duplicated material
  85934. * @returns the cloned material
  85935. */
  85936. clone(name: string): ShaderMaterial;
  85937. /**
  85938. * Disposes the material
  85939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85941. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85942. */
  85943. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85944. /**
  85945. * Serializes this material in a JSON representation
  85946. * @returns the serialized material object
  85947. */
  85948. serialize(): any;
  85949. /**
  85950. * Creates a shader material from parsed shader material data
  85951. * @param source defines the JSON represnetation of the material
  85952. * @param scene defines the hosting scene
  85953. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85954. * @returns a new material
  85955. */
  85956. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85957. }
  85958. }
  85959. declare module BABYLON {
  85960. /** @hidden */
  85961. export var colorPixelShader: {
  85962. name: string;
  85963. shader: string;
  85964. };
  85965. }
  85966. declare module BABYLON {
  85967. /** @hidden */
  85968. export var colorVertexShader: {
  85969. name: string;
  85970. shader: string;
  85971. };
  85972. }
  85973. declare module BABYLON {
  85974. /**
  85975. * Line mesh
  85976. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85977. */
  85978. export class LinesMesh extends Mesh {
  85979. /**
  85980. * If vertex color should be applied to the mesh
  85981. */
  85982. readonly useVertexColor?: boolean | undefined;
  85983. /**
  85984. * If vertex alpha should be applied to the mesh
  85985. */
  85986. readonly useVertexAlpha?: boolean | undefined;
  85987. /**
  85988. * Color of the line (Default: White)
  85989. */
  85990. color: Color3;
  85991. /**
  85992. * Alpha of the line (Default: 1)
  85993. */
  85994. alpha: number;
  85995. /**
  85996. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85997. * This margin is expressed in world space coordinates, so its value may vary.
  85998. * Default value is 0.1
  85999. */
  86000. intersectionThreshold: number;
  86001. private _colorShader;
  86002. private color4;
  86003. /**
  86004. * Creates a new LinesMesh
  86005. * @param name defines the name
  86006. * @param scene defines the hosting scene
  86007. * @param parent defines the parent mesh if any
  86008. * @param source defines the optional source LinesMesh used to clone data from
  86009. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86010. * When false, achieved by calling a clone(), also passing False.
  86011. * This will make creation of children, recursive.
  86012. * @param useVertexColor defines if this LinesMesh supports vertex color
  86013. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86014. */
  86015. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86016. /**
  86017. * If vertex color should be applied to the mesh
  86018. */
  86019. useVertexColor?: boolean | undefined,
  86020. /**
  86021. * If vertex alpha should be applied to the mesh
  86022. */
  86023. useVertexAlpha?: boolean | undefined);
  86024. private _addClipPlaneDefine;
  86025. private _removeClipPlaneDefine;
  86026. isReady(): boolean;
  86027. /**
  86028. * Returns the string "LineMesh"
  86029. */
  86030. getClassName(): string;
  86031. /**
  86032. * @hidden
  86033. */
  86034. /**
  86035. * @hidden
  86036. */
  86037. material: Material;
  86038. /**
  86039. * @hidden
  86040. */
  86041. readonly checkCollisions: boolean;
  86042. /** @hidden */
  86043. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86044. /** @hidden */
  86045. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86046. /**
  86047. * Disposes of the line mesh
  86048. * @param doNotRecurse If children should be disposed
  86049. */
  86050. dispose(doNotRecurse?: boolean): void;
  86051. /**
  86052. * Returns a new LineMesh object cloned from the current one.
  86053. */
  86054. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86055. /**
  86056. * Creates a new InstancedLinesMesh object from the mesh model.
  86057. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86058. * @param name defines the name of the new instance
  86059. * @returns a new InstancedLinesMesh
  86060. */
  86061. createInstance(name: string): InstancedLinesMesh;
  86062. }
  86063. /**
  86064. * Creates an instance based on a source LinesMesh
  86065. */
  86066. export class InstancedLinesMesh extends InstancedMesh {
  86067. /**
  86068. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86069. * This margin is expressed in world space coordinates, so its value may vary.
  86070. * Initilized with the intersectionThreshold value of the source LinesMesh
  86071. */
  86072. intersectionThreshold: number;
  86073. constructor(name: string, source: LinesMesh);
  86074. /**
  86075. * Returns the string "InstancedLinesMesh".
  86076. */
  86077. getClassName(): string;
  86078. }
  86079. }
  86080. declare module BABYLON {
  86081. /** @hidden */
  86082. export var linePixelShader: {
  86083. name: string;
  86084. shader: string;
  86085. };
  86086. }
  86087. declare module BABYLON {
  86088. /** @hidden */
  86089. export var lineVertexShader: {
  86090. name: string;
  86091. shader: string;
  86092. };
  86093. }
  86094. declare module BABYLON {
  86095. interface AbstractMesh {
  86096. /**
  86097. * Gets the edgesRenderer associated with the mesh
  86098. */
  86099. edgesRenderer: Nullable<EdgesRenderer>;
  86100. }
  86101. interface LinesMesh {
  86102. /**
  86103. * Enables the edge rendering mode on the mesh.
  86104. * This mode makes the mesh edges visible
  86105. * @param epsilon defines the maximal distance between two angles to detect a face
  86106. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86107. * @returns the currentAbstractMesh
  86108. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86109. */
  86110. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86111. }
  86112. interface InstancedLinesMesh {
  86113. /**
  86114. * Enables the edge rendering mode on the mesh.
  86115. * This mode makes the mesh edges visible
  86116. * @param epsilon defines the maximal distance between two angles to detect a face
  86117. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86118. * @returns the current InstancedLinesMesh
  86119. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86120. */
  86121. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86122. }
  86123. /**
  86124. * Defines the minimum contract an Edges renderer should follow.
  86125. */
  86126. export interface IEdgesRenderer extends IDisposable {
  86127. /**
  86128. * Gets or sets a boolean indicating if the edgesRenderer is active
  86129. */
  86130. isEnabled: boolean;
  86131. /**
  86132. * Renders the edges of the attached mesh,
  86133. */
  86134. render(): void;
  86135. /**
  86136. * Checks wether or not the edges renderer is ready to render.
  86137. * @return true if ready, otherwise false.
  86138. */
  86139. isReady(): boolean;
  86140. }
  86141. /**
  86142. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86143. */
  86144. export class EdgesRenderer implements IEdgesRenderer {
  86145. /**
  86146. * Define the size of the edges with an orthographic camera
  86147. */
  86148. edgesWidthScalerForOrthographic: number;
  86149. /**
  86150. * Define the size of the edges with a perspective camera
  86151. */
  86152. edgesWidthScalerForPerspective: number;
  86153. protected _source: AbstractMesh;
  86154. protected _linesPositions: number[];
  86155. protected _linesNormals: number[];
  86156. protected _linesIndices: number[];
  86157. protected _epsilon: number;
  86158. protected _indicesCount: number;
  86159. protected _lineShader: ShaderMaterial;
  86160. protected _ib: DataBuffer;
  86161. protected _buffers: {
  86162. [key: string]: Nullable<VertexBuffer>;
  86163. };
  86164. protected _checkVerticesInsteadOfIndices: boolean;
  86165. private _meshRebuildObserver;
  86166. private _meshDisposeObserver;
  86167. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86168. isEnabled: boolean;
  86169. /**
  86170. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86171. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86172. * @param source Mesh used to create edges
  86173. * @param epsilon sum of angles in adjacency to check for edge
  86174. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86175. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86176. */
  86177. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86178. protected _prepareRessources(): void;
  86179. /** @hidden */
  86180. _rebuild(): void;
  86181. /**
  86182. * Releases the required resources for the edges renderer
  86183. */
  86184. dispose(): void;
  86185. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86186. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86187. /**
  86188. * Checks if the pair of p0 and p1 is en edge
  86189. * @param faceIndex
  86190. * @param edge
  86191. * @param faceNormals
  86192. * @param p0
  86193. * @param p1
  86194. * @private
  86195. */
  86196. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86197. /**
  86198. * push line into the position, normal and index buffer
  86199. * @protected
  86200. */
  86201. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86202. /**
  86203. * Generates lines edges from adjacencjes
  86204. * @private
  86205. */
  86206. _generateEdgesLines(): void;
  86207. /**
  86208. * Checks wether or not the edges renderer is ready to render.
  86209. * @return true if ready, otherwise false.
  86210. */
  86211. isReady(): boolean;
  86212. /**
  86213. * Renders the edges of the attached mesh,
  86214. */
  86215. render(): void;
  86216. }
  86217. /**
  86218. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86219. */
  86220. export class LineEdgesRenderer extends EdgesRenderer {
  86221. /**
  86222. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86223. * @param source LineMesh used to generate edges
  86224. * @param epsilon not important (specified angle for edge detection)
  86225. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86226. */
  86227. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86228. /**
  86229. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86230. */
  86231. _generateEdgesLines(): void;
  86232. }
  86233. }
  86234. declare module BABYLON {
  86235. /**
  86236. * This represents the object necessary to create a rendering group.
  86237. * This is exclusively used and created by the rendering manager.
  86238. * To modify the behavior, you use the available helpers in your scene or meshes.
  86239. * @hidden
  86240. */
  86241. export class RenderingGroup {
  86242. index: number;
  86243. private static _zeroVector;
  86244. private _scene;
  86245. private _opaqueSubMeshes;
  86246. private _transparentSubMeshes;
  86247. private _alphaTestSubMeshes;
  86248. private _depthOnlySubMeshes;
  86249. private _particleSystems;
  86250. private _spriteManagers;
  86251. private _opaqueSortCompareFn;
  86252. private _alphaTestSortCompareFn;
  86253. private _transparentSortCompareFn;
  86254. private _renderOpaque;
  86255. private _renderAlphaTest;
  86256. private _renderTransparent;
  86257. /** @hidden */
  86258. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86259. onBeforeTransparentRendering: () => void;
  86260. /**
  86261. * Set the opaque sort comparison function.
  86262. * If null the sub meshes will be render in the order they were created
  86263. */
  86264. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86265. /**
  86266. * Set the alpha test sort comparison function.
  86267. * If null the sub meshes will be render in the order they were created
  86268. */
  86269. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86270. /**
  86271. * Set the transparent sort comparison function.
  86272. * If null the sub meshes will be render in the order they were created
  86273. */
  86274. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86275. /**
  86276. * Creates a new rendering group.
  86277. * @param index The rendering group index
  86278. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86279. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86280. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86281. */
  86282. 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>);
  86283. /**
  86284. * Render all the sub meshes contained in the group.
  86285. * @param customRenderFunction Used to override the default render behaviour of the group.
  86286. * @returns true if rendered some submeshes.
  86287. */
  86288. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86289. /**
  86290. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86291. * @param subMeshes The submeshes to render
  86292. */
  86293. private renderOpaqueSorted;
  86294. /**
  86295. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86296. * @param subMeshes The submeshes to render
  86297. */
  86298. private renderAlphaTestSorted;
  86299. /**
  86300. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86301. * @param subMeshes The submeshes to render
  86302. */
  86303. private renderTransparentSorted;
  86304. /**
  86305. * Renders the submeshes in a specified order.
  86306. * @param subMeshes The submeshes to sort before render
  86307. * @param sortCompareFn The comparison function use to sort
  86308. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86309. * @param transparent Specifies to activate blending if true
  86310. */
  86311. private static renderSorted;
  86312. /**
  86313. * Renders the submeshes in the order they were dispatched (no sort applied).
  86314. * @param subMeshes The submeshes to render
  86315. */
  86316. private static renderUnsorted;
  86317. /**
  86318. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86319. * are rendered back to front if in the same alpha index.
  86320. *
  86321. * @param a The first submesh
  86322. * @param b The second submesh
  86323. * @returns The result of the comparison
  86324. */
  86325. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86326. /**
  86327. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86328. * are rendered back to front.
  86329. *
  86330. * @param a The first submesh
  86331. * @param b The second submesh
  86332. * @returns The result of the comparison
  86333. */
  86334. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86335. /**
  86336. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86337. * are rendered front to back (prevent overdraw).
  86338. *
  86339. * @param a The first submesh
  86340. * @param b The second submesh
  86341. * @returns The result of the comparison
  86342. */
  86343. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86344. /**
  86345. * Resets the different lists of submeshes to prepare a new frame.
  86346. */
  86347. prepare(): void;
  86348. dispose(): void;
  86349. /**
  86350. * Inserts the submesh in its correct queue depending on its material.
  86351. * @param subMesh The submesh to dispatch
  86352. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86353. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86354. */
  86355. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86356. dispatchSprites(spriteManager: ISpriteManager): void;
  86357. dispatchParticles(particleSystem: IParticleSystem): void;
  86358. private _renderParticles;
  86359. private _renderSprites;
  86360. }
  86361. }
  86362. declare module BABYLON {
  86363. /**
  86364. * Interface describing the different options available in the rendering manager
  86365. * regarding Auto Clear between groups.
  86366. */
  86367. export interface IRenderingManagerAutoClearSetup {
  86368. /**
  86369. * Defines whether or not autoclear is enable.
  86370. */
  86371. autoClear: boolean;
  86372. /**
  86373. * Defines whether or not to autoclear the depth buffer.
  86374. */
  86375. depth: boolean;
  86376. /**
  86377. * Defines whether or not to autoclear the stencil buffer.
  86378. */
  86379. stencil: boolean;
  86380. }
  86381. /**
  86382. * This class is used by the onRenderingGroupObservable
  86383. */
  86384. export class RenderingGroupInfo {
  86385. /**
  86386. * The Scene that being rendered
  86387. */
  86388. scene: Scene;
  86389. /**
  86390. * The camera currently used for the rendering pass
  86391. */
  86392. camera: Nullable<Camera>;
  86393. /**
  86394. * The ID of the renderingGroup being processed
  86395. */
  86396. renderingGroupId: number;
  86397. }
  86398. /**
  86399. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86400. * It is enable to manage the different groups as well as the different necessary sort functions.
  86401. * This should not be used directly aside of the few static configurations
  86402. */
  86403. export class RenderingManager {
  86404. /**
  86405. * The max id used for rendering groups (not included)
  86406. */
  86407. static MAX_RENDERINGGROUPS: number;
  86408. /**
  86409. * The min id used for rendering groups (included)
  86410. */
  86411. static MIN_RENDERINGGROUPS: number;
  86412. /**
  86413. * Used to globally prevent autoclearing scenes.
  86414. */
  86415. static AUTOCLEAR: boolean;
  86416. /**
  86417. * @hidden
  86418. */
  86419. _useSceneAutoClearSetup: boolean;
  86420. private _scene;
  86421. private _renderingGroups;
  86422. private _depthStencilBufferAlreadyCleaned;
  86423. private _autoClearDepthStencil;
  86424. private _customOpaqueSortCompareFn;
  86425. private _customAlphaTestSortCompareFn;
  86426. private _customTransparentSortCompareFn;
  86427. private _renderingGroupInfo;
  86428. /**
  86429. * Instantiates a new rendering group for a particular scene
  86430. * @param scene Defines the scene the groups belongs to
  86431. */
  86432. constructor(scene: Scene);
  86433. private _clearDepthStencilBuffer;
  86434. /**
  86435. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86436. * @hidden
  86437. */
  86438. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86439. /**
  86440. * Resets the different information of the group to prepare a new frame
  86441. * @hidden
  86442. */
  86443. reset(): void;
  86444. /**
  86445. * Dispose and release the group and its associated resources.
  86446. * @hidden
  86447. */
  86448. dispose(): void;
  86449. /**
  86450. * Clear the info related to rendering groups preventing retention points during dispose.
  86451. */
  86452. freeRenderingGroups(): void;
  86453. private _prepareRenderingGroup;
  86454. /**
  86455. * Add a sprite manager to the rendering manager in order to render it this frame.
  86456. * @param spriteManager Define the sprite manager to render
  86457. */
  86458. dispatchSprites(spriteManager: ISpriteManager): void;
  86459. /**
  86460. * Add a particle system to the rendering manager in order to render it this frame.
  86461. * @param particleSystem Define the particle system to render
  86462. */
  86463. dispatchParticles(particleSystem: IParticleSystem): void;
  86464. /**
  86465. * Add a submesh to the manager in order to render it this frame
  86466. * @param subMesh The submesh to dispatch
  86467. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86468. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86469. */
  86470. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86471. /**
  86472. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86473. * This allowed control for front to back rendering or reversly depending of the special needs.
  86474. *
  86475. * @param renderingGroupId The rendering group id corresponding to its index
  86476. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86477. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86478. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86479. */
  86480. 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;
  86481. /**
  86482. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86483. *
  86484. * @param renderingGroupId The rendering group id corresponding to its index
  86485. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86486. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86487. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86488. */
  86489. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86490. /**
  86491. * Gets the current auto clear configuration for one rendering group of the rendering
  86492. * manager.
  86493. * @param index the rendering group index to get the information for
  86494. * @returns The auto clear setup for the requested rendering group
  86495. */
  86496. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86497. }
  86498. }
  86499. declare module BABYLON {
  86500. /**
  86501. * This Helps creating a texture that will be created from a camera in your scene.
  86502. * It is basically a dynamic texture that could be used to create special effects for instance.
  86503. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86504. */
  86505. export class RenderTargetTexture extends Texture {
  86506. isCube: boolean;
  86507. /**
  86508. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86509. */
  86510. static readonly REFRESHRATE_RENDER_ONCE: number;
  86511. /**
  86512. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86513. */
  86514. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86515. /**
  86516. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86517. * the central point of your effect and can save a lot of performances.
  86518. */
  86519. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86520. /**
  86521. * Use this predicate to dynamically define the list of mesh you want to render.
  86522. * If set, the renderList property will be overwritten.
  86523. */
  86524. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86525. private _renderList;
  86526. /**
  86527. * Use this list to define the list of mesh you want to render.
  86528. */
  86529. renderList: Nullable<Array<AbstractMesh>>;
  86530. private _hookArray;
  86531. /**
  86532. * Define if particles should be rendered in your texture.
  86533. */
  86534. renderParticles: boolean;
  86535. /**
  86536. * Define if sprites should be rendered in your texture.
  86537. */
  86538. renderSprites: boolean;
  86539. /**
  86540. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86541. */
  86542. coordinatesMode: number;
  86543. /**
  86544. * Define the camera used to render the texture.
  86545. */
  86546. activeCamera: Nullable<Camera>;
  86547. /**
  86548. * Override the render function of the texture with your own one.
  86549. */
  86550. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86551. /**
  86552. * Define if camera post processes should be use while rendering the texture.
  86553. */
  86554. useCameraPostProcesses: boolean;
  86555. /**
  86556. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86557. */
  86558. ignoreCameraViewport: boolean;
  86559. private _postProcessManager;
  86560. private _postProcesses;
  86561. private _resizeObserver;
  86562. /**
  86563. * An event triggered when the texture is unbind.
  86564. */
  86565. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86566. /**
  86567. * An event triggered when the texture is unbind.
  86568. */
  86569. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86570. private _onAfterUnbindObserver;
  86571. /**
  86572. * Set a after unbind callback in the texture.
  86573. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86574. */
  86575. onAfterUnbind: () => void;
  86576. /**
  86577. * An event triggered before rendering the texture
  86578. */
  86579. onBeforeRenderObservable: Observable<number>;
  86580. private _onBeforeRenderObserver;
  86581. /**
  86582. * Set a before render callback in the texture.
  86583. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86584. */
  86585. onBeforeRender: (faceIndex: number) => void;
  86586. /**
  86587. * An event triggered after rendering the texture
  86588. */
  86589. onAfterRenderObservable: Observable<number>;
  86590. private _onAfterRenderObserver;
  86591. /**
  86592. * Set a after render callback in the texture.
  86593. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86594. */
  86595. onAfterRender: (faceIndex: number) => void;
  86596. /**
  86597. * An event triggered after the texture clear
  86598. */
  86599. onClearObservable: Observable<Engine>;
  86600. private _onClearObserver;
  86601. /**
  86602. * Set a clear callback in the texture.
  86603. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86604. */
  86605. onClear: (Engine: Engine) => void;
  86606. /**
  86607. * An event triggered when the texture is resized.
  86608. */
  86609. onResizeObservable: Observable<RenderTargetTexture>;
  86610. /**
  86611. * Define the clear color of the Render Target if it should be different from the scene.
  86612. */
  86613. clearColor: Color4;
  86614. protected _size: number | {
  86615. width: number;
  86616. height: number;
  86617. };
  86618. protected _initialSizeParameter: number | {
  86619. width: number;
  86620. height: number;
  86621. } | {
  86622. ratio: number;
  86623. };
  86624. protected _sizeRatio: Nullable<number>;
  86625. /** @hidden */
  86626. _generateMipMaps: boolean;
  86627. protected _renderingManager: RenderingManager;
  86628. /** @hidden */
  86629. _waitingRenderList: string[];
  86630. protected _doNotChangeAspectRatio: boolean;
  86631. protected _currentRefreshId: number;
  86632. protected _refreshRate: number;
  86633. protected _textureMatrix: Matrix;
  86634. protected _samples: number;
  86635. protected _renderTargetOptions: RenderTargetCreationOptions;
  86636. /**
  86637. * Gets render target creation options that were used.
  86638. */
  86639. readonly renderTargetOptions: RenderTargetCreationOptions;
  86640. protected _engine: Engine;
  86641. protected _onRatioRescale(): void;
  86642. /**
  86643. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86644. * It must define where the camera used to render the texture is set
  86645. */
  86646. boundingBoxPosition: Vector3;
  86647. private _boundingBoxSize;
  86648. /**
  86649. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86650. * When defined, the cubemap will switch to local mode
  86651. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86652. * @example https://www.babylonjs-playground.com/#RNASML
  86653. */
  86654. boundingBoxSize: Vector3;
  86655. /**
  86656. * In case the RTT has been created with a depth texture, get the associated
  86657. * depth texture.
  86658. * Otherwise, return null.
  86659. */
  86660. depthStencilTexture: Nullable<InternalTexture>;
  86661. /**
  86662. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86663. * or used a shadow, depth texture...
  86664. * @param name The friendly name of the texture
  86665. * @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)
  86666. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86667. * @param generateMipMaps True if mip maps need to be generated after render.
  86668. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86669. * @param type The type of the buffer in the RTT (int, half float, float...)
  86670. * @param isCube True if a cube texture needs to be created
  86671. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86672. * @param generateDepthBuffer True to generate a depth buffer
  86673. * @param generateStencilBuffer True to generate a stencil buffer
  86674. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86675. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86676. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86677. */
  86678. constructor(name: string, size: number | {
  86679. width: number;
  86680. height: number;
  86681. } | {
  86682. ratio: number;
  86683. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86684. /**
  86685. * Creates a depth stencil texture.
  86686. * This is only available in WebGL 2 or with the depth texture extension available.
  86687. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86688. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86689. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86690. */
  86691. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86692. private _processSizeParameter;
  86693. /**
  86694. * Define the number of samples to use in case of MSAA.
  86695. * It defaults to one meaning no MSAA has been enabled.
  86696. */
  86697. samples: number;
  86698. /**
  86699. * Resets the refresh counter of the texture and start bak from scratch.
  86700. * Could be useful to regenerate the texture if it is setup to render only once.
  86701. */
  86702. resetRefreshCounter(): void;
  86703. /**
  86704. * Define the refresh rate of the texture or the rendering frequency.
  86705. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86706. */
  86707. refreshRate: number;
  86708. /**
  86709. * Adds a post process to the render target rendering passes.
  86710. * @param postProcess define the post process to add
  86711. */
  86712. addPostProcess(postProcess: PostProcess): void;
  86713. /**
  86714. * Clear all the post processes attached to the render target
  86715. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86716. */
  86717. clearPostProcesses(dispose?: boolean): void;
  86718. /**
  86719. * Remove one of the post process from the list of attached post processes to the texture
  86720. * @param postProcess define the post process to remove from the list
  86721. */
  86722. removePostProcess(postProcess: PostProcess): void;
  86723. /** @hidden */
  86724. _shouldRender(): boolean;
  86725. /**
  86726. * Gets the actual render size of the texture.
  86727. * @returns the width of the render size
  86728. */
  86729. getRenderSize(): number;
  86730. /**
  86731. * Gets the actual render width of the texture.
  86732. * @returns the width of the render size
  86733. */
  86734. getRenderWidth(): number;
  86735. /**
  86736. * Gets the actual render height of the texture.
  86737. * @returns the height of the render size
  86738. */
  86739. getRenderHeight(): number;
  86740. /**
  86741. * Get if the texture can be rescaled or not.
  86742. */
  86743. readonly canRescale: boolean;
  86744. /**
  86745. * Resize the texture using a ratio.
  86746. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86747. */
  86748. scale(ratio: number): void;
  86749. /**
  86750. * Get the texture reflection matrix used to rotate/transform the reflection.
  86751. * @returns the reflection matrix
  86752. */
  86753. getReflectionTextureMatrix(): Matrix;
  86754. /**
  86755. * Resize the texture to a new desired size.
  86756. * Be carrefull as it will recreate all the data in the new texture.
  86757. * @param size Define the new size. It can be:
  86758. * - a number for squared texture,
  86759. * - an object containing { width: number, height: number }
  86760. * - or an object containing a ratio { ratio: number }
  86761. */
  86762. resize(size: number | {
  86763. width: number;
  86764. height: number;
  86765. } | {
  86766. ratio: number;
  86767. }): void;
  86768. /**
  86769. * Renders all the objects from the render list into the texture.
  86770. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86771. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86772. */
  86773. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86774. private _bestReflectionRenderTargetDimension;
  86775. /**
  86776. * @hidden
  86777. * @param faceIndex face index to bind to if this is a cubetexture
  86778. */
  86779. _bindFrameBuffer(faceIndex?: number): void;
  86780. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86781. private renderToTarget;
  86782. /**
  86783. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86784. * This allowed control for front to back rendering or reversly depending of the special needs.
  86785. *
  86786. * @param renderingGroupId The rendering group id corresponding to its index
  86787. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86788. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86789. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86790. */
  86791. 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;
  86792. /**
  86793. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86794. *
  86795. * @param renderingGroupId The rendering group id corresponding to its index
  86796. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86797. */
  86798. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86799. /**
  86800. * Clones the texture.
  86801. * @returns the cloned texture
  86802. */
  86803. clone(): RenderTargetTexture;
  86804. /**
  86805. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86806. * @returns The JSON representation of the texture
  86807. */
  86808. serialize(): any;
  86809. /**
  86810. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86811. */
  86812. disposeFramebufferObjects(): void;
  86813. /**
  86814. * Dispose the texture and release its associated resources.
  86815. */
  86816. dispose(): void;
  86817. /** @hidden */
  86818. _rebuild(): void;
  86819. /**
  86820. * Clear the info related to rendering groups preventing retention point in material dispose.
  86821. */
  86822. freeRenderingGroups(): void;
  86823. /**
  86824. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86825. * @returns the view count
  86826. */
  86827. getViewCount(): number;
  86828. }
  86829. }
  86830. declare module BABYLON {
  86831. /**
  86832. * Base class for the main features of a material in Babylon.js
  86833. */
  86834. export class Material implements IAnimatable {
  86835. /**
  86836. * Returns the triangle fill mode
  86837. */
  86838. static readonly TriangleFillMode: number;
  86839. /**
  86840. * Returns the wireframe mode
  86841. */
  86842. static readonly WireFrameFillMode: number;
  86843. /**
  86844. * Returns the point fill mode
  86845. */
  86846. static readonly PointFillMode: number;
  86847. /**
  86848. * Returns the point list draw mode
  86849. */
  86850. static readonly PointListDrawMode: number;
  86851. /**
  86852. * Returns the line list draw mode
  86853. */
  86854. static readonly LineListDrawMode: number;
  86855. /**
  86856. * Returns the line loop draw mode
  86857. */
  86858. static readonly LineLoopDrawMode: number;
  86859. /**
  86860. * Returns the line strip draw mode
  86861. */
  86862. static readonly LineStripDrawMode: number;
  86863. /**
  86864. * Returns the triangle strip draw mode
  86865. */
  86866. static readonly TriangleStripDrawMode: number;
  86867. /**
  86868. * Returns the triangle fan draw mode
  86869. */
  86870. static readonly TriangleFanDrawMode: number;
  86871. /**
  86872. * Stores the clock-wise side orientation
  86873. */
  86874. static readonly ClockWiseSideOrientation: number;
  86875. /**
  86876. * Stores the counter clock-wise side orientation
  86877. */
  86878. static readonly CounterClockWiseSideOrientation: number;
  86879. /**
  86880. * The dirty texture flag value
  86881. */
  86882. static readonly TextureDirtyFlag: number;
  86883. /**
  86884. * The dirty light flag value
  86885. */
  86886. static readonly LightDirtyFlag: number;
  86887. /**
  86888. * The dirty fresnel flag value
  86889. */
  86890. static readonly FresnelDirtyFlag: number;
  86891. /**
  86892. * The dirty attribute flag value
  86893. */
  86894. static readonly AttributesDirtyFlag: number;
  86895. /**
  86896. * The dirty misc flag value
  86897. */
  86898. static readonly MiscDirtyFlag: number;
  86899. /**
  86900. * The all dirty flag value
  86901. */
  86902. static readonly AllDirtyFlag: number;
  86903. /**
  86904. * The ID of the material
  86905. */
  86906. id: string;
  86907. /**
  86908. * Gets or sets the unique id of the material
  86909. */
  86910. uniqueId: number;
  86911. /**
  86912. * The name of the material
  86913. */
  86914. name: string;
  86915. /**
  86916. * Gets or sets user defined metadata
  86917. */
  86918. metadata: any;
  86919. /**
  86920. * For internal use only. Please do not use.
  86921. */
  86922. reservedDataStore: any;
  86923. /**
  86924. * Specifies if the ready state should be checked on each call
  86925. */
  86926. checkReadyOnEveryCall: boolean;
  86927. /**
  86928. * Specifies if the ready state should be checked once
  86929. */
  86930. checkReadyOnlyOnce: boolean;
  86931. /**
  86932. * The state of the material
  86933. */
  86934. state: string;
  86935. /**
  86936. * The alpha value of the material
  86937. */
  86938. protected _alpha: number;
  86939. /**
  86940. * List of inspectable custom properties (used by the Inspector)
  86941. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86942. */
  86943. inspectableCustomProperties: IInspectable[];
  86944. /**
  86945. * Sets the alpha value of the material
  86946. */
  86947. /**
  86948. * Gets the alpha value of the material
  86949. */
  86950. alpha: number;
  86951. /**
  86952. * Specifies if back face culling is enabled
  86953. */
  86954. protected _backFaceCulling: boolean;
  86955. /**
  86956. * Sets the back-face culling state
  86957. */
  86958. /**
  86959. * Gets the back-face culling state
  86960. */
  86961. backFaceCulling: boolean;
  86962. /**
  86963. * Stores the value for side orientation
  86964. */
  86965. sideOrientation: number;
  86966. /**
  86967. * Callback triggered when the material is compiled
  86968. */
  86969. onCompiled: Nullable<(effect: Effect) => void>;
  86970. /**
  86971. * Callback triggered when an error occurs
  86972. */
  86973. onError: Nullable<(effect: Effect, errors: string) => void>;
  86974. /**
  86975. * Callback triggered to get the render target textures
  86976. */
  86977. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  86978. /**
  86979. * Gets a boolean indicating that current material needs to register RTT
  86980. */
  86981. readonly hasRenderTargetTextures: boolean;
  86982. /**
  86983. * Specifies if the material should be serialized
  86984. */
  86985. doNotSerialize: boolean;
  86986. /**
  86987. * @hidden
  86988. */
  86989. _storeEffectOnSubMeshes: boolean;
  86990. /**
  86991. * Stores the animations for the material
  86992. */
  86993. animations: Nullable<Array<Animation>>;
  86994. /**
  86995. * An event triggered when the material is disposed
  86996. */
  86997. onDisposeObservable: Observable<Material>;
  86998. /**
  86999. * An observer which watches for dispose events
  87000. */
  87001. private _onDisposeObserver;
  87002. private _onUnBindObservable;
  87003. /**
  87004. * Called during a dispose event
  87005. */
  87006. onDispose: () => void;
  87007. private _onBindObservable;
  87008. /**
  87009. * An event triggered when the material is bound
  87010. */
  87011. readonly onBindObservable: Observable<AbstractMesh>;
  87012. /**
  87013. * An observer which watches for bind events
  87014. */
  87015. private _onBindObserver;
  87016. /**
  87017. * Called during a bind event
  87018. */
  87019. onBind: (Mesh: AbstractMesh) => void;
  87020. /**
  87021. * An event triggered when the material is unbound
  87022. */
  87023. readonly onUnBindObservable: Observable<Material>;
  87024. /**
  87025. * Stores the value of the alpha mode
  87026. */
  87027. private _alphaMode;
  87028. /**
  87029. * Sets the value of the alpha mode.
  87030. *
  87031. * | Value | Type | Description |
  87032. * | --- | --- | --- |
  87033. * | 0 | ALPHA_DISABLE | |
  87034. * | 1 | ALPHA_ADD | |
  87035. * | 2 | ALPHA_COMBINE | |
  87036. * | 3 | ALPHA_SUBTRACT | |
  87037. * | 4 | ALPHA_MULTIPLY | |
  87038. * | 5 | ALPHA_MAXIMIZED | |
  87039. * | 6 | ALPHA_ONEONE | |
  87040. * | 7 | ALPHA_PREMULTIPLIED | |
  87041. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87042. * | 9 | ALPHA_INTERPOLATE | |
  87043. * | 10 | ALPHA_SCREENMODE | |
  87044. *
  87045. */
  87046. /**
  87047. * Gets the value of the alpha mode
  87048. */
  87049. alphaMode: number;
  87050. /**
  87051. * Stores the state of the need depth pre-pass value
  87052. */
  87053. private _needDepthPrePass;
  87054. /**
  87055. * Sets the need depth pre-pass value
  87056. */
  87057. /**
  87058. * Gets the depth pre-pass value
  87059. */
  87060. needDepthPrePass: boolean;
  87061. /**
  87062. * Specifies if depth writing should be disabled
  87063. */
  87064. disableDepthWrite: boolean;
  87065. /**
  87066. * Specifies if depth writing should be forced
  87067. */
  87068. forceDepthWrite: boolean;
  87069. /**
  87070. * Specifies if there should be a separate pass for culling
  87071. */
  87072. separateCullingPass: boolean;
  87073. /**
  87074. * Stores the state specifing if fog should be enabled
  87075. */
  87076. private _fogEnabled;
  87077. /**
  87078. * Sets the state for enabling fog
  87079. */
  87080. /**
  87081. * Gets the value of the fog enabled state
  87082. */
  87083. fogEnabled: boolean;
  87084. /**
  87085. * Stores the size of points
  87086. */
  87087. pointSize: number;
  87088. /**
  87089. * Stores the z offset value
  87090. */
  87091. zOffset: number;
  87092. /**
  87093. * Gets a value specifying if wireframe mode is enabled
  87094. */
  87095. /**
  87096. * Sets the state of wireframe mode
  87097. */
  87098. wireframe: boolean;
  87099. /**
  87100. * Gets the value specifying if point clouds are enabled
  87101. */
  87102. /**
  87103. * Sets the state of point cloud mode
  87104. */
  87105. pointsCloud: boolean;
  87106. /**
  87107. * Gets the material fill mode
  87108. */
  87109. /**
  87110. * Sets the material fill mode
  87111. */
  87112. fillMode: number;
  87113. /**
  87114. * @hidden
  87115. * Stores the effects for the material
  87116. */
  87117. _effect: Nullable<Effect>;
  87118. /**
  87119. * @hidden
  87120. * Specifies if the material was previously ready
  87121. */
  87122. _wasPreviouslyReady: boolean;
  87123. /**
  87124. * Specifies if uniform buffers should be used
  87125. */
  87126. private _useUBO;
  87127. /**
  87128. * Stores a reference to the scene
  87129. */
  87130. private _scene;
  87131. /**
  87132. * Stores the fill mode state
  87133. */
  87134. private _fillMode;
  87135. /**
  87136. * Specifies if the depth write state should be cached
  87137. */
  87138. private _cachedDepthWriteState;
  87139. /**
  87140. * Stores the uniform buffer
  87141. */
  87142. protected _uniformBuffer: UniformBuffer;
  87143. /** @hidden */
  87144. _indexInSceneMaterialArray: number;
  87145. /** @hidden */
  87146. meshMap: Nullable<{
  87147. [id: string]: AbstractMesh | undefined;
  87148. }>;
  87149. /**
  87150. * Creates a material instance
  87151. * @param name defines the name of the material
  87152. * @param scene defines the scene to reference
  87153. * @param doNotAdd specifies if the material should be added to the scene
  87154. */
  87155. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87156. /**
  87157. * Returns a string representation of the current material
  87158. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87159. * @returns a string with material information
  87160. */
  87161. toString(fullDetails?: boolean): string;
  87162. /**
  87163. * Gets the class name of the material
  87164. * @returns a string with the class name of the material
  87165. */
  87166. getClassName(): string;
  87167. /**
  87168. * Specifies if updates for the material been locked
  87169. */
  87170. readonly isFrozen: boolean;
  87171. /**
  87172. * Locks updates for the material
  87173. */
  87174. freeze(): void;
  87175. /**
  87176. * Unlocks updates for the material
  87177. */
  87178. unfreeze(): void;
  87179. /**
  87180. * Specifies if the material is ready to be used
  87181. * @param mesh defines the mesh to check
  87182. * @param useInstances specifies if instances should be used
  87183. * @returns a boolean indicating if the material is ready to be used
  87184. */
  87185. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87186. /**
  87187. * Specifies that the submesh is ready to be used
  87188. * @param mesh defines the mesh to check
  87189. * @param subMesh defines which submesh to check
  87190. * @param useInstances specifies that instances should be used
  87191. * @returns a boolean indicating that the submesh is ready or not
  87192. */
  87193. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87194. /**
  87195. * Returns the material effect
  87196. * @returns the effect associated with the material
  87197. */
  87198. getEffect(): Nullable<Effect>;
  87199. /**
  87200. * Returns the current scene
  87201. * @returns a Scene
  87202. */
  87203. getScene(): Scene;
  87204. /**
  87205. * Specifies if the material will require alpha blending
  87206. * @returns a boolean specifying if alpha blending is needed
  87207. */
  87208. needAlphaBlending(): boolean;
  87209. /**
  87210. * Specifies if the mesh will require alpha blending
  87211. * @param mesh defines the mesh to check
  87212. * @returns a boolean specifying if alpha blending is needed for the mesh
  87213. */
  87214. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87215. /**
  87216. * Specifies if this material should be rendered in alpha test mode
  87217. * @returns a boolean specifying if an alpha test is needed.
  87218. */
  87219. needAlphaTesting(): boolean;
  87220. /**
  87221. * Gets the texture used for the alpha test
  87222. * @returns the texture to use for alpha testing
  87223. */
  87224. getAlphaTestTexture(): Nullable<BaseTexture>;
  87225. /**
  87226. * Marks the material to indicate that it needs to be re-calculated
  87227. */
  87228. markDirty(): void;
  87229. /** @hidden */
  87230. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87231. /**
  87232. * Binds the material to the mesh
  87233. * @param world defines the world transformation matrix
  87234. * @param mesh defines the mesh to bind the material to
  87235. */
  87236. bind(world: Matrix, mesh?: Mesh): void;
  87237. /**
  87238. * Binds the submesh to the material
  87239. * @param world defines the world transformation matrix
  87240. * @param mesh defines the mesh containing the submesh
  87241. * @param subMesh defines the submesh to bind the material to
  87242. */
  87243. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87244. /**
  87245. * Binds the world matrix to the material
  87246. * @param world defines the world transformation matrix
  87247. */
  87248. bindOnlyWorldMatrix(world: Matrix): void;
  87249. /**
  87250. * Binds the scene's uniform buffer to the effect.
  87251. * @param effect defines the effect to bind to the scene uniform buffer
  87252. * @param sceneUbo defines the uniform buffer storing scene data
  87253. */
  87254. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87255. /**
  87256. * Binds the view matrix to the effect
  87257. * @param effect defines the effect to bind the view matrix to
  87258. */
  87259. bindView(effect: Effect): void;
  87260. /**
  87261. * Binds the view projection matrix to the effect
  87262. * @param effect defines the effect to bind the view projection matrix to
  87263. */
  87264. bindViewProjection(effect: Effect): void;
  87265. /**
  87266. * Specifies if material alpha testing should be turned on for the mesh
  87267. * @param mesh defines the mesh to check
  87268. */
  87269. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87270. /**
  87271. * Processes to execute after binding the material to a mesh
  87272. * @param mesh defines the rendered mesh
  87273. */
  87274. protected _afterBind(mesh?: Mesh): void;
  87275. /**
  87276. * Unbinds the material from the mesh
  87277. */
  87278. unbind(): void;
  87279. /**
  87280. * Gets the active textures from the material
  87281. * @returns an array of textures
  87282. */
  87283. getActiveTextures(): BaseTexture[];
  87284. /**
  87285. * Specifies if the material uses a texture
  87286. * @param texture defines the texture to check against the material
  87287. * @returns a boolean specifying if the material uses the texture
  87288. */
  87289. hasTexture(texture: BaseTexture): boolean;
  87290. /**
  87291. * Makes a duplicate of the material, and gives it a new name
  87292. * @param name defines the new name for the duplicated material
  87293. * @returns the cloned material
  87294. */
  87295. clone(name: string): Nullable<Material>;
  87296. /**
  87297. * Gets the meshes bound to the material
  87298. * @returns an array of meshes bound to the material
  87299. */
  87300. getBindedMeshes(): AbstractMesh[];
  87301. /**
  87302. * Force shader compilation
  87303. * @param mesh defines the mesh associated with this material
  87304. * @param onCompiled defines a function to execute once the material is compiled
  87305. * @param options defines the options to configure the compilation
  87306. */
  87307. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87308. clipPlane: boolean;
  87309. }>): void;
  87310. /**
  87311. * Force shader compilation
  87312. * @param mesh defines the mesh that will use this material
  87313. * @param options defines additional options for compiling the shaders
  87314. * @returns a promise that resolves when the compilation completes
  87315. */
  87316. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87317. clipPlane: boolean;
  87318. }>): Promise<void>;
  87319. private static readonly _AllDirtyCallBack;
  87320. private static readonly _ImageProcessingDirtyCallBack;
  87321. private static readonly _TextureDirtyCallBack;
  87322. private static readonly _FresnelDirtyCallBack;
  87323. private static readonly _MiscDirtyCallBack;
  87324. private static readonly _LightsDirtyCallBack;
  87325. private static readonly _AttributeDirtyCallBack;
  87326. private static _FresnelAndMiscDirtyCallBack;
  87327. private static _TextureAndMiscDirtyCallBack;
  87328. private static readonly _DirtyCallbackArray;
  87329. private static readonly _RunDirtyCallBacks;
  87330. /**
  87331. * Marks a define in the material to indicate that it needs to be re-computed
  87332. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87333. */
  87334. markAsDirty(flag: number): void;
  87335. /**
  87336. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87337. * @param func defines a function which checks material defines against the submeshes
  87338. */
  87339. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87340. /**
  87341. * Indicates that we need to re-calculated for all submeshes
  87342. */
  87343. protected _markAllSubMeshesAsAllDirty(): void;
  87344. /**
  87345. * Indicates that image processing needs to be re-calculated for all submeshes
  87346. */
  87347. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87348. /**
  87349. * Indicates that textures need to be re-calculated for all submeshes
  87350. */
  87351. protected _markAllSubMeshesAsTexturesDirty(): void;
  87352. /**
  87353. * Indicates that fresnel needs to be re-calculated for all submeshes
  87354. */
  87355. protected _markAllSubMeshesAsFresnelDirty(): void;
  87356. /**
  87357. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87358. */
  87359. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87360. /**
  87361. * Indicates that lights need to be re-calculated for all submeshes
  87362. */
  87363. protected _markAllSubMeshesAsLightsDirty(): void;
  87364. /**
  87365. * Indicates that attributes need to be re-calculated for all submeshes
  87366. */
  87367. protected _markAllSubMeshesAsAttributesDirty(): void;
  87368. /**
  87369. * Indicates that misc needs to be re-calculated for all submeshes
  87370. */
  87371. protected _markAllSubMeshesAsMiscDirty(): void;
  87372. /**
  87373. * Indicates that textures and misc need to be re-calculated for all submeshes
  87374. */
  87375. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87376. /**
  87377. * Disposes the material
  87378. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87379. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87380. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87381. */
  87382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87383. /** @hidden */
  87384. private releaseVertexArrayObject;
  87385. /**
  87386. * Serializes this material
  87387. * @returns the serialized material object
  87388. */
  87389. serialize(): any;
  87390. /**
  87391. * Creates a material from parsed material data
  87392. * @param parsedMaterial defines parsed material data
  87393. * @param scene defines the hosting scene
  87394. * @param rootUrl defines the root URL to use to load textures
  87395. * @returns a new material
  87396. */
  87397. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87398. }
  87399. }
  87400. declare module BABYLON {
  87401. /**
  87402. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87403. * separate meshes. This can be use to improve performances.
  87404. * @see http://doc.babylonjs.com/how_to/multi_materials
  87405. */
  87406. export class MultiMaterial extends Material {
  87407. private _subMaterials;
  87408. /**
  87409. * Gets or Sets the list of Materials used within the multi material.
  87410. * They need to be ordered according to the submeshes order in the associated mesh
  87411. */
  87412. subMaterials: Nullable<Material>[];
  87413. /**
  87414. * Function used to align with Node.getChildren()
  87415. * @returns the list of Materials used within the multi material
  87416. */
  87417. getChildren(): Nullable<Material>[];
  87418. /**
  87419. * Instantiates a new Multi Material
  87420. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87421. * separate meshes. This can be use to improve performances.
  87422. * @see http://doc.babylonjs.com/how_to/multi_materials
  87423. * @param name Define the name in the scene
  87424. * @param scene Define the scene the material belongs to
  87425. */
  87426. constructor(name: string, scene: Scene);
  87427. private _hookArray;
  87428. /**
  87429. * Get one of the submaterial by its index in the submaterials array
  87430. * @param index The index to look the sub material at
  87431. * @returns The Material if the index has been defined
  87432. */
  87433. getSubMaterial(index: number): Nullable<Material>;
  87434. /**
  87435. * Get the list of active textures for the whole sub materials list.
  87436. * @returns All the textures that will be used during the rendering
  87437. */
  87438. getActiveTextures(): BaseTexture[];
  87439. /**
  87440. * Gets the current class name of the material e.g. "MultiMaterial"
  87441. * Mainly use in serialization.
  87442. * @returns the class name
  87443. */
  87444. getClassName(): string;
  87445. /**
  87446. * Checks if the material is ready to render the requested sub mesh
  87447. * @param mesh Define the mesh the submesh belongs to
  87448. * @param subMesh Define the sub mesh to look readyness for
  87449. * @param useInstances Define whether or not the material is used with instances
  87450. * @returns true if ready, otherwise false
  87451. */
  87452. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87453. /**
  87454. * Clones the current material and its related sub materials
  87455. * @param name Define the name of the newly cloned material
  87456. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87457. * @returns the cloned material
  87458. */
  87459. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87460. /**
  87461. * Serializes the materials into a JSON representation.
  87462. * @returns the JSON representation
  87463. */
  87464. serialize(): any;
  87465. /**
  87466. * Dispose the material and release its associated resources
  87467. * @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)
  87468. * @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)
  87469. * @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)
  87470. */
  87471. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87472. /**
  87473. * Creates a MultiMaterial from parsed MultiMaterial data.
  87474. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87475. * @param scene defines the hosting scene
  87476. * @returns a new MultiMaterial
  87477. */
  87478. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87479. }
  87480. }
  87481. declare module BABYLON {
  87482. /**
  87483. * Base class for submeshes
  87484. */
  87485. export class BaseSubMesh {
  87486. /** @hidden */
  87487. _materialDefines: Nullable<MaterialDefines>;
  87488. /** @hidden */
  87489. _materialEffect: Nullable<Effect>;
  87490. /**
  87491. * Gets associated effect
  87492. */
  87493. readonly effect: Nullable<Effect>;
  87494. /**
  87495. * Sets associated effect (effect used to render this submesh)
  87496. * @param effect defines the effect to associate with
  87497. * @param defines defines the set of defines used to compile this effect
  87498. */
  87499. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87500. }
  87501. /**
  87502. * Defines a subdivision inside a mesh
  87503. */
  87504. export class SubMesh extends BaseSubMesh implements ICullable {
  87505. /** the material index to use */
  87506. materialIndex: number;
  87507. /** vertex index start */
  87508. verticesStart: number;
  87509. /** vertices count */
  87510. verticesCount: number;
  87511. /** index start */
  87512. indexStart: number;
  87513. /** indices count */
  87514. indexCount: number;
  87515. /** @hidden */
  87516. _linesIndexCount: number;
  87517. private _mesh;
  87518. private _renderingMesh;
  87519. private _boundingInfo;
  87520. private _linesIndexBuffer;
  87521. /** @hidden */
  87522. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87523. /** @hidden */
  87524. _trianglePlanes: Plane[];
  87525. /** @hidden */
  87526. _lastColliderTransformMatrix: Nullable<Matrix>;
  87527. /** @hidden */
  87528. _renderId: number;
  87529. /** @hidden */
  87530. _alphaIndex: number;
  87531. /** @hidden */
  87532. _distanceToCamera: number;
  87533. /** @hidden */
  87534. _id: number;
  87535. private _currentMaterial;
  87536. /**
  87537. * Add a new submesh to a mesh
  87538. * @param materialIndex defines the material index to use
  87539. * @param verticesStart defines vertex index start
  87540. * @param verticesCount defines vertices count
  87541. * @param indexStart defines index start
  87542. * @param indexCount defines indices count
  87543. * @param mesh defines the parent mesh
  87544. * @param renderingMesh defines an optional rendering mesh
  87545. * @param createBoundingBox defines if bounding box should be created for this submesh
  87546. * @returns the new submesh
  87547. */
  87548. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87549. /**
  87550. * Creates a new submesh
  87551. * @param materialIndex defines the material index to use
  87552. * @param verticesStart defines vertex index start
  87553. * @param verticesCount defines vertices count
  87554. * @param indexStart defines index start
  87555. * @param indexCount defines indices count
  87556. * @param mesh defines the parent mesh
  87557. * @param renderingMesh defines an optional rendering mesh
  87558. * @param createBoundingBox defines if bounding box should be created for this submesh
  87559. */
  87560. constructor(
  87561. /** the material index to use */
  87562. materialIndex: number,
  87563. /** vertex index start */
  87564. verticesStart: number,
  87565. /** vertices count */
  87566. verticesCount: number,
  87567. /** index start */
  87568. indexStart: number,
  87569. /** indices count */
  87570. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87571. /**
  87572. * Returns true if this submesh covers the entire parent mesh
  87573. * @ignorenaming
  87574. */
  87575. readonly IsGlobal: boolean;
  87576. /**
  87577. * Returns the submesh BoudingInfo object
  87578. * @returns current bounding info (or mesh's one if the submesh is global)
  87579. */
  87580. getBoundingInfo(): BoundingInfo;
  87581. /**
  87582. * Sets the submesh BoundingInfo
  87583. * @param boundingInfo defines the new bounding info to use
  87584. * @returns the SubMesh
  87585. */
  87586. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87587. /**
  87588. * Returns the mesh of the current submesh
  87589. * @return the parent mesh
  87590. */
  87591. getMesh(): AbstractMesh;
  87592. /**
  87593. * Returns the rendering mesh of the submesh
  87594. * @returns the rendering mesh (could be different from parent mesh)
  87595. */
  87596. getRenderingMesh(): Mesh;
  87597. /**
  87598. * Returns the submesh material
  87599. * @returns null or the current material
  87600. */
  87601. getMaterial(): Nullable<Material>;
  87602. /**
  87603. * Sets a new updated BoundingInfo object to the submesh
  87604. * @param data defines an optional position array to use to determine the bounding info
  87605. * @returns the SubMesh
  87606. */
  87607. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87608. /** @hidden */
  87609. _checkCollision(collider: Collider): boolean;
  87610. /**
  87611. * Updates the submesh BoundingInfo
  87612. * @param world defines the world matrix to use to update the bounding info
  87613. * @returns the submesh
  87614. */
  87615. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87616. /**
  87617. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87618. * @param frustumPlanes defines the frustum planes
  87619. * @returns true if the submesh is intersecting with the frustum
  87620. */
  87621. isInFrustum(frustumPlanes: Plane[]): boolean;
  87622. /**
  87623. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87624. * @param frustumPlanes defines the frustum planes
  87625. * @returns true if the submesh is inside the frustum
  87626. */
  87627. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87628. /**
  87629. * Renders the submesh
  87630. * @param enableAlphaMode defines if alpha needs to be used
  87631. * @returns the submesh
  87632. */
  87633. render(enableAlphaMode: boolean): SubMesh;
  87634. /**
  87635. * @hidden
  87636. */
  87637. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87638. /**
  87639. * Checks if the submesh intersects with a ray
  87640. * @param ray defines the ray to test
  87641. * @returns true is the passed ray intersects the submesh bounding box
  87642. */
  87643. canIntersects(ray: Ray): boolean;
  87644. /**
  87645. * Intersects current submesh with a ray
  87646. * @param ray defines the ray to test
  87647. * @param positions defines mesh's positions array
  87648. * @param indices defines mesh's indices array
  87649. * @param fastCheck defines if only bounding info should be used
  87650. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87651. * @returns intersection info or null if no intersection
  87652. */
  87653. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87654. /** @hidden */
  87655. private _intersectLines;
  87656. /** @hidden */
  87657. private _intersectUnIndexedLines;
  87658. /** @hidden */
  87659. private _intersectTriangles;
  87660. /** @hidden */
  87661. private _intersectUnIndexedTriangles;
  87662. /** @hidden */
  87663. _rebuild(): void;
  87664. /**
  87665. * Creates a new submesh from the passed mesh
  87666. * @param newMesh defines the new hosting mesh
  87667. * @param newRenderingMesh defines an optional rendering mesh
  87668. * @returns the new submesh
  87669. */
  87670. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87671. /**
  87672. * Release associated resources
  87673. */
  87674. dispose(): void;
  87675. /**
  87676. * Gets the class name
  87677. * @returns the string "SubMesh".
  87678. */
  87679. getClassName(): string;
  87680. /**
  87681. * Creates a new submesh from indices data
  87682. * @param materialIndex the index of the main mesh material
  87683. * @param startIndex the index where to start the copy in the mesh indices array
  87684. * @param indexCount the number of indices to copy then from the startIndex
  87685. * @param mesh the main mesh to create the submesh from
  87686. * @param renderingMesh the optional rendering mesh
  87687. * @returns a new submesh
  87688. */
  87689. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87690. }
  87691. }
  87692. declare module BABYLON {
  87693. /**
  87694. * Class used to represent data loading progression
  87695. */
  87696. export class SceneLoaderFlags {
  87697. private static _ForceFullSceneLoadingForIncremental;
  87698. private static _ShowLoadingScreen;
  87699. private static _CleanBoneMatrixWeights;
  87700. private static _loggingLevel;
  87701. /**
  87702. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87703. */
  87704. static ForceFullSceneLoadingForIncremental: boolean;
  87705. /**
  87706. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87707. */
  87708. static ShowLoadingScreen: boolean;
  87709. /**
  87710. * Defines the current logging level (while loading the scene)
  87711. * @ignorenaming
  87712. */
  87713. static loggingLevel: number;
  87714. /**
  87715. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87716. */
  87717. static CleanBoneMatrixWeights: boolean;
  87718. }
  87719. }
  87720. declare module BABYLON {
  87721. /**
  87722. * Class used to store geometry data (vertex buffers + index buffer)
  87723. */
  87724. export class Geometry implements IGetSetVerticesData {
  87725. /**
  87726. * Gets or sets the ID of the geometry
  87727. */
  87728. id: string;
  87729. /**
  87730. * Gets or sets the unique ID of the geometry
  87731. */
  87732. uniqueId: number;
  87733. /**
  87734. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87735. */
  87736. delayLoadState: number;
  87737. /**
  87738. * Gets the file containing the data to load when running in delay load state
  87739. */
  87740. delayLoadingFile: Nullable<string>;
  87741. /**
  87742. * Callback called when the geometry is updated
  87743. */
  87744. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87745. private _scene;
  87746. private _engine;
  87747. private _meshes;
  87748. private _totalVertices;
  87749. /** @hidden */
  87750. _indices: IndicesArray;
  87751. /** @hidden */
  87752. _vertexBuffers: {
  87753. [key: string]: VertexBuffer;
  87754. };
  87755. private _isDisposed;
  87756. private _extend;
  87757. private _boundingBias;
  87758. /** @hidden */
  87759. _delayInfo: Array<string>;
  87760. private _indexBuffer;
  87761. private _indexBufferIsUpdatable;
  87762. /** @hidden */
  87763. _boundingInfo: Nullable<BoundingInfo>;
  87764. /** @hidden */
  87765. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87766. /** @hidden */
  87767. _softwareSkinningFrameId: number;
  87768. private _vertexArrayObjects;
  87769. private _updatable;
  87770. /** @hidden */
  87771. _positions: Nullable<Vector3[]>;
  87772. /**
  87773. * 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
  87774. */
  87775. /**
  87776. * 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
  87777. */
  87778. boundingBias: Vector2;
  87779. /**
  87780. * Static function used to attach a new empty geometry to a mesh
  87781. * @param mesh defines the mesh to attach the geometry to
  87782. * @returns the new Geometry
  87783. */
  87784. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87785. /**
  87786. * Creates a new geometry
  87787. * @param id defines the unique ID
  87788. * @param scene defines the hosting scene
  87789. * @param vertexData defines the VertexData used to get geometry data
  87790. * @param updatable defines if geometry must be updatable (false by default)
  87791. * @param mesh defines the mesh that will be associated with the geometry
  87792. */
  87793. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87794. /**
  87795. * Gets the current extend of the geometry
  87796. */
  87797. readonly extend: {
  87798. minimum: Vector3;
  87799. maximum: Vector3;
  87800. };
  87801. /**
  87802. * Gets the hosting scene
  87803. * @returns the hosting Scene
  87804. */
  87805. getScene(): Scene;
  87806. /**
  87807. * Gets the hosting engine
  87808. * @returns the hosting Engine
  87809. */
  87810. getEngine(): Engine;
  87811. /**
  87812. * Defines if the geometry is ready to use
  87813. * @returns true if the geometry is ready to be used
  87814. */
  87815. isReady(): boolean;
  87816. /**
  87817. * Gets a value indicating that the geometry should not be serialized
  87818. */
  87819. readonly doNotSerialize: boolean;
  87820. /** @hidden */
  87821. _rebuild(): void;
  87822. /**
  87823. * Affects all geometry data in one call
  87824. * @param vertexData defines the geometry data
  87825. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87826. */
  87827. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87828. /**
  87829. * Set specific vertex data
  87830. * @param kind defines the data kind (Position, normal, etc...)
  87831. * @param data defines the vertex data to use
  87832. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87833. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87834. */
  87835. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87836. /**
  87837. * Removes a specific vertex data
  87838. * @param kind defines the data kind (Position, normal, etc...)
  87839. */
  87840. removeVerticesData(kind: string): void;
  87841. /**
  87842. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87843. * @param buffer defines the vertex buffer to use
  87844. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87845. */
  87846. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87847. /**
  87848. * Update a specific vertex buffer
  87849. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87850. * It will do nothing if the buffer is not updatable
  87851. * @param kind defines the data kind (Position, normal, etc...)
  87852. * @param data defines the data to use
  87853. * @param offset defines the offset in the target buffer where to store the data
  87854. * @param useBytes set to true if the offset is in bytes
  87855. */
  87856. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87857. /**
  87858. * Update a specific vertex buffer
  87859. * This function will create a new buffer if the current one is not updatable
  87860. * @param kind defines the data kind (Position, normal, etc...)
  87861. * @param data defines the data to use
  87862. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87863. */
  87864. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87865. private _updateBoundingInfo;
  87866. /** @hidden */
  87867. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87868. /**
  87869. * Gets total number of vertices
  87870. * @returns the total number of vertices
  87871. */
  87872. getTotalVertices(): number;
  87873. /**
  87874. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87875. * @param kind defines the data kind (Position, normal, etc...)
  87876. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87877. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87878. * @returns a float array containing vertex data
  87879. */
  87880. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87881. /**
  87882. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87883. * @param kind defines the data kind (Position, normal, etc...)
  87884. * @returns true if the vertex buffer with the specified kind is updatable
  87885. */
  87886. isVertexBufferUpdatable(kind: string): boolean;
  87887. /**
  87888. * Gets a specific vertex buffer
  87889. * @param kind defines the data kind (Position, normal, etc...)
  87890. * @returns a VertexBuffer
  87891. */
  87892. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87893. /**
  87894. * Returns all vertex buffers
  87895. * @return an object holding all vertex buffers indexed by kind
  87896. */
  87897. getVertexBuffers(): Nullable<{
  87898. [key: string]: VertexBuffer;
  87899. }>;
  87900. /**
  87901. * Gets a boolean indicating if specific vertex buffer is present
  87902. * @param kind defines the data kind (Position, normal, etc...)
  87903. * @returns true if data is present
  87904. */
  87905. isVerticesDataPresent(kind: string): boolean;
  87906. /**
  87907. * Gets a list of all attached data kinds (Position, normal, etc...)
  87908. * @returns a list of string containing all kinds
  87909. */
  87910. getVerticesDataKinds(): string[];
  87911. /**
  87912. * Update index buffer
  87913. * @param indices defines the indices to store in the index buffer
  87914. * @param offset defines the offset in the target buffer where to store the data
  87915. * @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)
  87916. */
  87917. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87918. /**
  87919. * Creates a new index buffer
  87920. * @param indices defines the indices to store in the index buffer
  87921. * @param totalVertices defines the total number of vertices (could be null)
  87922. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87923. */
  87924. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87925. /**
  87926. * Return the total number of indices
  87927. * @returns the total number of indices
  87928. */
  87929. getTotalIndices(): number;
  87930. /**
  87931. * Gets the index buffer array
  87932. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87933. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87934. * @returns the index buffer array
  87935. */
  87936. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87937. /**
  87938. * Gets the index buffer
  87939. * @return the index buffer
  87940. */
  87941. getIndexBuffer(): Nullable<DataBuffer>;
  87942. /** @hidden */
  87943. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87944. /**
  87945. * Release the associated resources for a specific mesh
  87946. * @param mesh defines the source mesh
  87947. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87948. */
  87949. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  87950. /**
  87951. * Apply current geometry to a given mesh
  87952. * @param mesh defines the mesh to apply geometry to
  87953. */
  87954. applyToMesh(mesh: Mesh): void;
  87955. private _updateExtend;
  87956. private _applyToMesh;
  87957. private notifyUpdate;
  87958. /**
  87959. * Load the geometry if it was flagged as delay loaded
  87960. * @param scene defines the hosting scene
  87961. * @param onLoaded defines a callback called when the geometry is loaded
  87962. */
  87963. load(scene: Scene, onLoaded?: () => void): void;
  87964. private _queueLoad;
  87965. /**
  87966. * Invert the geometry to move from a right handed system to a left handed one.
  87967. */
  87968. toLeftHanded(): void;
  87969. /** @hidden */
  87970. _resetPointsArrayCache(): void;
  87971. /** @hidden */
  87972. _generatePointsArray(): boolean;
  87973. /**
  87974. * Gets a value indicating if the geometry is disposed
  87975. * @returns true if the geometry was disposed
  87976. */
  87977. isDisposed(): boolean;
  87978. private _disposeVertexArrayObjects;
  87979. /**
  87980. * Free all associated resources
  87981. */
  87982. dispose(): void;
  87983. /**
  87984. * Clone the current geometry into a new geometry
  87985. * @param id defines the unique ID of the new geometry
  87986. * @returns a new geometry object
  87987. */
  87988. copy(id: string): Geometry;
  87989. /**
  87990. * Serialize the current geometry info (and not the vertices data) into a JSON object
  87991. * @return a JSON representation of the current geometry data (without the vertices data)
  87992. */
  87993. serialize(): any;
  87994. private toNumberArray;
  87995. /**
  87996. * Serialize all vertices data into a JSON oject
  87997. * @returns a JSON representation of the current geometry data
  87998. */
  87999. serializeVerticeData(): any;
  88000. /**
  88001. * Extracts a clone of a mesh geometry
  88002. * @param mesh defines the source mesh
  88003. * @param id defines the unique ID of the new geometry object
  88004. * @returns the new geometry object
  88005. */
  88006. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88007. /**
  88008. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88009. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88010. * Be aware Math.random() could cause collisions, but:
  88011. * "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"
  88012. * @returns a string containing a new GUID
  88013. */
  88014. static RandomId(): string;
  88015. /** @hidden */
  88016. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88017. private static _CleanMatricesWeights;
  88018. /**
  88019. * Create a new geometry from persisted data (Using .babylon file format)
  88020. * @param parsedVertexData defines the persisted data
  88021. * @param scene defines the hosting scene
  88022. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88023. * @returns the new geometry object
  88024. */
  88025. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88026. }
  88027. }
  88028. declare module BABYLON {
  88029. /**
  88030. * Define an interface for all classes that will get and set the data on vertices
  88031. */
  88032. export interface IGetSetVerticesData {
  88033. /**
  88034. * Gets a boolean indicating if specific vertex data is present
  88035. * @param kind defines the vertex data kind to use
  88036. * @returns true is data kind is present
  88037. */
  88038. isVerticesDataPresent(kind: string): boolean;
  88039. /**
  88040. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88041. * @param kind defines the data kind (Position, normal, etc...)
  88042. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88043. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88044. * @returns a float array containing vertex data
  88045. */
  88046. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88047. /**
  88048. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88049. * @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.
  88050. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88051. * @returns the indices array or an empty array if the mesh has no geometry
  88052. */
  88053. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88054. /**
  88055. * Set specific vertex data
  88056. * @param kind defines the data kind (Position, normal, etc...)
  88057. * @param data defines the vertex data to use
  88058. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88059. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88060. */
  88061. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88062. /**
  88063. * Update a specific associated vertex buffer
  88064. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88065. * - VertexBuffer.PositionKind
  88066. * - VertexBuffer.UVKind
  88067. * - VertexBuffer.UV2Kind
  88068. * - VertexBuffer.UV3Kind
  88069. * - VertexBuffer.UV4Kind
  88070. * - VertexBuffer.UV5Kind
  88071. * - VertexBuffer.UV6Kind
  88072. * - VertexBuffer.ColorKind
  88073. * - VertexBuffer.MatricesIndicesKind
  88074. * - VertexBuffer.MatricesIndicesExtraKind
  88075. * - VertexBuffer.MatricesWeightsKind
  88076. * - VertexBuffer.MatricesWeightsExtraKind
  88077. * @param data defines the data source
  88078. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88079. * @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)
  88080. */
  88081. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88082. /**
  88083. * Creates a new index buffer
  88084. * @param indices defines the indices to store in the index buffer
  88085. * @param totalVertices defines the total number of vertices (could be null)
  88086. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88087. */
  88088. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88089. }
  88090. /**
  88091. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88092. */
  88093. export class VertexData {
  88094. /**
  88095. * Mesh side orientation : usually the external or front surface
  88096. */
  88097. static readonly FRONTSIDE: number;
  88098. /**
  88099. * Mesh side orientation : usually the internal or back surface
  88100. */
  88101. static readonly BACKSIDE: number;
  88102. /**
  88103. * Mesh side orientation : both internal and external or front and back surfaces
  88104. */
  88105. static readonly DOUBLESIDE: number;
  88106. /**
  88107. * Mesh side orientation : by default, `FRONTSIDE`
  88108. */
  88109. static readonly DEFAULTSIDE: number;
  88110. /**
  88111. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88112. */
  88113. positions: Nullable<FloatArray>;
  88114. /**
  88115. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88116. */
  88117. normals: Nullable<FloatArray>;
  88118. /**
  88119. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88120. */
  88121. tangents: Nullable<FloatArray>;
  88122. /**
  88123. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88124. */
  88125. uvs: Nullable<FloatArray>;
  88126. /**
  88127. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88128. */
  88129. uvs2: Nullable<FloatArray>;
  88130. /**
  88131. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88132. */
  88133. uvs3: Nullable<FloatArray>;
  88134. /**
  88135. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88136. */
  88137. uvs4: Nullable<FloatArray>;
  88138. /**
  88139. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88140. */
  88141. uvs5: Nullable<FloatArray>;
  88142. /**
  88143. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88144. */
  88145. uvs6: Nullable<FloatArray>;
  88146. /**
  88147. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88148. */
  88149. colors: Nullable<FloatArray>;
  88150. /**
  88151. * 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).
  88152. */
  88153. matricesIndices: Nullable<FloatArray>;
  88154. /**
  88155. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88156. */
  88157. matricesWeights: Nullable<FloatArray>;
  88158. /**
  88159. * An array extending the number of possible indices
  88160. */
  88161. matricesIndicesExtra: Nullable<FloatArray>;
  88162. /**
  88163. * An array extending the number of possible weights when the number of indices is extended
  88164. */
  88165. matricesWeightsExtra: Nullable<FloatArray>;
  88166. /**
  88167. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88168. */
  88169. indices: Nullable<IndicesArray>;
  88170. /**
  88171. * Uses the passed data array to set the set the values for the specified kind of data
  88172. * @param data a linear array of floating numbers
  88173. * @param kind the type of data that is being set, eg positions, colors etc
  88174. */
  88175. set(data: FloatArray, kind: string): void;
  88176. /**
  88177. * Associates the vertexData to the passed Mesh.
  88178. * Sets it as updatable or not (default `false`)
  88179. * @param mesh the mesh the vertexData is applied to
  88180. * @param updatable when used and having the value true allows new data to update the vertexData
  88181. * @returns the VertexData
  88182. */
  88183. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88184. /**
  88185. * Associates the vertexData to the passed Geometry.
  88186. * Sets it as updatable or not (default `false`)
  88187. * @param geometry the geometry the vertexData is applied to
  88188. * @param updatable when used and having the value true allows new data to update the vertexData
  88189. * @returns VertexData
  88190. */
  88191. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88192. /**
  88193. * Updates the associated mesh
  88194. * @param mesh the mesh to be updated
  88195. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88196. * @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
  88197. * @returns VertexData
  88198. */
  88199. updateMesh(mesh: Mesh): VertexData;
  88200. /**
  88201. * Updates the associated geometry
  88202. * @param geometry the geometry to be updated
  88203. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88204. * @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
  88205. * @returns VertexData.
  88206. */
  88207. updateGeometry(geometry: Geometry): VertexData;
  88208. private _applyTo;
  88209. private _update;
  88210. /**
  88211. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88212. * @param matrix the transforming matrix
  88213. * @returns the VertexData
  88214. */
  88215. transform(matrix: Matrix): VertexData;
  88216. /**
  88217. * Merges the passed VertexData into the current one
  88218. * @param other the VertexData to be merged into the current one
  88219. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88220. * @returns the modified VertexData
  88221. */
  88222. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88223. private _mergeElement;
  88224. private _validate;
  88225. /**
  88226. * Serializes the VertexData
  88227. * @returns a serialized object
  88228. */
  88229. serialize(): any;
  88230. /**
  88231. * Extracts the vertexData from a mesh
  88232. * @param mesh the mesh from which to extract the VertexData
  88233. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88234. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88235. * @returns the object VertexData associated to the passed mesh
  88236. */
  88237. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88238. /**
  88239. * Extracts the vertexData from the geometry
  88240. * @param geometry the geometry from which to extract the VertexData
  88241. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88242. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88243. * @returns the object VertexData associated to the passed mesh
  88244. */
  88245. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88246. private static _ExtractFrom;
  88247. /**
  88248. * Creates the VertexData for a Ribbon
  88249. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88250. * * pathArray array of paths, each of which an array of successive Vector3
  88251. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88252. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88253. * * 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
  88254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88255. * * 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)
  88256. * * 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)
  88257. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88258. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88259. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88260. * @returns the VertexData of the ribbon
  88261. */
  88262. static CreateRibbon(options: {
  88263. pathArray: Vector3[][];
  88264. closeArray?: boolean;
  88265. closePath?: boolean;
  88266. offset?: number;
  88267. sideOrientation?: number;
  88268. frontUVs?: Vector4;
  88269. backUVs?: Vector4;
  88270. invertUV?: boolean;
  88271. uvs?: Vector2[];
  88272. colors?: Color4[];
  88273. }): VertexData;
  88274. /**
  88275. * Creates the VertexData for a box
  88276. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88277. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88278. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88279. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88280. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88281. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88282. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88283. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88284. * * 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)
  88285. * * 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)
  88286. * @returns the VertexData of the box
  88287. */
  88288. static CreateBox(options: {
  88289. size?: number;
  88290. width?: number;
  88291. height?: number;
  88292. depth?: number;
  88293. faceUV?: Vector4[];
  88294. faceColors?: Color4[];
  88295. sideOrientation?: number;
  88296. frontUVs?: Vector4;
  88297. backUVs?: Vector4;
  88298. }): VertexData;
  88299. /**
  88300. * Creates the VertexData for a tiled box
  88301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88302. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88303. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88304. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88306. * @returns the VertexData of the box
  88307. */
  88308. static CreateTiledBox(options: {
  88309. pattern?: number;
  88310. width?: number;
  88311. height?: number;
  88312. depth?: number;
  88313. tileSize?: number;
  88314. tileWidth?: number;
  88315. tileHeight?: number;
  88316. alignHorizontal?: number;
  88317. alignVertical?: number;
  88318. faceUV?: Vector4[];
  88319. faceColors?: Color4[];
  88320. sideOrientation?: number;
  88321. }): VertexData;
  88322. /**
  88323. * Creates the VertexData for a tiled plane
  88324. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88325. * * pattern a limited pattern arrangement depending on the number
  88326. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88327. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88328. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88329. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88330. * * 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)
  88331. * * 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)
  88332. * @returns the VertexData of the tiled plane
  88333. */
  88334. static CreateTiledPlane(options: {
  88335. pattern?: number;
  88336. tileSize?: number;
  88337. tileWidth?: number;
  88338. tileHeight?: number;
  88339. size?: number;
  88340. width?: number;
  88341. height?: number;
  88342. alignHorizontal?: number;
  88343. alignVertical?: number;
  88344. sideOrientation?: number;
  88345. frontUVs?: Vector4;
  88346. backUVs?: Vector4;
  88347. }): VertexData;
  88348. /**
  88349. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88350. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88351. * * segments sets the number of horizontal strips optional, default 32
  88352. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88353. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88354. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88355. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88356. * * 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
  88357. * * 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
  88358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88359. * * 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)
  88360. * * 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)
  88361. * @returns the VertexData of the ellipsoid
  88362. */
  88363. static CreateSphere(options: {
  88364. segments?: number;
  88365. diameter?: number;
  88366. diameterX?: number;
  88367. diameterY?: number;
  88368. diameterZ?: number;
  88369. arc?: number;
  88370. slice?: number;
  88371. sideOrientation?: number;
  88372. frontUVs?: Vector4;
  88373. backUVs?: Vector4;
  88374. }): VertexData;
  88375. /**
  88376. * Creates the VertexData for a cylinder, cone or prism
  88377. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88378. * * height sets the height (y direction) of the cylinder, optional, default 2
  88379. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88380. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88381. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88382. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88383. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88384. * * 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
  88385. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88386. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88387. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88388. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88390. * * 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)
  88391. * * 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)
  88392. * @returns the VertexData of the cylinder, cone or prism
  88393. */
  88394. static CreateCylinder(options: {
  88395. height?: number;
  88396. diameterTop?: number;
  88397. diameterBottom?: number;
  88398. diameter?: number;
  88399. tessellation?: number;
  88400. subdivisions?: number;
  88401. arc?: number;
  88402. faceColors?: Color4[];
  88403. faceUV?: Vector4[];
  88404. hasRings?: boolean;
  88405. enclose?: boolean;
  88406. sideOrientation?: number;
  88407. frontUVs?: Vector4;
  88408. backUVs?: Vector4;
  88409. }): VertexData;
  88410. /**
  88411. * Creates the VertexData for a torus
  88412. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88413. * * diameter the diameter of the torus, optional default 1
  88414. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88415. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88417. * * 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)
  88418. * * 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)
  88419. * @returns the VertexData of the torus
  88420. */
  88421. static CreateTorus(options: {
  88422. diameter?: number;
  88423. thickness?: number;
  88424. tessellation?: number;
  88425. sideOrientation?: number;
  88426. frontUVs?: Vector4;
  88427. backUVs?: Vector4;
  88428. }): VertexData;
  88429. /**
  88430. * Creates the VertexData of the LineSystem
  88431. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88432. * - lines an array of lines, each line being an array of successive Vector3
  88433. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88434. * @returns the VertexData of the LineSystem
  88435. */
  88436. static CreateLineSystem(options: {
  88437. lines: Vector3[][];
  88438. colors?: Nullable<Color4[][]>;
  88439. }): VertexData;
  88440. /**
  88441. * Create the VertexData for a DashedLines
  88442. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88443. * - points an array successive Vector3
  88444. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88445. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88446. * - dashNb the intended total number of dashes, optional, default 200
  88447. * @returns the VertexData for the DashedLines
  88448. */
  88449. static CreateDashedLines(options: {
  88450. points: Vector3[];
  88451. dashSize?: number;
  88452. gapSize?: number;
  88453. dashNb?: number;
  88454. }): VertexData;
  88455. /**
  88456. * Creates the VertexData for a Ground
  88457. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88458. * - width the width (x direction) of the ground, optional, default 1
  88459. * - height the height (z direction) of the ground, optional, default 1
  88460. * - subdivisions the number of subdivisions per side, optional, default 1
  88461. * @returns the VertexData of the Ground
  88462. */
  88463. static CreateGround(options: {
  88464. width?: number;
  88465. height?: number;
  88466. subdivisions?: number;
  88467. subdivisionsX?: number;
  88468. subdivisionsY?: number;
  88469. }): VertexData;
  88470. /**
  88471. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88472. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88473. * * xmin the ground minimum X coordinate, optional, default -1
  88474. * * zmin the ground minimum Z coordinate, optional, default -1
  88475. * * xmax the ground maximum X coordinate, optional, default 1
  88476. * * zmax the ground maximum Z coordinate, optional, default 1
  88477. * * 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}
  88478. * * 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}
  88479. * @returns the VertexData of the TiledGround
  88480. */
  88481. static CreateTiledGround(options: {
  88482. xmin: number;
  88483. zmin: number;
  88484. xmax: number;
  88485. zmax: number;
  88486. subdivisions?: {
  88487. w: number;
  88488. h: number;
  88489. };
  88490. precision?: {
  88491. w: number;
  88492. h: number;
  88493. };
  88494. }): VertexData;
  88495. /**
  88496. * Creates the VertexData of the Ground designed from a heightmap
  88497. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88498. * * width the width (x direction) of the ground
  88499. * * height the height (z direction) of the ground
  88500. * * subdivisions the number of subdivisions per side
  88501. * * minHeight the minimum altitude on the ground, optional, default 0
  88502. * * maxHeight the maximum altitude on the ground, optional default 1
  88503. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88504. * * buffer the array holding the image color data
  88505. * * bufferWidth the width of image
  88506. * * bufferHeight the height of image
  88507. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88508. * @returns the VertexData of the Ground designed from a heightmap
  88509. */
  88510. static CreateGroundFromHeightMap(options: {
  88511. width: number;
  88512. height: number;
  88513. subdivisions: number;
  88514. minHeight: number;
  88515. maxHeight: number;
  88516. colorFilter: Color3;
  88517. buffer: Uint8Array;
  88518. bufferWidth: number;
  88519. bufferHeight: number;
  88520. alphaFilter: number;
  88521. }): VertexData;
  88522. /**
  88523. * Creates the VertexData for a Plane
  88524. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88525. * * size sets the width and height of the plane to the value of size, optional default 1
  88526. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88527. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88529. * * 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)
  88530. * * 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)
  88531. * @returns the VertexData of the box
  88532. */
  88533. static CreatePlane(options: {
  88534. size?: number;
  88535. width?: number;
  88536. height?: number;
  88537. sideOrientation?: number;
  88538. frontUVs?: Vector4;
  88539. backUVs?: Vector4;
  88540. }): VertexData;
  88541. /**
  88542. * Creates the VertexData of the Disc or regular Polygon
  88543. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88544. * * radius the radius of the disc, optional default 0.5
  88545. * * tessellation the number of polygon sides, optional, default 64
  88546. * * 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
  88547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88548. * * 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)
  88549. * * 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)
  88550. * @returns the VertexData of the box
  88551. */
  88552. static CreateDisc(options: {
  88553. radius?: number;
  88554. tessellation?: number;
  88555. arc?: number;
  88556. sideOrientation?: number;
  88557. frontUVs?: Vector4;
  88558. backUVs?: Vector4;
  88559. }): VertexData;
  88560. /**
  88561. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88562. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88563. * @param polygon a mesh built from polygonTriangulation.build()
  88564. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88565. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88566. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88567. * @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)
  88568. * @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)
  88569. * @returns the VertexData of the Polygon
  88570. */
  88571. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88572. /**
  88573. * Creates the VertexData of the IcoSphere
  88574. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88575. * * radius the radius of the IcoSphere, optional default 1
  88576. * * radiusX allows stretching in the x direction, optional, default radius
  88577. * * radiusY allows stretching in the y direction, optional, default radius
  88578. * * radiusZ allows stretching in the z direction, optional, default radius
  88579. * * flat when true creates a flat shaded mesh, optional, default true
  88580. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88581. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88582. * * 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)
  88583. * * 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)
  88584. * @returns the VertexData of the IcoSphere
  88585. */
  88586. static CreateIcoSphere(options: {
  88587. radius?: number;
  88588. radiusX?: number;
  88589. radiusY?: number;
  88590. radiusZ?: number;
  88591. flat?: boolean;
  88592. subdivisions?: number;
  88593. sideOrientation?: number;
  88594. frontUVs?: Vector4;
  88595. backUVs?: Vector4;
  88596. }): VertexData;
  88597. /**
  88598. * Creates the VertexData for a Polyhedron
  88599. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88600. * * type provided types are:
  88601. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88602. * * 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)
  88603. * * size the size of the IcoSphere, optional default 1
  88604. * * sizeX allows stretching in the x direction, optional, default size
  88605. * * sizeY allows stretching in the y direction, optional, default size
  88606. * * sizeZ allows stretching in the z direction, optional, default size
  88607. * * 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
  88608. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88609. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88610. * * flat when true creates a flat shaded mesh, optional, default true
  88611. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88612. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88613. * * 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)
  88614. * * 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)
  88615. * @returns the VertexData of the Polyhedron
  88616. */
  88617. static CreatePolyhedron(options: {
  88618. type?: number;
  88619. size?: number;
  88620. sizeX?: number;
  88621. sizeY?: number;
  88622. sizeZ?: number;
  88623. custom?: any;
  88624. faceUV?: Vector4[];
  88625. faceColors?: Color4[];
  88626. flat?: boolean;
  88627. sideOrientation?: number;
  88628. frontUVs?: Vector4;
  88629. backUVs?: Vector4;
  88630. }): VertexData;
  88631. /**
  88632. * Creates the VertexData for a TorusKnot
  88633. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88634. * * radius the radius of the torus knot, optional, default 2
  88635. * * tube the thickness of the tube, optional, default 0.5
  88636. * * radialSegments the number of sides on each tube segments, optional, default 32
  88637. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88638. * * p the number of windings around the z axis, optional, default 2
  88639. * * q the number of windings around the x axis, optional, default 3
  88640. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88641. * * 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)
  88642. * * 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)
  88643. * @returns the VertexData of the Torus Knot
  88644. */
  88645. static CreateTorusKnot(options: {
  88646. radius?: number;
  88647. tube?: number;
  88648. radialSegments?: number;
  88649. tubularSegments?: number;
  88650. p?: number;
  88651. q?: number;
  88652. sideOrientation?: number;
  88653. frontUVs?: Vector4;
  88654. backUVs?: Vector4;
  88655. }): VertexData;
  88656. /**
  88657. * Compute normals for given positions and indices
  88658. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88659. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88660. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88661. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88662. * * facetNormals : optional array of facet normals (vector3)
  88663. * * facetPositions : optional array of facet positions (vector3)
  88664. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88665. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88666. * * bInfo : optional bounding info, required for facetPartitioning computation
  88667. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88668. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88669. * * useRightHandedSystem: optional boolean to for right handed system computation
  88670. * * depthSort : optional boolean to enable the facet depth sort computation
  88671. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88672. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88673. */
  88674. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88675. facetNormals?: any;
  88676. facetPositions?: any;
  88677. facetPartitioning?: any;
  88678. ratio?: number;
  88679. bInfo?: any;
  88680. bbSize?: Vector3;
  88681. subDiv?: any;
  88682. useRightHandedSystem?: boolean;
  88683. depthSort?: boolean;
  88684. distanceTo?: Vector3;
  88685. depthSortedFacets?: any;
  88686. }): void;
  88687. /** @hidden */
  88688. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88689. /**
  88690. * Applies VertexData created from the imported parameters to the geometry
  88691. * @param parsedVertexData the parsed data from an imported file
  88692. * @param geometry the geometry to apply the VertexData to
  88693. */
  88694. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88695. }
  88696. }
  88697. declare module BABYLON {
  88698. /**
  88699. * Defines a target to use with MorphTargetManager
  88700. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88701. */
  88702. export class MorphTarget implements IAnimatable {
  88703. /** defines the name of the target */
  88704. name: string;
  88705. /**
  88706. * Gets or sets the list of animations
  88707. */
  88708. animations: Animation[];
  88709. private _scene;
  88710. private _positions;
  88711. private _normals;
  88712. private _tangents;
  88713. private _uvs;
  88714. private _influence;
  88715. /**
  88716. * Observable raised when the influence changes
  88717. */
  88718. onInfluenceChanged: Observable<boolean>;
  88719. /** @hidden */
  88720. _onDataLayoutChanged: Observable<void>;
  88721. /**
  88722. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88723. */
  88724. influence: number;
  88725. /**
  88726. * Gets or sets the id of the morph Target
  88727. */
  88728. id: string;
  88729. private _animationPropertiesOverride;
  88730. /**
  88731. * Gets or sets the animation properties override
  88732. */
  88733. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88734. /**
  88735. * Creates a new MorphTarget
  88736. * @param name defines the name of the target
  88737. * @param influence defines the influence to use
  88738. * @param scene defines the scene the morphtarget belongs to
  88739. */
  88740. constructor(
  88741. /** defines the name of the target */
  88742. name: string, influence?: number, scene?: Nullable<Scene>);
  88743. /**
  88744. * Gets a boolean defining if the target contains position data
  88745. */
  88746. readonly hasPositions: boolean;
  88747. /**
  88748. * Gets a boolean defining if the target contains normal data
  88749. */
  88750. readonly hasNormals: boolean;
  88751. /**
  88752. * Gets a boolean defining if the target contains tangent data
  88753. */
  88754. readonly hasTangents: boolean;
  88755. /**
  88756. * Gets a boolean defining if the target contains texture coordinates data
  88757. */
  88758. readonly hasUVs: boolean;
  88759. /**
  88760. * Affects position data to this target
  88761. * @param data defines the position data to use
  88762. */
  88763. setPositions(data: Nullable<FloatArray>): void;
  88764. /**
  88765. * Gets the position data stored in this target
  88766. * @returns a FloatArray containing the position data (or null if not present)
  88767. */
  88768. getPositions(): Nullable<FloatArray>;
  88769. /**
  88770. * Affects normal data to this target
  88771. * @param data defines the normal data to use
  88772. */
  88773. setNormals(data: Nullable<FloatArray>): void;
  88774. /**
  88775. * Gets the normal data stored in this target
  88776. * @returns a FloatArray containing the normal data (or null if not present)
  88777. */
  88778. getNormals(): Nullable<FloatArray>;
  88779. /**
  88780. * Affects tangent data to this target
  88781. * @param data defines the tangent data to use
  88782. */
  88783. setTangents(data: Nullable<FloatArray>): void;
  88784. /**
  88785. * Gets the tangent data stored in this target
  88786. * @returns a FloatArray containing the tangent data (or null if not present)
  88787. */
  88788. getTangents(): Nullable<FloatArray>;
  88789. /**
  88790. * Affects texture coordinates data to this target
  88791. * @param data defines the texture coordinates data to use
  88792. */
  88793. setUVs(data: Nullable<FloatArray>): void;
  88794. /**
  88795. * Gets the texture coordinates data stored in this target
  88796. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88797. */
  88798. getUVs(): Nullable<FloatArray>;
  88799. /**
  88800. * Serializes the current target into a Serialization object
  88801. * @returns the serialized object
  88802. */
  88803. serialize(): any;
  88804. /**
  88805. * Returns the string "MorphTarget"
  88806. * @returns "MorphTarget"
  88807. */
  88808. getClassName(): string;
  88809. /**
  88810. * Creates a new target from serialized data
  88811. * @param serializationObject defines the serialized data to use
  88812. * @returns a new MorphTarget
  88813. */
  88814. static Parse(serializationObject: any): MorphTarget;
  88815. /**
  88816. * Creates a MorphTarget from mesh data
  88817. * @param mesh defines the source mesh
  88818. * @param name defines the name to use for the new target
  88819. * @param influence defines the influence to attach to the target
  88820. * @returns a new MorphTarget
  88821. */
  88822. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88823. }
  88824. }
  88825. declare module BABYLON {
  88826. /**
  88827. * This class is used to deform meshes using morphing between different targets
  88828. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88829. */
  88830. export class MorphTargetManager {
  88831. private _targets;
  88832. private _targetInfluenceChangedObservers;
  88833. private _targetDataLayoutChangedObservers;
  88834. private _activeTargets;
  88835. private _scene;
  88836. private _influences;
  88837. private _supportsNormals;
  88838. private _supportsTangents;
  88839. private _supportsUVs;
  88840. private _vertexCount;
  88841. private _uniqueId;
  88842. private _tempInfluences;
  88843. /**
  88844. * Gets or sets a boolean indicating if normals must be morphed
  88845. */
  88846. enableNormalMorphing: boolean;
  88847. /**
  88848. * Gets or sets a boolean indicating if tangents must be morphed
  88849. */
  88850. enableTangentMorphing: boolean;
  88851. /**
  88852. * Gets or sets a boolean indicating if UV must be morphed
  88853. */
  88854. enableUVMorphing: boolean;
  88855. /**
  88856. * Creates a new MorphTargetManager
  88857. * @param scene defines the current scene
  88858. */
  88859. constructor(scene?: Nullable<Scene>);
  88860. /**
  88861. * Gets the unique ID of this manager
  88862. */
  88863. readonly uniqueId: number;
  88864. /**
  88865. * Gets the number of vertices handled by this manager
  88866. */
  88867. readonly vertexCount: number;
  88868. /**
  88869. * Gets a boolean indicating if this manager supports morphing of normals
  88870. */
  88871. readonly supportsNormals: boolean;
  88872. /**
  88873. * Gets a boolean indicating if this manager supports morphing of tangents
  88874. */
  88875. readonly supportsTangents: boolean;
  88876. /**
  88877. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88878. */
  88879. readonly supportsUVs: boolean;
  88880. /**
  88881. * Gets the number of targets stored in this manager
  88882. */
  88883. readonly numTargets: number;
  88884. /**
  88885. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88886. */
  88887. readonly numInfluencers: number;
  88888. /**
  88889. * Gets the list of influences (one per target)
  88890. */
  88891. readonly influences: Float32Array;
  88892. /**
  88893. * Gets the active target at specified index. An active target is a target with an influence > 0
  88894. * @param index defines the index to check
  88895. * @returns the requested target
  88896. */
  88897. getActiveTarget(index: number): MorphTarget;
  88898. /**
  88899. * Gets the target at specified index
  88900. * @param index defines the index to check
  88901. * @returns the requested target
  88902. */
  88903. getTarget(index: number): MorphTarget;
  88904. /**
  88905. * Add a new target to this manager
  88906. * @param target defines the target to add
  88907. */
  88908. addTarget(target: MorphTarget): void;
  88909. /**
  88910. * Removes a target from the manager
  88911. * @param target defines the target to remove
  88912. */
  88913. removeTarget(target: MorphTarget): void;
  88914. /**
  88915. * Serializes the current manager into a Serialization object
  88916. * @returns the serialized object
  88917. */
  88918. serialize(): any;
  88919. private _syncActiveTargets;
  88920. /**
  88921. * Syncrhonize the targets with all the meshes using this morph target manager
  88922. */
  88923. synchronize(): void;
  88924. /**
  88925. * Creates a new MorphTargetManager from serialized data
  88926. * @param serializationObject defines the serialized data
  88927. * @param scene defines the hosting scene
  88928. * @returns the new MorphTargetManager
  88929. */
  88930. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88931. }
  88932. }
  88933. declare module BABYLON {
  88934. /**
  88935. * Class used to represent a specific level of detail of a mesh
  88936. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88937. */
  88938. export class MeshLODLevel {
  88939. /** Defines the distance where this level should start being displayed */
  88940. distance: number;
  88941. /** Defines the mesh to use to render this level */
  88942. mesh: Nullable<Mesh>;
  88943. /**
  88944. * Creates a new LOD level
  88945. * @param distance defines the distance where this level should star being displayed
  88946. * @param mesh defines the mesh to use to render this level
  88947. */
  88948. constructor(
  88949. /** Defines the distance where this level should start being displayed */
  88950. distance: number,
  88951. /** Defines the mesh to use to render this level */
  88952. mesh: Nullable<Mesh>);
  88953. }
  88954. }
  88955. declare module BABYLON {
  88956. /**
  88957. * Mesh representing the gorund
  88958. */
  88959. export class GroundMesh extends Mesh {
  88960. /** If octree should be generated */
  88961. generateOctree: boolean;
  88962. private _heightQuads;
  88963. /** @hidden */
  88964. _subdivisionsX: number;
  88965. /** @hidden */
  88966. _subdivisionsY: number;
  88967. /** @hidden */
  88968. _width: number;
  88969. /** @hidden */
  88970. _height: number;
  88971. /** @hidden */
  88972. _minX: number;
  88973. /** @hidden */
  88974. _maxX: number;
  88975. /** @hidden */
  88976. _minZ: number;
  88977. /** @hidden */
  88978. _maxZ: number;
  88979. constructor(name: string, scene: Scene);
  88980. /**
  88981. * "GroundMesh"
  88982. * @returns "GroundMesh"
  88983. */
  88984. getClassName(): string;
  88985. /**
  88986. * The minimum of x and y subdivisions
  88987. */
  88988. readonly subdivisions: number;
  88989. /**
  88990. * X subdivisions
  88991. */
  88992. readonly subdivisionsX: number;
  88993. /**
  88994. * Y subdivisions
  88995. */
  88996. readonly subdivisionsY: number;
  88997. /**
  88998. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  88999. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89000. * @param chunksCount the number of subdivisions for x and y
  89001. * @param octreeBlocksSize (Default: 32)
  89002. */
  89003. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89004. /**
  89005. * Returns a height (y) value in the Worl system :
  89006. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89007. * @param x x coordinate
  89008. * @param z z coordinate
  89009. * @returns the ground y position if (x, z) are outside the ground surface.
  89010. */
  89011. getHeightAtCoordinates(x: number, z: number): number;
  89012. /**
  89013. * Returns a normalized vector (Vector3) orthogonal to the ground
  89014. * at the ground coordinates (x, z) expressed in the World system.
  89015. * @param x x coordinate
  89016. * @param z z coordinate
  89017. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89018. */
  89019. getNormalAtCoordinates(x: number, z: number): Vector3;
  89020. /**
  89021. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89022. * at the ground coordinates (x, z) expressed in the World system.
  89023. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89024. * @param x x coordinate
  89025. * @param z z coordinate
  89026. * @param ref vector to store the result
  89027. * @returns the GroundMesh.
  89028. */
  89029. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89030. /**
  89031. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89032. * if the ground has been updated.
  89033. * This can be used in the render loop.
  89034. * @returns the GroundMesh.
  89035. */
  89036. updateCoordinateHeights(): GroundMesh;
  89037. private _getFacetAt;
  89038. private _initHeightQuads;
  89039. private _computeHeightQuads;
  89040. /**
  89041. * Serializes this ground mesh
  89042. * @param serializationObject object to write serialization to
  89043. */
  89044. serialize(serializationObject: any): void;
  89045. /**
  89046. * Parses a serialized ground mesh
  89047. * @param parsedMesh the serialized mesh
  89048. * @param scene the scene to create the ground mesh in
  89049. * @returns the created ground mesh
  89050. */
  89051. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89052. }
  89053. }
  89054. declare module BABYLON {
  89055. /**
  89056. * Interface for Physics-Joint data
  89057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89058. */
  89059. export interface PhysicsJointData {
  89060. /**
  89061. * The main pivot of the joint
  89062. */
  89063. mainPivot?: Vector3;
  89064. /**
  89065. * The connected pivot of the joint
  89066. */
  89067. connectedPivot?: Vector3;
  89068. /**
  89069. * The main axis of the joint
  89070. */
  89071. mainAxis?: Vector3;
  89072. /**
  89073. * The connected axis of the joint
  89074. */
  89075. connectedAxis?: Vector3;
  89076. /**
  89077. * The collision of the joint
  89078. */
  89079. collision?: boolean;
  89080. /**
  89081. * Native Oimo/Cannon/Energy data
  89082. */
  89083. nativeParams?: any;
  89084. }
  89085. /**
  89086. * This is a holder class for the physics joint created by the physics plugin
  89087. * It holds a set of functions to control the underlying joint
  89088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89089. */
  89090. export class PhysicsJoint {
  89091. /**
  89092. * The type of the physics joint
  89093. */
  89094. type: number;
  89095. /**
  89096. * The data for the physics joint
  89097. */
  89098. jointData: PhysicsJointData;
  89099. private _physicsJoint;
  89100. protected _physicsPlugin: IPhysicsEnginePlugin;
  89101. /**
  89102. * Initializes the physics joint
  89103. * @param type The type of the physics joint
  89104. * @param jointData The data for the physics joint
  89105. */
  89106. constructor(
  89107. /**
  89108. * The type of the physics joint
  89109. */
  89110. type: number,
  89111. /**
  89112. * The data for the physics joint
  89113. */
  89114. jointData: PhysicsJointData);
  89115. /**
  89116. * Gets the physics joint
  89117. */
  89118. /**
  89119. * Sets the physics joint
  89120. */
  89121. physicsJoint: any;
  89122. /**
  89123. * Sets the physics plugin
  89124. */
  89125. physicsPlugin: IPhysicsEnginePlugin;
  89126. /**
  89127. * Execute a function that is physics-plugin specific.
  89128. * @param {Function} func the function that will be executed.
  89129. * It accepts two parameters: the physics world and the physics joint
  89130. */
  89131. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89132. /**
  89133. * Distance-Joint type
  89134. */
  89135. static DistanceJoint: number;
  89136. /**
  89137. * Hinge-Joint type
  89138. */
  89139. static HingeJoint: number;
  89140. /**
  89141. * Ball-and-Socket joint type
  89142. */
  89143. static BallAndSocketJoint: number;
  89144. /**
  89145. * Wheel-Joint type
  89146. */
  89147. static WheelJoint: number;
  89148. /**
  89149. * Slider-Joint type
  89150. */
  89151. static SliderJoint: number;
  89152. /**
  89153. * Prismatic-Joint type
  89154. */
  89155. static PrismaticJoint: number;
  89156. /**
  89157. * Universal-Joint type
  89158. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89159. */
  89160. static UniversalJoint: number;
  89161. /**
  89162. * Hinge-Joint 2 type
  89163. */
  89164. static Hinge2Joint: number;
  89165. /**
  89166. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89167. */
  89168. static PointToPointJoint: number;
  89169. /**
  89170. * Spring-Joint type
  89171. */
  89172. static SpringJoint: number;
  89173. /**
  89174. * Lock-Joint type
  89175. */
  89176. static LockJoint: number;
  89177. }
  89178. /**
  89179. * A class representing a physics distance joint
  89180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89181. */
  89182. export class DistanceJoint extends PhysicsJoint {
  89183. /**
  89184. *
  89185. * @param jointData The data for the Distance-Joint
  89186. */
  89187. constructor(jointData: DistanceJointData);
  89188. /**
  89189. * Update the predefined distance.
  89190. * @param maxDistance The maximum preferred distance
  89191. * @param minDistance The minimum preferred distance
  89192. */
  89193. updateDistance(maxDistance: number, minDistance?: number): void;
  89194. }
  89195. /**
  89196. * Represents a Motor-Enabled Joint
  89197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89198. */
  89199. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89200. /**
  89201. * Initializes the Motor-Enabled Joint
  89202. * @param type The type of the joint
  89203. * @param jointData The physica joint data for the joint
  89204. */
  89205. constructor(type: number, jointData: PhysicsJointData);
  89206. /**
  89207. * Set the motor values.
  89208. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89209. * @param force the force to apply
  89210. * @param maxForce max force for this motor.
  89211. */
  89212. setMotor(force?: number, maxForce?: number): void;
  89213. /**
  89214. * Set the motor's limits.
  89215. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89216. * @param upperLimit The upper limit of the motor
  89217. * @param lowerLimit The lower limit of the motor
  89218. */
  89219. setLimit(upperLimit: number, lowerLimit?: number): void;
  89220. }
  89221. /**
  89222. * This class represents a single physics Hinge-Joint
  89223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89224. */
  89225. export class HingeJoint extends MotorEnabledJoint {
  89226. /**
  89227. * Initializes the Hinge-Joint
  89228. * @param jointData The joint data for the Hinge-Joint
  89229. */
  89230. constructor(jointData: PhysicsJointData);
  89231. /**
  89232. * Set the motor values.
  89233. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89234. * @param {number} force the force to apply
  89235. * @param {number} maxForce max force for this motor.
  89236. */
  89237. setMotor(force?: number, maxForce?: number): void;
  89238. /**
  89239. * Set the motor's limits.
  89240. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89241. * @param upperLimit The upper limit of the motor
  89242. * @param lowerLimit The lower limit of the motor
  89243. */
  89244. setLimit(upperLimit: number, lowerLimit?: number): void;
  89245. }
  89246. /**
  89247. * This class represents a dual hinge physics joint (same as wheel joint)
  89248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89249. */
  89250. export class Hinge2Joint extends MotorEnabledJoint {
  89251. /**
  89252. * Initializes the Hinge2-Joint
  89253. * @param jointData The joint data for the Hinge2-Joint
  89254. */
  89255. constructor(jointData: PhysicsJointData);
  89256. /**
  89257. * Set the motor values.
  89258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89259. * @param {number} targetSpeed the speed the motor is to reach
  89260. * @param {number} maxForce max force for this motor.
  89261. * @param {motorIndex} the motor's index, 0 or 1.
  89262. */
  89263. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89264. /**
  89265. * Set the motor limits.
  89266. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89267. * @param {number} upperLimit the upper limit
  89268. * @param {number} lowerLimit lower limit
  89269. * @param {motorIndex} the motor's index, 0 or 1.
  89270. */
  89271. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89272. }
  89273. /**
  89274. * Interface for a motor enabled joint
  89275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89276. */
  89277. export interface IMotorEnabledJoint {
  89278. /**
  89279. * Physics joint
  89280. */
  89281. physicsJoint: any;
  89282. /**
  89283. * Sets the motor of the motor-enabled joint
  89284. * @param force The force of the motor
  89285. * @param maxForce The maximum force of the motor
  89286. * @param motorIndex The index of the motor
  89287. */
  89288. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89289. /**
  89290. * Sets the limit of the motor
  89291. * @param upperLimit The upper limit of the motor
  89292. * @param lowerLimit The lower limit of the motor
  89293. * @param motorIndex The index of the motor
  89294. */
  89295. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89296. }
  89297. /**
  89298. * Joint data for a Distance-Joint
  89299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89300. */
  89301. export interface DistanceJointData extends PhysicsJointData {
  89302. /**
  89303. * Max distance the 2 joint objects can be apart
  89304. */
  89305. maxDistance: number;
  89306. }
  89307. /**
  89308. * Joint data from a spring joint
  89309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89310. */
  89311. export interface SpringJointData extends PhysicsJointData {
  89312. /**
  89313. * Length of the spring
  89314. */
  89315. length: number;
  89316. /**
  89317. * Stiffness of the spring
  89318. */
  89319. stiffness: number;
  89320. /**
  89321. * Damping of the spring
  89322. */
  89323. damping: number;
  89324. /** this callback will be called when applying the force to the impostors. */
  89325. forceApplicationCallback: () => void;
  89326. }
  89327. }
  89328. declare module BABYLON {
  89329. /**
  89330. * Holds the data for the raycast result
  89331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89332. */
  89333. export class PhysicsRaycastResult {
  89334. private _hasHit;
  89335. private _hitDistance;
  89336. private _hitNormalWorld;
  89337. private _hitPointWorld;
  89338. private _rayFromWorld;
  89339. private _rayToWorld;
  89340. /**
  89341. * Gets if there was a hit
  89342. */
  89343. readonly hasHit: boolean;
  89344. /**
  89345. * Gets the distance from the hit
  89346. */
  89347. readonly hitDistance: number;
  89348. /**
  89349. * Gets the hit normal/direction in the world
  89350. */
  89351. readonly hitNormalWorld: Vector3;
  89352. /**
  89353. * Gets the hit point in the world
  89354. */
  89355. readonly hitPointWorld: Vector3;
  89356. /**
  89357. * Gets the ray "start point" of the ray in the world
  89358. */
  89359. readonly rayFromWorld: Vector3;
  89360. /**
  89361. * Gets the ray "end point" of the ray in the world
  89362. */
  89363. readonly rayToWorld: Vector3;
  89364. /**
  89365. * Sets the hit data (normal & point in world space)
  89366. * @param hitNormalWorld defines the normal in world space
  89367. * @param hitPointWorld defines the point in world space
  89368. */
  89369. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89370. /**
  89371. * Sets the distance from the start point to the hit point
  89372. * @param distance
  89373. */
  89374. setHitDistance(distance: number): void;
  89375. /**
  89376. * Calculates the distance manually
  89377. */
  89378. calculateHitDistance(): void;
  89379. /**
  89380. * Resets all the values to default
  89381. * @param from The from point on world space
  89382. * @param to The to point on world space
  89383. */
  89384. reset(from?: Vector3, to?: Vector3): void;
  89385. }
  89386. /**
  89387. * Interface for the size containing width and height
  89388. */
  89389. interface IXYZ {
  89390. /**
  89391. * X
  89392. */
  89393. x: number;
  89394. /**
  89395. * Y
  89396. */
  89397. y: number;
  89398. /**
  89399. * Z
  89400. */
  89401. z: number;
  89402. }
  89403. }
  89404. declare module BABYLON {
  89405. /**
  89406. * Interface used to describe a physics joint
  89407. */
  89408. export interface PhysicsImpostorJoint {
  89409. /** Defines the main impostor to which the joint is linked */
  89410. mainImpostor: PhysicsImpostor;
  89411. /** Defines the impostor that is connected to the main impostor using this joint */
  89412. connectedImpostor: PhysicsImpostor;
  89413. /** Defines the joint itself */
  89414. joint: PhysicsJoint;
  89415. }
  89416. /** @hidden */
  89417. export interface IPhysicsEnginePlugin {
  89418. world: any;
  89419. name: string;
  89420. setGravity(gravity: Vector3): void;
  89421. setTimeStep(timeStep: number): void;
  89422. getTimeStep(): number;
  89423. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89424. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89425. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89426. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89427. removePhysicsBody(impostor: PhysicsImpostor): void;
  89428. generateJoint(joint: PhysicsImpostorJoint): void;
  89429. removeJoint(joint: PhysicsImpostorJoint): void;
  89430. isSupported(): boolean;
  89431. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89432. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89433. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89434. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89435. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89436. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89437. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89438. getBodyMass(impostor: PhysicsImpostor): number;
  89439. getBodyFriction(impostor: PhysicsImpostor): number;
  89440. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89441. getBodyRestitution(impostor: PhysicsImpostor): number;
  89442. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89443. getBodyPressure?(impostor: PhysicsImpostor): number;
  89444. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89445. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89446. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89447. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89448. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89449. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89450. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89451. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89452. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89453. sleepBody(impostor: PhysicsImpostor): void;
  89454. wakeUpBody(impostor: PhysicsImpostor): void;
  89455. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89456. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89457. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89458. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89459. getRadius(impostor: PhysicsImpostor): number;
  89460. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89461. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89462. dispose(): void;
  89463. }
  89464. /**
  89465. * Interface used to define a physics engine
  89466. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89467. */
  89468. export interface IPhysicsEngine {
  89469. /**
  89470. * Gets the gravity vector used by the simulation
  89471. */
  89472. gravity: Vector3;
  89473. /**
  89474. * Sets the gravity vector used by the simulation
  89475. * @param gravity defines the gravity vector to use
  89476. */
  89477. setGravity(gravity: Vector3): void;
  89478. /**
  89479. * Set the time step of the physics engine.
  89480. * Default is 1/60.
  89481. * To slow it down, enter 1/600 for example.
  89482. * To speed it up, 1/30
  89483. * @param newTimeStep the new timestep to apply to this world.
  89484. */
  89485. setTimeStep(newTimeStep: number): void;
  89486. /**
  89487. * Get the time step of the physics engine.
  89488. * @returns the current time step
  89489. */
  89490. getTimeStep(): number;
  89491. /**
  89492. * Release all resources
  89493. */
  89494. dispose(): void;
  89495. /**
  89496. * Gets the name of the current physics plugin
  89497. * @returns the name of the plugin
  89498. */
  89499. getPhysicsPluginName(): string;
  89500. /**
  89501. * Adding a new impostor for the impostor tracking.
  89502. * This will be done by the impostor itself.
  89503. * @param impostor the impostor to add
  89504. */
  89505. addImpostor(impostor: PhysicsImpostor): void;
  89506. /**
  89507. * Remove an impostor from the engine.
  89508. * This impostor and its mesh will not longer be updated by the physics engine.
  89509. * @param impostor the impostor to remove
  89510. */
  89511. removeImpostor(impostor: PhysicsImpostor): void;
  89512. /**
  89513. * Add a joint to the physics engine
  89514. * @param mainImpostor defines the main impostor to which the joint is added.
  89515. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89516. * @param joint defines the joint that will connect both impostors.
  89517. */
  89518. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89519. /**
  89520. * Removes a joint from the simulation
  89521. * @param mainImpostor defines the impostor used with the joint
  89522. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89523. * @param joint defines the joint to remove
  89524. */
  89525. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89526. /**
  89527. * Gets the current plugin used to run the simulation
  89528. * @returns current plugin
  89529. */
  89530. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89531. /**
  89532. * Gets the list of physic impostors
  89533. * @returns an array of PhysicsImpostor
  89534. */
  89535. getImpostors(): Array<PhysicsImpostor>;
  89536. /**
  89537. * Gets the impostor for a physics enabled object
  89538. * @param object defines the object impersonated by the impostor
  89539. * @returns the PhysicsImpostor or null if not found
  89540. */
  89541. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89542. /**
  89543. * Gets the impostor for a physics body object
  89544. * @param body defines physics body used by the impostor
  89545. * @returns the PhysicsImpostor or null if not found
  89546. */
  89547. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89548. /**
  89549. * Does a raycast in the physics world
  89550. * @param from when should the ray start?
  89551. * @param to when should the ray end?
  89552. * @returns PhysicsRaycastResult
  89553. */
  89554. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89555. /**
  89556. * Called by the scene. No need to call it.
  89557. * @param delta defines the timespam between frames
  89558. */
  89559. _step(delta: number): void;
  89560. }
  89561. }
  89562. declare module BABYLON {
  89563. /**
  89564. * The interface for the physics imposter parameters
  89565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89566. */
  89567. export interface PhysicsImpostorParameters {
  89568. /**
  89569. * The mass of the physics imposter
  89570. */
  89571. mass: number;
  89572. /**
  89573. * The friction of the physics imposter
  89574. */
  89575. friction?: number;
  89576. /**
  89577. * The coefficient of restitution of the physics imposter
  89578. */
  89579. restitution?: number;
  89580. /**
  89581. * The native options of the physics imposter
  89582. */
  89583. nativeOptions?: any;
  89584. /**
  89585. * Specifies if the parent should be ignored
  89586. */
  89587. ignoreParent?: boolean;
  89588. /**
  89589. * Specifies if bi-directional transformations should be disabled
  89590. */
  89591. disableBidirectionalTransformation?: boolean;
  89592. /**
  89593. * The pressure inside the physics imposter, soft object only
  89594. */
  89595. pressure?: number;
  89596. /**
  89597. * The stiffness the physics imposter, soft object only
  89598. */
  89599. stiffness?: number;
  89600. /**
  89601. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89602. */
  89603. velocityIterations?: number;
  89604. /**
  89605. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89606. */
  89607. positionIterations?: number;
  89608. /**
  89609. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89610. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89611. * Add to fix multiple points
  89612. */
  89613. fixedPoints?: number;
  89614. /**
  89615. * The collision margin around a soft object
  89616. */
  89617. margin?: number;
  89618. /**
  89619. * The collision margin around a soft object
  89620. */
  89621. damping?: number;
  89622. /**
  89623. * The path for a rope based on an extrusion
  89624. */
  89625. path?: any;
  89626. /**
  89627. * The shape of an extrusion used for a rope based on an extrusion
  89628. */
  89629. shape?: any;
  89630. }
  89631. /**
  89632. * Interface for a physics-enabled object
  89633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89634. */
  89635. export interface IPhysicsEnabledObject {
  89636. /**
  89637. * The position of the physics-enabled object
  89638. */
  89639. position: Vector3;
  89640. /**
  89641. * The rotation of the physics-enabled object
  89642. */
  89643. rotationQuaternion: Nullable<Quaternion>;
  89644. /**
  89645. * The scale of the physics-enabled object
  89646. */
  89647. scaling: Vector3;
  89648. /**
  89649. * The rotation of the physics-enabled object
  89650. */
  89651. rotation?: Vector3;
  89652. /**
  89653. * The parent of the physics-enabled object
  89654. */
  89655. parent?: any;
  89656. /**
  89657. * The bounding info of the physics-enabled object
  89658. * @returns The bounding info of the physics-enabled object
  89659. */
  89660. getBoundingInfo(): BoundingInfo;
  89661. /**
  89662. * Computes the world matrix
  89663. * @param force Specifies if the world matrix should be computed by force
  89664. * @returns A world matrix
  89665. */
  89666. computeWorldMatrix(force: boolean): Matrix;
  89667. /**
  89668. * Gets the world matrix
  89669. * @returns A world matrix
  89670. */
  89671. getWorldMatrix?(): Matrix;
  89672. /**
  89673. * Gets the child meshes
  89674. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89675. * @returns An array of abstract meshes
  89676. */
  89677. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89678. /**
  89679. * Gets the vertex data
  89680. * @param kind The type of vertex data
  89681. * @returns A nullable array of numbers, or a float32 array
  89682. */
  89683. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89684. /**
  89685. * Gets the indices from the mesh
  89686. * @returns A nullable array of index arrays
  89687. */
  89688. getIndices?(): Nullable<IndicesArray>;
  89689. /**
  89690. * Gets the scene from the mesh
  89691. * @returns the indices array or null
  89692. */
  89693. getScene?(): Scene;
  89694. /**
  89695. * Gets the absolute position from the mesh
  89696. * @returns the absolute position
  89697. */
  89698. getAbsolutePosition(): Vector3;
  89699. /**
  89700. * Gets the absolute pivot point from the mesh
  89701. * @returns the absolute pivot point
  89702. */
  89703. getAbsolutePivotPoint(): Vector3;
  89704. /**
  89705. * Rotates the mesh
  89706. * @param axis The axis of rotation
  89707. * @param amount The amount of rotation
  89708. * @param space The space of the rotation
  89709. * @returns The rotation transform node
  89710. */
  89711. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89712. /**
  89713. * Translates the mesh
  89714. * @param axis The axis of translation
  89715. * @param distance The distance of translation
  89716. * @param space The space of the translation
  89717. * @returns The transform node
  89718. */
  89719. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89720. /**
  89721. * Sets the absolute position of the mesh
  89722. * @param absolutePosition The absolute position of the mesh
  89723. * @returns The transform node
  89724. */
  89725. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89726. /**
  89727. * Gets the class name of the mesh
  89728. * @returns The class name
  89729. */
  89730. getClassName(): string;
  89731. }
  89732. /**
  89733. * Represents a physics imposter
  89734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89735. */
  89736. export class PhysicsImpostor {
  89737. /**
  89738. * The physics-enabled object used as the physics imposter
  89739. */
  89740. object: IPhysicsEnabledObject;
  89741. /**
  89742. * The type of the physics imposter
  89743. */
  89744. type: number;
  89745. private _options;
  89746. private _scene?;
  89747. /**
  89748. * The default object size of the imposter
  89749. */
  89750. static DEFAULT_OBJECT_SIZE: Vector3;
  89751. /**
  89752. * The identity quaternion of the imposter
  89753. */
  89754. static IDENTITY_QUATERNION: Quaternion;
  89755. /** @hidden */
  89756. _pluginData: any;
  89757. private _physicsEngine;
  89758. private _physicsBody;
  89759. private _bodyUpdateRequired;
  89760. private _onBeforePhysicsStepCallbacks;
  89761. private _onAfterPhysicsStepCallbacks;
  89762. /** @hidden */
  89763. _onPhysicsCollideCallbacks: Array<{
  89764. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89765. otherImpostors: Array<PhysicsImpostor>;
  89766. }>;
  89767. private _deltaPosition;
  89768. private _deltaRotation;
  89769. private _deltaRotationConjugated;
  89770. /** @hidden */
  89771. _isFromLine: boolean;
  89772. private _parent;
  89773. private _isDisposed;
  89774. private static _tmpVecs;
  89775. private static _tmpQuat;
  89776. /**
  89777. * Specifies if the physics imposter is disposed
  89778. */
  89779. readonly isDisposed: boolean;
  89780. /**
  89781. * Gets the mass of the physics imposter
  89782. */
  89783. mass: number;
  89784. /**
  89785. * Gets the coefficient of friction
  89786. */
  89787. /**
  89788. * Sets the coefficient of friction
  89789. */
  89790. friction: number;
  89791. /**
  89792. * Gets the coefficient of restitution
  89793. */
  89794. /**
  89795. * Sets the coefficient of restitution
  89796. */
  89797. restitution: number;
  89798. /**
  89799. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89800. */
  89801. /**
  89802. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89803. */
  89804. pressure: number;
  89805. /**
  89806. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89807. */
  89808. /**
  89809. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89810. */
  89811. stiffness: number;
  89812. /**
  89813. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89814. */
  89815. /**
  89816. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89817. */
  89818. velocityIterations: number;
  89819. /**
  89820. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89821. */
  89822. /**
  89823. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89824. */
  89825. positionIterations: number;
  89826. /**
  89827. * The unique id of the physics imposter
  89828. * set by the physics engine when adding this impostor to the array
  89829. */
  89830. uniqueId: number;
  89831. /**
  89832. * @hidden
  89833. */
  89834. soft: boolean;
  89835. /**
  89836. * @hidden
  89837. */
  89838. segments: number;
  89839. private _joints;
  89840. /**
  89841. * Initializes the physics imposter
  89842. * @param object The physics-enabled object used as the physics imposter
  89843. * @param type The type of the physics imposter
  89844. * @param _options The options for the physics imposter
  89845. * @param _scene The Babylon scene
  89846. */
  89847. constructor(
  89848. /**
  89849. * The physics-enabled object used as the physics imposter
  89850. */
  89851. object: IPhysicsEnabledObject,
  89852. /**
  89853. * The type of the physics imposter
  89854. */
  89855. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89856. /**
  89857. * This function will completly initialize this impostor.
  89858. * It will create a new body - but only if this mesh has no parent.
  89859. * If it has, this impostor will not be used other than to define the impostor
  89860. * of the child mesh.
  89861. * @hidden
  89862. */
  89863. _init(): void;
  89864. private _getPhysicsParent;
  89865. /**
  89866. * Should a new body be generated.
  89867. * @returns boolean specifying if body initialization is required
  89868. */
  89869. isBodyInitRequired(): boolean;
  89870. /**
  89871. * Sets the updated scaling
  89872. * @param updated Specifies if the scaling is updated
  89873. */
  89874. setScalingUpdated(): void;
  89875. /**
  89876. * Force a regeneration of this or the parent's impostor's body.
  89877. * Use under cautious - This will remove all joints already implemented.
  89878. */
  89879. forceUpdate(): void;
  89880. /**
  89881. * Gets the body that holds this impostor. Either its own, or its parent.
  89882. */
  89883. /**
  89884. * Set the physics body. Used mainly by the physics engine/plugin
  89885. */
  89886. physicsBody: any;
  89887. /**
  89888. * Get the parent of the physics imposter
  89889. * @returns Physics imposter or null
  89890. */
  89891. /**
  89892. * Sets the parent of the physics imposter
  89893. */
  89894. parent: Nullable<PhysicsImpostor>;
  89895. /**
  89896. * Resets the update flags
  89897. */
  89898. resetUpdateFlags(): void;
  89899. /**
  89900. * Gets the object extend size
  89901. * @returns the object extend size
  89902. */
  89903. getObjectExtendSize(): Vector3;
  89904. /**
  89905. * Gets the object center
  89906. * @returns The object center
  89907. */
  89908. getObjectCenter(): Vector3;
  89909. /**
  89910. * Get a specific parametes from the options parameter
  89911. * @param paramName The object parameter name
  89912. * @returns The object parameter
  89913. */
  89914. getParam(paramName: string): any;
  89915. /**
  89916. * Sets a specific parameter in the options given to the physics plugin
  89917. * @param paramName The parameter name
  89918. * @param value The value of the parameter
  89919. */
  89920. setParam(paramName: string, value: number): void;
  89921. /**
  89922. * Specifically change the body's mass option. Won't recreate the physics body object
  89923. * @param mass The mass of the physics imposter
  89924. */
  89925. setMass(mass: number): void;
  89926. /**
  89927. * Gets the linear velocity
  89928. * @returns linear velocity or null
  89929. */
  89930. getLinearVelocity(): Nullable<Vector3>;
  89931. /**
  89932. * Sets the linear velocity
  89933. * @param velocity linear velocity or null
  89934. */
  89935. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89936. /**
  89937. * Gets the angular velocity
  89938. * @returns angular velocity or null
  89939. */
  89940. getAngularVelocity(): Nullable<Vector3>;
  89941. /**
  89942. * Sets the angular velocity
  89943. * @param velocity The velocity or null
  89944. */
  89945. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89946. /**
  89947. * Execute a function with the physics plugin native code
  89948. * Provide a function the will have two variables - the world object and the physics body object
  89949. * @param func The function to execute with the physics plugin native code
  89950. */
  89951. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  89952. /**
  89953. * Register a function that will be executed before the physics world is stepping forward
  89954. * @param func The function to execute before the physics world is stepped forward
  89955. */
  89956. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89957. /**
  89958. * Unregister a function that will be executed before the physics world is stepping forward
  89959. * @param func The function to execute before the physics world is stepped forward
  89960. */
  89961. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89962. /**
  89963. * Register a function that will be executed after the physics step
  89964. * @param func The function to execute after physics step
  89965. */
  89966. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89967. /**
  89968. * Unregisters a function that will be executed after the physics step
  89969. * @param func The function to execute after physics step
  89970. */
  89971. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89972. /**
  89973. * register a function that will be executed when this impostor collides against a different body
  89974. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  89975. * @param func Callback that is executed on collision
  89976. */
  89977. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  89978. /**
  89979. * Unregisters the physics imposter on contact
  89980. * @param collideAgainst The physics object to collide against
  89981. * @param func Callback to execute on collision
  89982. */
  89983. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  89984. private _tmpQuat;
  89985. private _tmpQuat2;
  89986. /**
  89987. * Get the parent rotation
  89988. * @returns The parent rotation
  89989. */
  89990. getParentsRotation(): Quaternion;
  89991. /**
  89992. * this function is executed by the physics engine.
  89993. */
  89994. beforeStep: () => void;
  89995. /**
  89996. * this function is executed by the physics engine
  89997. */
  89998. afterStep: () => void;
  89999. /**
  90000. * Legacy collision detection event support
  90001. */
  90002. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90003. /**
  90004. * event and body object due to cannon's event-based architecture.
  90005. */
  90006. onCollide: (e: {
  90007. body: any;
  90008. }) => void;
  90009. /**
  90010. * Apply a force
  90011. * @param force The force to apply
  90012. * @param contactPoint The contact point for the force
  90013. * @returns The physics imposter
  90014. */
  90015. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90016. /**
  90017. * Apply an impulse
  90018. * @param force The impulse force
  90019. * @param contactPoint The contact point for the impulse force
  90020. * @returns The physics imposter
  90021. */
  90022. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90023. /**
  90024. * A help function to create a joint
  90025. * @param otherImpostor A physics imposter used to create a joint
  90026. * @param jointType The type of joint
  90027. * @param jointData The data for the joint
  90028. * @returns The physics imposter
  90029. */
  90030. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90031. /**
  90032. * Add a joint to this impostor with a different impostor
  90033. * @param otherImpostor A physics imposter used to add a joint
  90034. * @param joint The joint to add
  90035. * @returns The physics imposter
  90036. */
  90037. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90038. /**
  90039. * Add an anchor to a cloth impostor
  90040. * @param otherImpostor rigid impostor to anchor to
  90041. * @param width ratio across width from 0 to 1
  90042. * @param height ratio up height from 0 to 1
  90043. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90044. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90045. * @returns impostor the soft imposter
  90046. */
  90047. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90048. /**
  90049. * Add a hook to a rope impostor
  90050. * @param otherImpostor rigid impostor to anchor to
  90051. * @param length ratio across rope from 0 to 1
  90052. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90053. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90054. * @returns impostor the rope imposter
  90055. */
  90056. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90057. /**
  90058. * Will keep this body still, in a sleep mode.
  90059. * @returns the physics imposter
  90060. */
  90061. sleep(): PhysicsImpostor;
  90062. /**
  90063. * Wake the body up.
  90064. * @returns The physics imposter
  90065. */
  90066. wakeUp(): PhysicsImpostor;
  90067. /**
  90068. * Clones the physics imposter
  90069. * @param newObject The physics imposter clones to this physics-enabled object
  90070. * @returns A nullable physics imposter
  90071. */
  90072. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90073. /**
  90074. * Disposes the physics imposter
  90075. */
  90076. dispose(): void;
  90077. /**
  90078. * Sets the delta position
  90079. * @param position The delta position amount
  90080. */
  90081. setDeltaPosition(position: Vector3): void;
  90082. /**
  90083. * Sets the delta rotation
  90084. * @param rotation The delta rotation amount
  90085. */
  90086. setDeltaRotation(rotation: Quaternion): void;
  90087. /**
  90088. * Gets the box size of the physics imposter and stores the result in the input parameter
  90089. * @param result Stores the box size
  90090. * @returns The physics imposter
  90091. */
  90092. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90093. /**
  90094. * Gets the radius of the physics imposter
  90095. * @returns Radius of the physics imposter
  90096. */
  90097. getRadius(): number;
  90098. /**
  90099. * Sync a bone with this impostor
  90100. * @param bone The bone to sync to the impostor.
  90101. * @param boneMesh The mesh that the bone is influencing.
  90102. * @param jointPivot The pivot of the joint / bone in local space.
  90103. * @param distToJoint Optional distance from the impostor to the joint.
  90104. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90105. */
  90106. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90107. /**
  90108. * Sync impostor to a bone
  90109. * @param bone The bone that the impostor will be synced to.
  90110. * @param boneMesh The mesh that the bone is influencing.
  90111. * @param jointPivot The pivot of the joint / bone in local space.
  90112. * @param distToJoint Optional distance from the impostor to the joint.
  90113. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90114. * @param boneAxis Optional vector3 axis the bone is aligned with
  90115. */
  90116. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90117. /**
  90118. * No-Imposter type
  90119. */
  90120. static NoImpostor: number;
  90121. /**
  90122. * Sphere-Imposter type
  90123. */
  90124. static SphereImpostor: number;
  90125. /**
  90126. * Box-Imposter type
  90127. */
  90128. static BoxImpostor: number;
  90129. /**
  90130. * Plane-Imposter type
  90131. */
  90132. static PlaneImpostor: number;
  90133. /**
  90134. * Mesh-imposter type
  90135. */
  90136. static MeshImpostor: number;
  90137. /**
  90138. * Capsule-Impostor type (Ammo.js plugin only)
  90139. */
  90140. static CapsuleImpostor: number;
  90141. /**
  90142. * Cylinder-Imposter type
  90143. */
  90144. static CylinderImpostor: number;
  90145. /**
  90146. * Particle-Imposter type
  90147. */
  90148. static ParticleImpostor: number;
  90149. /**
  90150. * Heightmap-Imposter type
  90151. */
  90152. static HeightmapImpostor: number;
  90153. /**
  90154. * ConvexHull-Impostor type (Ammo.js plugin only)
  90155. */
  90156. static ConvexHullImpostor: number;
  90157. /**
  90158. * Rope-Imposter type
  90159. */
  90160. static RopeImpostor: number;
  90161. /**
  90162. * Cloth-Imposter type
  90163. */
  90164. static ClothImpostor: number;
  90165. /**
  90166. * Softbody-Imposter type
  90167. */
  90168. static SoftbodyImpostor: number;
  90169. }
  90170. }
  90171. declare module BABYLON {
  90172. /**
  90173. * @hidden
  90174. **/
  90175. export class _CreationDataStorage {
  90176. closePath?: boolean;
  90177. closeArray?: boolean;
  90178. idx: number[];
  90179. dashSize: number;
  90180. gapSize: number;
  90181. path3D: Path3D;
  90182. pathArray: Vector3[][];
  90183. arc: number;
  90184. radius: number;
  90185. cap: number;
  90186. tessellation: number;
  90187. }
  90188. /**
  90189. * @hidden
  90190. **/
  90191. class _InstanceDataStorage {
  90192. visibleInstances: any;
  90193. batchCache: _InstancesBatch;
  90194. instancesBufferSize: number;
  90195. instancesBuffer: Nullable<Buffer>;
  90196. instancesData: Float32Array;
  90197. overridenInstanceCount: number;
  90198. isFrozen: boolean;
  90199. previousBatch: Nullable<_InstancesBatch>;
  90200. hardwareInstancedRendering: boolean;
  90201. sideOrientation: number;
  90202. }
  90203. /**
  90204. * @hidden
  90205. **/
  90206. export class _InstancesBatch {
  90207. mustReturn: boolean;
  90208. visibleInstances: Nullable<InstancedMesh[]>[];
  90209. renderSelf: boolean[];
  90210. hardwareInstancedRendering: boolean[];
  90211. }
  90212. /**
  90213. * Class used to represent renderable models
  90214. */
  90215. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90216. /**
  90217. * Mesh side orientation : usually the external or front surface
  90218. */
  90219. static readonly FRONTSIDE: number;
  90220. /**
  90221. * Mesh side orientation : usually the internal or back surface
  90222. */
  90223. static readonly BACKSIDE: number;
  90224. /**
  90225. * Mesh side orientation : both internal and external or front and back surfaces
  90226. */
  90227. static readonly DOUBLESIDE: number;
  90228. /**
  90229. * Mesh side orientation : by default, `FRONTSIDE`
  90230. */
  90231. static readonly DEFAULTSIDE: number;
  90232. /**
  90233. * Mesh cap setting : no cap
  90234. */
  90235. static readonly NO_CAP: number;
  90236. /**
  90237. * Mesh cap setting : one cap at the beginning of the mesh
  90238. */
  90239. static readonly CAP_START: number;
  90240. /**
  90241. * Mesh cap setting : one cap at the end of the mesh
  90242. */
  90243. static readonly CAP_END: number;
  90244. /**
  90245. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90246. */
  90247. static readonly CAP_ALL: number;
  90248. /**
  90249. * Mesh pattern setting : no flip or rotate
  90250. */
  90251. static readonly NO_FLIP: number;
  90252. /**
  90253. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90254. */
  90255. static readonly FLIP_TILE: number;
  90256. /**
  90257. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90258. */
  90259. static readonly ROTATE_TILE: number;
  90260. /**
  90261. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90262. */
  90263. static readonly FLIP_ROW: number;
  90264. /**
  90265. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90266. */
  90267. static readonly ROTATE_ROW: number;
  90268. /**
  90269. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90270. */
  90271. static readonly FLIP_N_ROTATE_TILE: number;
  90272. /**
  90273. * Mesh pattern setting : rotate pattern and rotate
  90274. */
  90275. static readonly FLIP_N_ROTATE_ROW: number;
  90276. /**
  90277. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90278. */
  90279. static readonly CENTER: number;
  90280. /**
  90281. * Mesh tile positioning : part tiles on left
  90282. */
  90283. static readonly LEFT: number;
  90284. /**
  90285. * Mesh tile positioning : part tiles on right
  90286. */
  90287. static readonly RIGHT: number;
  90288. /**
  90289. * Mesh tile positioning : part tiles on top
  90290. */
  90291. static readonly TOP: number;
  90292. /**
  90293. * Mesh tile positioning : part tiles on bottom
  90294. */
  90295. static readonly BOTTOM: number;
  90296. /**
  90297. * Gets the default side orientation.
  90298. * @param orientation the orientation to value to attempt to get
  90299. * @returns the default orientation
  90300. * @hidden
  90301. */
  90302. static _GetDefaultSideOrientation(orientation?: number): number;
  90303. private _internalMeshDataInfo;
  90304. /**
  90305. * An event triggered before rendering the mesh
  90306. */
  90307. readonly onBeforeRenderObservable: Observable<Mesh>;
  90308. /**
  90309. * An event triggered before binding the mesh
  90310. */
  90311. readonly onBeforeBindObservable: Observable<Mesh>;
  90312. /**
  90313. * An event triggered after rendering the mesh
  90314. */
  90315. readonly onAfterRenderObservable: Observable<Mesh>;
  90316. /**
  90317. * An event triggered before drawing the mesh
  90318. */
  90319. readonly onBeforeDrawObservable: Observable<Mesh>;
  90320. private _onBeforeDrawObserver;
  90321. /**
  90322. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90323. */
  90324. onBeforeDraw: () => void;
  90325. readonly hasInstances: boolean;
  90326. /**
  90327. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90328. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90329. */
  90330. delayLoadState: number;
  90331. /**
  90332. * Gets the list of instances created from this mesh
  90333. * it is not supposed to be modified manually.
  90334. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90335. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90336. */
  90337. instances: InstancedMesh[];
  90338. /**
  90339. * Gets the file containing delay loading data for this mesh
  90340. */
  90341. delayLoadingFile: string;
  90342. /** @hidden */
  90343. _binaryInfo: any;
  90344. /**
  90345. * User defined function used to change how LOD level selection is done
  90346. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90347. */
  90348. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90349. /**
  90350. * Gets or sets the morph target manager
  90351. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90352. */
  90353. morphTargetManager: Nullable<MorphTargetManager>;
  90354. /** @hidden */
  90355. _creationDataStorage: Nullable<_CreationDataStorage>;
  90356. /** @hidden */
  90357. _geometry: Nullable<Geometry>;
  90358. /** @hidden */
  90359. _delayInfo: Array<string>;
  90360. /** @hidden */
  90361. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90362. /** @hidden */
  90363. _instanceDataStorage: _InstanceDataStorage;
  90364. private _effectiveMaterial;
  90365. /** @hidden */
  90366. _shouldGenerateFlatShading: boolean;
  90367. /** @hidden */
  90368. _originalBuilderSideOrientation: number;
  90369. /**
  90370. * Use this property to change the original side orientation defined at construction time
  90371. */
  90372. overrideMaterialSideOrientation: Nullable<number>;
  90373. /**
  90374. * Gets the source mesh (the one used to clone this one from)
  90375. */
  90376. readonly source: Nullable<Mesh>;
  90377. /**
  90378. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90379. */
  90380. isUnIndexed: boolean;
  90381. /**
  90382. * @constructor
  90383. * @param name The value used by scene.getMeshByName() to do a lookup.
  90384. * @param scene The scene to add this mesh to.
  90385. * @param parent The parent of this mesh, if it has one
  90386. * @param source An optional Mesh from which geometry is shared, cloned.
  90387. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90388. * When false, achieved by calling a clone(), also passing False.
  90389. * This will make creation of children, recursive.
  90390. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90391. */
  90392. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90393. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90394. /**
  90395. * Gets the class name
  90396. * @returns the string "Mesh".
  90397. */
  90398. getClassName(): string;
  90399. /** @hidden */
  90400. readonly _isMesh: boolean;
  90401. /**
  90402. * Returns a description of this mesh
  90403. * @param fullDetails define if full details about this mesh must be used
  90404. * @returns a descriptive string representing this mesh
  90405. */
  90406. toString(fullDetails?: boolean): string;
  90407. /** @hidden */
  90408. _unBindEffect(): void;
  90409. /**
  90410. * Gets a boolean indicating if this mesh has LOD
  90411. */
  90412. readonly hasLODLevels: boolean;
  90413. /**
  90414. * Gets the list of MeshLODLevel associated with the current mesh
  90415. * @returns an array of MeshLODLevel
  90416. */
  90417. getLODLevels(): MeshLODLevel[];
  90418. private _sortLODLevels;
  90419. /**
  90420. * Add a mesh as LOD level triggered at the given distance.
  90421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90422. * @param distance The distance from the center of the object to show this level
  90423. * @param mesh The mesh to be added as LOD level (can be null)
  90424. * @return This mesh (for chaining)
  90425. */
  90426. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90427. /**
  90428. * Returns the LOD level mesh at the passed distance or null if not found.
  90429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90430. * @param distance The distance from the center of the object to show this level
  90431. * @returns a Mesh or `null`
  90432. */
  90433. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90434. /**
  90435. * Remove a mesh from the LOD array
  90436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90437. * @param mesh defines the mesh to be removed
  90438. * @return This mesh (for chaining)
  90439. */
  90440. removeLODLevel(mesh: Mesh): Mesh;
  90441. /**
  90442. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90444. * @param camera defines the camera to use to compute distance
  90445. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90446. * @return This mesh (for chaining)
  90447. */
  90448. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90449. /**
  90450. * Gets the mesh internal Geometry object
  90451. */
  90452. readonly geometry: Nullable<Geometry>;
  90453. /**
  90454. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90455. * @returns the total number of vertices
  90456. */
  90457. getTotalVertices(): number;
  90458. /**
  90459. * Returns the content of an associated vertex buffer
  90460. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90461. * - VertexBuffer.PositionKind
  90462. * - VertexBuffer.UVKind
  90463. * - VertexBuffer.UV2Kind
  90464. * - VertexBuffer.UV3Kind
  90465. * - VertexBuffer.UV4Kind
  90466. * - VertexBuffer.UV5Kind
  90467. * - VertexBuffer.UV6Kind
  90468. * - VertexBuffer.ColorKind
  90469. * - VertexBuffer.MatricesIndicesKind
  90470. * - VertexBuffer.MatricesIndicesExtraKind
  90471. * - VertexBuffer.MatricesWeightsKind
  90472. * - VertexBuffer.MatricesWeightsExtraKind
  90473. * @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
  90474. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90475. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90476. */
  90477. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90478. /**
  90479. * Returns the mesh VertexBuffer object from the requested `kind`
  90480. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90481. * - VertexBuffer.PositionKind
  90482. * - VertexBuffer.NormalKind
  90483. * - VertexBuffer.UVKind
  90484. * - VertexBuffer.UV2Kind
  90485. * - VertexBuffer.UV3Kind
  90486. * - VertexBuffer.UV4Kind
  90487. * - VertexBuffer.UV5Kind
  90488. * - VertexBuffer.UV6Kind
  90489. * - VertexBuffer.ColorKind
  90490. * - VertexBuffer.MatricesIndicesKind
  90491. * - VertexBuffer.MatricesIndicesExtraKind
  90492. * - VertexBuffer.MatricesWeightsKind
  90493. * - VertexBuffer.MatricesWeightsExtraKind
  90494. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90495. */
  90496. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90497. /**
  90498. * Tests if a specific vertex buffer is associated with this mesh
  90499. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90500. * - VertexBuffer.PositionKind
  90501. * - VertexBuffer.NormalKind
  90502. * - VertexBuffer.UVKind
  90503. * - VertexBuffer.UV2Kind
  90504. * - VertexBuffer.UV3Kind
  90505. * - VertexBuffer.UV4Kind
  90506. * - VertexBuffer.UV5Kind
  90507. * - VertexBuffer.UV6Kind
  90508. * - VertexBuffer.ColorKind
  90509. * - VertexBuffer.MatricesIndicesKind
  90510. * - VertexBuffer.MatricesIndicesExtraKind
  90511. * - VertexBuffer.MatricesWeightsKind
  90512. * - VertexBuffer.MatricesWeightsExtraKind
  90513. * @returns a boolean
  90514. */
  90515. isVerticesDataPresent(kind: string): boolean;
  90516. /**
  90517. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90518. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90519. * - VertexBuffer.PositionKind
  90520. * - VertexBuffer.UVKind
  90521. * - VertexBuffer.UV2Kind
  90522. * - VertexBuffer.UV3Kind
  90523. * - VertexBuffer.UV4Kind
  90524. * - VertexBuffer.UV5Kind
  90525. * - VertexBuffer.UV6Kind
  90526. * - VertexBuffer.ColorKind
  90527. * - VertexBuffer.MatricesIndicesKind
  90528. * - VertexBuffer.MatricesIndicesExtraKind
  90529. * - VertexBuffer.MatricesWeightsKind
  90530. * - VertexBuffer.MatricesWeightsExtraKind
  90531. * @returns a boolean
  90532. */
  90533. isVertexBufferUpdatable(kind: string): boolean;
  90534. /**
  90535. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90536. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90537. * - VertexBuffer.PositionKind
  90538. * - VertexBuffer.NormalKind
  90539. * - VertexBuffer.UVKind
  90540. * - VertexBuffer.UV2Kind
  90541. * - VertexBuffer.UV3Kind
  90542. * - VertexBuffer.UV4Kind
  90543. * - VertexBuffer.UV5Kind
  90544. * - VertexBuffer.UV6Kind
  90545. * - VertexBuffer.ColorKind
  90546. * - VertexBuffer.MatricesIndicesKind
  90547. * - VertexBuffer.MatricesIndicesExtraKind
  90548. * - VertexBuffer.MatricesWeightsKind
  90549. * - VertexBuffer.MatricesWeightsExtraKind
  90550. * @returns an array of strings
  90551. */
  90552. getVerticesDataKinds(): string[];
  90553. /**
  90554. * Returns a positive integer : the total number of indices in this mesh geometry.
  90555. * @returns the numner of indices or zero if the mesh has no geometry.
  90556. */
  90557. getTotalIndices(): number;
  90558. /**
  90559. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90560. * @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.
  90561. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90562. * @returns the indices array or an empty array if the mesh has no geometry
  90563. */
  90564. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90565. readonly isBlocked: boolean;
  90566. /**
  90567. * Determine if the current mesh is ready to be rendered
  90568. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90569. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90570. * @returns true if all associated assets are ready (material, textures, shaders)
  90571. */
  90572. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90573. /**
  90574. * 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.
  90575. */
  90576. readonly areNormalsFrozen: boolean;
  90577. /**
  90578. * 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.
  90579. * @returns the current mesh
  90580. */
  90581. freezeNormals(): Mesh;
  90582. /**
  90583. * 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
  90584. * @returns the current mesh
  90585. */
  90586. unfreezeNormals(): Mesh;
  90587. /**
  90588. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90589. */
  90590. overridenInstanceCount: number;
  90591. /** @hidden */
  90592. _preActivate(): Mesh;
  90593. /** @hidden */
  90594. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90595. /** @hidden */
  90596. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90597. /**
  90598. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90599. * This means the mesh underlying bounding box and sphere are recomputed.
  90600. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90601. * @returns the current mesh
  90602. */
  90603. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90604. /** @hidden */
  90605. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90606. /**
  90607. * This function will subdivide the mesh into multiple submeshes
  90608. * @param count defines the expected number of submeshes
  90609. */
  90610. subdivide(count: number): void;
  90611. /**
  90612. * Copy a FloatArray into a specific associated vertex buffer
  90613. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90614. * - VertexBuffer.PositionKind
  90615. * - VertexBuffer.UVKind
  90616. * - VertexBuffer.UV2Kind
  90617. * - VertexBuffer.UV3Kind
  90618. * - VertexBuffer.UV4Kind
  90619. * - VertexBuffer.UV5Kind
  90620. * - VertexBuffer.UV6Kind
  90621. * - VertexBuffer.ColorKind
  90622. * - VertexBuffer.MatricesIndicesKind
  90623. * - VertexBuffer.MatricesIndicesExtraKind
  90624. * - VertexBuffer.MatricesWeightsKind
  90625. * - VertexBuffer.MatricesWeightsExtraKind
  90626. * @param data defines the data source
  90627. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90628. * @param stride defines the data stride size (can be null)
  90629. * @returns the current mesh
  90630. */
  90631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90632. /**
  90633. * Flags an associated vertex buffer as updatable
  90634. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90635. * - VertexBuffer.PositionKind
  90636. * - VertexBuffer.UVKind
  90637. * - VertexBuffer.UV2Kind
  90638. * - VertexBuffer.UV3Kind
  90639. * - VertexBuffer.UV4Kind
  90640. * - VertexBuffer.UV5Kind
  90641. * - VertexBuffer.UV6Kind
  90642. * - VertexBuffer.ColorKind
  90643. * - VertexBuffer.MatricesIndicesKind
  90644. * - VertexBuffer.MatricesIndicesExtraKind
  90645. * - VertexBuffer.MatricesWeightsKind
  90646. * - VertexBuffer.MatricesWeightsExtraKind
  90647. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90648. */
  90649. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90650. /**
  90651. * Sets the mesh global Vertex Buffer
  90652. * @param buffer defines the buffer to use
  90653. * @returns the current mesh
  90654. */
  90655. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90656. /**
  90657. * Update a specific associated vertex buffer
  90658. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90659. * - VertexBuffer.PositionKind
  90660. * - VertexBuffer.UVKind
  90661. * - VertexBuffer.UV2Kind
  90662. * - VertexBuffer.UV3Kind
  90663. * - VertexBuffer.UV4Kind
  90664. * - VertexBuffer.UV5Kind
  90665. * - VertexBuffer.UV6Kind
  90666. * - VertexBuffer.ColorKind
  90667. * - VertexBuffer.MatricesIndicesKind
  90668. * - VertexBuffer.MatricesIndicesExtraKind
  90669. * - VertexBuffer.MatricesWeightsKind
  90670. * - VertexBuffer.MatricesWeightsExtraKind
  90671. * @param data defines the data source
  90672. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90673. * @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)
  90674. * @returns the current mesh
  90675. */
  90676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90677. /**
  90678. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90679. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90680. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90681. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90682. * @returns the current mesh
  90683. */
  90684. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90685. /**
  90686. * Creates a un-shared specific occurence of the geometry for the mesh.
  90687. * @returns the current mesh
  90688. */
  90689. makeGeometryUnique(): Mesh;
  90690. /**
  90691. * Set the index buffer of this mesh
  90692. * @param indices defines the source data
  90693. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90694. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90695. * @returns the current mesh
  90696. */
  90697. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90698. /**
  90699. * Update the current index buffer
  90700. * @param indices defines the source data
  90701. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90702. * @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)
  90703. * @returns the current mesh
  90704. */
  90705. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90706. /**
  90707. * Invert the geometry to move from a right handed system to a left handed one.
  90708. * @returns the current mesh
  90709. */
  90710. toLeftHanded(): Mesh;
  90711. /** @hidden */
  90712. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90713. /** @hidden */
  90714. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90715. /**
  90716. * Registers for this mesh a javascript function called just before the rendering process
  90717. * @param func defines the function to call before rendering this mesh
  90718. * @returns the current mesh
  90719. */
  90720. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90721. /**
  90722. * Disposes a previously registered javascript function called before the rendering
  90723. * @param func defines the function to remove
  90724. * @returns the current mesh
  90725. */
  90726. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90727. /**
  90728. * Registers for this mesh a javascript function called just after the rendering is complete
  90729. * @param func defines the function to call after rendering this mesh
  90730. * @returns the current mesh
  90731. */
  90732. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90733. /**
  90734. * Disposes a previously registered javascript function called after the rendering.
  90735. * @param func defines the function to remove
  90736. * @returns the current mesh
  90737. */
  90738. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90739. /** @hidden */
  90740. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90741. /** @hidden */
  90742. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90743. /** @hidden */
  90744. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90745. /** @hidden */
  90746. _rebuild(): void;
  90747. /** @hidden */
  90748. _freeze(): void;
  90749. /** @hidden */
  90750. _unFreeze(): void;
  90751. /**
  90752. * 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
  90753. * @param subMesh defines the subMesh to render
  90754. * @param enableAlphaMode defines if alpha mode can be changed
  90755. * @returns the current mesh
  90756. */
  90757. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90758. private _onBeforeDraw;
  90759. /**
  90760. * Renormalize the mesh and patch it up if there are no weights
  90761. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90762. * However in the case of zero weights then we set just a single influence to 1.
  90763. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90764. */
  90765. cleanMatrixWeights(): void;
  90766. private normalizeSkinFourWeights;
  90767. private normalizeSkinWeightsAndExtra;
  90768. /**
  90769. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90770. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90771. * the user know there was an issue with importing the mesh
  90772. * @returns a validation object with skinned, valid and report string
  90773. */
  90774. validateSkinning(): {
  90775. skinned: boolean;
  90776. valid: boolean;
  90777. report: string;
  90778. };
  90779. /** @hidden */
  90780. _checkDelayState(): Mesh;
  90781. private _queueLoad;
  90782. /**
  90783. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90784. * A mesh is in the frustum if its bounding box intersects the frustum
  90785. * @param frustumPlanes defines the frustum to test
  90786. * @returns true if the mesh is in the frustum planes
  90787. */
  90788. isInFrustum(frustumPlanes: Plane[]): boolean;
  90789. /**
  90790. * Sets the mesh material by the material or multiMaterial `id` property
  90791. * @param id is a string identifying the material or the multiMaterial
  90792. * @returns the current mesh
  90793. */
  90794. setMaterialByID(id: string): Mesh;
  90795. /**
  90796. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90797. * @returns an array of IAnimatable
  90798. */
  90799. getAnimatables(): IAnimatable[];
  90800. /**
  90801. * Modifies the mesh geometry according to the passed transformation matrix.
  90802. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90803. * The mesh normals are modified using the same transformation.
  90804. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90805. * @param transform defines the transform matrix to use
  90806. * @see http://doc.babylonjs.com/resources/baking_transformations
  90807. * @returns the current mesh
  90808. */
  90809. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90810. /**
  90811. * Modifies the mesh geometry according to its own current World Matrix.
  90812. * The mesh World Matrix is then reset.
  90813. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90814. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90815. * @see http://doc.babylonjs.com/resources/baking_transformations
  90816. * @returns the current mesh
  90817. */
  90818. bakeCurrentTransformIntoVertices(): Mesh;
  90819. /** @hidden */
  90820. readonly _positions: Nullable<Vector3[]>;
  90821. /** @hidden */
  90822. _resetPointsArrayCache(): Mesh;
  90823. /** @hidden */
  90824. _generatePointsArray(): boolean;
  90825. /**
  90826. * Returns a new Mesh object generated from the current mesh properties.
  90827. * This method must not get confused with createInstance()
  90828. * @param name is a string, the name given to the new mesh
  90829. * @param newParent can be any Node object (default `null`)
  90830. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90831. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90832. * @returns a new mesh
  90833. */
  90834. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90835. /**
  90836. * Releases resources associated with this mesh.
  90837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90839. */
  90840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90841. /**
  90842. * Modifies the mesh geometry according to a displacement map.
  90843. * 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.
  90844. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90845. * @param url is a string, the URL from the image file is to be downloaded.
  90846. * @param minHeight is the lower limit of the displacement.
  90847. * @param maxHeight is the upper limit of the displacement.
  90848. * @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.
  90849. * @param uvOffset is an optional vector2 used to offset UV.
  90850. * @param uvScale is an optional vector2 used to scale UV.
  90851. * @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.
  90852. * @returns the Mesh.
  90853. */
  90854. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90855. /**
  90856. * Modifies the mesh geometry according to a displacementMap buffer.
  90857. * 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.
  90858. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90859. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90860. * @param heightMapWidth is the width of the buffer image.
  90861. * @param heightMapHeight is the height of the buffer image.
  90862. * @param minHeight is the lower limit of the displacement.
  90863. * @param maxHeight is the upper limit of the displacement.
  90864. * @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.
  90865. * @param uvOffset is an optional vector2 used to offset UV.
  90866. * @param uvScale is an optional vector2 used to scale UV.
  90867. * @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.
  90868. * @returns the Mesh.
  90869. */
  90870. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90871. /**
  90872. * Modify the mesh to get a flat shading rendering.
  90873. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90874. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90875. * @returns current mesh
  90876. */
  90877. convertToFlatShadedMesh(): Mesh;
  90878. /**
  90879. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90880. * In other words, more vertices, no more indices and a single bigger VBO.
  90881. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90882. * @returns current mesh
  90883. */
  90884. convertToUnIndexedMesh(): Mesh;
  90885. /**
  90886. * Inverses facet orientations.
  90887. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90888. * @param flipNormals will also inverts the normals
  90889. * @returns current mesh
  90890. */
  90891. flipFaces(flipNormals?: boolean): Mesh;
  90892. /**
  90893. * Increase the number of facets and hence vertices in a mesh
  90894. * Vertex normals are interpolated from existing vertex normals
  90895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90896. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90897. */
  90898. increaseVertices(numberPerEdge: number): void;
  90899. /**
  90900. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90901. * This will undo any application of covertToFlatShadedMesh
  90902. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90903. */
  90904. forceSharedVertices(): void;
  90905. /** @hidden */
  90906. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90907. /** @hidden */
  90908. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90909. /**
  90910. * Creates a new InstancedMesh object from the mesh model.
  90911. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90912. * @param name defines the name of the new instance
  90913. * @returns a new InstancedMesh
  90914. */
  90915. createInstance(name: string): InstancedMesh;
  90916. /**
  90917. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90918. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90919. * @returns the current mesh
  90920. */
  90921. synchronizeInstances(): Mesh;
  90922. /**
  90923. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90924. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90925. * This should be used together with the simplification to avoid disappearing triangles.
  90926. * @param successCallback an optional success callback to be called after the optimization finished.
  90927. * @returns the current mesh
  90928. */
  90929. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90930. /**
  90931. * Serialize current mesh
  90932. * @param serializationObject defines the object which will receive the serialization data
  90933. */
  90934. serialize(serializationObject: any): void;
  90935. /** @hidden */
  90936. _syncGeometryWithMorphTargetManager(): void;
  90937. /** @hidden */
  90938. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90939. /**
  90940. * Returns a new Mesh object parsed from the source provided.
  90941. * @param parsedMesh is the source
  90942. * @param scene defines the hosting scene
  90943. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90944. * @returns a new Mesh
  90945. */
  90946. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90947. /**
  90948. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90949. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90950. * @param name defines the name of the mesh to create
  90951. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90952. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90953. * @param closePath creates a seam between the first and the last points of each path of the path array
  90954. * @param offset is taken in account only if the `pathArray` is containing a single path
  90955. * @param scene defines the hosting scene
  90956. * @param updatable defines if the mesh must be flagged as updatable
  90957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90958. * @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)
  90959. * @returns a new Mesh
  90960. */
  90961. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90962. /**
  90963. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90964. * @param name defines the name of the mesh to create
  90965. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90966. * @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
  90967. * @param scene defines the hosting scene
  90968. * @param updatable defines if the mesh must be flagged as updatable
  90969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90970. * @returns a new Mesh
  90971. */
  90972. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90973. /**
  90974. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90975. * @param name defines the name of the mesh to create
  90976. * @param size sets the size (float) of each box side (default 1)
  90977. * @param scene defines the hosting scene
  90978. * @param updatable defines if the mesh must be flagged as updatable
  90979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90980. * @returns a new Mesh
  90981. */
  90982. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90983. /**
  90984. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90985. * @param name defines the name of the mesh to create
  90986. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90987. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90988. * @param scene defines the hosting scene
  90989. * @param updatable defines if the mesh must be flagged as updatable
  90990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90991. * @returns a new Mesh
  90992. */
  90993. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90994. /**
  90995. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90996. * @param name defines the name of the mesh to create
  90997. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90998. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90999. * @param scene defines the hosting scene
  91000. * @returns a new Mesh
  91001. */
  91002. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91003. /**
  91004. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91005. * @param name defines the name of the mesh to create
  91006. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91007. * @param diameterTop set the top cap diameter (floats, default 1)
  91008. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91009. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91010. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91011. * @param scene defines the hosting scene
  91012. * @param updatable defines if the mesh must be flagged as updatable
  91013. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91014. * @returns a new Mesh
  91015. */
  91016. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91017. /**
  91018. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91019. * @param name defines the name of the mesh to create
  91020. * @param diameter sets the diameter size (float) of the torus (default 1)
  91021. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91022. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91023. * @param scene defines the hosting scene
  91024. * @param updatable defines if the mesh must be flagged as updatable
  91025. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91026. * @returns a new Mesh
  91027. */
  91028. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91029. /**
  91030. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91031. * @param name defines the name of the mesh to create
  91032. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91033. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91034. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91035. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91036. * @param p the number of windings on X axis (positive integers, default 2)
  91037. * @param q the number of windings on Y axis (positive integers, default 3)
  91038. * @param scene defines the hosting scene
  91039. * @param updatable defines if the mesh must be flagged as updatable
  91040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91041. * @returns a new Mesh
  91042. */
  91043. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91044. /**
  91045. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91046. * @param name defines the name of the mesh to create
  91047. * @param points is an array successive Vector3
  91048. * @param scene defines the hosting scene
  91049. * @param updatable defines if the mesh must be flagged as updatable
  91050. * @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).
  91051. * @returns a new Mesh
  91052. */
  91053. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91054. /**
  91055. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91056. * @param name defines the name of the mesh to create
  91057. * @param points is an array successive Vector3
  91058. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91059. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91060. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91061. * @param scene defines the hosting scene
  91062. * @param updatable defines if the mesh must be flagged as updatable
  91063. * @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)
  91064. * @returns a new Mesh
  91065. */
  91066. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91067. /**
  91068. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91070. * 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.
  91071. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91072. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91073. * Remember you can only change the shape positions, not their number when updating a polygon.
  91074. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91075. * @param name defines the name of the mesh to create
  91076. * @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
  91077. * @param scene defines the hosting scene
  91078. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91079. * @param updatable defines if the mesh must be flagged as updatable
  91080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91081. * @param earcutInjection can be used to inject your own earcut reference
  91082. * @returns a new Mesh
  91083. */
  91084. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91085. /**
  91086. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91087. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91088. * @param name defines the name of the mesh to create
  91089. * @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
  91090. * @param depth defines the height of extrusion
  91091. * @param scene defines the hosting scene
  91092. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91093. * @param updatable defines if the mesh must be flagged as updatable
  91094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91095. * @param earcutInjection can be used to inject your own earcut reference
  91096. * @returns a new Mesh
  91097. */
  91098. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91099. /**
  91100. * Creates an extruded shape mesh.
  91101. * 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
  91102. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91104. * @param name defines the name of the mesh to create
  91105. * @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
  91106. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91107. * @param scale is the value to scale the shape
  91108. * @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
  91109. * @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
  91110. * @param scene defines the hosting scene
  91111. * @param updatable defines if the mesh must be flagged as updatable
  91112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91113. * @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)
  91114. * @returns a new Mesh
  91115. */
  91116. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91117. /**
  91118. * Creates an custom extruded shape mesh.
  91119. * The custom extrusion is a parametric shape.
  91120. * It has no predefined shape. Its final shape will depend on the input parameters.
  91121. * Please consider using the same method from the MeshBuilder class instead
  91122. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91123. * @param name defines the name of the mesh to create
  91124. * @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
  91125. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91126. * @param scaleFunction is a custom Javascript function called on each path point
  91127. * @param rotationFunction is a custom Javascript function called on each path point
  91128. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91129. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91130. * @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
  91131. * @param scene defines the hosting scene
  91132. * @param updatable defines if the mesh must be flagged as updatable
  91133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91134. * @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)
  91135. * @returns a new Mesh
  91136. */
  91137. 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;
  91138. /**
  91139. * Creates lathe mesh.
  91140. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91141. * Please consider using the same method from the MeshBuilder class instead
  91142. * @param name defines the name of the mesh to create
  91143. * @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
  91144. * @param radius is the radius value of the lathe
  91145. * @param tessellation is the side number of the lathe.
  91146. * @param scene defines the hosting scene
  91147. * @param updatable defines if the mesh must be flagged as updatable
  91148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91149. * @returns a new Mesh
  91150. */
  91151. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91152. /**
  91153. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91154. * @param name defines the name of the mesh to create
  91155. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91156. * @param scene defines the hosting scene
  91157. * @param updatable defines if the mesh must be flagged as updatable
  91158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91159. * @returns a new Mesh
  91160. */
  91161. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91162. /**
  91163. * Creates a ground mesh.
  91164. * Please consider using the same method from the MeshBuilder class instead
  91165. * @param name defines the name of the mesh to create
  91166. * @param width set the width of the ground
  91167. * @param height set the height of the ground
  91168. * @param subdivisions sets the number of subdivisions per side
  91169. * @param scene defines the hosting scene
  91170. * @param updatable defines if the mesh must be flagged as updatable
  91171. * @returns a new Mesh
  91172. */
  91173. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91174. /**
  91175. * Creates a tiled ground mesh.
  91176. * Please consider using the same method from the MeshBuilder class instead
  91177. * @param name defines the name of the mesh to create
  91178. * @param xmin set the ground minimum X coordinate
  91179. * @param zmin set the ground minimum Y coordinate
  91180. * @param xmax set the ground maximum X coordinate
  91181. * @param zmax set the ground maximum Z coordinate
  91182. * @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
  91183. * @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
  91184. * @param scene defines the hosting scene
  91185. * @param updatable defines if the mesh must be flagged as updatable
  91186. * @returns a new Mesh
  91187. */
  91188. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91189. w: number;
  91190. h: number;
  91191. }, precision: {
  91192. w: number;
  91193. h: number;
  91194. }, scene: Scene, updatable?: boolean): Mesh;
  91195. /**
  91196. * Creates a ground mesh from a height map.
  91197. * Please consider using the same method from the MeshBuilder class instead
  91198. * @see http://doc.babylonjs.com/babylon101/height_map
  91199. * @param name defines the name of the mesh to create
  91200. * @param url sets the URL of the height map image resource
  91201. * @param width set the ground width size
  91202. * @param height set the ground height size
  91203. * @param subdivisions sets the number of subdivision per side
  91204. * @param minHeight is the minimum altitude on the ground
  91205. * @param maxHeight is the maximum altitude on the ground
  91206. * @param scene defines the hosting scene
  91207. * @param updatable defines if the mesh must be flagged as updatable
  91208. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91209. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91210. * @returns a new Mesh
  91211. */
  91212. 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;
  91213. /**
  91214. * Creates a tube mesh.
  91215. * The tube is a parametric shape.
  91216. * It has no predefined shape. Its final shape will depend on the input parameters.
  91217. * Please consider using the same method from the MeshBuilder class instead
  91218. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91219. * @param name defines the name of the mesh to create
  91220. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91221. * @param radius sets the tube radius size
  91222. * @param tessellation is the number of sides on the tubular surface
  91223. * @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
  91224. * @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
  91225. * @param scene defines the hosting scene
  91226. * @param updatable defines if the mesh must be flagged as updatable
  91227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91228. * @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)
  91229. * @returns a new Mesh
  91230. */
  91231. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91232. (i: number, distance: number): number;
  91233. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91234. /**
  91235. * Creates a polyhedron mesh.
  91236. * Please consider using the same method from the MeshBuilder class instead.
  91237. * * 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
  91238. * * The parameter `size` (positive float, default 1) sets the polygon size
  91239. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91240. * * 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`
  91241. * * 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
  91242. * * 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)`)
  91243. * * 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
  91244. * * 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
  91245. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91246. * * If you create a double-sided mesh, you can choose what parts of 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
  91247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91248. * @param name defines the name of the mesh to create
  91249. * @param options defines the options used to create the mesh
  91250. * @param scene defines the hosting scene
  91251. * @returns a new Mesh
  91252. */
  91253. static CreatePolyhedron(name: string, options: {
  91254. type?: number;
  91255. size?: number;
  91256. sizeX?: number;
  91257. sizeY?: number;
  91258. sizeZ?: number;
  91259. custom?: any;
  91260. faceUV?: Vector4[];
  91261. faceColors?: Color4[];
  91262. updatable?: boolean;
  91263. sideOrientation?: number;
  91264. }, scene: Scene): Mesh;
  91265. /**
  91266. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91267. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91268. * * 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`)
  91269. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91270. * * 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
  91271. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91272. * * If you create a double-sided mesh, you can choose what parts of 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
  91273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91274. * @param name defines the name of the mesh
  91275. * @param options defines the options used to create the mesh
  91276. * @param scene defines the hosting scene
  91277. * @returns a new Mesh
  91278. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91279. */
  91280. static CreateIcoSphere(name: string, options: {
  91281. radius?: number;
  91282. flat?: boolean;
  91283. subdivisions?: number;
  91284. sideOrientation?: number;
  91285. updatable?: boolean;
  91286. }, scene: Scene): Mesh;
  91287. /**
  91288. * Creates a decal mesh.
  91289. * Please consider using the same method from the MeshBuilder class instead.
  91290. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91291. * @param name defines the name of the mesh
  91292. * @param sourceMesh defines the mesh receiving the decal
  91293. * @param position sets the position of the decal in world coordinates
  91294. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91295. * @param size sets the decal scaling
  91296. * @param angle sets the angle to rotate the decal
  91297. * @returns a new Mesh
  91298. */
  91299. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91300. /**
  91301. * Prepare internal position array for software CPU skinning
  91302. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91303. */
  91304. setPositionsForCPUSkinning(): Float32Array;
  91305. /**
  91306. * Prepare internal normal array for software CPU skinning
  91307. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91308. */
  91309. setNormalsForCPUSkinning(): Float32Array;
  91310. /**
  91311. * Updates the vertex buffer by applying transformation from the bones
  91312. * @param skeleton defines the skeleton to apply to current mesh
  91313. * @returns the current mesh
  91314. */
  91315. applySkeleton(skeleton: Skeleton): Mesh;
  91316. /**
  91317. * 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
  91318. * @param meshes defines the list of meshes to scan
  91319. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91320. */
  91321. static MinMax(meshes: AbstractMesh[]): {
  91322. min: Vector3;
  91323. max: Vector3;
  91324. };
  91325. /**
  91326. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91327. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91328. * @returns a vector3
  91329. */
  91330. static Center(meshesOrMinMaxVector: {
  91331. min: Vector3;
  91332. max: Vector3;
  91333. } | AbstractMesh[]): Vector3;
  91334. /**
  91335. * Merge the array of meshes into a single mesh for performance reasons.
  91336. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91337. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91338. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91339. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91340. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91341. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91342. * @returns a new mesh
  91343. */
  91344. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91345. /** @hidden */
  91346. addInstance(instance: InstancedMesh): void;
  91347. /** @hidden */
  91348. removeInstance(instance: InstancedMesh): void;
  91349. }
  91350. }
  91351. declare module BABYLON {
  91352. /**
  91353. * This is the base class of all the camera used in the application.
  91354. * @see http://doc.babylonjs.com/features/cameras
  91355. */
  91356. export class Camera extends Node {
  91357. /** @hidden */
  91358. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91359. /**
  91360. * This is the default projection mode used by the cameras.
  91361. * It helps recreating a feeling of perspective and better appreciate depth.
  91362. * This is the best way to simulate real life cameras.
  91363. */
  91364. static readonly PERSPECTIVE_CAMERA: number;
  91365. /**
  91366. * This helps creating camera with an orthographic mode.
  91367. * 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.
  91368. */
  91369. static readonly ORTHOGRAPHIC_CAMERA: number;
  91370. /**
  91371. * This is the default FOV mode for perspective cameras.
  91372. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91373. */
  91374. static readonly FOVMODE_VERTICAL_FIXED: number;
  91375. /**
  91376. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91377. */
  91378. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91379. /**
  91380. * This specifies ther is no need for a camera rig.
  91381. * Basically only one eye is rendered corresponding to the camera.
  91382. */
  91383. static readonly RIG_MODE_NONE: number;
  91384. /**
  91385. * Simulates a camera Rig with one blue eye and one red eye.
  91386. * This can be use with 3d blue and red glasses.
  91387. */
  91388. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91389. /**
  91390. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91391. */
  91392. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91393. /**
  91394. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91395. */
  91396. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91397. /**
  91398. * Defines that both eyes of the camera will be rendered over under each other.
  91399. */
  91400. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91401. /**
  91402. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91403. */
  91404. static readonly RIG_MODE_VR: number;
  91405. /**
  91406. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91407. */
  91408. static readonly RIG_MODE_WEBVR: number;
  91409. /**
  91410. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91411. */
  91412. static readonly RIG_MODE_CUSTOM: number;
  91413. /**
  91414. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91415. */
  91416. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91417. /**
  91418. * Define the input manager associated with the camera.
  91419. */
  91420. inputs: CameraInputsManager<Camera>;
  91421. /** @hidden */
  91422. _position: Vector3;
  91423. /**
  91424. * Define the current local position of the camera in the scene
  91425. */
  91426. position: Vector3;
  91427. /**
  91428. * The vector the camera should consider as up.
  91429. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91430. */
  91431. upVector: Vector3;
  91432. /**
  91433. * Define the current limit on the left side for an orthographic camera
  91434. * In scene unit
  91435. */
  91436. orthoLeft: Nullable<number>;
  91437. /**
  91438. * Define the current limit on the right side for an orthographic camera
  91439. * In scene unit
  91440. */
  91441. orthoRight: Nullable<number>;
  91442. /**
  91443. * Define the current limit on the bottom side for an orthographic camera
  91444. * In scene unit
  91445. */
  91446. orthoBottom: Nullable<number>;
  91447. /**
  91448. * Define the current limit on the top side for an orthographic camera
  91449. * In scene unit
  91450. */
  91451. orthoTop: Nullable<number>;
  91452. /**
  91453. * Field Of View is set in Radians. (default is 0.8)
  91454. */
  91455. fov: number;
  91456. /**
  91457. * Define the minimum distance the camera can see from.
  91458. * This is important to note that the depth buffer are not infinite and the closer it starts
  91459. * the more your scene might encounter depth fighting issue.
  91460. */
  91461. minZ: number;
  91462. /**
  91463. * Define the maximum distance the camera can see to.
  91464. * This is important to note that the depth buffer are not infinite and the further it end
  91465. * the more your scene might encounter depth fighting issue.
  91466. */
  91467. maxZ: number;
  91468. /**
  91469. * Define the default inertia of the camera.
  91470. * This helps giving a smooth feeling to the camera movement.
  91471. */
  91472. inertia: number;
  91473. /**
  91474. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91475. */
  91476. mode: number;
  91477. /**
  91478. * Define wether the camera is intermediate.
  91479. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91480. */
  91481. isIntermediate: boolean;
  91482. /**
  91483. * Define the viewport of the camera.
  91484. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91485. */
  91486. viewport: Viewport;
  91487. /**
  91488. * Restricts the camera to viewing objects with the same layerMask.
  91489. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91490. */
  91491. layerMask: number;
  91492. /**
  91493. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91494. */
  91495. fovMode: number;
  91496. /**
  91497. * Rig mode of the camera.
  91498. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91499. * This is normally controlled byt the camera themselves as internal use.
  91500. */
  91501. cameraRigMode: number;
  91502. /**
  91503. * Defines the distance between both "eyes" in case of a RIG
  91504. */
  91505. interaxialDistance: number;
  91506. /**
  91507. * Defines if stereoscopic rendering is done side by side or over under.
  91508. */
  91509. isStereoscopicSideBySide: boolean;
  91510. /**
  91511. * 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
  91512. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91513. * else in the scene. (Eg. security camera)
  91514. *
  91515. * 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)
  91516. */
  91517. customRenderTargets: RenderTargetTexture[];
  91518. /**
  91519. * When set, the camera will render to this render target instead of the default canvas
  91520. *
  91521. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91522. */
  91523. outputRenderTarget: Nullable<RenderTargetTexture>;
  91524. /**
  91525. * Observable triggered when the camera view matrix has changed.
  91526. */
  91527. onViewMatrixChangedObservable: Observable<Camera>;
  91528. /**
  91529. * Observable triggered when the camera Projection matrix has changed.
  91530. */
  91531. onProjectionMatrixChangedObservable: Observable<Camera>;
  91532. /**
  91533. * Observable triggered when the inputs have been processed.
  91534. */
  91535. onAfterCheckInputsObservable: Observable<Camera>;
  91536. /**
  91537. * Observable triggered when reset has been called and applied to the camera.
  91538. */
  91539. onRestoreStateObservable: Observable<Camera>;
  91540. /** @hidden */
  91541. _cameraRigParams: any;
  91542. /** @hidden */
  91543. _rigCameras: Camera[];
  91544. /** @hidden */
  91545. _rigPostProcess: Nullable<PostProcess>;
  91546. protected _webvrViewMatrix: Matrix;
  91547. /** @hidden */
  91548. _skipRendering: boolean;
  91549. /** @hidden */
  91550. _projectionMatrix: Matrix;
  91551. /** @hidden */
  91552. _postProcesses: Nullable<PostProcess>[];
  91553. /** @hidden */
  91554. _activeMeshes: SmartArray<AbstractMesh>;
  91555. protected _globalPosition: Vector3;
  91556. /** @hidden */
  91557. _computedViewMatrix: Matrix;
  91558. private _doNotComputeProjectionMatrix;
  91559. private _transformMatrix;
  91560. private _frustumPlanes;
  91561. private _refreshFrustumPlanes;
  91562. private _storedFov;
  91563. private _stateStored;
  91564. /**
  91565. * Instantiates a new camera object.
  91566. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91567. * @see http://doc.babylonjs.com/features/cameras
  91568. * @param name Defines the name of the camera in the scene
  91569. * @param position Defines the position of the camera
  91570. * @param scene Defines the scene the camera belongs too
  91571. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91572. */
  91573. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91574. /**
  91575. * Store current camera state (fov, position, etc..)
  91576. * @returns the camera
  91577. */
  91578. storeState(): Camera;
  91579. /**
  91580. * Restores the camera state values if it has been stored. You must call storeState() first
  91581. */
  91582. protected _restoreStateValues(): boolean;
  91583. /**
  91584. * Restored camera state. You must call storeState() first.
  91585. * @returns true if restored and false otherwise
  91586. */
  91587. restoreState(): boolean;
  91588. /**
  91589. * Gets the class name of the camera.
  91590. * @returns the class name
  91591. */
  91592. getClassName(): string;
  91593. /** @hidden */
  91594. readonly _isCamera: boolean;
  91595. /**
  91596. * Gets a string representation of the camera useful for debug purpose.
  91597. * @param fullDetails Defines that a more verboe level of logging is required
  91598. * @returns the string representation
  91599. */
  91600. toString(fullDetails?: boolean): string;
  91601. /**
  91602. * Gets the current world space position of the camera.
  91603. */
  91604. readonly globalPosition: Vector3;
  91605. /**
  91606. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91607. * @returns the active meshe list
  91608. */
  91609. getActiveMeshes(): SmartArray<AbstractMesh>;
  91610. /**
  91611. * Check wether a mesh is part of the current active mesh list of the camera
  91612. * @param mesh Defines the mesh to check
  91613. * @returns true if active, false otherwise
  91614. */
  91615. isActiveMesh(mesh: Mesh): boolean;
  91616. /**
  91617. * Is this camera ready to be used/rendered
  91618. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91619. * @return true if the camera is ready
  91620. */
  91621. isReady(completeCheck?: boolean): boolean;
  91622. /** @hidden */
  91623. _initCache(): void;
  91624. /** @hidden */
  91625. _updateCache(ignoreParentClass?: boolean): void;
  91626. /** @hidden */
  91627. _isSynchronized(): boolean;
  91628. /** @hidden */
  91629. _isSynchronizedViewMatrix(): boolean;
  91630. /** @hidden */
  91631. _isSynchronizedProjectionMatrix(): boolean;
  91632. /**
  91633. * Attach the input controls to a specific dom element to get the input from.
  91634. * @param element Defines the element the controls should be listened from
  91635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91636. */
  91637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91638. /**
  91639. * Detach the current controls from the specified dom element.
  91640. * @param element Defines the element to stop listening the inputs from
  91641. */
  91642. detachControl(element: HTMLElement): void;
  91643. /**
  91644. * Update the camera state according to the different inputs gathered during the frame.
  91645. */
  91646. update(): void;
  91647. /** @hidden */
  91648. _checkInputs(): void;
  91649. /** @hidden */
  91650. readonly rigCameras: Camera[];
  91651. /**
  91652. * Gets the post process used by the rig cameras
  91653. */
  91654. readonly rigPostProcess: Nullable<PostProcess>;
  91655. /**
  91656. * Internal, gets the first post proces.
  91657. * @returns the first post process to be run on this camera.
  91658. */
  91659. _getFirstPostProcess(): Nullable<PostProcess>;
  91660. private _cascadePostProcessesToRigCams;
  91661. /**
  91662. * Attach a post process to the camera.
  91663. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91664. * @param postProcess The post process to attach to the camera
  91665. * @param insertAt The position of the post process in case several of them are in use in the scene
  91666. * @returns the position the post process has been inserted at
  91667. */
  91668. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91669. /**
  91670. * Detach a post process to the camera.
  91671. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91672. * @param postProcess The post process to detach from the camera
  91673. */
  91674. detachPostProcess(postProcess: PostProcess): void;
  91675. /**
  91676. * Gets the current world matrix of the camera
  91677. */
  91678. getWorldMatrix(): Matrix;
  91679. /** @hidden */
  91680. _getViewMatrix(): Matrix;
  91681. /**
  91682. * Gets the current view matrix of the camera.
  91683. * @param force forces the camera to recompute the matrix without looking at the cached state
  91684. * @returns the view matrix
  91685. */
  91686. getViewMatrix(force?: boolean): Matrix;
  91687. /**
  91688. * Freeze the projection matrix.
  91689. * It will prevent the cache check of the camera projection compute and can speed up perf
  91690. * if no parameter of the camera are meant to change
  91691. * @param projection Defines manually a projection if necessary
  91692. */
  91693. freezeProjectionMatrix(projection?: Matrix): void;
  91694. /**
  91695. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91696. */
  91697. unfreezeProjectionMatrix(): void;
  91698. /**
  91699. * Gets the current projection matrix of the camera.
  91700. * @param force forces the camera to recompute the matrix without looking at the cached state
  91701. * @returns the projection matrix
  91702. */
  91703. getProjectionMatrix(force?: boolean): Matrix;
  91704. /**
  91705. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91706. * @returns a Matrix
  91707. */
  91708. getTransformationMatrix(): Matrix;
  91709. private _updateFrustumPlanes;
  91710. /**
  91711. * Checks if a cullable object (mesh...) is in the camera frustum
  91712. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91713. * @param target The object to check
  91714. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91715. * @returns true if the object is in frustum otherwise false
  91716. */
  91717. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91718. /**
  91719. * Checks if a cullable object (mesh...) is in the camera frustum
  91720. * Unlike isInFrustum this cheks the full bounding box
  91721. * @param target The object to check
  91722. * @returns true if the object is in frustum otherwise false
  91723. */
  91724. isCompletelyInFrustum(target: ICullable): boolean;
  91725. /**
  91726. * Gets a ray in the forward direction from the camera.
  91727. * @param length Defines the length of the ray to create
  91728. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91729. * @param origin Defines the start point of the ray which defaults to the camera position
  91730. * @returns the forward ray
  91731. */
  91732. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91733. /**
  91734. * Releases resources associated with this node.
  91735. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91736. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91737. */
  91738. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91739. /** @hidden */
  91740. _isLeftCamera: boolean;
  91741. /**
  91742. * Gets the left camera of a rig setup in case of Rigged Camera
  91743. */
  91744. readonly isLeftCamera: boolean;
  91745. /** @hidden */
  91746. _isRightCamera: boolean;
  91747. /**
  91748. * Gets the right camera of a rig setup in case of Rigged Camera
  91749. */
  91750. readonly isRightCamera: boolean;
  91751. /**
  91752. * Gets the left camera of a rig setup in case of Rigged Camera
  91753. */
  91754. readonly leftCamera: Nullable<FreeCamera>;
  91755. /**
  91756. * Gets the right camera of a rig setup in case of Rigged Camera
  91757. */
  91758. readonly rightCamera: Nullable<FreeCamera>;
  91759. /**
  91760. * Gets the left camera target of a rig setup in case of Rigged Camera
  91761. * @returns the target position
  91762. */
  91763. getLeftTarget(): Nullable<Vector3>;
  91764. /**
  91765. * Gets the right camera target of a rig setup in case of Rigged Camera
  91766. * @returns the target position
  91767. */
  91768. getRightTarget(): Nullable<Vector3>;
  91769. /**
  91770. * @hidden
  91771. */
  91772. setCameraRigMode(mode: number, rigParams: any): void;
  91773. /** @hidden */
  91774. static _setStereoscopicRigMode(camera: Camera): void;
  91775. /** @hidden */
  91776. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91777. /** @hidden */
  91778. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91779. /** @hidden */
  91780. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91781. /** @hidden */
  91782. _getVRProjectionMatrix(): Matrix;
  91783. protected _updateCameraRotationMatrix(): void;
  91784. protected _updateWebVRCameraRotationMatrix(): void;
  91785. /**
  91786. * This function MUST be overwritten by the different WebVR cameras available.
  91787. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91788. * @hidden
  91789. */
  91790. _getWebVRProjectionMatrix(): Matrix;
  91791. /**
  91792. * This function MUST be overwritten by the different WebVR cameras available.
  91793. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91794. * @hidden
  91795. */
  91796. _getWebVRViewMatrix(): Matrix;
  91797. /** @hidden */
  91798. setCameraRigParameter(name: string, value: any): void;
  91799. /**
  91800. * needs to be overridden by children so sub has required properties to be copied
  91801. * @hidden
  91802. */
  91803. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91804. /**
  91805. * May need to be overridden by children
  91806. * @hidden
  91807. */
  91808. _updateRigCameras(): void;
  91809. /** @hidden */
  91810. _setupInputs(): void;
  91811. /**
  91812. * Serialiaze the camera setup to a json represention
  91813. * @returns the JSON representation
  91814. */
  91815. serialize(): any;
  91816. /**
  91817. * Clones the current camera.
  91818. * @param name The cloned camera name
  91819. * @returns the cloned camera
  91820. */
  91821. clone(name: string): Camera;
  91822. /**
  91823. * Gets the direction of the camera relative to a given local axis.
  91824. * @param localAxis Defines the reference axis to provide a relative direction.
  91825. * @return the direction
  91826. */
  91827. getDirection(localAxis: Vector3): Vector3;
  91828. /**
  91829. * Returns the current camera absolute rotation
  91830. */
  91831. readonly absoluteRotation: Quaternion;
  91832. /**
  91833. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91834. * @param localAxis Defines the reference axis to provide a relative direction.
  91835. * @param result Defines the vector to store the result in
  91836. */
  91837. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91838. /**
  91839. * Gets a camera constructor for a given camera type
  91840. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91841. * @param name The name of the camera the result will be able to instantiate
  91842. * @param scene The scene the result will construct the camera in
  91843. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91844. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91845. * @returns a factory method to construc the camera
  91846. */
  91847. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91848. /**
  91849. * Compute the world matrix of the camera.
  91850. * @returns the camera workd matrix
  91851. */
  91852. computeWorldMatrix(): Matrix;
  91853. /**
  91854. * Parse a JSON and creates the camera from the parsed information
  91855. * @param parsedCamera The JSON to parse
  91856. * @param scene The scene to instantiate the camera in
  91857. * @returns the newly constructed camera
  91858. */
  91859. static Parse(parsedCamera: any, scene: Scene): Camera;
  91860. }
  91861. }
  91862. declare module BABYLON {
  91863. /**
  91864. * Class containing static functions to help procedurally build meshes
  91865. */
  91866. export class DiscBuilder {
  91867. /**
  91868. * Creates a plane polygonal mesh. By default, this is a disc
  91869. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91870. * * 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
  91871. * * 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
  91872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91875. * @param name defines the name of the mesh
  91876. * @param options defines the options used to create the mesh
  91877. * @param scene defines the hosting scene
  91878. * @returns the plane polygonal mesh
  91879. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91880. */
  91881. static CreateDisc(name: string, options: {
  91882. radius?: number;
  91883. tessellation?: number;
  91884. arc?: number;
  91885. updatable?: boolean;
  91886. sideOrientation?: number;
  91887. frontUVs?: Vector4;
  91888. backUVs?: Vector4;
  91889. }, scene?: Nullable<Scene>): Mesh;
  91890. }
  91891. }
  91892. declare module BABYLON {
  91893. /**
  91894. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91895. *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.
  91896. * The SPS is also a particle system. It provides some methods to manage the particles.
  91897. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91898. *
  91899. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91900. */
  91901. export class SolidParticleSystem implements IDisposable {
  91902. /**
  91903. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91904. * Example : var p = SPS.particles[i];
  91905. */
  91906. particles: SolidParticle[];
  91907. /**
  91908. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91909. */
  91910. nbParticles: number;
  91911. /**
  91912. * If the particles must ever face the camera (default false). Useful for planar particles.
  91913. */
  91914. billboard: boolean;
  91915. /**
  91916. * Recompute normals when adding a shape
  91917. */
  91918. recomputeNormals: boolean;
  91919. /**
  91920. * This a counter ofr your own usage. It's not set by any SPS functions.
  91921. */
  91922. counter: number;
  91923. /**
  91924. * The SPS name. This name is also given to the underlying mesh.
  91925. */
  91926. name: string;
  91927. /**
  91928. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91929. */
  91930. mesh: Mesh;
  91931. /**
  91932. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91933. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91934. */
  91935. vars: any;
  91936. /**
  91937. * This array is populated when the SPS is set as 'pickable'.
  91938. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91939. * Each element of this array is an object `{idx: int, faceId: int}`.
  91940. * `idx` is the picked particle index in the `SPS.particles` array
  91941. * `faceId` is the picked face index counted within this particle.
  91942. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91943. */
  91944. pickedParticles: {
  91945. idx: number;
  91946. faceId: number;
  91947. }[];
  91948. /**
  91949. * This array is populated when `enableDepthSort` is set to true.
  91950. * Each element of this array is an instance of the class DepthSortedParticle.
  91951. */
  91952. depthSortedParticles: DepthSortedParticle[];
  91953. /**
  91954. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  91955. * @hidden
  91956. */
  91957. _bSphereOnly: boolean;
  91958. /**
  91959. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  91960. * @hidden
  91961. */
  91962. _bSphereRadiusFactor: number;
  91963. private _scene;
  91964. private _positions;
  91965. private _indices;
  91966. private _normals;
  91967. private _colors;
  91968. private _uvs;
  91969. private _indices32;
  91970. private _positions32;
  91971. private _normals32;
  91972. private _fixedNormal32;
  91973. private _colors32;
  91974. private _uvs32;
  91975. private _index;
  91976. private _updatable;
  91977. private _pickable;
  91978. private _isVisibilityBoxLocked;
  91979. private _alwaysVisible;
  91980. private _depthSort;
  91981. private _shapeCounter;
  91982. private _copy;
  91983. private _color;
  91984. private _computeParticleColor;
  91985. private _computeParticleTexture;
  91986. private _computeParticleRotation;
  91987. private _computeParticleVertex;
  91988. private _computeBoundingBox;
  91989. private _depthSortParticles;
  91990. private _camera;
  91991. private _mustUnrotateFixedNormals;
  91992. private _particlesIntersect;
  91993. private _needs32Bits;
  91994. /**
  91995. * Creates a SPS (Solid Particle System) object.
  91996. * @param name (String) is the SPS name, this will be the underlying mesh name.
  91997. * @param scene (Scene) is the scene in which the SPS is added.
  91998. * @param options defines the options of the sps e.g.
  91999. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92000. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92001. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92002. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92003. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92004. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92005. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92006. */
  92007. constructor(name: string, scene: Scene, options?: {
  92008. updatable?: boolean;
  92009. isPickable?: boolean;
  92010. enableDepthSort?: boolean;
  92011. particleIntersection?: boolean;
  92012. boundingSphereOnly?: boolean;
  92013. bSphereRadiusFactor?: number;
  92014. });
  92015. /**
  92016. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92017. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92018. * @returns the created mesh
  92019. */
  92020. buildMesh(): Mesh;
  92021. /**
  92022. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92023. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92024. * Thus the particles generated from `digest()` have their property `position` set yet.
  92025. * @param mesh ( Mesh ) is the mesh to be digested
  92026. * @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
  92027. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92028. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92029. * @returns the current SPS
  92030. */
  92031. digest(mesh: Mesh, options?: {
  92032. facetNb?: number;
  92033. number?: number;
  92034. delta?: number;
  92035. }): SolidParticleSystem;
  92036. private _unrotateFixedNormals;
  92037. private _resetCopy;
  92038. private _meshBuilder;
  92039. private _posToShape;
  92040. private _uvsToShapeUV;
  92041. private _addParticle;
  92042. /**
  92043. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92044. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92045. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92046. * @param nb (positive integer) the number of particles to be created from this model
  92047. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92048. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92049. * @returns the number of shapes in the system
  92050. */
  92051. addShape(mesh: Mesh, nb: number, options?: {
  92052. positionFunction?: any;
  92053. vertexFunction?: any;
  92054. }): number;
  92055. private _rebuildParticle;
  92056. /**
  92057. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92058. * @returns the SPS.
  92059. */
  92060. rebuildMesh(): SolidParticleSystem;
  92061. /**
  92062. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92063. * This method calls `updateParticle()` for each particle of the SPS.
  92064. * For an animated SPS, it is usually called within the render loop.
  92065. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92066. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92067. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92068. * @returns the SPS.
  92069. */
  92070. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92071. /**
  92072. * Disposes the SPS.
  92073. */
  92074. dispose(): void;
  92075. /**
  92076. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92077. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92078. * @returns the SPS.
  92079. */
  92080. refreshVisibleSize(): SolidParticleSystem;
  92081. /**
  92082. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92083. * @param size the size (float) of the visibility box
  92084. * note : this doesn't lock the SPS mesh bounding box.
  92085. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92086. */
  92087. setVisibilityBox(size: number): void;
  92088. /**
  92089. * Gets whether the SPS as always visible or not
  92090. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92091. */
  92092. /**
  92093. * Sets the SPS as always visible or not
  92094. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92095. */
  92096. isAlwaysVisible: boolean;
  92097. /**
  92098. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92099. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92100. */
  92101. /**
  92102. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92103. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92104. */
  92105. isVisibilityBoxLocked: boolean;
  92106. /**
  92107. * Tells to `setParticles()` to compute the particle rotations or not.
  92108. * Default value : true. The SPS is faster when it's set to false.
  92109. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92110. */
  92111. /**
  92112. * Gets if `setParticles()` computes the particle rotations or not.
  92113. * Default value : true. The SPS is faster when it's set to false.
  92114. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92115. */
  92116. computeParticleRotation: boolean;
  92117. /**
  92118. * Tells to `setParticles()` to compute the particle colors or not.
  92119. * Default value : true. The SPS is faster when it's set to false.
  92120. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92121. */
  92122. /**
  92123. * Gets if `setParticles()` computes the particle colors or not.
  92124. * Default value : true. The SPS is faster when it's set to false.
  92125. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92126. */
  92127. computeParticleColor: boolean;
  92128. /**
  92129. * Gets if `setParticles()` computes the particle textures or not.
  92130. * Default value : true. The SPS is faster when it's set to false.
  92131. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92132. */
  92133. computeParticleTexture: boolean;
  92134. /**
  92135. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92136. * Default value : false. The SPS is faster when it's set to false.
  92137. * Note : the particle custom vertex positions aren't stored values.
  92138. */
  92139. /**
  92140. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92141. * Default value : false. The SPS is faster when it's set to false.
  92142. * Note : the particle custom vertex positions aren't stored values.
  92143. */
  92144. computeParticleVertex: boolean;
  92145. /**
  92146. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92147. */
  92148. /**
  92149. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92150. */
  92151. computeBoundingBox: boolean;
  92152. /**
  92153. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92154. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92155. * Default : `true`
  92156. */
  92157. /**
  92158. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92159. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92160. * Default : `true`
  92161. */
  92162. depthSortParticles: boolean;
  92163. /**
  92164. * This function does nothing. It may be overwritten to set all the particle first values.
  92165. * The SPS doesn't call this function, you may have to call it by your own.
  92166. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92167. */
  92168. initParticles(): void;
  92169. /**
  92170. * This function does nothing. It may be overwritten to recycle a particle.
  92171. * The SPS doesn't call this function, you may have to call it by your own.
  92172. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92173. * @param particle The particle to recycle
  92174. * @returns the recycled particle
  92175. */
  92176. recycleParticle(particle: SolidParticle): SolidParticle;
  92177. /**
  92178. * Updates a particle : this function should be overwritten by the user.
  92179. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92180. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92181. * @example : just set a particle position or velocity and recycle conditions
  92182. * @param particle The particle to update
  92183. * @returns the updated particle
  92184. */
  92185. updateParticle(particle: SolidParticle): SolidParticle;
  92186. /**
  92187. * Updates a vertex of a particle : it can be overwritten by the user.
  92188. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92189. * @param particle the current particle
  92190. * @param vertex the current index of the current particle
  92191. * @param pt the index of the current vertex in the particle shape
  92192. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92193. * @example : just set a vertex particle position
  92194. * @returns the updated vertex
  92195. */
  92196. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92197. /**
  92198. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92199. * This does nothing and may be overwritten by the user.
  92200. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92201. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92202. * @param update the boolean update value actually passed to setParticles()
  92203. */
  92204. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92205. /**
  92206. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92207. * This will be passed three parameters.
  92208. * This does nothing and may be overwritten by the user.
  92209. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92210. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92211. * @param update the boolean update value actually passed to setParticles()
  92212. */
  92213. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92214. }
  92215. }
  92216. declare module BABYLON {
  92217. /**
  92218. * Represents one particle of a solid particle system.
  92219. */
  92220. export class SolidParticle {
  92221. /**
  92222. * particle global index
  92223. */
  92224. idx: number;
  92225. /**
  92226. * The color of the particle
  92227. */
  92228. color: Nullable<Color4>;
  92229. /**
  92230. * The world space position of the particle.
  92231. */
  92232. position: Vector3;
  92233. /**
  92234. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92235. */
  92236. rotation: Vector3;
  92237. /**
  92238. * The world space rotation quaternion of the particle.
  92239. */
  92240. rotationQuaternion: Nullable<Quaternion>;
  92241. /**
  92242. * The scaling of the particle.
  92243. */
  92244. scaling: Vector3;
  92245. /**
  92246. * The uvs of the particle.
  92247. */
  92248. uvs: Vector4;
  92249. /**
  92250. * The current speed of the particle.
  92251. */
  92252. velocity: Vector3;
  92253. /**
  92254. * The pivot point in the particle local space.
  92255. */
  92256. pivot: Vector3;
  92257. /**
  92258. * Must the particle be translated from its pivot point in its local space ?
  92259. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92260. * Default : false
  92261. */
  92262. translateFromPivot: boolean;
  92263. /**
  92264. * Is the particle active or not ?
  92265. */
  92266. alive: boolean;
  92267. /**
  92268. * Is the particle visible or not ?
  92269. */
  92270. isVisible: boolean;
  92271. /**
  92272. * Index of this particle in the global "positions" array (Internal use)
  92273. * @hidden
  92274. */
  92275. _pos: number;
  92276. /**
  92277. * @hidden Index of this particle in the global "indices" array (Internal use)
  92278. */
  92279. _ind: number;
  92280. /**
  92281. * @hidden ModelShape of this particle (Internal use)
  92282. */
  92283. _model: ModelShape;
  92284. /**
  92285. * ModelShape id of this particle
  92286. */
  92287. shapeId: number;
  92288. /**
  92289. * Index of the particle in its shape id
  92290. */
  92291. idxInShape: number;
  92292. /**
  92293. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92294. */
  92295. _modelBoundingInfo: BoundingInfo;
  92296. /**
  92297. * @hidden Particle BoundingInfo object (Internal use)
  92298. */
  92299. _boundingInfo: BoundingInfo;
  92300. /**
  92301. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92302. */
  92303. _sps: SolidParticleSystem;
  92304. /**
  92305. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92306. */
  92307. _stillInvisible: boolean;
  92308. /**
  92309. * @hidden Last computed particle rotation matrix
  92310. */
  92311. _rotationMatrix: number[];
  92312. /**
  92313. * Parent particle Id, if any.
  92314. * Default null.
  92315. */
  92316. parentId: Nullable<number>;
  92317. /**
  92318. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92319. * The possible values are :
  92320. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92321. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92322. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92323. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92324. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92325. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92326. * */
  92327. cullingStrategy: number;
  92328. /**
  92329. * @hidden Internal global position in the SPS.
  92330. */
  92331. _globalPosition: Vector3;
  92332. /**
  92333. * Creates a Solid Particle object.
  92334. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92335. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92336. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92337. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92338. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92339. * @param shapeId (integer) is the model shape identifier in the SPS.
  92340. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92341. * @param sps defines the sps it is associated to
  92342. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92343. */
  92344. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92345. /**
  92346. * Legacy support, changed scale to scaling
  92347. */
  92348. /**
  92349. * Legacy support, changed scale to scaling
  92350. */
  92351. scale: Vector3;
  92352. /**
  92353. * Legacy support, changed quaternion to rotationQuaternion
  92354. */
  92355. /**
  92356. * Legacy support, changed quaternion to rotationQuaternion
  92357. */
  92358. quaternion: Nullable<Quaternion>;
  92359. /**
  92360. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92361. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92362. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92363. * @returns true if it intersects
  92364. */
  92365. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92366. /**
  92367. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92368. * A particle is in the frustum if its bounding box intersects the frustum
  92369. * @param frustumPlanes defines the frustum to test
  92370. * @returns true if the particle is in the frustum planes
  92371. */
  92372. isInFrustum(frustumPlanes: Plane[]): boolean;
  92373. /**
  92374. * get the rotation matrix of the particle
  92375. * @hidden
  92376. */
  92377. getRotationMatrix(m: Matrix): void;
  92378. }
  92379. /**
  92380. * Represents the shape of the model used by one particle of a solid particle system.
  92381. * SPS internal tool, don't use it manually.
  92382. */
  92383. export class ModelShape {
  92384. /**
  92385. * The shape id
  92386. * @hidden
  92387. */
  92388. shapeID: number;
  92389. /**
  92390. * flat array of model positions (internal use)
  92391. * @hidden
  92392. */
  92393. _shape: Vector3[];
  92394. /**
  92395. * flat array of model UVs (internal use)
  92396. * @hidden
  92397. */
  92398. _shapeUV: number[];
  92399. /**
  92400. * length of the shape in the model indices array (internal use)
  92401. * @hidden
  92402. */
  92403. _indicesLength: number;
  92404. /**
  92405. * Custom position function (internal use)
  92406. * @hidden
  92407. */
  92408. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92409. /**
  92410. * Custom vertex function (internal use)
  92411. * @hidden
  92412. */
  92413. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92414. /**
  92415. * 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.
  92416. * SPS internal tool, don't use it manually.
  92417. * @hidden
  92418. */
  92419. 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>);
  92420. }
  92421. /**
  92422. * Represents a Depth Sorted Particle in the solid particle system.
  92423. */
  92424. export class DepthSortedParticle {
  92425. /**
  92426. * Index of the particle in the "indices" array
  92427. */
  92428. ind: number;
  92429. /**
  92430. * Length of the particle shape in the "indices" array
  92431. */
  92432. indicesLength: number;
  92433. /**
  92434. * Squared distance from the particle to the camera
  92435. */
  92436. sqDistance: number;
  92437. }
  92438. }
  92439. declare module BABYLON {
  92440. /**
  92441. * @hidden
  92442. */
  92443. export class _MeshCollisionData {
  92444. _checkCollisions: boolean;
  92445. _collisionMask: number;
  92446. _collisionGroup: number;
  92447. _collider: Nullable<Collider>;
  92448. _oldPositionForCollisions: Vector3;
  92449. _diffPositionForCollisions: Vector3;
  92450. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92451. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92452. }
  92453. }
  92454. declare module BABYLON {
  92455. /** @hidden */
  92456. class _FacetDataStorage {
  92457. facetPositions: Vector3[];
  92458. facetNormals: Vector3[];
  92459. facetPartitioning: number[][];
  92460. facetNb: number;
  92461. partitioningSubdivisions: number;
  92462. partitioningBBoxRatio: number;
  92463. facetDataEnabled: boolean;
  92464. facetParameters: any;
  92465. bbSize: Vector3;
  92466. subDiv: {
  92467. max: number;
  92468. X: number;
  92469. Y: number;
  92470. Z: number;
  92471. };
  92472. facetDepthSort: boolean;
  92473. facetDepthSortEnabled: boolean;
  92474. depthSortedIndices: IndicesArray;
  92475. depthSortedFacets: {
  92476. ind: number;
  92477. sqDistance: number;
  92478. }[];
  92479. facetDepthSortFunction: (f1: {
  92480. ind: number;
  92481. sqDistance: number;
  92482. }, f2: {
  92483. ind: number;
  92484. sqDistance: number;
  92485. }) => number;
  92486. facetDepthSortFrom: Vector3;
  92487. facetDepthSortOrigin: Vector3;
  92488. invertedMatrix: Matrix;
  92489. }
  92490. /**
  92491. * @hidden
  92492. **/
  92493. class _InternalAbstractMeshDataInfo {
  92494. _hasVertexAlpha: boolean;
  92495. _useVertexColors: boolean;
  92496. _numBoneInfluencers: number;
  92497. _applyFog: boolean;
  92498. _receiveShadows: boolean;
  92499. _facetData: _FacetDataStorage;
  92500. _visibility: number;
  92501. _skeleton: Nullable<Skeleton>;
  92502. _layerMask: number;
  92503. _computeBonesUsingShaders: boolean;
  92504. _isActive: boolean;
  92505. _onlyForInstances: boolean;
  92506. _isActiveIntermediate: boolean;
  92507. _onlyForInstancesIntermediate: boolean;
  92508. }
  92509. /**
  92510. * Class used to store all common mesh properties
  92511. */
  92512. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92513. /** No occlusion */
  92514. static OCCLUSION_TYPE_NONE: number;
  92515. /** Occlusion set to optimisitic */
  92516. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92517. /** Occlusion set to strict */
  92518. static OCCLUSION_TYPE_STRICT: number;
  92519. /** Use an accurante occlusion algorithm */
  92520. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92521. /** Use a conservative occlusion algorithm */
  92522. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92523. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92524. * Test order :
  92525. * Is the bounding sphere outside the frustum ?
  92526. * If not, are the bounding box vertices outside the frustum ?
  92527. * It not, then the cullable object is in the frustum.
  92528. */
  92529. static readonly CULLINGSTRATEGY_STANDARD: number;
  92530. /** Culling strategy : Bounding Sphere Only.
  92531. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92532. * It's also less accurate than the standard because some not visible objects can still be selected.
  92533. * Test : is the bounding sphere outside the frustum ?
  92534. * If not, then the cullable object is in the frustum.
  92535. */
  92536. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92537. /** Culling strategy : Optimistic Inclusion.
  92538. * This in an inclusion test first, then the standard exclusion test.
  92539. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92540. * 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.
  92541. * Anyway, it's as accurate as the standard strategy.
  92542. * Test :
  92543. * Is the cullable object bounding sphere center in the frustum ?
  92544. * If not, apply the default culling strategy.
  92545. */
  92546. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92547. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92548. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92549. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92550. * 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.
  92551. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92552. * Test :
  92553. * Is the cullable object bounding sphere center in the frustum ?
  92554. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92555. */
  92556. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92557. /**
  92558. * No billboard
  92559. */
  92560. static readonly BILLBOARDMODE_NONE: number;
  92561. /** Billboard on X axis */
  92562. static readonly BILLBOARDMODE_X: number;
  92563. /** Billboard on Y axis */
  92564. static readonly BILLBOARDMODE_Y: number;
  92565. /** Billboard on Z axis */
  92566. static readonly BILLBOARDMODE_Z: number;
  92567. /** Billboard on all axes */
  92568. static readonly BILLBOARDMODE_ALL: number;
  92569. /** Billboard on using position instead of orientation */
  92570. static readonly BILLBOARDMODE_USE_POSITION: number;
  92571. /** @hidden */
  92572. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92573. /**
  92574. * The culling strategy to use to check whether the mesh must be rendered or not.
  92575. * This value can be changed at any time and will be used on the next render mesh selection.
  92576. * The possible values are :
  92577. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92578. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92579. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92580. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92581. * Please read each static variable documentation to get details about the culling process.
  92582. * */
  92583. cullingStrategy: number;
  92584. /**
  92585. * Gets the number of facets in the mesh
  92586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92587. */
  92588. readonly facetNb: number;
  92589. /**
  92590. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92592. */
  92593. partitioningSubdivisions: number;
  92594. /**
  92595. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92596. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92598. */
  92599. partitioningBBoxRatio: number;
  92600. /**
  92601. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92602. * Works only for updatable meshes.
  92603. * Doesn't work with multi-materials
  92604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92605. */
  92606. mustDepthSortFacets: boolean;
  92607. /**
  92608. * The location (Vector3) where the facet depth sort must be computed from.
  92609. * By default, the active camera position.
  92610. * Used only when facet depth sort is enabled
  92611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92612. */
  92613. facetDepthSortFrom: Vector3;
  92614. /**
  92615. * gets a boolean indicating if facetData is enabled
  92616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92617. */
  92618. readonly isFacetDataEnabled: boolean;
  92619. /** @hidden */
  92620. _updateNonUniformScalingState(value: boolean): boolean;
  92621. /**
  92622. * An event triggered when this mesh collides with another one
  92623. */
  92624. onCollideObservable: Observable<AbstractMesh>;
  92625. /** Set a function to call when this mesh collides with another one */
  92626. onCollide: () => void;
  92627. /**
  92628. * An event triggered when the collision's position changes
  92629. */
  92630. onCollisionPositionChangeObservable: Observable<Vector3>;
  92631. /** Set a function to call when the collision's position changes */
  92632. onCollisionPositionChange: () => void;
  92633. /**
  92634. * An event triggered when material is changed
  92635. */
  92636. onMaterialChangedObservable: Observable<AbstractMesh>;
  92637. /**
  92638. * Gets or sets the orientation for POV movement & rotation
  92639. */
  92640. definedFacingForward: boolean;
  92641. /** @hidden */
  92642. _occlusionQuery: Nullable<WebGLQuery>;
  92643. /** @hidden */
  92644. _renderingGroup: Nullable<RenderingGroup>;
  92645. /**
  92646. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92647. */
  92648. /**
  92649. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92650. */
  92651. visibility: number;
  92652. /** Gets or sets the alpha index used to sort transparent meshes
  92653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92654. */
  92655. alphaIndex: number;
  92656. /**
  92657. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92658. */
  92659. isVisible: boolean;
  92660. /**
  92661. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92662. */
  92663. isPickable: boolean;
  92664. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92665. showSubMeshesBoundingBox: boolean;
  92666. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92667. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92668. */
  92669. isBlocker: boolean;
  92670. /**
  92671. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92672. */
  92673. enablePointerMoveEvents: boolean;
  92674. /**
  92675. * Specifies the rendering group id for this mesh (0 by default)
  92676. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92677. */
  92678. renderingGroupId: number;
  92679. private _material;
  92680. /** Gets or sets current material */
  92681. material: Nullable<Material>;
  92682. /**
  92683. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92684. * @see http://doc.babylonjs.com/babylon101/shadows
  92685. */
  92686. receiveShadows: boolean;
  92687. /** Defines color to use when rendering outline */
  92688. outlineColor: Color3;
  92689. /** Define width to use when rendering outline */
  92690. outlineWidth: number;
  92691. /** Defines color to use when rendering overlay */
  92692. overlayColor: Color3;
  92693. /** Defines alpha to use when rendering overlay */
  92694. overlayAlpha: number;
  92695. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92696. hasVertexAlpha: boolean;
  92697. /** 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) */
  92698. useVertexColors: boolean;
  92699. /**
  92700. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92701. */
  92702. computeBonesUsingShaders: boolean;
  92703. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92704. numBoneInfluencers: number;
  92705. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92706. applyFog: boolean;
  92707. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92708. useOctreeForRenderingSelection: boolean;
  92709. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92710. useOctreeForPicking: boolean;
  92711. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92712. useOctreeForCollisions: boolean;
  92713. /**
  92714. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92715. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92716. */
  92717. layerMask: number;
  92718. /**
  92719. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92720. */
  92721. alwaysSelectAsActiveMesh: boolean;
  92722. /**
  92723. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92724. */
  92725. doNotSyncBoundingInfo: boolean;
  92726. /**
  92727. * Gets or sets the current action manager
  92728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92729. */
  92730. actionManager: Nullable<AbstractActionManager>;
  92731. private _meshCollisionData;
  92732. /**
  92733. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92735. */
  92736. ellipsoid: Vector3;
  92737. /**
  92738. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92739. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92740. */
  92741. ellipsoidOffset: Vector3;
  92742. /**
  92743. * Gets or sets a collision mask used to mask collisions (default is -1).
  92744. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92745. */
  92746. collisionMask: number;
  92747. /**
  92748. * Gets or sets the current collision group mask (-1 by default).
  92749. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92750. */
  92751. collisionGroup: number;
  92752. /**
  92753. * Defines edge width used when edgesRenderer is enabled
  92754. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92755. */
  92756. edgesWidth: number;
  92757. /**
  92758. * Defines edge color used when edgesRenderer is enabled
  92759. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92760. */
  92761. edgesColor: Color4;
  92762. /** @hidden */
  92763. _edgesRenderer: Nullable<IEdgesRenderer>;
  92764. /** @hidden */
  92765. _masterMesh: Nullable<AbstractMesh>;
  92766. /** @hidden */
  92767. _boundingInfo: Nullable<BoundingInfo>;
  92768. /** @hidden */
  92769. _renderId: number;
  92770. /**
  92771. * Gets or sets the list of subMeshes
  92772. * @see http://doc.babylonjs.com/how_to/multi_materials
  92773. */
  92774. subMeshes: SubMesh[];
  92775. /** @hidden */
  92776. _intersectionsInProgress: AbstractMesh[];
  92777. /** @hidden */
  92778. _unIndexed: boolean;
  92779. /** @hidden */
  92780. _lightSources: Light[];
  92781. /** Gets the list of lights affecting that mesh */
  92782. readonly lightSources: Light[];
  92783. /** @hidden */
  92784. readonly _positions: Nullable<Vector3[]>;
  92785. /** @hidden */
  92786. _waitingData: {
  92787. lods: Nullable<any>;
  92788. actions: Nullable<any>;
  92789. freezeWorldMatrix: Nullable<boolean>;
  92790. };
  92791. /** @hidden */
  92792. _bonesTransformMatrices: Nullable<Float32Array>;
  92793. /** @hidden */
  92794. _transformMatrixTexture: Nullable<RawTexture>;
  92795. /**
  92796. * Gets or sets a skeleton to apply skining transformations
  92797. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92798. */
  92799. skeleton: Nullable<Skeleton>;
  92800. /**
  92801. * An event triggered when the mesh is rebuilt.
  92802. */
  92803. onRebuildObservable: Observable<AbstractMesh>;
  92804. /**
  92805. * Creates a new AbstractMesh
  92806. * @param name defines the name of the mesh
  92807. * @param scene defines the hosting scene
  92808. */
  92809. constructor(name: string, scene?: Nullable<Scene>);
  92810. /**
  92811. * Returns the string "AbstractMesh"
  92812. * @returns "AbstractMesh"
  92813. */
  92814. getClassName(): string;
  92815. /**
  92816. * Gets a string representation of the current mesh
  92817. * @param fullDetails defines a boolean indicating if full details must be included
  92818. * @returns a string representation of the current mesh
  92819. */
  92820. toString(fullDetails?: boolean): string;
  92821. /**
  92822. * @hidden
  92823. */
  92824. protected _getEffectiveParent(): Nullable<Node>;
  92825. /** @hidden */
  92826. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92827. /** @hidden */
  92828. _rebuild(): void;
  92829. /** @hidden */
  92830. _resyncLightSources(): void;
  92831. /** @hidden */
  92832. _resyncLighSource(light: Light): void;
  92833. /** @hidden */
  92834. _unBindEffect(): void;
  92835. /** @hidden */
  92836. _removeLightSource(light: Light, dispose: boolean): void;
  92837. private _markSubMeshesAsDirty;
  92838. /** @hidden */
  92839. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92840. /** @hidden */
  92841. _markSubMeshesAsAttributesDirty(): void;
  92842. /** @hidden */
  92843. _markSubMeshesAsMiscDirty(): void;
  92844. /**
  92845. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92846. */
  92847. scaling: Vector3;
  92848. /**
  92849. * Returns true if the mesh is blocked. Implemented by child classes
  92850. */
  92851. readonly isBlocked: boolean;
  92852. /**
  92853. * Returns the mesh itself by default. Implemented by child classes
  92854. * @param camera defines the camera to use to pick the right LOD level
  92855. * @returns the currentAbstractMesh
  92856. */
  92857. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92858. /**
  92859. * Returns 0 by default. Implemented by child classes
  92860. * @returns an integer
  92861. */
  92862. getTotalVertices(): number;
  92863. /**
  92864. * Returns a positive integer : the total number of indices in this mesh geometry.
  92865. * @returns the numner of indices or zero if the mesh has no geometry.
  92866. */
  92867. getTotalIndices(): number;
  92868. /**
  92869. * Returns null by default. Implemented by child classes
  92870. * @returns null
  92871. */
  92872. getIndices(): Nullable<IndicesArray>;
  92873. /**
  92874. * Returns the array of the requested vertex data kind. Implemented by child classes
  92875. * @param kind defines the vertex data kind to use
  92876. * @returns null
  92877. */
  92878. getVerticesData(kind: string): Nullable<FloatArray>;
  92879. /**
  92880. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92881. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92882. * Note that a new underlying VertexBuffer object is created each call.
  92883. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92884. * @param kind defines vertex data kind:
  92885. * * VertexBuffer.PositionKind
  92886. * * VertexBuffer.UVKind
  92887. * * VertexBuffer.UV2Kind
  92888. * * VertexBuffer.UV3Kind
  92889. * * VertexBuffer.UV4Kind
  92890. * * VertexBuffer.UV5Kind
  92891. * * VertexBuffer.UV6Kind
  92892. * * VertexBuffer.ColorKind
  92893. * * VertexBuffer.MatricesIndicesKind
  92894. * * VertexBuffer.MatricesIndicesExtraKind
  92895. * * VertexBuffer.MatricesWeightsKind
  92896. * * VertexBuffer.MatricesWeightsExtraKind
  92897. * @param data defines the data source
  92898. * @param updatable defines if the data must be flagged as updatable (or static)
  92899. * @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
  92900. * @returns the current mesh
  92901. */
  92902. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92903. /**
  92904. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92905. * If the mesh has no geometry, it is simply returned as it is.
  92906. * @param kind defines vertex data kind:
  92907. * * VertexBuffer.PositionKind
  92908. * * VertexBuffer.UVKind
  92909. * * VertexBuffer.UV2Kind
  92910. * * VertexBuffer.UV3Kind
  92911. * * VertexBuffer.UV4Kind
  92912. * * VertexBuffer.UV5Kind
  92913. * * VertexBuffer.UV6Kind
  92914. * * VertexBuffer.ColorKind
  92915. * * VertexBuffer.MatricesIndicesKind
  92916. * * VertexBuffer.MatricesIndicesExtraKind
  92917. * * VertexBuffer.MatricesWeightsKind
  92918. * * VertexBuffer.MatricesWeightsExtraKind
  92919. * @param data defines the data source
  92920. * @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
  92921. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92922. * @returns the current mesh
  92923. */
  92924. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92925. /**
  92926. * Sets the mesh indices,
  92927. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92928. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92929. * @param totalVertices Defines the total number of vertices
  92930. * @returns the current mesh
  92931. */
  92932. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92933. /**
  92934. * Gets a boolean indicating if specific vertex data is present
  92935. * @param kind defines the vertex data kind to use
  92936. * @returns true is data kind is present
  92937. */
  92938. isVerticesDataPresent(kind: string): boolean;
  92939. /**
  92940. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  92941. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  92942. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  92943. * @returns a BoundingInfo
  92944. */
  92945. getBoundingInfo(): BoundingInfo;
  92946. /**
  92947. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92948. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92949. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92950. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92951. * @returns the current mesh
  92952. */
  92953. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  92954. /**
  92955. * Overwrite the current bounding info
  92956. * @param boundingInfo defines the new bounding info
  92957. * @returns the current mesh
  92958. */
  92959. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  92960. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  92961. readonly useBones: boolean;
  92962. /** @hidden */
  92963. _preActivate(): void;
  92964. /** @hidden */
  92965. _preActivateForIntermediateRendering(renderId: number): void;
  92966. /** @hidden */
  92967. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92968. /** @hidden */
  92969. _postActivate(): void;
  92970. /** @hidden */
  92971. _freeze(): void;
  92972. /** @hidden */
  92973. _unFreeze(): void;
  92974. /**
  92975. * Gets the current world matrix
  92976. * @returns a Matrix
  92977. */
  92978. getWorldMatrix(): Matrix;
  92979. /** @hidden */
  92980. _getWorldMatrixDeterminant(): number;
  92981. /**
  92982. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  92983. */
  92984. readonly isAnInstance: boolean;
  92985. /**
  92986. * Gets a boolean indicating if this mesh has instances
  92987. */
  92988. readonly hasInstances: boolean;
  92989. /**
  92990. * Perform relative position change from the point of view of behind the front of the mesh.
  92991. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92992. * Supports definition of mesh facing forward or backward
  92993. * @param amountRight defines the distance on the right axis
  92994. * @param amountUp defines the distance on the up axis
  92995. * @param amountForward defines the distance on the forward axis
  92996. * @returns the current mesh
  92997. */
  92998. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  92999. /**
  93000. * Calculate relative position change from the point of view of behind the front of the mesh.
  93001. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93002. * Supports definition of mesh facing forward or backward
  93003. * @param amountRight defines the distance on the right axis
  93004. * @param amountUp defines the distance on the up axis
  93005. * @param amountForward defines the distance on the forward axis
  93006. * @returns the new displacement vector
  93007. */
  93008. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93009. /**
  93010. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93011. * Supports definition of mesh facing forward or backward
  93012. * @param flipBack defines the flip
  93013. * @param twirlClockwise defines the twirl
  93014. * @param tiltRight defines the tilt
  93015. * @returns the current mesh
  93016. */
  93017. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93018. /**
  93019. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93020. * Supports definition of mesh facing forward or backward.
  93021. * @param flipBack defines the flip
  93022. * @param twirlClockwise defines the twirl
  93023. * @param tiltRight defines the tilt
  93024. * @returns the new rotation vector
  93025. */
  93026. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93027. /**
  93028. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93029. * This means the mesh underlying bounding box and sphere are recomputed.
  93030. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93031. * @returns the current mesh
  93032. */
  93033. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93034. /** @hidden */
  93035. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93036. /** @hidden */
  93037. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93038. /** @hidden */
  93039. _updateBoundingInfo(): AbstractMesh;
  93040. /** @hidden */
  93041. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93042. /** @hidden */
  93043. protected _afterComputeWorldMatrix(): void;
  93044. /** @hidden */
  93045. readonly _effectiveMesh: AbstractMesh;
  93046. /**
  93047. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93048. * A mesh is in the frustum if its bounding box intersects the frustum
  93049. * @param frustumPlanes defines the frustum to test
  93050. * @returns true if the mesh is in the frustum planes
  93051. */
  93052. isInFrustum(frustumPlanes: Plane[]): boolean;
  93053. /**
  93054. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93055. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93056. * @param frustumPlanes defines the frustum to test
  93057. * @returns true if the mesh is completely in the frustum planes
  93058. */
  93059. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93060. /**
  93061. * True if the mesh intersects another mesh or a SolidParticle object
  93062. * @param mesh defines a target mesh or SolidParticle to test
  93063. * @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)
  93064. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93065. * @returns true if there is an intersection
  93066. */
  93067. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93068. /**
  93069. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93070. * @param point defines the point to test
  93071. * @returns true if there is an intersection
  93072. */
  93073. intersectsPoint(point: Vector3): boolean;
  93074. /**
  93075. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93076. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93077. */
  93078. checkCollisions: boolean;
  93079. /**
  93080. * Gets Collider object used to compute collisions (not physics)
  93081. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93082. */
  93083. readonly collider: Nullable<Collider>;
  93084. /**
  93085. * Move the mesh using collision engine
  93086. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93087. * @param displacement defines the requested displacement vector
  93088. * @returns the current mesh
  93089. */
  93090. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93091. private _onCollisionPositionChange;
  93092. /** @hidden */
  93093. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93094. /** @hidden */
  93095. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93096. /** @hidden */
  93097. _checkCollision(collider: Collider): AbstractMesh;
  93098. /** @hidden */
  93099. _generatePointsArray(): boolean;
  93100. /**
  93101. * Checks if the passed Ray intersects with the mesh
  93102. * @param ray defines the ray to use
  93103. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93104. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93105. * @returns the picking info
  93106. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93107. */
  93108. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93109. /**
  93110. * Clones the current mesh
  93111. * @param name defines the mesh name
  93112. * @param newParent defines the new mesh parent
  93113. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93114. * @returns the new mesh
  93115. */
  93116. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93117. /**
  93118. * Disposes all the submeshes of the current meshnp
  93119. * @returns the current mesh
  93120. */
  93121. releaseSubMeshes(): AbstractMesh;
  93122. /**
  93123. * Releases resources associated with this abstract mesh.
  93124. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93125. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93126. */
  93127. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93128. /**
  93129. * Adds the passed mesh as a child to the current mesh
  93130. * @param mesh defines the child mesh
  93131. * @returns the current mesh
  93132. */
  93133. addChild(mesh: AbstractMesh): AbstractMesh;
  93134. /**
  93135. * Removes the passed mesh from the current mesh children list
  93136. * @param mesh defines the child mesh
  93137. * @returns the current mesh
  93138. */
  93139. removeChild(mesh: AbstractMesh): AbstractMesh;
  93140. /** @hidden */
  93141. private _initFacetData;
  93142. /**
  93143. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93144. * This method can be called within the render loop.
  93145. * 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
  93146. * @returns the current mesh
  93147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93148. */
  93149. updateFacetData(): AbstractMesh;
  93150. /**
  93151. * Returns the facetLocalNormals array.
  93152. * The normals are expressed in the mesh local spac
  93153. * @returns an array of Vector3
  93154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93155. */
  93156. getFacetLocalNormals(): Vector3[];
  93157. /**
  93158. * Returns the facetLocalPositions array.
  93159. * The facet positions are expressed in the mesh local space
  93160. * @returns an array of Vector3
  93161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93162. */
  93163. getFacetLocalPositions(): Vector3[];
  93164. /**
  93165. * Returns the facetLocalPartioning array
  93166. * @returns an array of array of numbers
  93167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93168. */
  93169. getFacetLocalPartitioning(): number[][];
  93170. /**
  93171. * Returns the i-th facet position in the world system.
  93172. * This method allocates a new Vector3 per call
  93173. * @param i defines the facet index
  93174. * @returns a new Vector3
  93175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93176. */
  93177. getFacetPosition(i: number): Vector3;
  93178. /**
  93179. * Sets the reference Vector3 with the i-th facet position in the world system
  93180. * @param i defines the facet index
  93181. * @param ref defines the target vector
  93182. * @returns the current mesh
  93183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93184. */
  93185. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93186. /**
  93187. * Returns the i-th facet normal in the world system.
  93188. * This method allocates a new Vector3 per call
  93189. * @param i defines the facet index
  93190. * @returns a new Vector3
  93191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93192. */
  93193. getFacetNormal(i: number): Vector3;
  93194. /**
  93195. * Sets the reference Vector3 with the i-th facet normal in the world system
  93196. * @param i defines the facet index
  93197. * @param ref defines the target vector
  93198. * @returns the current mesh
  93199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93200. */
  93201. getFacetNormalToRef(i: number, ref: Vector3): this;
  93202. /**
  93203. * 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)
  93204. * @param x defines x coordinate
  93205. * @param y defines y coordinate
  93206. * @param z defines z coordinate
  93207. * @returns the array of facet indexes
  93208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93209. */
  93210. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93211. /**
  93212. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93213. * @param projected sets as the (x,y,z) world projection on the facet
  93214. * @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
  93215. * @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
  93216. * @param x defines x coordinate
  93217. * @param y defines y coordinate
  93218. * @param z defines z coordinate
  93219. * @returns the face index if found (or null instead)
  93220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93221. */
  93222. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93223. /**
  93224. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93225. * @param projected sets as the (x,y,z) local projection on the facet
  93226. * @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
  93227. * @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
  93228. * @param x defines x coordinate
  93229. * @param y defines y coordinate
  93230. * @param z defines z coordinate
  93231. * @returns the face index if found (or null instead)
  93232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93233. */
  93234. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93235. /**
  93236. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93237. * @returns the parameters
  93238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93239. */
  93240. getFacetDataParameters(): any;
  93241. /**
  93242. * Disables the feature FacetData and frees the related memory
  93243. * @returns the current mesh
  93244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93245. */
  93246. disableFacetData(): AbstractMesh;
  93247. /**
  93248. * Updates the AbstractMesh indices array
  93249. * @param indices defines the data source
  93250. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93251. * @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)
  93252. * @returns the current mesh
  93253. */
  93254. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93255. /**
  93256. * Creates new normals data for the mesh
  93257. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93258. * @returns the current mesh
  93259. */
  93260. createNormals(updatable: boolean): AbstractMesh;
  93261. /**
  93262. * Align the mesh with a normal
  93263. * @param normal defines the normal to use
  93264. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93265. * @returns the current mesh
  93266. */
  93267. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93268. /** @hidden */
  93269. _checkOcclusionQuery(): boolean;
  93270. /**
  93271. * Disables the mesh edge rendering mode
  93272. * @returns the currentAbstractMesh
  93273. */
  93274. disableEdgesRendering(): AbstractMesh;
  93275. /**
  93276. * Enables the edge rendering mode on the mesh.
  93277. * This mode makes the mesh edges visible
  93278. * @param epsilon defines the maximal distance between two angles to detect a face
  93279. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93280. * @returns the currentAbstractMesh
  93281. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93282. */
  93283. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93284. }
  93285. }
  93286. declare module BABYLON {
  93287. /**
  93288. * Interface used to define ActionEvent
  93289. */
  93290. export interface IActionEvent {
  93291. /** The mesh or sprite that triggered the action */
  93292. source: any;
  93293. /** The X mouse cursor position at the time of the event */
  93294. pointerX: number;
  93295. /** The Y mouse cursor position at the time of the event */
  93296. pointerY: number;
  93297. /** The mesh that is currently pointed at (can be null) */
  93298. meshUnderPointer: Nullable<AbstractMesh>;
  93299. /** the original (browser) event that triggered the ActionEvent */
  93300. sourceEvent?: any;
  93301. /** additional data for the event */
  93302. additionalData?: any;
  93303. }
  93304. /**
  93305. * ActionEvent is the event being sent when an action is triggered.
  93306. */
  93307. export class ActionEvent implements IActionEvent {
  93308. /** The mesh or sprite that triggered the action */
  93309. source: any;
  93310. /** The X mouse cursor position at the time of the event */
  93311. pointerX: number;
  93312. /** The Y mouse cursor position at the time of the event */
  93313. pointerY: number;
  93314. /** The mesh that is currently pointed at (can be null) */
  93315. meshUnderPointer: Nullable<AbstractMesh>;
  93316. /** the original (browser) event that triggered the ActionEvent */
  93317. sourceEvent?: any;
  93318. /** additional data for the event */
  93319. additionalData?: any;
  93320. /**
  93321. * Creates a new ActionEvent
  93322. * @param source The mesh or sprite that triggered the action
  93323. * @param pointerX The X mouse cursor position at the time of the event
  93324. * @param pointerY The Y mouse cursor position at the time of the event
  93325. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93326. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93327. * @param additionalData additional data for the event
  93328. */
  93329. constructor(
  93330. /** The mesh or sprite that triggered the action */
  93331. source: any,
  93332. /** The X mouse cursor position at the time of the event */
  93333. pointerX: number,
  93334. /** The Y mouse cursor position at the time of the event */
  93335. pointerY: number,
  93336. /** The mesh that is currently pointed at (can be null) */
  93337. meshUnderPointer: Nullable<AbstractMesh>,
  93338. /** the original (browser) event that triggered the ActionEvent */
  93339. sourceEvent?: any,
  93340. /** additional data for the event */
  93341. additionalData?: any);
  93342. /**
  93343. * Helper function to auto-create an ActionEvent from a source mesh.
  93344. * @param source The source mesh that triggered the event
  93345. * @param evt The original (browser) event
  93346. * @param additionalData additional data for the event
  93347. * @returns the new ActionEvent
  93348. */
  93349. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93350. /**
  93351. * Helper function to auto-create an ActionEvent from a source sprite
  93352. * @param source The source sprite that triggered the event
  93353. * @param scene Scene associated with the sprite
  93354. * @param evt The original (browser) event
  93355. * @param additionalData additional data for the event
  93356. * @returns the new ActionEvent
  93357. */
  93358. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93359. /**
  93360. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93361. * @param scene the scene where the event occurred
  93362. * @param evt The original (browser) event
  93363. * @returns the new ActionEvent
  93364. */
  93365. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93366. /**
  93367. * Helper function to auto-create an ActionEvent from a primitive
  93368. * @param prim defines the target primitive
  93369. * @param pointerPos defines the pointer position
  93370. * @param evt The original (browser) event
  93371. * @param additionalData additional data for the event
  93372. * @returns the new ActionEvent
  93373. */
  93374. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93375. }
  93376. }
  93377. declare module BABYLON {
  93378. /**
  93379. * Abstract class used to decouple action Manager from scene and meshes.
  93380. * Do not instantiate.
  93381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93382. */
  93383. export abstract class AbstractActionManager implements IDisposable {
  93384. /** Gets the list of active triggers */
  93385. static Triggers: {
  93386. [key: string]: number;
  93387. };
  93388. /** Gets the cursor to use when hovering items */
  93389. hoverCursor: string;
  93390. /** Gets the list of actions */
  93391. actions: IAction[];
  93392. /**
  93393. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93394. */
  93395. isRecursive: boolean;
  93396. /**
  93397. * Releases all associated resources
  93398. */
  93399. abstract dispose(): void;
  93400. /**
  93401. * Does this action manager has pointer triggers
  93402. */
  93403. abstract readonly hasPointerTriggers: boolean;
  93404. /**
  93405. * Does this action manager has pick triggers
  93406. */
  93407. abstract readonly hasPickTriggers: boolean;
  93408. /**
  93409. * Process a specific trigger
  93410. * @param trigger defines the trigger to process
  93411. * @param evt defines the event details to be processed
  93412. */
  93413. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93414. /**
  93415. * Does this action manager handles actions of any of the given triggers
  93416. * @param triggers defines the triggers to be tested
  93417. * @return a boolean indicating whether one (or more) of the triggers is handled
  93418. */
  93419. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93420. /**
  93421. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93422. * speed.
  93423. * @param triggerA defines the trigger to be tested
  93424. * @param triggerB defines the trigger to be tested
  93425. * @return a boolean indicating whether one (or more) of the triggers is handled
  93426. */
  93427. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93428. /**
  93429. * Does this action manager handles actions of a given trigger
  93430. * @param trigger defines the trigger to be tested
  93431. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93432. * @return whether the trigger is handled
  93433. */
  93434. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93435. /**
  93436. * Serialize this manager to a JSON object
  93437. * @param name defines the property name to store this manager
  93438. * @returns a JSON representation of this manager
  93439. */
  93440. abstract serialize(name: string): any;
  93441. /**
  93442. * Registers an action to this action manager
  93443. * @param action defines the action to be registered
  93444. * @return the action amended (prepared) after registration
  93445. */
  93446. abstract registerAction(action: IAction): Nullable<IAction>;
  93447. /**
  93448. * Unregisters an action to this action manager
  93449. * @param action defines the action to be unregistered
  93450. * @return a boolean indicating whether the action has been unregistered
  93451. */
  93452. abstract unregisterAction(action: IAction): Boolean;
  93453. /**
  93454. * Does exist one action manager with at least one trigger
  93455. **/
  93456. static readonly HasTriggers: boolean;
  93457. /**
  93458. * Does exist one action manager with at least one pick trigger
  93459. **/
  93460. static readonly HasPickTriggers: boolean;
  93461. /**
  93462. * Does exist one action manager that handles actions of a given trigger
  93463. * @param trigger defines the trigger to be tested
  93464. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93465. **/
  93466. static HasSpecificTrigger(trigger: number): boolean;
  93467. }
  93468. }
  93469. declare module BABYLON {
  93470. /**
  93471. * Defines how a node can be built from a string name.
  93472. */
  93473. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93474. /**
  93475. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93476. */
  93477. export class Node implements IBehaviorAware<Node> {
  93478. /** @hidden */
  93479. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93480. private static _NodeConstructors;
  93481. /**
  93482. * Add a new node constructor
  93483. * @param type defines the type name of the node to construct
  93484. * @param constructorFunc defines the constructor function
  93485. */
  93486. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93487. /**
  93488. * Returns a node constructor based on type name
  93489. * @param type defines the type name
  93490. * @param name defines the new node name
  93491. * @param scene defines the hosting scene
  93492. * @param options defines optional options to transmit to constructors
  93493. * @returns the new constructor or null
  93494. */
  93495. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93496. /**
  93497. * Gets or sets the name of the node
  93498. */
  93499. name: string;
  93500. /**
  93501. * Gets or sets the id of the node
  93502. */
  93503. id: string;
  93504. /**
  93505. * Gets or sets the unique id of the node
  93506. */
  93507. uniqueId: number;
  93508. /**
  93509. * Gets or sets a string used to store user defined state for the node
  93510. */
  93511. state: string;
  93512. /**
  93513. * Gets or sets an object used to store user defined information for the node
  93514. */
  93515. metadata: any;
  93516. /**
  93517. * For internal use only. Please do not use.
  93518. */
  93519. reservedDataStore: any;
  93520. /**
  93521. * List of inspectable custom properties (used by the Inspector)
  93522. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93523. */
  93524. inspectableCustomProperties: IInspectable[];
  93525. /**
  93526. * Gets or sets a boolean used to define if the node must be serialized
  93527. */
  93528. doNotSerialize: boolean;
  93529. /** @hidden */
  93530. _isDisposed: boolean;
  93531. /**
  93532. * Gets a list of Animations associated with the node
  93533. */
  93534. animations: Animation[];
  93535. protected _ranges: {
  93536. [name: string]: Nullable<AnimationRange>;
  93537. };
  93538. /**
  93539. * Callback raised when the node is ready to be used
  93540. */
  93541. onReady: Nullable<(node: Node) => void>;
  93542. private _isEnabled;
  93543. private _isParentEnabled;
  93544. private _isReady;
  93545. /** @hidden */
  93546. _currentRenderId: number;
  93547. private _parentUpdateId;
  93548. /** @hidden */
  93549. _childUpdateId: number;
  93550. /** @hidden */
  93551. _waitingParentId: Nullable<string>;
  93552. /** @hidden */
  93553. _scene: Scene;
  93554. /** @hidden */
  93555. _cache: any;
  93556. private _parentNode;
  93557. private _children;
  93558. /** @hidden */
  93559. _worldMatrix: Matrix;
  93560. /** @hidden */
  93561. _worldMatrixDeterminant: number;
  93562. /** @hidden */
  93563. _worldMatrixDeterminantIsDirty: boolean;
  93564. /** @hidden */
  93565. private _sceneRootNodesIndex;
  93566. /**
  93567. * Gets a boolean indicating if the node has been disposed
  93568. * @returns true if the node was disposed
  93569. */
  93570. isDisposed(): boolean;
  93571. /**
  93572. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93573. * @see https://doc.babylonjs.com/how_to/parenting
  93574. */
  93575. parent: Nullable<Node>;
  93576. private addToSceneRootNodes;
  93577. private removeFromSceneRootNodes;
  93578. private _animationPropertiesOverride;
  93579. /**
  93580. * Gets or sets the animation properties override
  93581. */
  93582. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93583. /**
  93584. * Gets a string idenfifying the name of the class
  93585. * @returns "Node" string
  93586. */
  93587. getClassName(): string;
  93588. /** @hidden */
  93589. readonly _isNode: boolean;
  93590. /**
  93591. * An event triggered when the mesh is disposed
  93592. */
  93593. onDisposeObservable: Observable<Node>;
  93594. private _onDisposeObserver;
  93595. /**
  93596. * Sets a callback that will be raised when the node will be disposed
  93597. */
  93598. onDispose: () => void;
  93599. /**
  93600. * Creates a new Node
  93601. * @param name the name and id to be given to this node
  93602. * @param scene the scene this node will be added to
  93603. * @param addToRootNodes the node will be added to scene.rootNodes
  93604. */
  93605. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93606. /**
  93607. * Gets the scene of the node
  93608. * @returns a scene
  93609. */
  93610. getScene(): Scene;
  93611. /**
  93612. * Gets the engine of the node
  93613. * @returns a Engine
  93614. */
  93615. getEngine(): Engine;
  93616. private _behaviors;
  93617. /**
  93618. * Attach a behavior to the node
  93619. * @see http://doc.babylonjs.com/features/behaviour
  93620. * @param behavior defines the behavior to attach
  93621. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93622. * @returns the current Node
  93623. */
  93624. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93625. /**
  93626. * Remove an attached behavior
  93627. * @see http://doc.babylonjs.com/features/behaviour
  93628. * @param behavior defines the behavior to attach
  93629. * @returns the current Node
  93630. */
  93631. removeBehavior(behavior: Behavior<Node>): Node;
  93632. /**
  93633. * Gets the list of attached behaviors
  93634. * @see http://doc.babylonjs.com/features/behaviour
  93635. */
  93636. readonly behaviors: Behavior<Node>[];
  93637. /**
  93638. * Gets an attached behavior by name
  93639. * @param name defines the name of the behavior to look for
  93640. * @see http://doc.babylonjs.com/features/behaviour
  93641. * @returns null if behavior was not found else the requested behavior
  93642. */
  93643. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93644. /**
  93645. * Returns the latest update of the World matrix
  93646. * @returns a Matrix
  93647. */
  93648. getWorldMatrix(): Matrix;
  93649. /** @hidden */
  93650. _getWorldMatrixDeterminant(): number;
  93651. /**
  93652. * Returns directly the latest state of the mesh World matrix.
  93653. * A Matrix is returned.
  93654. */
  93655. readonly worldMatrixFromCache: Matrix;
  93656. /** @hidden */
  93657. _initCache(): void;
  93658. /** @hidden */
  93659. updateCache(force?: boolean): void;
  93660. /** @hidden */
  93661. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93662. /** @hidden */
  93663. _updateCache(ignoreParentClass?: boolean): void;
  93664. /** @hidden */
  93665. _isSynchronized(): boolean;
  93666. /** @hidden */
  93667. _markSyncedWithParent(): void;
  93668. /** @hidden */
  93669. isSynchronizedWithParent(): boolean;
  93670. /** @hidden */
  93671. isSynchronized(): boolean;
  93672. /**
  93673. * Is this node ready to be used/rendered
  93674. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93675. * @return true if the node is ready
  93676. */
  93677. isReady(completeCheck?: boolean): boolean;
  93678. /**
  93679. * Is this node enabled?
  93680. * 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
  93681. * @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
  93682. * @return whether this node (and its parent) is enabled
  93683. */
  93684. isEnabled(checkAncestors?: boolean): boolean;
  93685. /** @hidden */
  93686. protected _syncParentEnabledState(): void;
  93687. /**
  93688. * Set the enabled state of this node
  93689. * @param value defines the new enabled state
  93690. */
  93691. setEnabled(value: boolean): void;
  93692. /**
  93693. * Is this node a descendant of the given node?
  93694. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93695. * @param ancestor defines the parent node to inspect
  93696. * @returns a boolean indicating if this node is a descendant of the given node
  93697. */
  93698. isDescendantOf(ancestor: Node): boolean;
  93699. /** @hidden */
  93700. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93701. /**
  93702. * Will return all nodes that have this node as ascendant
  93703. * @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
  93704. * @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
  93705. * @return all children nodes of all types
  93706. */
  93707. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93708. /**
  93709. * Get all child-meshes of this node
  93710. * @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)
  93711. * @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
  93712. * @returns an array of AbstractMesh
  93713. */
  93714. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93715. /**
  93716. * Get all direct children of this node
  93717. * @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
  93718. * @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)
  93719. * @returns an array of Node
  93720. */
  93721. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93722. /** @hidden */
  93723. _setReady(state: boolean): void;
  93724. /**
  93725. * Get an animation by name
  93726. * @param name defines the name of the animation to look for
  93727. * @returns null if not found else the requested animation
  93728. */
  93729. getAnimationByName(name: string): Nullable<Animation>;
  93730. /**
  93731. * Creates an animation range for this node
  93732. * @param name defines the name of the range
  93733. * @param from defines the starting key
  93734. * @param to defines the end key
  93735. */
  93736. createAnimationRange(name: string, from: number, to: number): void;
  93737. /**
  93738. * Delete a specific animation range
  93739. * @param name defines the name of the range to delete
  93740. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93741. */
  93742. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93743. /**
  93744. * Get an animation range by name
  93745. * @param name defines the name of the animation range to look for
  93746. * @returns null if not found else the requested animation range
  93747. */
  93748. getAnimationRange(name: string): Nullable<AnimationRange>;
  93749. /**
  93750. * Gets the list of all animation ranges defined on this node
  93751. * @returns an array
  93752. */
  93753. getAnimationRanges(): Nullable<AnimationRange>[];
  93754. /**
  93755. * Will start the animation sequence
  93756. * @param name defines the range frames for animation sequence
  93757. * @param loop defines if the animation should loop (false by default)
  93758. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93759. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93760. * @returns the object created for this animation. If range does not exist, it will return null
  93761. */
  93762. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93763. /**
  93764. * Serialize animation ranges into a JSON compatible object
  93765. * @returns serialization object
  93766. */
  93767. serializeAnimationRanges(): any;
  93768. /**
  93769. * Computes the world matrix of the node
  93770. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93771. * @returns the world matrix
  93772. */
  93773. computeWorldMatrix(force?: boolean): Matrix;
  93774. /**
  93775. * Releases resources associated with this node.
  93776. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93777. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93778. */
  93779. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93780. /**
  93781. * Parse animation range data from a serialization object and store them into a given node
  93782. * @param node defines where to store the animation ranges
  93783. * @param parsedNode defines the serialization object to read data from
  93784. * @param scene defines the hosting scene
  93785. */
  93786. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93787. /**
  93788. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93789. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93790. * @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
  93791. * @returns the new bounding vectors
  93792. */
  93793. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93794. min: Vector3;
  93795. max: Vector3;
  93796. };
  93797. }
  93798. }
  93799. declare module BABYLON {
  93800. /**
  93801. * @hidden
  93802. */
  93803. export class _IAnimationState {
  93804. key: number;
  93805. repeatCount: number;
  93806. workValue?: any;
  93807. loopMode?: number;
  93808. offsetValue?: any;
  93809. highLimitValue?: any;
  93810. }
  93811. /**
  93812. * Class used to store any kind of animation
  93813. */
  93814. export class Animation {
  93815. /**Name of the animation */
  93816. name: string;
  93817. /**Property to animate */
  93818. targetProperty: string;
  93819. /**The frames per second of the animation */
  93820. framePerSecond: number;
  93821. /**The data type of the animation */
  93822. dataType: number;
  93823. /**The loop mode of the animation */
  93824. loopMode?: number | undefined;
  93825. /**Specifies if blending should be enabled */
  93826. enableBlending?: boolean | undefined;
  93827. /**
  93828. * Use matrix interpolation instead of using direct key value when animating matrices
  93829. */
  93830. static AllowMatricesInterpolation: boolean;
  93831. /**
  93832. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93833. */
  93834. static AllowMatrixDecomposeForInterpolation: boolean;
  93835. /**
  93836. * Stores the key frames of the animation
  93837. */
  93838. private _keys;
  93839. /**
  93840. * Stores the easing function of the animation
  93841. */
  93842. private _easingFunction;
  93843. /**
  93844. * @hidden Internal use only
  93845. */
  93846. _runtimeAnimations: RuntimeAnimation[];
  93847. /**
  93848. * The set of event that will be linked to this animation
  93849. */
  93850. private _events;
  93851. /**
  93852. * Stores an array of target property paths
  93853. */
  93854. targetPropertyPath: string[];
  93855. /**
  93856. * Stores the blending speed of the animation
  93857. */
  93858. blendingSpeed: number;
  93859. /**
  93860. * Stores the animation ranges for the animation
  93861. */
  93862. private _ranges;
  93863. /**
  93864. * @hidden Internal use
  93865. */
  93866. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93867. /**
  93868. * Sets up an animation
  93869. * @param property The property to animate
  93870. * @param animationType The animation type to apply
  93871. * @param framePerSecond The frames per second of the animation
  93872. * @param easingFunction The easing function used in the animation
  93873. * @returns The created animation
  93874. */
  93875. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93876. /**
  93877. * Create and start an animation on a node
  93878. * @param name defines the name of the global animation that will be run on all nodes
  93879. * @param node defines the root node where the animation will take place
  93880. * @param targetProperty defines property to animate
  93881. * @param framePerSecond defines the number of frame per second yo use
  93882. * @param totalFrame defines the number of frames in total
  93883. * @param from defines the initial value
  93884. * @param to defines the final value
  93885. * @param loopMode defines which loop mode you want to use (off by default)
  93886. * @param easingFunction defines the easing function to use (linear by default)
  93887. * @param onAnimationEnd defines the callback to call when animation end
  93888. * @returns the animatable created for this animation
  93889. */
  93890. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93891. /**
  93892. * Create and start an animation on a node and its descendants
  93893. * @param name defines the name of the global animation that will be run on all nodes
  93894. * @param node defines the root node where the animation will take place
  93895. * @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
  93896. * @param targetProperty defines property to animate
  93897. * @param framePerSecond defines the number of frame per second to use
  93898. * @param totalFrame defines the number of frames in total
  93899. * @param from defines the initial value
  93900. * @param to defines the final value
  93901. * @param loopMode defines which loop mode you want to use (off by default)
  93902. * @param easingFunction defines the easing function to use (linear by default)
  93903. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93904. * @returns the list of animatables created for all nodes
  93905. * @example https://www.babylonjs-playground.com/#MH0VLI
  93906. */
  93907. 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[]>;
  93908. /**
  93909. * Creates a new animation, merges it with the existing animations and starts it
  93910. * @param name Name of the animation
  93911. * @param node Node which contains the scene that begins the animations
  93912. * @param targetProperty Specifies which property to animate
  93913. * @param framePerSecond The frames per second of the animation
  93914. * @param totalFrame The total number of frames
  93915. * @param from The frame at the beginning of the animation
  93916. * @param to The frame at the end of the animation
  93917. * @param loopMode Specifies the loop mode of the animation
  93918. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93919. * @param onAnimationEnd Callback to run once the animation is complete
  93920. * @returns Nullable animation
  93921. */
  93922. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93923. /**
  93924. * Transition property of an host to the target Value
  93925. * @param property The property to transition
  93926. * @param targetValue The target Value of the property
  93927. * @param host The object where the property to animate belongs
  93928. * @param scene Scene used to run the animation
  93929. * @param frameRate Framerate (in frame/s) to use
  93930. * @param transition The transition type we want to use
  93931. * @param duration The duration of the animation, in milliseconds
  93932. * @param onAnimationEnd Callback trigger at the end of the animation
  93933. * @returns Nullable animation
  93934. */
  93935. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93936. /**
  93937. * Return the array of runtime animations currently using this animation
  93938. */
  93939. readonly runtimeAnimations: RuntimeAnimation[];
  93940. /**
  93941. * Specifies if any of the runtime animations are currently running
  93942. */
  93943. readonly hasRunningRuntimeAnimations: boolean;
  93944. /**
  93945. * Initializes the animation
  93946. * @param name Name of the animation
  93947. * @param targetProperty Property to animate
  93948. * @param framePerSecond The frames per second of the animation
  93949. * @param dataType The data type of the animation
  93950. * @param loopMode The loop mode of the animation
  93951. * @param enableBlending Specifies if blending should be enabled
  93952. */
  93953. constructor(
  93954. /**Name of the animation */
  93955. name: string,
  93956. /**Property to animate */
  93957. targetProperty: string,
  93958. /**The frames per second of the animation */
  93959. framePerSecond: number,
  93960. /**The data type of the animation */
  93961. dataType: number,
  93962. /**The loop mode of the animation */
  93963. loopMode?: number | undefined,
  93964. /**Specifies if blending should be enabled */
  93965. enableBlending?: boolean | undefined);
  93966. /**
  93967. * Converts the animation to a string
  93968. * @param fullDetails support for multiple levels of logging within scene loading
  93969. * @returns String form of the animation
  93970. */
  93971. toString(fullDetails?: boolean): string;
  93972. /**
  93973. * Add an event to this animation
  93974. * @param event Event to add
  93975. */
  93976. addEvent(event: AnimationEvent): void;
  93977. /**
  93978. * Remove all events found at the given frame
  93979. * @param frame The frame to remove events from
  93980. */
  93981. removeEvents(frame: number): void;
  93982. /**
  93983. * Retrieves all the events from the animation
  93984. * @returns Events from the animation
  93985. */
  93986. getEvents(): AnimationEvent[];
  93987. /**
  93988. * Creates an animation range
  93989. * @param name Name of the animation range
  93990. * @param from Starting frame of the animation range
  93991. * @param to Ending frame of the animation
  93992. */
  93993. createRange(name: string, from: number, to: number): void;
  93994. /**
  93995. * Deletes an animation range by name
  93996. * @param name Name of the animation range to delete
  93997. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  93998. */
  93999. deleteRange(name: string, deleteFrames?: boolean): void;
  94000. /**
  94001. * Gets the animation range by name, or null if not defined
  94002. * @param name Name of the animation range
  94003. * @returns Nullable animation range
  94004. */
  94005. getRange(name: string): Nullable<AnimationRange>;
  94006. /**
  94007. * Gets the key frames from the animation
  94008. * @returns The key frames of the animation
  94009. */
  94010. getKeys(): Array<IAnimationKey>;
  94011. /**
  94012. * Gets the highest frame rate of the animation
  94013. * @returns Highest frame rate of the animation
  94014. */
  94015. getHighestFrame(): number;
  94016. /**
  94017. * Gets the easing function of the animation
  94018. * @returns Easing function of the animation
  94019. */
  94020. getEasingFunction(): IEasingFunction;
  94021. /**
  94022. * Sets the easing function of the animation
  94023. * @param easingFunction A custom mathematical formula for animation
  94024. */
  94025. setEasingFunction(easingFunction: EasingFunction): void;
  94026. /**
  94027. * Interpolates a scalar linearly
  94028. * @param startValue Start value of the animation curve
  94029. * @param endValue End value of the animation curve
  94030. * @param gradient Scalar amount to interpolate
  94031. * @returns Interpolated scalar value
  94032. */
  94033. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94034. /**
  94035. * Interpolates a scalar cubically
  94036. * @param startValue Start value of the animation curve
  94037. * @param outTangent End tangent of the animation
  94038. * @param endValue End value of the animation curve
  94039. * @param inTangent Start tangent of the animation curve
  94040. * @param gradient Scalar amount to interpolate
  94041. * @returns Interpolated scalar value
  94042. */
  94043. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94044. /**
  94045. * Interpolates a quaternion using a spherical linear interpolation
  94046. * @param startValue Start value of the animation curve
  94047. * @param endValue End value of the animation curve
  94048. * @param gradient Scalar amount to interpolate
  94049. * @returns Interpolated quaternion value
  94050. */
  94051. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94052. /**
  94053. * Interpolates a quaternion cubically
  94054. * @param startValue Start value of the animation curve
  94055. * @param outTangent End tangent of the animation curve
  94056. * @param endValue End value of the animation curve
  94057. * @param inTangent Start tangent of the animation curve
  94058. * @param gradient Scalar amount to interpolate
  94059. * @returns Interpolated quaternion value
  94060. */
  94061. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94062. /**
  94063. * Interpolates a Vector3 linearl
  94064. * @param startValue Start value of the animation curve
  94065. * @param endValue End value of the animation curve
  94066. * @param gradient Scalar amount to interpolate
  94067. * @returns Interpolated scalar value
  94068. */
  94069. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94070. /**
  94071. * Interpolates a Vector3 cubically
  94072. * @param startValue Start value of the animation curve
  94073. * @param outTangent End tangent of the animation
  94074. * @param endValue End value of the animation curve
  94075. * @param inTangent Start tangent of the animation curve
  94076. * @param gradient Scalar amount to interpolate
  94077. * @returns InterpolatedVector3 value
  94078. */
  94079. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94080. /**
  94081. * Interpolates a Vector2 linearly
  94082. * @param startValue Start value of the animation curve
  94083. * @param endValue End value of the animation curve
  94084. * @param gradient Scalar amount to interpolate
  94085. * @returns Interpolated Vector2 value
  94086. */
  94087. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94088. /**
  94089. * Interpolates a Vector2 cubically
  94090. * @param startValue Start value of the animation curve
  94091. * @param outTangent End tangent of the animation
  94092. * @param endValue End value of the animation curve
  94093. * @param inTangent Start tangent of the animation curve
  94094. * @param gradient Scalar amount to interpolate
  94095. * @returns Interpolated Vector2 value
  94096. */
  94097. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94098. /**
  94099. * Interpolates a size linearly
  94100. * @param startValue Start value of the animation curve
  94101. * @param endValue End value of the animation curve
  94102. * @param gradient Scalar amount to interpolate
  94103. * @returns Interpolated Size value
  94104. */
  94105. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94106. /**
  94107. * Interpolates a Color3 linearly
  94108. * @param startValue Start value of the animation curve
  94109. * @param endValue End value of the animation curve
  94110. * @param gradient Scalar amount to interpolate
  94111. * @returns Interpolated Color3 value
  94112. */
  94113. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94114. /**
  94115. * @hidden Internal use only
  94116. */
  94117. _getKeyValue(value: any): any;
  94118. /**
  94119. * @hidden Internal use only
  94120. */
  94121. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94122. /**
  94123. * Defines the function to use to interpolate matrices
  94124. * @param startValue defines the start matrix
  94125. * @param endValue defines the end matrix
  94126. * @param gradient defines the gradient between both matrices
  94127. * @param result defines an optional target matrix where to store the interpolation
  94128. * @returns the interpolated matrix
  94129. */
  94130. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94131. /**
  94132. * Makes a copy of the animation
  94133. * @returns Cloned animation
  94134. */
  94135. clone(): Animation;
  94136. /**
  94137. * Sets the key frames of the animation
  94138. * @param values The animation key frames to set
  94139. */
  94140. setKeys(values: Array<IAnimationKey>): void;
  94141. /**
  94142. * Serializes the animation to an object
  94143. * @returns Serialized object
  94144. */
  94145. serialize(): any;
  94146. /**
  94147. * Float animation type
  94148. */
  94149. private static _ANIMATIONTYPE_FLOAT;
  94150. /**
  94151. * Vector3 animation type
  94152. */
  94153. private static _ANIMATIONTYPE_VECTOR3;
  94154. /**
  94155. * Quaternion animation type
  94156. */
  94157. private static _ANIMATIONTYPE_QUATERNION;
  94158. /**
  94159. * Matrix animation type
  94160. */
  94161. private static _ANIMATIONTYPE_MATRIX;
  94162. /**
  94163. * Color3 animation type
  94164. */
  94165. private static _ANIMATIONTYPE_COLOR3;
  94166. /**
  94167. * Vector2 animation type
  94168. */
  94169. private static _ANIMATIONTYPE_VECTOR2;
  94170. /**
  94171. * Size animation type
  94172. */
  94173. private static _ANIMATIONTYPE_SIZE;
  94174. /**
  94175. * Relative Loop Mode
  94176. */
  94177. private static _ANIMATIONLOOPMODE_RELATIVE;
  94178. /**
  94179. * Cycle Loop Mode
  94180. */
  94181. private static _ANIMATIONLOOPMODE_CYCLE;
  94182. /**
  94183. * Constant Loop Mode
  94184. */
  94185. private static _ANIMATIONLOOPMODE_CONSTANT;
  94186. /**
  94187. * Get the float animation type
  94188. */
  94189. static readonly ANIMATIONTYPE_FLOAT: number;
  94190. /**
  94191. * Get the Vector3 animation type
  94192. */
  94193. static readonly ANIMATIONTYPE_VECTOR3: number;
  94194. /**
  94195. * Get the Vector2 animation type
  94196. */
  94197. static readonly ANIMATIONTYPE_VECTOR2: number;
  94198. /**
  94199. * Get the Size animation type
  94200. */
  94201. static readonly ANIMATIONTYPE_SIZE: number;
  94202. /**
  94203. * Get the Quaternion animation type
  94204. */
  94205. static readonly ANIMATIONTYPE_QUATERNION: number;
  94206. /**
  94207. * Get the Matrix animation type
  94208. */
  94209. static readonly ANIMATIONTYPE_MATRIX: number;
  94210. /**
  94211. * Get the Color3 animation type
  94212. */
  94213. static readonly ANIMATIONTYPE_COLOR3: number;
  94214. /**
  94215. * Get the Relative Loop Mode
  94216. */
  94217. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94218. /**
  94219. * Get the Cycle Loop Mode
  94220. */
  94221. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94222. /**
  94223. * Get the Constant Loop Mode
  94224. */
  94225. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94226. /** @hidden */
  94227. static _UniversalLerp(left: any, right: any, amount: number): any;
  94228. /**
  94229. * Parses an animation object and creates an animation
  94230. * @param parsedAnimation Parsed animation object
  94231. * @returns Animation object
  94232. */
  94233. static Parse(parsedAnimation: any): Animation;
  94234. /**
  94235. * Appends the serialized animations from the source animations
  94236. * @param source Source containing the animations
  94237. * @param destination Target to store the animations
  94238. */
  94239. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94240. }
  94241. }
  94242. declare module BABYLON {
  94243. /**
  94244. * Interface containing an array of animations
  94245. */
  94246. export interface IAnimatable {
  94247. /**
  94248. * Array of animations
  94249. */
  94250. animations: Nullable<Array<Animation>>;
  94251. }
  94252. }
  94253. declare module BABYLON {
  94254. /**
  94255. * This represents all the required information to add a fresnel effect on a material:
  94256. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94257. */
  94258. export class FresnelParameters {
  94259. private _isEnabled;
  94260. /**
  94261. * Define if the fresnel effect is enable or not.
  94262. */
  94263. isEnabled: boolean;
  94264. /**
  94265. * Define the color used on edges (grazing angle)
  94266. */
  94267. leftColor: Color3;
  94268. /**
  94269. * Define the color used on center
  94270. */
  94271. rightColor: Color3;
  94272. /**
  94273. * Define bias applied to computed fresnel term
  94274. */
  94275. bias: number;
  94276. /**
  94277. * Defined the power exponent applied to fresnel term
  94278. */
  94279. power: number;
  94280. /**
  94281. * Clones the current fresnel and its valuues
  94282. * @returns a clone fresnel configuration
  94283. */
  94284. clone(): FresnelParameters;
  94285. /**
  94286. * Serializes the current fresnel parameters to a JSON representation.
  94287. * @return the JSON serialization
  94288. */
  94289. serialize(): any;
  94290. /**
  94291. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94292. * @param parsedFresnelParameters Define the JSON representation
  94293. * @returns the parsed parameters
  94294. */
  94295. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94296. }
  94297. }
  94298. declare module BABYLON {
  94299. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94300. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94301. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94302. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94303. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94304. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94305. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94306. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94307. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94308. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94309. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94310. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94311. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94312. /**
  94313. * Decorator used to define property that can be serialized as reference to a camera
  94314. * @param sourceName defines the name of the property to decorate
  94315. */
  94316. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94317. /**
  94318. * Class used to help serialization objects
  94319. */
  94320. export class SerializationHelper {
  94321. /** @hidden */
  94322. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94323. /** @hidden */
  94324. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94325. /** @hidden */
  94326. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94327. /** @hidden */
  94328. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94329. /**
  94330. * Appends the serialized animations from the source animations
  94331. * @param source Source containing the animations
  94332. * @param destination Target to store the animations
  94333. */
  94334. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94335. /**
  94336. * Static function used to serialized a specific entity
  94337. * @param entity defines the entity to serialize
  94338. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94339. * @returns a JSON compatible object representing the serialization of the entity
  94340. */
  94341. static Serialize<T>(entity: T, serializationObject?: any): any;
  94342. /**
  94343. * Creates a new entity from a serialization data object
  94344. * @param creationFunction defines a function used to instanciated the new entity
  94345. * @param source defines the source serialization data
  94346. * @param scene defines the hosting scene
  94347. * @param rootUrl defines the root url for resources
  94348. * @returns a new entity
  94349. */
  94350. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94351. /**
  94352. * Clones an object
  94353. * @param creationFunction defines the function used to instanciate the new object
  94354. * @param source defines the source object
  94355. * @returns the cloned object
  94356. */
  94357. static Clone<T>(creationFunction: () => T, source: T): T;
  94358. /**
  94359. * Instanciates a new object based on a source one (some data will be shared between both object)
  94360. * @param creationFunction defines the function used to instanciate the new object
  94361. * @param source defines the source object
  94362. * @returns the new object
  94363. */
  94364. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94365. }
  94366. }
  94367. declare module BABYLON {
  94368. /**
  94369. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  94370. */
  94371. export interface CubeMapInfo {
  94372. /**
  94373. * The pixel array for the front face.
  94374. * This is stored in format, left to right, up to down format.
  94375. */
  94376. front: Nullable<ArrayBufferView>;
  94377. /**
  94378. * The pixel array for the back face.
  94379. * This is stored in format, left to right, up to down format.
  94380. */
  94381. back: Nullable<ArrayBufferView>;
  94382. /**
  94383. * The pixel array for the left face.
  94384. * This is stored in format, left to right, up to down format.
  94385. */
  94386. left: Nullable<ArrayBufferView>;
  94387. /**
  94388. * The pixel array for the right face.
  94389. * This is stored in format, left to right, up to down format.
  94390. */
  94391. right: Nullable<ArrayBufferView>;
  94392. /**
  94393. * The pixel array for the up face.
  94394. * This is stored in format, left to right, up to down format.
  94395. */
  94396. up: Nullable<ArrayBufferView>;
  94397. /**
  94398. * The pixel array for the down face.
  94399. * This is stored in format, left to right, up to down format.
  94400. */
  94401. down: Nullable<ArrayBufferView>;
  94402. /**
  94403. * The size of the cubemap stored.
  94404. *
  94405. * Each faces will be size * size pixels.
  94406. */
  94407. size: number;
  94408. /**
  94409. * The format of the texture.
  94410. *
  94411. * RGBA, RGB.
  94412. */
  94413. format: number;
  94414. /**
  94415. * The type of the texture data.
  94416. *
  94417. * UNSIGNED_INT, FLOAT.
  94418. */
  94419. type: number;
  94420. /**
  94421. * Specifies whether the texture is in gamma space.
  94422. */
  94423. gammaSpace: boolean;
  94424. }
  94425. /**
  94426. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94427. */
  94428. export class PanoramaToCubeMapTools {
  94429. private static FACE_FRONT;
  94430. private static FACE_BACK;
  94431. private static FACE_RIGHT;
  94432. private static FACE_LEFT;
  94433. private static FACE_DOWN;
  94434. private static FACE_UP;
  94435. /**
  94436. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94437. *
  94438. * @param float32Array The source data.
  94439. * @param inputWidth The width of the input panorama.
  94440. * @param inputHeight The height of the input panorama.
  94441. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94442. * @return The cubemap data
  94443. */
  94444. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  94445. private static CreateCubemapTexture;
  94446. private static CalcProjectionSpherical;
  94447. }
  94448. }
  94449. declare module BABYLON {
  94450. /**
  94451. * Helper class dealing with the extraction of spherical polynomial dataArray
  94452. * from a cube map.
  94453. */
  94454. export class CubeMapToSphericalPolynomialTools {
  94455. private static FileFaces;
  94456. /**
  94457. * Converts a texture to the according Spherical Polynomial data.
  94458. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94459. *
  94460. * @param texture The texture to extract the information from.
  94461. * @return The Spherical Polynomial data.
  94462. */
  94463. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  94464. /**
  94465. * Converts a cubemap to the according Spherical Polynomial data.
  94466. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94467. *
  94468. * @param cubeInfo The Cube map to extract the information from.
  94469. * @return The Spherical Polynomial data.
  94470. */
  94471. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  94472. }
  94473. }
  94474. declare module BABYLON {
  94475. /**
  94476. * Class used to manipulate GUIDs
  94477. */
  94478. export class GUID {
  94479. /**
  94480. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94481. * Be aware Math.random() could cause collisions, but:
  94482. * "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"
  94483. * @returns a pseudo random id
  94484. */
  94485. static RandomId(): string;
  94486. }
  94487. }
  94488. declare module BABYLON {
  94489. /**
  94490. * Base class of all the textures in babylon.
  94491. * It groups all the common properties the materials, post process, lights... might need
  94492. * in order to make a correct use of the texture.
  94493. */
  94494. export class BaseTexture implements IAnimatable {
  94495. /**
  94496. * Default anisotropic filtering level for the application.
  94497. * It is set to 4 as a good tradeoff between perf and quality.
  94498. */
  94499. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94500. /**
  94501. * Gets or sets the unique id of the texture
  94502. */
  94503. uniqueId: number;
  94504. /**
  94505. * Define the name of the texture.
  94506. */
  94507. name: string;
  94508. /**
  94509. * Gets or sets an object used to store user defined information.
  94510. */
  94511. metadata: any;
  94512. /**
  94513. * For internal use only. Please do not use.
  94514. */
  94515. reservedDataStore: any;
  94516. private _hasAlpha;
  94517. /**
  94518. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94519. */
  94520. hasAlpha: boolean;
  94521. /**
  94522. * Defines if the alpha value should be determined via the rgb values.
  94523. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94524. */
  94525. getAlphaFromRGB: boolean;
  94526. /**
  94527. * Intensity or strength of the texture.
  94528. * It is commonly used by materials to fine tune the intensity of the texture
  94529. */
  94530. level: number;
  94531. /**
  94532. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94533. * This is part of the texture as textures usually maps to one uv set.
  94534. */
  94535. coordinatesIndex: number;
  94536. private _coordinatesMode;
  94537. /**
  94538. * How a texture is mapped.
  94539. *
  94540. * | Value | Type | Description |
  94541. * | ----- | ----------------------------------- | ----------- |
  94542. * | 0 | EXPLICIT_MODE | |
  94543. * | 1 | SPHERICAL_MODE | |
  94544. * | 2 | PLANAR_MODE | |
  94545. * | 3 | CUBIC_MODE | |
  94546. * | 4 | PROJECTION_MODE | |
  94547. * | 5 | SKYBOX_MODE | |
  94548. * | 6 | INVCUBIC_MODE | |
  94549. * | 7 | EQUIRECTANGULAR_MODE | |
  94550. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94551. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94552. */
  94553. coordinatesMode: number;
  94554. /**
  94555. * | Value | Type | Description |
  94556. * | ----- | ------------------ | ----------- |
  94557. * | 0 | CLAMP_ADDRESSMODE | |
  94558. * | 1 | WRAP_ADDRESSMODE | |
  94559. * | 2 | MIRROR_ADDRESSMODE | |
  94560. */
  94561. wrapU: number;
  94562. /**
  94563. * | Value | Type | Description |
  94564. * | ----- | ------------------ | ----------- |
  94565. * | 0 | CLAMP_ADDRESSMODE | |
  94566. * | 1 | WRAP_ADDRESSMODE | |
  94567. * | 2 | MIRROR_ADDRESSMODE | |
  94568. */
  94569. wrapV: number;
  94570. /**
  94571. * | Value | Type | Description |
  94572. * | ----- | ------------------ | ----------- |
  94573. * | 0 | CLAMP_ADDRESSMODE | |
  94574. * | 1 | WRAP_ADDRESSMODE | |
  94575. * | 2 | MIRROR_ADDRESSMODE | |
  94576. */
  94577. wrapR: number;
  94578. /**
  94579. * With compliant hardware and browser (supporting anisotropic filtering)
  94580. * this defines the level of anisotropic filtering in the texture.
  94581. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94582. */
  94583. anisotropicFilteringLevel: number;
  94584. /**
  94585. * Define if the texture is a cube texture or if false a 2d texture.
  94586. */
  94587. isCube: boolean;
  94588. /**
  94589. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94590. */
  94591. is3D: boolean;
  94592. /**
  94593. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94594. * HDR texture are usually stored in linear space.
  94595. * This only impacts the PBR and Background materials
  94596. */
  94597. gammaSpace: boolean;
  94598. /**
  94599. * Gets or sets whether or not the texture contains RGBD data.
  94600. */
  94601. isRGBD: boolean;
  94602. /**
  94603. * Is Z inverted in the texture (useful in a cube texture).
  94604. */
  94605. invertZ: boolean;
  94606. /**
  94607. * Are mip maps generated for this texture or not.
  94608. */
  94609. readonly noMipmap: boolean;
  94610. /**
  94611. * @hidden
  94612. */
  94613. lodLevelInAlpha: boolean;
  94614. /**
  94615. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94616. */
  94617. lodGenerationOffset: number;
  94618. /**
  94619. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94620. */
  94621. lodGenerationScale: number;
  94622. /**
  94623. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94624. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94625. * average roughness values.
  94626. */
  94627. linearSpecularLOD: boolean;
  94628. /**
  94629. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94630. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94631. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94632. */
  94633. irradianceTexture: Nullable<BaseTexture>;
  94634. /**
  94635. * Define if the texture is a render target.
  94636. */
  94637. isRenderTarget: boolean;
  94638. /**
  94639. * Define the unique id of the texture in the scene.
  94640. */
  94641. readonly uid: string;
  94642. /**
  94643. * Return a string representation of the texture.
  94644. * @returns the texture as a string
  94645. */
  94646. toString(): string;
  94647. /**
  94648. * Get the class name of the texture.
  94649. * @returns "BaseTexture"
  94650. */
  94651. getClassName(): string;
  94652. /**
  94653. * Define the list of animation attached to the texture.
  94654. */
  94655. animations: Animation[];
  94656. /**
  94657. * An event triggered when the texture is disposed.
  94658. */
  94659. onDisposeObservable: Observable<BaseTexture>;
  94660. private _onDisposeObserver;
  94661. /**
  94662. * Callback triggered when the texture has been disposed.
  94663. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94664. */
  94665. onDispose: () => void;
  94666. /**
  94667. * Define the current state of the loading sequence when in delayed load mode.
  94668. */
  94669. delayLoadState: number;
  94670. private _scene;
  94671. /** @hidden */
  94672. _texture: Nullable<InternalTexture>;
  94673. private _uid;
  94674. /**
  94675. * Define if the texture is preventinga material to render or not.
  94676. * If not and the texture is not ready, the engine will use a default black texture instead.
  94677. */
  94678. readonly isBlocking: boolean;
  94679. /**
  94680. * Instantiates a new BaseTexture.
  94681. * Base class of all the textures in babylon.
  94682. * It groups all the common properties the materials, post process, lights... might need
  94683. * in order to make a correct use of the texture.
  94684. * @param scene Define the scene the texture blongs to
  94685. */
  94686. constructor(scene: Nullable<Scene>);
  94687. /**
  94688. * Get the scene the texture belongs to.
  94689. * @returns the scene or null if undefined
  94690. */
  94691. getScene(): Nullable<Scene>;
  94692. /**
  94693. * Get the texture transform matrix used to offset tile the texture for istance.
  94694. * @returns the transformation matrix
  94695. */
  94696. getTextureMatrix(): Matrix;
  94697. /**
  94698. * Get the texture reflection matrix used to rotate/transform the reflection.
  94699. * @returns the reflection matrix
  94700. */
  94701. getReflectionTextureMatrix(): Matrix;
  94702. /**
  94703. * Get the underlying lower level texture from Babylon.
  94704. * @returns the insternal texture
  94705. */
  94706. getInternalTexture(): Nullable<InternalTexture>;
  94707. /**
  94708. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94709. * @returns true if ready or not blocking
  94710. */
  94711. isReadyOrNotBlocking(): boolean;
  94712. /**
  94713. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94714. * @returns true if fully ready
  94715. */
  94716. isReady(): boolean;
  94717. private _cachedSize;
  94718. /**
  94719. * Get the size of the texture.
  94720. * @returns the texture size.
  94721. */
  94722. getSize(): ISize;
  94723. /**
  94724. * Get the base size of the texture.
  94725. * It can be different from the size if the texture has been resized for POT for instance
  94726. * @returns the base size
  94727. */
  94728. getBaseSize(): ISize;
  94729. /**
  94730. * Update the sampling mode of the texture.
  94731. * Default is Trilinear mode.
  94732. *
  94733. * | Value | Type | Description |
  94734. * | ----- | ------------------ | ----------- |
  94735. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94736. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94737. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94738. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94739. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94740. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94741. * | 7 | NEAREST_LINEAR | |
  94742. * | 8 | NEAREST_NEAREST | |
  94743. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94744. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94745. * | 11 | LINEAR_LINEAR | |
  94746. * | 12 | LINEAR_NEAREST | |
  94747. *
  94748. * > _mag_: magnification filter (close to the viewer)
  94749. * > _min_: minification filter (far from the viewer)
  94750. * > _mip_: filter used between mip map levels
  94751. *@param samplingMode Define the new sampling mode of the texture
  94752. */
  94753. updateSamplingMode(samplingMode: number): void;
  94754. /**
  94755. * Scales the texture if is `canRescale()`
  94756. * @param ratio the resize factor we want to use to rescale
  94757. */
  94758. scale(ratio: number): void;
  94759. /**
  94760. * Get if the texture can rescale.
  94761. */
  94762. readonly canRescale: boolean;
  94763. /** @hidden */
  94764. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94765. /** @hidden */
  94766. _rebuild(): void;
  94767. /**
  94768. * Triggers the load sequence in delayed load mode.
  94769. */
  94770. delayLoad(): void;
  94771. /**
  94772. * Clones the texture.
  94773. * @returns the cloned texture
  94774. */
  94775. clone(): Nullable<BaseTexture>;
  94776. /**
  94777. * Get the texture underlying type (INT, FLOAT...)
  94778. */
  94779. readonly textureType: number;
  94780. /**
  94781. * Get the texture underlying format (RGB, RGBA...)
  94782. */
  94783. readonly textureFormat: number;
  94784. /**
  94785. * Indicates that textures need to be re-calculated for all materials
  94786. */
  94787. protected _markAllSubMeshesAsTexturesDirty(): void;
  94788. /**
  94789. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94790. * This will returns an RGBA array buffer containing either in values (0-255) or
  94791. * float values (0-1) depending of the underlying buffer type.
  94792. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94793. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94794. * @param buffer defines a user defined buffer to fill with data (can be null)
  94795. * @returns The Array buffer containing the pixels data.
  94796. */
  94797. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94798. /**
  94799. * Release and destroy the underlying lower level texture aka internalTexture.
  94800. */
  94801. releaseInternalTexture(): void;
  94802. /**
  94803. * Get the polynomial representation of the texture data.
  94804. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94805. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94806. */
  94807. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94808. /** @hidden */
  94809. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94810. /** @hidden */
  94811. readonly _lodTextureMid: Nullable<BaseTexture>;
  94812. /** @hidden */
  94813. readonly _lodTextureLow: Nullable<BaseTexture>;
  94814. /**
  94815. * Dispose the texture and release its associated resources.
  94816. */
  94817. dispose(): void;
  94818. /**
  94819. * Serialize the texture into a JSON representation that can be parsed later on.
  94820. * @returns the JSON representation of the texture
  94821. */
  94822. serialize(): any;
  94823. /**
  94824. * Helper function to be called back once a list of texture contains only ready textures.
  94825. * @param textures Define the list of textures to wait for
  94826. * @param callback Define the callback triggered once the entire list will be ready
  94827. */
  94828. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94829. }
  94830. }
  94831. declare module BABYLON {
  94832. /**
  94833. * Options to be used when creating an effect.
  94834. */
  94835. export class EffectCreationOptions {
  94836. /**
  94837. * Atrributes that will be used in the shader.
  94838. */
  94839. attributes: string[];
  94840. /**
  94841. * Uniform varible names that will be set in the shader.
  94842. */
  94843. uniformsNames: string[];
  94844. /**
  94845. * Uniform buffer varible names that will be set in the shader.
  94846. */
  94847. uniformBuffersNames: string[];
  94848. /**
  94849. * Sampler texture variable names that will be set in the shader.
  94850. */
  94851. samplers: string[];
  94852. /**
  94853. * Define statements that will be set in the shader.
  94854. */
  94855. defines: any;
  94856. /**
  94857. * Possible fallbacks for this effect to improve performance when needed.
  94858. */
  94859. fallbacks: Nullable<IEffectFallbacks>;
  94860. /**
  94861. * Callback that will be called when the shader is compiled.
  94862. */
  94863. onCompiled: Nullable<(effect: Effect) => void>;
  94864. /**
  94865. * Callback that will be called if an error occurs during shader compilation.
  94866. */
  94867. onError: Nullable<(effect: Effect, errors: string) => void>;
  94868. /**
  94869. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94870. */
  94871. indexParameters?: any;
  94872. /**
  94873. * Max number of lights that can be used in the shader.
  94874. */
  94875. maxSimultaneousLights?: number;
  94876. /**
  94877. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94878. */
  94879. transformFeedbackVaryings?: Nullable<string[]>;
  94880. }
  94881. /**
  94882. * Effect containing vertex and fragment shader that can be executed on an object.
  94883. */
  94884. export class Effect implements IDisposable {
  94885. /**
  94886. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94887. */
  94888. static ShadersRepository: string;
  94889. /**
  94890. * Name of the effect.
  94891. */
  94892. name: any;
  94893. /**
  94894. * String container all the define statements that should be set on the shader.
  94895. */
  94896. defines: string;
  94897. /**
  94898. * Callback that will be called when the shader is compiled.
  94899. */
  94900. onCompiled: Nullable<(effect: Effect) => void>;
  94901. /**
  94902. * Callback that will be called if an error occurs during shader compilation.
  94903. */
  94904. onError: Nullable<(effect: Effect, errors: string) => void>;
  94905. /**
  94906. * Callback that will be called when effect is bound.
  94907. */
  94908. onBind: Nullable<(effect: Effect) => void>;
  94909. /**
  94910. * Unique ID of the effect.
  94911. */
  94912. uniqueId: number;
  94913. /**
  94914. * Observable that will be called when the shader is compiled.
  94915. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94916. */
  94917. onCompileObservable: Observable<Effect>;
  94918. /**
  94919. * Observable that will be called if an error occurs during shader compilation.
  94920. */
  94921. onErrorObservable: Observable<Effect>;
  94922. /** @hidden */
  94923. _onBindObservable: Nullable<Observable<Effect>>;
  94924. /**
  94925. * Observable that will be called when effect is bound.
  94926. */
  94927. readonly onBindObservable: Observable<Effect>;
  94928. /** @hidden */
  94929. _bonesComputationForcedToCPU: boolean;
  94930. private static _uniqueIdSeed;
  94931. private _engine;
  94932. private _uniformBuffersNames;
  94933. private _uniformsNames;
  94934. private _samplerList;
  94935. private _samplers;
  94936. private _isReady;
  94937. private _compilationError;
  94938. private _attributesNames;
  94939. private _attributes;
  94940. private _uniforms;
  94941. /**
  94942. * Key for the effect.
  94943. * @hidden
  94944. */
  94945. _key: string;
  94946. private _indexParameters;
  94947. private _fallbacks;
  94948. private _vertexSourceCode;
  94949. private _fragmentSourceCode;
  94950. private _vertexSourceCodeOverride;
  94951. private _fragmentSourceCodeOverride;
  94952. private _transformFeedbackVaryings;
  94953. /**
  94954. * Compiled shader to webGL program.
  94955. * @hidden
  94956. */
  94957. _pipelineContext: Nullable<IPipelineContext>;
  94958. private _valueCache;
  94959. private static _baseCache;
  94960. /**
  94961. * Instantiates an effect.
  94962. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94963. * @param baseName Name of the effect.
  94964. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94965. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94966. * @param samplers List of sampler variables that will be passed to the shader.
  94967. * @param engine Engine to be used to render the effect
  94968. * @param defines Define statements to be added to the shader.
  94969. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94970. * @param onCompiled Callback that will be called when the shader is compiled.
  94971. * @param onError Callback that will be called if an error occurs during shader compilation.
  94972. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94973. */
  94974. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94975. private _useFinalCode;
  94976. /**
  94977. * Unique key for this effect
  94978. */
  94979. readonly key: string;
  94980. /**
  94981. * If the effect has been compiled and prepared.
  94982. * @returns if the effect is compiled and prepared.
  94983. */
  94984. isReady(): boolean;
  94985. private _isReadyInternal;
  94986. /**
  94987. * The engine the effect was initialized with.
  94988. * @returns the engine.
  94989. */
  94990. getEngine(): Engine;
  94991. /**
  94992. * The pipeline context for this effect
  94993. * @returns the associated pipeline context
  94994. */
  94995. getPipelineContext(): Nullable<IPipelineContext>;
  94996. /**
  94997. * The set of names of attribute variables for the shader.
  94998. * @returns An array of attribute names.
  94999. */
  95000. getAttributesNames(): string[];
  95001. /**
  95002. * Returns the attribute at the given index.
  95003. * @param index The index of the attribute.
  95004. * @returns The location of the attribute.
  95005. */
  95006. getAttributeLocation(index: number): number;
  95007. /**
  95008. * Returns the attribute based on the name of the variable.
  95009. * @param name of the attribute to look up.
  95010. * @returns the attribute location.
  95011. */
  95012. getAttributeLocationByName(name: string): number;
  95013. /**
  95014. * The number of attributes.
  95015. * @returns the numnber of attributes.
  95016. */
  95017. getAttributesCount(): number;
  95018. /**
  95019. * Gets the index of a uniform variable.
  95020. * @param uniformName of the uniform to look up.
  95021. * @returns the index.
  95022. */
  95023. getUniformIndex(uniformName: string): number;
  95024. /**
  95025. * Returns the attribute based on the name of the variable.
  95026. * @param uniformName of the uniform to look up.
  95027. * @returns the location of the uniform.
  95028. */
  95029. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95030. /**
  95031. * Returns an array of sampler variable names
  95032. * @returns The array of sampler variable neames.
  95033. */
  95034. getSamplers(): string[];
  95035. /**
  95036. * The error from the last compilation.
  95037. * @returns the error string.
  95038. */
  95039. getCompilationError(): string;
  95040. /**
  95041. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95042. * @param func The callback to be used.
  95043. */
  95044. executeWhenCompiled(func: (effect: Effect) => void): void;
  95045. private _checkIsReady;
  95046. /** @hidden */
  95047. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  95048. /** @hidden */
  95049. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  95050. /** @hidden */
  95051. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  95052. /**
  95053. * Recompiles the webGL program
  95054. * @param vertexSourceCode The source code for the vertex shader.
  95055. * @param fragmentSourceCode The source code for the fragment shader.
  95056. * @param onCompiled Callback called when completed.
  95057. * @param onError Callback called on error.
  95058. * @hidden
  95059. */
  95060. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95061. /**
  95062. * Prepares the effect
  95063. * @hidden
  95064. */
  95065. _prepareEffect(): void;
  95066. private _processCompilationErrors;
  95067. /**
  95068. * Checks if the effect is supported. (Must be called after compilation)
  95069. */
  95070. readonly isSupported: boolean;
  95071. /**
  95072. * Binds a texture to the engine to be used as output of the shader.
  95073. * @param channel Name of the output variable.
  95074. * @param texture Texture to bind.
  95075. * @hidden
  95076. */
  95077. _bindTexture(channel: string, texture: InternalTexture): void;
  95078. /**
  95079. * Sets a texture on the engine to be used in the shader.
  95080. * @param channel Name of the sampler variable.
  95081. * @param texture Texture to set.
  95082. */
  95083. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95084. /**
  95085. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95086. * @param channel Name of the sampler variable.
  95087. * @param texture Texture to set.
  95088. */
  95089. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95090. /**
  95091. * Sets an array of textures on the engine to be used in the shader.
  95092. * @param channel Name of the variable.
  95093. * @param textures Textures to set.
  95094. */
  95095. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95096. /**
  95097. * 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)
  95098. * @param channel Name of the sampler variable.
  95099. * @param postProcess Post process to get the input texture from.
  95100. */
  95101. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95102. /**
  95103. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95104. * 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)
  95105. * @param channel Name of the sampler variable.
  95106. * @param postProcess Post process to get the output texture from.
  95107. */
  95108. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95109. /** @hidden */
  95110. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95111. /** @hidden */
  95112. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95113. /** @hidden */
  95114. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95115. /** @hidden */
  95116. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95117. /**
  95118. * Binds a buffer to a uniform.
  95119. * @param buffer Buffer to bind.
  95120. * @param name Name of the uniform variable to bind to.
  95121. */
  95122. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95123. /**
  95124. * Binds block to a uniform.
  95125. * @param blockName Name of the block to bind.
  95126. * @param index Index to bind.
  95127. */
  95128. bindUniformBlock(blockName: string, index: number): void;
  95129. /**
  95130. * Sets an interger value on a uniform variable.
  95131. * @param uniformName Name of the variable.
  95132. * @param value Value to be set.
  95133. * @returns this effect.
  95134. */
  95135. setInt(uniformName: string, value: number): Effect;
  95136. /**
  95137. * Sets an int array on a uniform variable.
  95138. * @param uniformName Name of the variable.
  95139. * @param array array to be set.
  95140. * @returns this effect.
  95141. */
  95142. setIntArray(uniformName: string, array: Int32Array): Effect;
  95143. /**
  95144. * 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)
  95145. * @param uniformName Name of the variable.
  95146. * @param array array to be set.
  95147. * @returns this effect.
  95148. */
  95149. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95150. /**
  95151. * 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)
  95152. * @param uniformName Name of the variable.
  95153. * @param array array to be set.
  95154. * @returns this effect.
  95155. */
  95156. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95157. /**
  95158. * 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)
  95159. * @param uniformName Name of the variable.
  95160. * @param array array to be set.
  95161. * @returns this effect.
  95162. */
  95163. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95164. /**
  95165. * Sets an float array on a uniform variable.
  95166. * @param uniformName Name of the variable.
  95167. * @param array array to be set.
  95168. * @returns this effect.
  95169. */
  95170. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95171. /**
  95172. * 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)
  95173. * @param uniformName Name of the variable.
  95174. * @param array array to be set.
  95175. * @returns this effect.
  95176. */
  95177. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95178. /**
  95179. * 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)
  95180. * @param uniformName Name of the variable.
  95181. * @param array array to be set.
  95182. * @returns this effect.
  95183. */
  95184. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95185. /**
  95186. * 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)
  95187. * @param uniformName Name of the variable.
  95188. * @param array array to be set.
  95189. * @returns this effect.
  95190. */
  95191. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95192. /**
  95193. * Sets an array on a uniform variable.
  95194. * @param uniformName Name of the variable.
  95195. * @param array array to be set.
  95196. * @returns this effect.
  95197. */
  95198. setArray(uniformName: string, array: number[]): Effect;
  95199. /**
  95200. * 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)
  95201. * @param uniformName Name of the variable.
  95202. * @param array array to be set.
  95203. * @returns this effect.
  95204. */
  95205. setArray2(uniformName: string, array: number[]): Effect;
  95206. /**
  95207. * 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)
  95208. * @param uniformName Name of the variable.
  95209. * @param array array to be set.
  95210. * @returns this effect.
  95211. */
  95212. setArray3(uniformName: string, array: number[]): Effect;
  95213. /**
  95214. * 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)
  95215. * @param uniformName Name of the variable.
  95216. * @param array array to be set.
  95217. * @returns this effect.
  95218. */
  95219. setArray4(uniformName: string, array: number[]): Effect;
  95220. /**
  95221. * Sets matrices on a uniform variable.
  95222. * @param uniformName Name of the variable.
  95223. * @param matrices matrices to be set.
  95224. * @returns this effect.
  95225. */
  95226. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95227. /**
  95228. * Sets matrix on a uniform variable.
  95229. * @param uniformName Name of the variable.
  95230. * @param matrix matrix to be set.
  95231. * @returns this effect.
  95232. */
  95233. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95234. /**
  95235. * 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)
  95236. * @param uniformName Name of the variable.
  95237. * @param matrix matrix to be set.
  95238. * @returns this effect.
  95239. */
  95240. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95241. /**
  95242. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95243. * @param uniformName Name of the variable.
  95244. * @param matrix matrix to be set.
  95245. * @returns this effect.
  95246. */
  95247. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95248. /**
  95249. * Sets a float on a uniform variable.
  95250. * @param uniformName Name of the variable.
  95251. * @param value value to be set.
  95252. * @returns this effect.
  95253. */
  95254. setFloat(uniformName: string, value: number): Effect;
  95255. /**
  95256. * Sets a boolean on a uniform variable.
  95257. * @param uniformName Name of the variable.
  95258. * @param bool value to be set.
  95259. * @returns this effect.
  95260. */
  95261. setBool(uniformName: string, bool: boolean): Effect;
  95262. /**
  95263. * Sets a Vector2 on a uniform variable.
  95264. * @param uniformName Name of the variable.
  95265. * @param vector2 vector2 to be set.
  95266. * @returns this effect.
  95267. */
  95268. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95269. /**
  95270. * Sets a float2 on a uniform variable.
  95271. * @param uniformName Name of the variable.
  95272. * @param x First float in float2.
  95273. * @param y Second float in float2.
  95274. * @returns this effect.
  95275. */
  95276. setFloat2(uniformName: string, x: number, y: number): Effect;
  95277. /**
  95278. * Sets a Vector3 on a uniform variable.
  95279. * @param uniformName Name of the variable.
  95280. * @param vector3 Value to be set.
  95281. * @returns this effect.
  95282. */
  95283. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95284. /**
  95285. * Sets a float3 on a uniform variable.
  95286. * @param uniformName Name of the variable.
  95287. * @param x First float in float3.
  95288. * @param y Second float in float3.
  95289. * @param z Third float in float3.
  95290. * @returns this effect.
  95291. */
  95292. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95293. /**
  95294. * Sets a Vector4 on a uniform variable.
  95295. * @param uniformName Name of the variable.
  95296. * @param vector4 Value to be set.
  95297. * @returns this effect.
  95298. */
  95299. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95300. /**
  95301. * Sets a float4 on a uniform variable.
  95302. * @param uniformName Name of the variable.
  95303. * @param x First float in float4.
  95304. * @param y Second float in float4.
  95305. * @param z Third float in float4.
  95306. * @param w Fourth float in float4.
  95307. * @returns this effect.
  95308. */
  95309. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95310. /**
  95311. * Sets a Color3 on a uniform variable.
  95312. * @param uniformName Name of the variable.
  95313. * @param color3 Value to be set.
  95314. * @returns this effect.
  95315. */
  95316. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95317. /**
  95318. * Sets a Color4 on a uniform variable.
  95319. * @param uniformName Name of the variable.
  95320. * @param color3 Value to be set.
  95321. * @param alpha Alpha value to be set.
  95322. * @returns this effect.
  95323. */
  95324. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95325. /**
  95326. * Sets a Color4 on a uniform variable
  95327. * @param uniformName defines the name of the variable
  95328. * @param color4 defines the value to be set
  95329. * @returns this effect.
  95330. */
  95331. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95332. /** Release all associated resources */
  95333. dispose(): void;
  95334. /**
  95335. * This function will add a new shader to the shader store
  95336. * @param name the name of the shader
  95337. * @param pixelShader optional pixel shader content
  95338. * @param vertexShader optional vertex shader content
  95339. */
  95340. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95341. /**
  95342. * Store of each shader (The can be looked up using effect.key)
  95343. */
  95344. static ShadersStore: {
  95345. [key: string]: string;
  95346. };
  95347. /**
  95348. * Store of each included file for a shader (The can be looked up using effect.key)
  95349. */
  95350. static IncludesShadersStore: {
  95351. [key: string]: string;
  95352. };
  95353. /**
  95354. * Resets the cache of effects.
  95355. */
  95356. static ResetCache(): void;
  95357. }
  95358. }
  95359. declare module BABYLON {
  95360. /**
  95361. * Class used to describe the capabilities of the engine relatively to the current browser
  95362. */
  95363. export class EngineCapabilities {
  95364. /** Maximum textures units per fragment shader */
  95365. maxTexturesImageUnits: number;
  95366. /** Maximum texture units per vertex shader */
  95367. maxVertexTextureImageUnits: number;
  95368. /** Maximum textures units in the entire pipeline */
  95369. maxCombinedTexturesImageUnits: number;
  95370. /** Maximum texture size */
  95371. maxTextureSize: number;
  95372. /** Maximum cube texture size */
  95373. maxCubemapTextureSize: number;
  95374. /** Maximum render texture size */
  95375. maxRenderTextureSize: number;
  95376. /** Maximum number of vertex attributes */
  95377. maxVertexAttribs: number;
  95378. /** Maximum number of varyings */
  95379. maxVaryingVectors: number;
  95380. /** Maximum number of uniforms per vertex shader */
  95381. maxVertexUniformVectors: number;
  95382. /** Maximum number of uniforms per fragment shader */
  95383. maxFragmentUniformVectors: number;
  95384. /** Defines if standard derivates (dx/dy) are supported */
  95385. standardDerivatives: boolean;
  95386. /** Defines if s3tc texture compression is supported */
  95387. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95388. /** Defines if pvrtc texture compression is supported */
  95389. pvrtc: any;
  95390. /** Defines if etc1 texture compression is supported */
  95391. etc1: any;
  95392. /** Defines if etc2 texture compression is supported */
  95393. etc2: any;
  95394. /** Defines if astc texture compression is supported */
  95395. astc: any;
  95396. /** Defines if float textures are supported */
  95397. textureFloat: boolean;
  95398. /** Defines if vertex array objects are supported */
  95399. vertexArrayObject: boolean;
  95400. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95401. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95402. /** Gets the maximum level of anisotropy supported */
  95403. maxAnisotropy: number;
  95404. /** Defines if instancing is supported */
  95405. instancedArrays: boolean;
  95406. /** Defines if 32 bits indices are supported */
  95407. uintIndices: boolean;
  95408. /** Defines if high precision shaders are supported */
  95409. highPrecisionShaderSupported: boolean;
  95410. /** Defines if depth reading in the fragment shader is supported */
  95411. fragmentDepthSupported: boolean;
  95412. /** Defines if float texture linear filtering is supported*/
  95413. textureFloatLinearFiltering: boolean;
  95414. /** Defines if rendering to float textures is supported */
  95415. textureFloatRender: boolean;
  95416. /** Defines if half float textures are supported*/
  95417. textureHalfFloat: boolean;
  95418. /** Defines if half float texture linear filtering is supported*/
  95419. textureHalfFloatLinearFiltering: boolean;
  95420. /** Defines if rendering to half float textures is supported */
  95421. textureHalfFloatRender: boolean;
  95422. /** Defines if textureLOD shader command is supported */
  95423. textureLOD: boolean;
  95424. /** Defines if draw buffers extension is supported */
  95425. drawBuffersExtension: boolean;
  95426. /** Defines if depth textures are supported */
  95427. depthTextureExtension: boolean;
  95428. /** Defines if float color buffer are supported */
  95429. colorBufferFloat: boolean;
  95430. /** Gets disjoint timer query extension (null if not supported) */
  95431. timerQuery: EXT_disjoint_timer_query;
  95432. /** Defines if timestamp can be used with timer query */
  95433. canUseTimestampForTimerQuery: boolean;
  95434. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95435. multiview: any;
  95436. /** Function used to let the system compiles shaders in background */
  95437. parallelShaderCompile: {
  95438. COMPLETION_STATUS_KHR: number;
  95439. };
  95440. /** Max number of texture samples for MSAA */
  95441. maxMSAASamples: number;
  95442. /** Defines if the blend min max extension is supported */
  95443. blendMinMax: boolean;
  95444. }
  95445. }
  95446. declare module BABYLON {
  95447. /**
  95448. * This class is used to track a performance counter which is number based.
  95449. * The user has access to many properties which give statistics of different nature.
  95450. *
  95451. * The implementer can track two kinds of Performance Counter: time and count.
  95452. * 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.
  95453. * 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.
  95454. */
  95455. export class PerfCounter {
  95456. /**
  95457. * Gets or sets a global boolean to turn on and off all the counters
  95458. */
  95459. static Enabled: boolean;
  95460. /**
  95461. * Returns the smallest value ever
  95462. */
  95463. readonly min: number;
  95464. /**
  95465. * Returns the biggest value ever
  95466. */
  95467. readonly max: number;
  95468. /**
  95469. * Returns the average value since the performance counter is running
  95470. */
  95471. readonly average: number;
  95472. /**
  95473. * Returns the average value of the last second the counter was monitored
  95474. */
  95475. readonly lastSecAverage: number;
  95476. /**
  95477. * Returns the current value
  95478. */
  95479. readonly current: number;
  95480. /**
  95481. * Gets the accumulated total
  95482. */
  95483. readonly total: number;
  95484. /**
  95485. * Gets the total value count
  95486. */
  95487. readonly count: number;
  95488. /**
  95489. * Creates a new counter
  95490. */
  95491. constructor();
  95492. /**
  95493. * Call this method to start monitoring a new frame.
  95494. * 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.
  95495. */
  95496. fetchNewFrame(): void;
  95497. /**
  95498. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95499. * @param newCount the count value to add to the monitored count
  95500. * @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.
  95501. */
  95502. addCount(newCount: number, fetchResult: boolean): void;
  95503. /**
  95504. * Start monitoring this performance counter
  95505. */
  95506. beginMonitoring(): void;
  95507. /**
  95508. * Compute the time lapsed since the previous beginMonitoring() call.
  95509. * @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
  95510. */
  95511. endMonitoring(newFrame?: boolean): void;
  95512. private _fetchResult;
  95513. private _startMonitoringTime;
  95514. private _min;
  95515. private _max;
  95516. private _average;
  95517. private _current;
  95518. private _totalValueCount;
  95519. private _totalAccumulated;
  95520. private _lastSecAverage;
  95521. private _lastSecAccumulated;
  95522. private _lastSecTime;
  95523. private _lastSecValueCount;
  95524. }
  95525. }
  95526. declare module BABYLON {
  95527. /**
  95528. * @hidden
  95529. **/
  95530. export class DepthCullingState {
  95531. private _isDepthTestDirty;
  95532. private _isDepthMaskDirty;
  95533. private _isDepthFuncDirty;
  95534. private _isCullFaceDirty;
  95535. private _isCullDirty;
  95536. private _isZOffsetDirty;
  95537. private _isFrontFaceDirty;
  95538. private _depthTest;
  95539. private _depthMask;
  95540. private _depthFunc;
  95541. private _cull;
  95542. private _cullFace;
  95543. private _zOffset;
  95544. private _frontFace;
  95545. /**
  95546. * Initializes the state.
  95547. */
  95548. constructor();
  95549. readonly isDirty: boolean;
  95550. zOffset: number;
  95551. cullFace: Nullable<number>;
  95552. cull: Nullable<boolean>;
  95553. depthFunc: Nullable<number>;
  95554. depthMask: boolean;
  95555. depthTest: boolean;
  95556. frontFace: Nullable<number>;
  95557. reset(): void;
  95558. apply(gl: WebGLRenderingContext): void;
  95559. }
  95560. }
  95561. declare module BABYLON {
  95562. /**
  95563. * @hidden
  95564. **/
  95565. export class StencilState {
  95566. /** 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 */
  95567. static readonly ALWAYS: number;
  95568. /** Passed to stencilOperation to specify that stencil value must be kept */
  95569. static readonly KEEP: number;
  95570. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95571. static readonly REPLACE: number;
  95572. private _isStencilTestDirty;
  95573. private _isStencilMaskDirty;
  95574. private _isStencilFuncDirty;
  95575. private _isStencilOpDirty;
  95576. private _stencilTest;
  95577. private _stencilMask;
  95578. private _stencilFunc;
  95579. private _stencilFuncRef;
  95580. private _stencilFuncMask;
  95581. private _stencilOpStencilFail;
  95582. private _stencilOpDepthFail;
  95583. private _stencilOpStencilDepthPass;
  95584. readonly isDirty: boolean;
  95585. stencilFunc: number;
  95586. stencilFuncRef: number;
  95587. stencilFuncMask: number;
  95588. stencilOpStencilFail: number;
  95589. stencilOpDepthFail: number;
  95590. stencilOpStencilDepthPass: number;
  95591. stencilMask: number;
  95592. stencilTest: boolean;
  95593. constructor();
  95594. reset(): void;
  95595. apply(gl: WebGLRenderingContext): void;
  95596. }
  95597. }
  95598. declare module BABYLON {
  95599. /**
  95600. * @hidden
  95601. **/
  95602. export class AlphaState {
  95603. private _isAlphaBlendDirty;
  95604. private _isBlendFunctionParametersDirty;
  95605. private _isBlendEquationParametersDirty;
  95606. private _isBlendConstantsDirty;
  95607. private _alphaBlend;
  95608. private _blendFunctionParameters;
  95609. private _blendEquationParameters;
  95610. private _blendConstants;
  95611. /**
  95612. * Initializes the state.
  95613. */
  95614. constructor();
  95615. readonly isDirty: boolean;
  95616. alphaBlend: boolean;
  95617. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95618. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95619. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95620. reset(): void;
  95621. apply(gl: WebGLRenderingContext): void;
  95622. }
  95623. }
  95624. declare module BABYLON {
  95625. /** @hidden */
  95626. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95627. attributeProcessor(attribute: string): string;
  95628. varyingProcessor(varying: string, isFragment: boolean): string;
  95629. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95630. }
  95631. }
  95632. declare module BABYLON {
  95633. /**
  95634. * Interface for attribute information associated with buffer instanciation
  95635. */
  95636. export class InstancingAttributeInfo {
  95637. /**
  95638. * Index/offset of the attribute in the vertex shader
  95639. */
  95640. index: number;
  95641. /**
  95642. * size of the attribute, 1, 2, 3 or 4
  95643. */
  95644. attributeSize: number;
  95645. /**
  95646. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95647. * default is FLOAT
  95648. */
  95649. attribyteType: number;
  95650. /**
  95651. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95652. */
  95653. normalized: boolean;
  95654. /**
  95655. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95656. */
  95657. offset: number;
  95658. /**
  95659. * Name of the GLSL attribute, for debugging purpose only
  95660. */
  95661. attributeName: string;
  95662. }
  95663. }
  95664. declare module BABYLON {
  95665. interface ThinEngine {
  95666. /**
  95667. * Update a video texture
  95668. * @param texture defines the texture to update
  95669. * @param video defines the video element to use
  95670. * @param invertY defines if data must be stored with Y axis inverted
  95671. */
  95672. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95673. }
  95674. }
  95675. declare module BABYLON {
  95676. /**
  95677. * Settings for finer control over video usage
  95678. */
  95679. export interface VideoTextureSettings {
  95680. /**
  95681. * Applies `autoplay` to video, if specified
  95682. */
  95683. autoPlay?: boolean;
  95684. /**
  95685. * Applies `loop` to video, if specified
  95686. */
  95687. loop?: boolean;
  95688. /**
  95689. * Automatically updates internal texture from video at every frame in the render loop
  95690. */
  95691. autoUpdateTexture: boolean;
  95692. /**
  95693. * Image src displayed during the video loading or until the user interacts with the video.
  95694. */
  95695. poster?: string;
  95696. }
  95697. /**
  95698. * If you want to display a video in your scene, this is the special texture for that.
  95699. * This special texture works similar to other textures, with the exception of a few parameters.
  95700. * @see https://doc.babylonjs.com/how_to/video_texture
  95701. */
  95702. export class VideoTexture extends Texture {
  95703. /**
  95704. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95705. */
  95706. readonly autoUpdateTexture: boolean;
  95707. /**
  95708. * The video instance used by the texture internally
  95709. */
  95710. readonly video: HTMLVideoElement;
  95711. private _onUserActionRequestedObservable;
  95712. /**
  95713. * Event triggerd when a dom action is required by the user to play the video.
  95714. * This happens due to recent changes in browser policies preventing video to auto start.
  95715. */
  95716. readonly onUserActionRequestedObservable: Observable<Texture>;
  95717. private _generateMipMaps;
  95718. private _engine;
  95719. private _stillImageCaptured;
  95720. private _displayingPosterTexture;
  95721. private _settings;
  95722. private _createInternalTextureOnEvent;
  95723. private _frameId;
  95724. /**
  95725. * Creates a video texture.
  95726. * If you want to display a video in your scene, this is the special texture for that.
  95727. * This special texture works similar to other textures, with the exception of a few parameters.
  95728. * @see https://doc.babylonjs.com/how_to/video_texture
  95729. * @param name optional name, will detect from video source, if not defined
  95730. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95731. * @param scene is obviously the current scene.
  95732. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95733. * @param invertY is false by default but can be used to invert video on Y axis
  95734. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95735. * @param settings allows finer control over video usage
  95736. */
  95737. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95738. private _getName;
  95739. private _getVideo;
  95740. private _createInternalTexture;
  95741. private reset;
  95742. /**
  95743. * @hidden Internal method to initiate `update`.
  95744. */
  95745. _rebuild(): void;
  95746. /**
  95747. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95748. */
  95749. update(): void;
  95750. /**
  95751. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95752. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95753. */
  95754. updateTexture(isVisible: boolean): void;
  95755. protected _updateInternalTexture: () => void;
  95756. /**
  95757. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95758. * @param url New url.
  95759. */
  95760. updateURL(url: string): void;
  95761. /**
  95762. * Dispose the texture and release its associated resources.
  95763. */
  95764. dispose(): void;
  95765. /**
  95766. * Creates a video texture straight from a stream.
  95767. * @param scene Define the scene the texture should be created in
  95768. * @param stream Define the stream the texture should be created from
  95769. * @returns The created video texture as a promise
  95770. */
  95771. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95772. /**
  95773. * Creates a video texture straight from your WebCam video feed.
  95774. * @param scene Define the scene the texture should be created in
  95775. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95776. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95777. * @returns The created video texture as a promise
  95778. */
  95779. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95780. minWidth: number;
  95781. maxWidth: number;
  95782. minHeight: number;
  95783. maxHeight: number;
  95784. deviceId: string;
  95785. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95786. /**
  95787. * Creates a video texture straight from your WebCam video feed.
  95788. * @param scene Define the scene the texture should be created in
  95789. * @param onReady Define a callback to triggered once the texture will be ready
  95790. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95791. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95792. */
  95793. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95794. minWidth: number;
  95795. maxWidth: number;
  95796. minHeight: number;
  95797. maxHeight: number;
  95798. deviceId: string;
  95799. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95800. }
  95801. }
  95802. declare module BABYLON {
  95803. /**
  95804. * Defines the interface used by objects working like Scene
  95805. * @hidden
  95806. */
  95807. interface ISceneLike {
  95808. _addPendingData(data: any): void;
  95809. _removePendingData(data: any): void;
  95810. offlineProvider: IOfflineProvider;
  95811. }
  95812. /** Interface defining initialization parameters for Engine class */
  95813. export interface EngineOptions extends WebGLContextAttributes {
  95814. /**
  95815. * Defines if the engine should no exceed a specified device ratio
  95816. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95817. */
  95818. limitDeviceRatio?: number;
  95819. /**
  95820. * Defines if webvr should be enabled automatically
  95821. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95822. */
  95823. autoEnableWebVR?: boolean;
  95824. /**
  95825. * Defines if webgl2 should be turned off even if supported
  95826. * @see http://doc.babylonjs.com/features/webgl2
  95827. */
  95828. disableWebGL2Support?: boolean;
  95829. /**
  95830. * Defines if webaudio should be initialized as well
  95831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95832. */
  95833. audioEngine?: boolean;
  95834. /**
  95835. * Defines if animations should run using a deterministic lock step
  95836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95837. */
  95838. deterministicLockstep?: boolean;
  95839. /** Defines the maximum steps to use with deterministic lock step mode */
  95840. lockstepMaxSteps?: number;
  95841. /**
  95842. * Defines that engine should ignore context lost events
  95843. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95844. */
  95845. doNotHandleContextLost?: boolean;
  95846. /**
  95847. * Defines that engine should ignore modifying touch action attribute and style
  95848. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95849. */
  95850. doNotHandleTouchAction?: boolean;
  95851. /**
  95852. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95853. */
  95854. useHighPrecisionFloats?: boolean;
  95855. }
  95856. /**
  95857. * The base engine class (root of all engines)
  95858. */
  95859. export class ThinEngine {
  95860. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95861. static ExceptionList: ({
  95862. key: string;
  95863. capture: string;
  95864. captureConstraint: number;
  95865. targets: string[];
  95866. } | {
  95867. key: string;
  95868. capture: null;
  95869. captureConstraint: null;
  95870. targets: string[];
  95871. })[];
  95872. /** @hidden */
  95873. static _TextureLoaders: IInternalTextureLoader[];
  95874. /**
  95875. * Returns the current npm package of the sdk
  95876. */
  95877. static readonly NpmPackage: string;
  95878. /**
  95879. * Returns the current version of the framework
  95880. */
  95881. static readonly Version: string;
  95882. /**
  95883. * Returns a string describing the current engine
  95884. */
  95885. readonly description: string;
  95886. /**
  95887. * Gets or sets the epsilon value used by collision engine
  95888. */
  95889. static CollisionsEpsilon: number;
  95890. /**
  95891. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95892. */
  95893. static ShadersRepository: string;
  95894. /** @hidden */
  95895. _shaderProcessor: IShaderProcessor;
  95896. /**
  95897. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95898. */
  95899. forcePOTTextures: boolean;
  95900. /**
  95901. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95902. */
  95903. isFullscreen: boolean;
  95904. /**
  95905. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95906. */
  95907. cullBackFaces: boolean;
  95908. /**
  95909. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95910. */
  95911. renderEvenInBackground: boolean;
  95912. /**
  95913. * Gets or sets a boolean indicating that cache can be kept between frames
  95914. */
  95915. preventCacheWipeBetweenFrames: boolean;
  95916. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95917. validateShaderPrograms: boolean;
  95918. /**
  95919. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95920. */
  95921. disableUniformBuffers: boolean;
  95922. /** @hidden */
  95923. _uniformBuffers: UniformBuffer[];
  95924. /**
  95925. * Gets a boolean indicating that the engine supports uniform buffers
  95926. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95927. */
  95928. readonly supportsUniformBuffers: boolean;
  95929. /** @hidden */
  95930. _gl: WebGLRenderingContext;
  95931. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95932. protected _windowIsBackground: boolean;
  95933. protected _webGLVersion: number;
  95934. protected _highPrecisionShadersAllowed: boolean;
  95935. /** @hidden */
  95936. readonly _shouldUseHighPrecisionShader: boolean;
  95937. /**
  95938. * Gets a boolean indicating that only power of 2 textures are supported
  95939. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95940. */
  95941. readonly needPOTTextures: boolean;
  95942. /** @hidden */
  95943. _badOS: boolean;
  95944. /** @hidden */
  95945. _badDesktopOS: boolean;
  95946. private _hardwareScalingLevel;
  95947. /** @hidden */
  95948. _caps: EngineCapabilities;
  95949. private _isStencilEnable;
  95950. protected _colorWrite: boolean;
  95951. /** @hidden */
  95952. _drawCalls: PerfCounter;
  95953. private _glVersion;
  95954. private _glRenderer;
  95955. private _glVendor;
  95956. /** @hidden */
  95957. _videoTextureSupported: boolean;
  95958. protected _renderingQueueLaunched: boolean;
  95959. protected _activeRenderLoops: (() => void)[];
  95960. /**
  95961. * Observable signaled when a context lost event is raised
  95962. */
  95963. onContextLostObservable: Observable<ThinEngine>;
  95964. /**
  95965. * Observable signaled when a context restored event is raised
  95966. */
  95967. onContextRestoredObservable: Observable<ThinEngine>;
  95968. private _onContextLost;
  95969. private _onContextRestored;
  95970. protected _contextWasLost: boolean;
  95971. /** @hidden */
  95972. _doNotHandleContextLost: boolean;
  95973. /**
  95974. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95976. */
  95977. doNotHandleContextLost: boolean;
  95978. /**
  95979. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95980. */
  95981. disableVertexArrayObjects: boolean;
  95982. /** @hidden */
  95983. protected _depthCullingState: DepthCullingState;
  95984. /** @hidden */
  95985. protected _stencilState: StencilState;
  95986. /** @hidden */
  95987. protected _alphaState: AlphaState;
  95988. /** @hidden */
  95989. _internalTexturesCache: InternalTexture[];
  95990. /** @hidden */
  95991. protected _activeChannel: number;
  95992. private _currentTextureChannel;
  95993. /** @hidden */
  95994. protected _boundTexturesCache: {
  95995. [key: string]: Nullable<InternalTexture>;
  95996. };
  95997. /** @hidden */
  95998. protected _currentEffect: Nullable<Effect>;
  95999. /** @hidden */
  96000. protected _currentProgram: Nullable<WebGLProgram>;
  96001. private _compiledEffects;
  96002. private _vertexAttribArraysEnabled;
  96003. /** @hidden */
  96004. protected _cachedViewport: Nullable<IViewportLike>;
  96005. private _cachedVertexArrayObject;
  96006. /** @hidden */
  96007. protected _cachedVertexBuffers: any;
  96008. /** @hidden */
  96009. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96010. /** @hidden */
  96011. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96012. /** @hidden */
  96013. _currentRenderTarget: Nullable<InternalTexture>;
  96014. private _uintIndicesCurrentlySet;
  96015. private _currentBoundBuffer;
  96016. /** @hidden */
  96017. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96018. private _currentBufferPointers;
  96019. private _currentInstanceLocations;
  96020. private _currentInstanceBuffers;
  96021. private _textureUnits;
  96022. /** @hidden */
  96023. _workingCanvas: Nullable<HTMLCanvasElement>;
  96024. /** @hidden */
  96025. _workingContext: Nullable<CanvasRenderingContext2D>;
  96026. /** @hidden */
  96027. _bindedRenderFunction: any;
  96028. private _vaoRecordInProgress;
  96029. private _mustWipeVertexAttributes;
  96030. private _emptyTexture;
  96031. private _emptyCubeTexture;
  96032. private _emptyTexture3D;
  96033. /** @hidden */
  96034. _frameHandler: number;
  96035. private _nextFreeTextureSlots;
  96036. private _maxSimultaneousTextures;
  96037. private _activeRequests;
  96038. protected _texturesSupported: string[];
  96039. /** @hidden */
  96040. _textureFormatInUse: Nullable<string>;
  96041. protected readonly _supportsHardwareTextureRescaling: boolean;
  96042. /**
  96043. * Gets the list of texture formats supported
  96044. */
  96045. readonly texturesSupported: Array<string>;
  96046. /**
  96047. * Gets the list of texture formats in use
  96048. */
  96049. readonly textureFormatInUse: Nullable<string>;
  96050. /**
  96051. * Gets the current viewport
  96052. */
  96053. readonly currentViewport: Nullable<IViewportLike>;
  96054. /**
  96055. * Gets the default empty texture
  96056. */
  96057. readonly emptyTexture: InternalTexture;
  96058. /**
  96059. * Gets the default empty 3D texture
  96060. */
  96061. readonly emptyTexture3D: InternalTexture;
  96062. /**
  96063. * Gets the default empty cube texture
  96064. */
  96065. readonly emptyCubeTexture: InternalTexture;
  96066. /**
  96067. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96068. */
  96069. readonly premultipliedAlpha: boolean;
  96070. /**
  96071. * Creates a new engine
  96072. * @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
  96073. * @param antialias defines enable antialiasing (default: false)
  96074. * @param options defines further options to be sent to the getContext() function
  96075. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96076. */
  96077. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96078. private _rebuildInternalTextures;
  96079. private _rebuildEffects;
  96080. /**
  96081. * Gets a boolean indicating if all created effects are ready
  96082. * @returns true if all effects are ready
  96083. */
  96084. areAllEffectsReady(): boolean;
  96085. protected _rebuildBuffers(): void;
  96086. private _initGLContext;
  96087. /**
  96088. * Gets version of the current webGL context
  96089. */
  96090. readonly webGLVersion: number;
  96091. /**
  96092. * Gets a string idenfifying the name of the class
  96093. * @returns "Engine" string
  96094. */
  96095. getClassName(): string;
  96096. /**
  96097. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96098. */
  96099. readonly isStencilEnable: boolean;
  96100. /** @hidden */
  96101. _prepareWorkingCanvas(): void;
  96102. /**
  96103. * Reset the texture cache to empty state
  96104. */
  96105. resetTextureCache(): void;
  96106. /**
  96107. * Gets an object containing information about the current webGL context
  96108. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96109. */
  96110. getGlInfo(): {
  96111. vendor: string;
  96112. renderer: string;
  96113. version: string;
  96114. };
  96115. /**
  96116. * Defines the hardware scaling level.
  96117. * By default the hardware scaling level is computed from the window device ratio.
  96118. * 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.
  96119. * @param level defines the level to use
  96120. */
  96121. setHardwareScalingLevel(level: number): void;
  96122. /**
  96123. * Gets the current hardware scaling level.
  96124. * By default the hardware scaling level is computed from the window device ratio.
  96125. * 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.
  96126. * @returns a number indicating the current hardware scaling level
  96127. */
  96128. getHardwareScalingLevel(): number;
  96129. /**
  96130. * Gets the list of loaded textures
  96131. * @returns an array containing all loaded textures
  96132. */
  96133. getLoadedTexturesCache(): InternalTexture[];
  96134. /**
  96135. * Gets the object containing all engine capabilities
  96136. * @returns the EngineCapabilities object
  96137. */
  96138. getCaps(): EngineCapabilities;
  96139. /**
  96140. * stop executing a render loop function and remove it from the execution array
  96141. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96142. */
  96143. stopRenderLoop(renderFunction?: () => void): void;
  96144. /** @hidden */
  96145. _renderLoop(): void;
  96146. /**
  96147. * Gets the HTML canvas attached with the current webGL context
  96148. * @returns a HTML canvas
  96149. */
  96150. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96151. /**
  96152. * Gets host window
  96153. * @returns the host window object
  96154. */
  96155. getHostWindow(): Window;
  96156. /**
  96157. * Gets the current render width
  96158. * @param useScreen defines if screen size must be used (or the current render target if any)
  96159. * @returns a number defining the current render width
  96160. */
  96161. getRenderWidth(useScreen?: boolean): number;
  96162. /**
  96163. * Gets the current render height
  96164. * @param useScreen defines if screen size must be used (or the current render target if any)
  96165. * @returns a number defining the current render height
  96166. */
  96167. getRenderHeight(useScreen?: boolean): number;
  96168. /**
  96169. * Can be used to override the current requestAnimationFrame requester.
  96170. * @hidden
  96171. */
  96172. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96173. /**
  96174. * Register and execute a render loop. The engine can have more than one render function
  96175. * @param renderFunction defines the function to continuously execute
  96176. */
  96177. runRenderLoop(renderFunction: () => void): void;
  96178. /**
  96179. * Clear the current render buffer or the current render target (if any is set up)
  96180. * @param color defines the color to use
  96181. * @param backBuffer defines if the back buffer must be cleared
  96182. * @param depth defines if the depth buffer must be cleared
  96183. * @param stencil defines if the stencil buffer must be cleared
  96184. */
  96185. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96186. private _viewportCached;
  96187. /** @hidden */
  96188. _viewport(x: number, y: number, width: number, height: number): void;
  96189. /**
  96190. * Set the WebGL's viewport
  96191. * @param viewport defines the viewport element to be used
  96192. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96193. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96194. */
  96195. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96196. /**
  96197. * Begin a new frame
  96198. */
  96199. beginFrame(): void;
  96200. /**
  96201. * Enf the current frame
  96202. */
  96203. endFrame(): void;
  96204. /**
  96205. * Resize the view according to the canvas' size
  96206. */
  96207. resize(): void;
  96208. /**
  96209. * Force a specific size of the canvas
  96210. * @param width defines the new canvas' width
  96211. * @param height defines the new canvas' height
  96212. */
  96213. setSize(width: number, height: number): void;
  96214. /**
  96215. * Binds the frame buffer to the specified texture.
  96216. * @param texture The texture to render to or null for the default canvas
  96217. * @param faceIndex The face of the texture to render to in case of cube texture
  96218. * @param requiredWidth The width of the target to render to
  96219. * @param requiredHeight The height of the target to render to
  96220. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96221. * @param depthStencilTexture The depth stencil texture to use to render
  96222. * @param lodLevel defines le lod level to bind to the frame buffer
  96223. */
  96224. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96225. /** @hidden */
  96226. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96227. /**
  96228. * Unbind the current render target texture from the webGL context
  96229. * @param texture defines the render target texture to unbind
  96230. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96231. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96232. */
  96233. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96234. /**
  96235. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96236. */
  96237. flushFramebuffer(): void;
  96238. /**
  96239. * Unbind the current render target and bind the default framebuffer
  96240. */
  96241. restoreDefaultFramebuffer(): void;
  96242. private _resetVertexBufferBinding;
  96243. /**
  96244. * Creates a vertex buffer
  96245. * @param data the data for the vertex buffer
  96246. * @returns the new WebGL static buffer
  96247. */
  96248. createVertexBuffer(data: DataArray): DataBuffer;
  96249. private _createVertexBuffer;
  96250. /**
  96251. * Creates a dynamic vertex buffer
  96252. * @param data the data for the dynamic vertex buffer
  96253. * @returns the new WebGL dynamic buffer
  96254. */
  96255. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96256. /**
  96257. * Update a dynamic index buffer
  96258. * @param indexBuffer defines the target index buffer
  96259. * @param indices defines the data to update
  96260. * @param offset defines the offset in the target index buffer where update should start
  96261. */
  96262. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96263. /**
  96264. * Updates a dynamic vertex buffer.
  96265. * @param vertexBuffer the vertex buffer to update
  96266. * @param data the data used to update the vertex buffer
  96267. * @param byteOffset the byte offset of the data
  96268. * @param byteLength the byte length of the data
  96269. */
  96270. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96271. private _resetIndexBufferBinding;
  96272. /**
  96273. * Creates a new index buffer
  96274. * @param indices defines the content of the index buffer
  96275. * @param updatable defines if the index buffer must be updatable
  96276. * @returns a new webGL buffer
  96277. */
  96278. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96279. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96280. /**
  96281. * Bind a webGL buffer to the webGL context
  96282. * @param buffer defines the buffer to bind
  96283. */
  96284. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96285. private bindIndexBuffer;
  96286. private bindBuffer;
  96287. /**
  96288. * update the bound buffer with the given data
  96289. * @param data defines the data to update
  96290. */
  96291. updateArrayBuffer(data: Float32Array): void;
  96292. private _vertexAttribPointer;
  96293. private _bindIndexBufferWithCache;
  96294. private _bindVertexBuffersAttributes;
  96295. /**
  96296. * Records a vertex array object
  96297. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96298. * @param vertexBuffers defines the list of vertex buffers to store
  96299. * @param indexBuffer defines the index buffer to store
  96300. * @param effect defines the effect to store
  96301. * @returns the new vertex array object
  96302. */
  96303. recordVertexArrayObject(vertexBuffers: {
  96304. [key: string]: VertexBuffer;
  96305. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96306. /**
  96307. * Bind a specific vertex array object
  96308. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96309. * @param vertexArrayObject defines the vertex array object to bind
  96310. * @param indexBuffer defines the index buffer to bind
  96311. */
  96312. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96313. /**
  96314. * Bind webGl buffers directly to the webGL context
  96315. * @param vertexBuffer defines the vertex buffer to bind
  96316. * @param indexBuffer defines the index buffer to bind
  96317. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96318. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96319. * @param effect defines the effect associated with the vertex buffer
  96320. */
  96321. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96322. private _unbindVertexArrayObject;
  96323. /**
  96324. * Bind a list of vertex buffers to the webGL context
  96325. * @param vertexBuffers defines the list of vertex buffers to bind
  96326. * @param indexBuffer defines the index buffer to bind
  96327. * @param effect defines the effect associated with the vertex buffers
  96328. */
  96329. bindBuffers(vertexBuffers: {
  96330. [key: string]: Nullable<VertexBuffer>;
  96331. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96332. /**
  96333. * Unbind all instance attributes
  96334. */
  96335. unbindInstanceAttributes(): void;
  96336. /**
  96337. * Release and free the memory of a vertex array object
  96338. * @param vao defines the vertex array object to delete
  96339. */
  96340. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96341. /** @hidden */
  96342. _releaseBuffer(buffer: DataBuffer): boolean;
  96343. protected _deleteBuffer(buffer: DataBuffer): void;
  96344. /**
  96345. * Creates a webGL buffer to use with instanciation
  96346. * @param capacity defines the size of the buffer
  96347. * @returns the webGL buffer
  96348. */
  96349. createInstancesBuffer(capacity: number): DataBuffer;
  96350. /**
  96351. * Delete a webGL buffer used with instanciation
  96352. * @param buffer defines the webGL buffer to delete
  96353. */
  96354. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96355. /**
  96356. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96357. * @param instancesBuffer defines the webGL buffer to update and bind
  96358. * @param data defines the data to store in the buffer
  96359. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96360. */
  96361. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96362. /**
  96363. * Apply all cached states (depth, culling, stencil and alpha)
  96364. */
  96365. applyStates(): void;
  96366. /**
  96367. * Send a draw order
  96368. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96369. * @param indexStart defines the starting index
  96370. * @param indexCount defines the number of index to draw
  96371. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96372. */
  96373. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96374. /**
  96375. * Draw a list of points
  96376. * @param verticesStart defines the index of first vertex to draw
  96377. * @param verticesCount defines the count of vertices to draw
  96378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96379. */
  96380. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96381. /**
  96382. * Draw a list of unindexed primitives
  96383. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96384. * @param verticesStart defines the index of first vertex to draw
  96385. * @param verticesCount defines the count of vertices to draw
  96386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96387. */
  96388. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96389. /**
  96390. * Draw a list of indexed primitives
  96391. * @param fillMode defines the primitive to use
  96392. * @param indexStart defines the starting index
  96393. * @param indexCount defines the number of index to draw
  96394. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96395. */
  96396. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96397. /**
  96398. * Draw a list of unindexed primitives
  96399. * @param fillMode defines the primitive to use
  96400. * @param verticesStart defines the index of first vertex to draw
  96401. * @param verticesCount defines the count of vertices to draw
  96402. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96403. */
  96404. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96405. private _drawMode;
  96406. /** @hidden */
  96407. _releaseEffect(effect: Effect): void;
  96408. /** @hidden */
  96409. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96410. /**
  96411. * Create a new effect (used to store vertex/fragment shaders)
  96412. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96413. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96414. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96415. * @param samplers defines an array of string used to represent textures
  96416. * @param defines defines the string containing the defines to use to compile the shaders
  96417. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96418. * @param onCompiled defines a function to call when the effect creation is successful
  96419. * @param onError defines a function to call when the effect creation has failed
  96420. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96421. * @returns the new Effect
  96422. */
  96423. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96424. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96425. private _compileShader;
  96426. private _compileRawShader;
  96427. /**
  96428. * Directly creates a webGL program
  96429. * @param pipelineContext defines the pipeline context to attach to
  96430. * @param vertexCode defines the vertex shader code to use
  96431. * @param fragmentCode defines the fragment shader code to use
  96432. * @param context defines the webGL context to use (if not set, the current one will be used)
  96433. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96434. * @returns the new webGL program
  96435. */
  96436. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96437. /**
  96438. * Creates a webGL program
  96439. * @param pipelineContext defines the pipeline context to attach to
  96440. * @param vertexCode defines the vertex shader code to use
  96441. * @param fragmentCode defines the fragment shader code to use
  96442. * @param defines defines the string containing the defines to use to compile the shaders
  96443. * @param context defines the webGL context to use (if not set, the current one will be used)
  96444. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96445. * @returns the new webGL program
  96446. */
  96447. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96448. /**
  96449. * Creates a new pipeline context
  96450. * @returns the new pipeline
  96451. */
  96452. createPipelineContext(): IPipelineContext;
  96453. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96454. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96455. /** @hidden */
  96456. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96457. /** @hidden */
  96458. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96459. /** @hidden */
  96460. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96461. /**
  96462. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96463. * @param pipelineContext defines the pipeline context to use
  96464. * @param uniformsNames defines the list of uniform names
  96465. * @returns an array of webGL uniform locations
  96466. */
  96467. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96468. /**
  96469. * Gets the lsit of active attributes for a given webGL program
  96470. * @param pipelineContext defines the pipeline context to use
  96471. * @param attributesNames defines the list of attribute names to get
  96472. * @returns an array of indices indicating the offset of each attribute
  96473. */
  96474. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96475. /**
  96476. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96477. * @param effect defines the effect to activate
  96478. */
  96479. enableEffect(effect: Nullable<Effect>): void;
  96480. /**
  96481. * Set the value of an uniform to an array of int32
  96482. * @param uniform defines the webGL uniform location where to store the value
  96483. * @param array defines the array of int32 to store
  96484. */
  96485. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96486. /**
  96487. * Set the value of an uniform to an array of int32 (stored as vec2)
  96488. * @param uniform defines the webGL uniform location where to store the value
  96489. * @param array defines the array of int32 to store
  96490. */
  96491. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96492. /**
  96493. * Set the value of an uniform to an array of int32 (stored as vec3)
  96494. * @param uniform defines the webGL uniform location where to store the value
  96495. * @param array defines the array of int32 to store
  96496. */
  96497. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96498. /**
  96499. * Set the value of an uniform to an array of int32 (stored as vec4)
  96500. * @param uniform defines the webGL uniform location where to store the value
  96501. * @param array defines the array of int32 to store
  96502. */
  96503. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96504. /**
  96505. * Set the value of an uniform to an array of float32
  96506. * @param uniform defines the webGL uniform location where to store the value
  96507. * @param array defines the array of float32 to store
  96508. */
  96509. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96510. /**
  96511. * Set the value of an uniform to an array of float32 (stored as vec2)
  96512. * @param uniform defines the webGL uniform location where to store the value
  96513. * @param array defines the array of float32 to store
  96514. */
  96515. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96516. /**
  96517. * Set the value of an uniform to an array of float32 (stored as vec3)
  96518. * @param uniform defines the webGL uniform location where to store the value
  96519. * @param array defines the array of float32 to store
  96520. */
  96521. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96522. /**
  96523. * Set the value of an uniform to an array of float32 (stored as vec4)
  96524. * @param uniform defines the webGL uniform location where to store the value
  96525. * @param array defines the array of float32 to store
  96526. */
  96527. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96528. /**
  96529. * Set the value of an uniform to an array of number
  96530. * @param uniform defines the webGL uniform location where to store the value
  96531. * @param array defines the array of number to store
  96532. */
  96533. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96534. /**
  96535. * Set the value of an uniform to an array of number (stored as vec2)
  96536. * @param uniform defines the webGL uniform location where to store the value
  96537. * @param array defines the array of number to store
  96538. */
  96539. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96540. /**
  96541. * Set the value of an uniform to an array of number (stored as vec3)
  96542. * @param uniform defines the webGL uniform location where to store the value
  96543. * @param array defines the array of number to store
  96544. */
  96545. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96546. /**
  96547. * Set the value of an uniform to an array of number (stored as vec4)
  96548. * @param uniform defines the webGL uniform location where to store the value
  96549. * @param array defines the array of number to store
  96550. */
  96551. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96552. /**
  96553. * Set the value of an uniform to an array of float32 (stored as matrices)
  96554. * @param uniform defines the webGL uniform location where to store the value
  96555. * @param matrices defines the array of float32 to store
  96556. */
  96557. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96558. /**
  96559. * Set the value of an uniform to a matrix (3x3)
  96560. * @param uniform defines the webGL uniform location where to store the value
  96561. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96562. */
  96563. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96564. /**
  96565. * Set the value of an uniform to a matrix (2x2)
  96566. * @param uniform defines the webGL uniform location where to store the value
  96567. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96568. */
  96569. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96570. /**
  96571. * Set the value of an uniform to a number (int)
  96572. * @param uniform defines the webGL uniform location where to store the value
  96573. * @param value defines the int number to store
  96574. */
  96575. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96576. /**
  96577. * Set the value of an uniform to a number (float)
  96578. * @param uniform defines the webGL uniform location where to store the value
  96579. * @param value defines the float number to store
  96580. */
  96581. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96582. /**
  96583. * Set the value of an uniform to a vec2
  96584. * @param uniform defines the webGL uniform location where to store the value
  96585. * @param x defines the 1st component of the value
  96586. * @param y defines the 2nd component of the value
  96587. */
  96588. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96589. /**
  96590. * Set the value of an uniform to a vec3
  96591. * @param uniform defines the webGL uniform location where to store the value
  96592. * @param x defines the 1st component of the value
  96593. * @param y defines the 2nd component of the value
  96594. * @param z defines the 3rd component of the value
  96595. */
  96596. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96597. /**
  96598. * Set the value of an uniform to a boolean
  96599. * @param uniform defines the webGL uniform location where to store the value
  96600. * @param bool defines the boolean to store
  96601. */
  96602. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96603. /**
  96604. * Set the value of an uniform to a vec4
  96605. * @param uniform defines the webGL uniform location where to store the value
  96606. * @param x defines the 1st component of the value
  96607. * @param y defines the 2nd component of the value
  96608. * @param z defines the 3rd component of the value
  96609. * @param w defines the 4th component of the value
  96610. */
  96611. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96612. /**
  96613. * Sets a Color4 on a uniform variable
  96614. * @param uniform defines the uniform location
  96615. * @param color4 defines the value to be set
  96616. */
  96617. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96618. /**
  96619. * Gets the depth culling state manager
  96620. */
  96621. readonly depthCullingState: DepthCullingState;
  96622. /**
  96623. * Gets the alpha state manager
  96624. */
  96625. readonly alphaState: AlphaState;
  96626. /**
  96627. * Gets the stencil state manager
  96628. */
  96629. readonly stencilState: StencilState;
  96630. /**
  96631. * Clears the list of texture accessible through engine.
  96632. * This can help preventing texture load conflict due to name collision.
  96633. */
  96634. clearInternalTexturesCache(): void;
  96635. /**
  96636. * Force the entire cache to be cleared
  96637. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96638. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96639. */
  96640. wipeCaches(bruteForce?: boolean): void;
  96641. /** @hidden */
  96642. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96643. min: number;
  96644. mag: number;
  96645. };
  96646. /** @hidden */
  96647. _createTexture(): WebGLTexture;
  96648. /**
  96649. * Usually called from Texture.ts.
  96650. * Passed information to create a WebGLTexture
  96651. * @param urlArg defines a value which contains one of the following:
  96652. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96653. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96654. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96655. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96656. * @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)
  96657. * @param scene needed for loading to the correct scene
  96658. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96659. * @param onLoad optional callback to be called upon successful completion
  96660. * @param onError optional callback to be called upon failure
  96661. * @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
  96662. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96663. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96664. * @param forcedExtension defines the extension to use to pick the right loader
  96665. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96666. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96667. */
  96668. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96669. /**
  96670. * @hidden
  96671. */
  96672. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96673. /**
  96674. * Creates a raw texture
  96675. * @param data defines the data to store in the texture
  96676. * @param width defines the width of the texture
  96677. * @param height defines the height of the texture
  96678. * @param format defines the format of the data
  96679. * @param generateMipMaps defines if the engine should generate the mip levels
  96680. * @param invertY defines if data must be stored with Y axis inverted
  96681. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96682. * @param compression defines the compression used (null by default)
  96683. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96684. * @returns the raw texture inside an InternalTexture
  96685. */
  96686. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96687. /**
  96688. * Creates a new raw cube texture
  96689. * @param data defines the array of data to use to create each face
  96690. * @param size defines the size of the textures
  96691. * @param format defines the format of the data
  96692. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96693. * @param generateMipMaps defines if the engine should generate the mip levels
  96694. * @param invertY defines if data must be stored with Y axis inverted
  96695. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96696. * @param compression defines the compression used (null by default)
  96697. * @returns the cube texture as an InternalTexture
  96698. */
  96699. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96700. /**
  96701. * Creates a new raw 3D texture
  96702. * @param data defines the data used to create the texture
  96703. * @param width defines the width of the texture
  96704. * @param height defines the height of the texture
  96705. * @param depth defines the depth of the texture
  96706. * @param format defines the format of the texture
  96707. * @param generateMipMaps defines if the engine must generate mip levels
  96708. * @param invertY defines if data must be stored with Y axis inverted
  96709. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96710. * @param compression defines the compressed used (can be null)
  96711. * @param textureType defines the compressed used (can be null)
  96712. * @returns a new raw 3D texture (stored in an InternalTexture)
  96713. */
  96714. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96715. private _unpackFlipYCached;
  96716. /**
  96717. * In case you are sharing the context with other applications, it might
  96718. * be interested to not cache the unpack flip y state to ensure a consistent
  96719. * value would be set.
  96720. */
  96721. enableUnpackFlipYCached: boolean;
  96722. /** @hidden */
  96723. _unpackFlipY(value: boolean): void;
  96724. /** @hidden */
  96725. _getUnpackAlignement(): number;
  96726. /**
  96727. * Update the sampling mode of a given texture
  96728. * @param samplingMode defines the required sampling mode
  96729. * @param texture defines the texture to update
  96730. */
  96731. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96732. /**
  96733. * Updates a depth texture Comparison Mode and Function.
  96734. * If the comparison Function is equal to 0, the mode will be set to none.
  96735. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96736. * @param texture The texture to set the comparison function for
  96737. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96738. */
  96739. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96740. /** @hidden */
  96741. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96742. width: number;
  96743. height: number;
  96744. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96745. /**
  96746. * Creates a depth stencil texture.
  96747. * This is only available in WebGL 2 or with the depth texture extension available.
  96748. * @param size The size of face edge in the texture.
  96749. * @param options The options defining the texture.
  96750. * @returns The texture
  96751. */
  96752. createDepthStencilTexture(size: number | {
  96753. width: number;
  96754. height: number;
  96755. }, options: DepthTextureCreationOptions): InternalTexture;
  96756. /**
  96757. * Creates a depth stencil texture.
  96758. * This is only available in WebGL 2 or with the depth texture extension available.
  96759. * @param size The size of face edge in the texture.
  96760. * @param options The options defining the texture.
  96761. * @returns The texture
  96762. */
  96763. private _createDepthStencilTexture;
  96764. /**
  96765. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96766. * @param renderTarget The render target to set the frame buffer for
  96767. */
  96768. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96769. /** @hidden */
  96770. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96771. /** @hidden */
  96772. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96773. /** @hidden */
  96774. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96775. /** @hidden */
  96776. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96777. /** @hidden */
  96778. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96779. /**
  96780. * @hidden
  96781. */
  96782. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96783. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96784. private _prepareWebGLTexture;
  96785. /** @hidden */
  96786. _releaseFramebufferObjects(texture: InternalTexture): void;
  96787. /** @hidden */
  96788. _releaseTexture(texture: InternalTexture): void;
  96789. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96790. protected _setProgram(program: WebGLProgram): void;
  96791. protected _boundUniforms: {
  96792. [key: number]: WebGLUniformLocation;
  96793. };
  96794. /**
  96795. * Binds an effect to the webGL context
  96796. * @param effect defines the effect to bind
  96797. */
  96798. bindSamplers(effect: Effect): void;
  96799. private _activateCurrentTexture;
  96800. /** @hidden */
  96801. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96802. /** @hidden */
  96803. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96804. /**
  96805. * Unbind all textures from the webGL context
  96806. */
  96807. unbindAllTextures(): void;
  96808. /**
  96809. * Sets a texture to the according uniform.
  96810. * @param channel The texture channel
  96811. * @param uniform The uniform to set
  96812. * @param texture The texture to apply
  96813. */
  96814. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96815. private _bindSamplerUniformToChannel;
  96816. private _getTextureWrapMode;
  96817. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96818. /**
  96819. * Sets an array of texture to the webGL context
  96820. * @param channel defines the channel where the texture array must be set
  96821. * @param uniform defines the associated uniform location
  96822. * @param textures defines the array of textures to bind
  96823. */
  96824. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96825. /** @hidden */
  96826. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96827. private _setTextureParameterFloat;
  96828. private _setTextureParameterInteger;
  96829. /**
  96830. * Unbind all vertex attributes from the webGL context
  96831. */
  96832. unbindAllAttributes(): void;
  96833. /**
  96834. * 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
  96835. */
  96836. releaseEffects(): void;
  96837. /**
  96838. * Dispose and release all associated resources
  96839. */
  96840. dispose(): void;
  96841. /**
  96842. * Attach a new callback raised when context lost event is fired
  96843. * @param callback defines the callback to call
  96844. */
  96845. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96846. /**
  96847. * Attach a new callback raised when context restored event is fired
  96848. * @param callback defines the callback to call
  96849. */
  96850. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96851. /**
  96852. * Get the current error code of the webGL context
  96853. * @returns the error code
  96854. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96855. */
  96856. getError(): number;
  96857. private _canRenderToFloatFramebuffer;
  96858. private _canRenderToHalfFloatFramebuffer;
  96859. private _canRenderToFramebuffer;
  96860. /** @hidden */
  96861. _getWebGLTextureType(type: number): number;
  96862. /** @hidden */
  96863. _getInternalFormat(format: number): number;
  96864. /** @hidden */
  96865. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96866. /** @hidden */
  96867. _getRGBAMultiSampleBufferFormat(type: number): number;
  96868. /** @hidden */
  96869. _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;
  96870. /**
  96871. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96872. * @returns true if the engine can be created
  96873. * @ignorenaming
  96874. */
  96875. static isSupported(): boolean;
  96876. /**
  96877. * Find the next highest power of two.
  96878. * @param x Number to start search from.
  96879. * @return Next highest power of two.
  96880. */
  96881. static CeilingPOT(x: number): number;
  96882. /**
  96883. * Find the next lowest power of two.
  96884. * @param x Number to start search from.
  96885. * @return Next lowest power of two.
  96886. */
  96887. static FloorPOT(x: number): number;
  96888. /**
  96889. * Find the nearest power of two.
  96890. * @param x Number to start search from.
  96891. * @return Next nearest power of two.
  96892. */
  96893. static NearestPOT(x: number): number;
  96894. /**
  96895. * Get the closest exponent of two
  96896. * @param value defines the value to approximate
  96897. * @param max defines the maximum value to return
  96898. * @param mode defines how to define the closest value
  96899. * @returns closest exponent of two of the given value
  96900. */
  96901. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96902. /**
  96903. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96904. * @param func - the function to be called
  96905. * @param requester - the object that will request the next frame. Falls back to window.
  96906. * @returns frame number
  96907. */
  96908. static QueueNewFrame(func: () => void, requester?: any): number;
  96909. }
  96910. }
  96911. declare module BABYLON {
  96912. /**
  96913. * Class used to store data associated with WebGL texture data for the engine
  96914. * This class should not be used directly
  96915. */
  96916. export class InternalTexture {
  96917. /** @hidden */
  96918. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  96919. /**
  96920. * The source of the texture data is unknown
  96921. */
  96922. static DATASOURCE_UNKNOWN: number;
  96923. /**
  96924. * Texture data comes from an URL
  96925. */
  96926. static DATASOURCE_URL: number;
  96927. /**
  96928. * Texture data is only used for temporary storage
  96929. */
  96930. static DATASOURCE_TEMP: number;
  96931. /**
  96932. * Texture data comes from raw data (ArrayBuffer)
  96933. */
  96934. static DATASOURCE_RAW: number;
  96935. /**
  96936. * Texture content is dynamic (video or dynamic texture)
  96937. */
  96938. static DATASOURCE_DYNAMIC: number;
  96939. /**
  96940. * Texture content is generated by rendering to it
  96941. */
  96942. static DATASOURCE_RENDERTARGET: number;
  96943. /**
  96944. * Texture content is part of a multi render target process
  96945. */
  96946. static DATASOURCE_MULTIRENDERTARGET: number;
  96947. /**
  96948. * Texture data comes from a cube data file
  96949. */
  96950. static DATASOURCE_CUBE: number;
  96951. /**
  96952. * Texture data comes from a raw cube data
  96953. */
  96954. static DATASOURCE_CUBERAW: number;
  96955. /**
  96956. * Texture data come from a prefiltered cube data file
  96957. */
  96958. static DATASOURCE_CUBEPREFILTERED: number;
  96959. /**
  96960. * Texture content is raw 3D data
  96961. */
  96962. static DATASOURCE_RAW3D: number;
  96963. /**
  96964. * Texture content is a depth texture
  96965. */
  96966. static DATASOURCE_DEPTHTEXTURE: number;
  96967. /**
  96968. * Texture data comes from a raw cube data encoded with RGBD
  96969. */
  96970. static DATASOURCE_CUBERAW_RGBD: number;
  96971. /**
  96972. * Defines if the texture is ready
  96973. */
  96974. isReady: boolean;
  96975. /**
  96976. * Defines if the texture is a cube texture
  96977. */
  96978. isCube: boolean;
  96979. /**
  96980. * Defines if the texture contains 3D data
  96981. */
  96982. is3D: boolean;
  96983. /**
  96984. * Defines if the texture contains multiview data
  96985. */
  96986. isMultiview: boolean;
  96987. /**
  96988. * Gets the URL used to load this texture
  96989. */
  96990. url: string;
  96991. /**
  96992. * Gets the sampling mode of the texture
  96993. */
  96994. samplingMode: number;
  96995. /**
  96996. * Gets a boolean indicating if the texture needs mipmaps generation
  96997. */
  96998. generateMipMaps: boolean;
  96999. /**
  97000. * Gets the number of samples used by the texture (WebGL2+ only)
  97001. */
  97002. samples: number;
  97003. /**
  97004. * Gets the type of the texture (int, float...)
  97005. */
  97006. type: number;
  97007. /**
  97008. * Gets the format of the texture (RGB, RGBA...)
  97009. */
  97010. format: number;
  97011. /**
  97012. * Observable called when the texture is loaded
  97013. */
  97014. onLoadedObservable: Observable<InternalTexture>;
  97015. /**
  97016. * Gets the width of the texture
  97017. */
  97018. width: number;
  97019. /**
  97020. * Gets the height of the texture
  97021. */
  97022. height: number;
  97023. /**
  97024. * Gets the depth of the texture
  97025. */
  97026. depth: number;
  97027. /**
  97028. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97029. */
  97030. baseWidth: number;
  97031. /**
  97032. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97033. */
  97034. baseHeight: number;
  97035. /**
  97036. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97037. */
  97038. baseDepth: number;
  97039. /**
  97040. * Gets a boolean indicating if the texture is inverted on Y axis
  97041. */
  97042. invertY: boolean;
  97043. /** @hidden */
  97044. _invertVScale: boolean;
  97045. /** @hidden */
  97046. _associatedChannel: number;
  97047. /** @hidden */
  97048. _dataSource: number;
  97049. /** @hidden */
  97050. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97051. /** @hidden */
  97052. _bufferView: Nullable<ArrayBufferView>;
  97053. /** @hidden */
  97054. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97055. /** @hidden */
  97056. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97057. /** @hidden */
  97058. _size: number;
  97059. /** @hidden */
  97060. _extension: string;
  97061. /** @hidden */
  97062. _files: Nullable<string[]>;
  97063. /** @hidden */
  97064. _workingCanvas: Nullable<HTMLCanvasElement>;
  97065. /** @hidden */
  97066. _workingContext: Nullable<CanvasRenderingContext2D>;
  97067. /** @hidden */
  97068. _framebuffer: Nullable<WebGLFramebuffer>;
  97069. /** @hidden */
  97070. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97071. /** @hidden */
  97072. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97073. /** @hidden */
  97074. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97075. /** @hidden */
  97076. _attachments: Nullable<number[]>;
  97077. /** @hidden */
  97078. _cachedCoordinatesMode: Nullable<number>;
  97079. /** @hidden */
  97080. _cachedWrapU: Nullable<number>;
  97081. /** @hidden */
  97082. _cachedWrapV: Nullable<number>;
  97083. /** @hidden */
  97084. _cachedWrapR: Nullable<number>;
  97085. /** @hidden */
  97086. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97087. /** @hidden */
  97088. _isDisabled: boolean;
  97089. /** @hidden */
  97090. _compression: Nullable<string>;
  97091. /** @hidden */
  97092. _generateStencilBuffer: boolean;
  97093. /** @hidden */
  97094. _generateDepthBuffer: boolean;
  97095. /** @hidden */
  97096. _comparisonFunction: number;
  97097. /** @hidden */
  97098. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97099. /** @hidden */
  97100. _lodGenerationScale: number;
  97101. /** @hidden */
  97102. _lodGenerationOffset: number;
  97103. /** @hidden */
  97104. _colorTextureArray: Nullable<WebGLTexture>;
  97105. /** @hidden */
  97106. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97107. /** @hidden */
  97108. _lodTextureHigh: Nullable<BaseTexture>;
  97109. /** @hidden */
  97110. _lodTextureMid: Nullable<BaseTexture>;
  97111. /** @hidden */
  97112. _lodTextureLow: Nullable<BaseTexture>;
  97113. /** @hidden */
  97114. _isRGBD: boolean;
  97115. /** @hidden */
  97116. _linearSpecularLOD: boolean;
  97117. /** @hidden */
  97118. _irradianceTexture: Nullable<BaseTexture>;
  97119. /** @hidden */
  97120. _webGLTexture: Nullable<WebGLTexture>;
  97121. /** @hidden */
  97122. _references: number;
  97123. private _engine;
  97124. /**
  97125. * Gets the Engine the texture belongs to.
  97126. * @returns The babylon engine
  97127. */
  97128. getEngine(): ThinEngine;
  97129. /**
  97130. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  97131. */
  97132. readonly dataSource: number;
  97133. /**
  97134. * Creates a new InternalTexture
  97135. * @param engine defines the engine to use
  97136. * @param dataSource defines the type of data that will be used
  97137. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97138. */
  97139. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  97140. /**
  97141. * Increments the number of references (ie. the number of Texture that point to it)
  97142. */
  97143. incrementReferences(): void;
  97144. /**
  97145. * Change the size of the texture (not the size of the content)
  97146. * @param width defines the new width
  97147. * @param height defines the new height
  97148. * @param depth defines the new depth (1 by default)
  97149. */
  97150. updateSize(width: int, height: int, depth?: int): void;
  97151. /** @hidden */
  97152. _rebuild(): void;
  97153. /** @hidden */
  97154. _swapAndDie(target: InternalTexture): void;
  97155. /**
  97156. * Dispose the current allocated resources
  97157. */
  97158. dispose(): void;
  97159. }
  97160. }
  97161. declare module BABYLON {
  97162. /**
  97163. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97165. */
  97166. export class Analyser {
  97167. /**
  97168. * Gets or sets the smoothing
  97169. * @ignorenaming
  97170. */
  97171. SMOOTHING: number;
  97172. /**
  97173. * Gets or sets the FFT table size
  97174. * @ignorenaming
  97175. */
  97176. FFT_SIZE: number;
  97177. /**
  97178. * Gets or sets the bar graph amplitude
  97179. * @ignorenaming
  97180. */
  97181. BARGRAPHAMPLITUDE: number;
  97182. /**
  97183. * Gets or sets the position of the debug canvas
  97184. * @ignorenaming
  97185. */
  97186. DEBUGCANVASPOS: {
  97187. x: number;
  97188. y: number;
  97189. };
  97190. /**
  97191. * Gets or sets the debug canvas size
  97192. * @ignorenaming
  97193. */
  97194. DEBUGCANVASSIZE: {
  97195. width: number;
  97196. height: number;
  97197. };
  97198. private _byteFreqs;
  97199. private _byteTime;
  97200. private _floatFreqs;
  97201. private _webAudioAnalyser;
  97202. private _debugCanvas;
  97203. private _debugCanvasContext;
  97204. private _scene;
  97205. private _registerFunc;
  97206. private _audioEngine;
  97207. /**
  97208. * Creates a new analyser
  97209. * @param scene defines hosting scene
  97210. */
  97211. constructor(scene: Scene);
  97212. /**
  97213. * Get the number of data values you will have to play with for the visualization
  97214. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97215. * @returns a number
  97216. */
  97217. getFrequencyBinCount(): number;
  97218. /**
  97219. * Gets the current frequency data as a byte array
  97220. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97221. * @returns a Uint8Array
  97222. */
  97223. getByteFrequencyData(): Uint8Array;
  97224. /**
  97225. * Gets the current waveform as a byte array
  97226. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97227. * @returns a Uint8Array
  97228. */
  97229. getByteTimeDomainData(): Uint8Array;
  97230. /**
  97231. * Gets the current frequency data as a float array
  97232. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97233. * @returns a Float32Array
  97234. */
  97235. getFloatFrequencyData(): Float32Array;
  97236. /**
  97237. * Renders the debug canvas
  97238. */
  97239. drawDebugCanvas(): void;
  97240. /**
  97241. * Stops rendering the debug canvas and removes it
  97242. */
  97243. stopDebugCanvas(): void;
  97244. /**
  97245. * Connects two audio nodes
  97246. * @param inputAudioNode defines first node to connect
  97247. * @param outputAudioNode defines second node to connect
  97248. */
  97249. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97250. /**
  97251. * Releases all associated resources
  97252. */
  97253. dispose(): void;
  97254. }
  97255. }
  97256. declare module BABYLON {
  97257. /**
  97258. * This represents an audio engine and it is responsible
  97259. * to play, synchronize and analyse sounds throughout the application.
  97260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97261. */
  97262. export interface IAudioEngine extends IDisposable {
  97263. /**
  97264. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97265. */
  97266. readonly canUseWebAudio: boolean;
  97267. /**
  97268. * Gets the current AudioContext if available.
  97269. */
  97270. readonly audioContext: Nullable<AudioContext>;
  97271. /**
  97272. * The master gain node defines the global audio volume of your audio engine.
  97273. */
  97274. readonly masterGain: GainNode;
  97275. /**
  97276. * Gets whether or not mp3 are supported by your browser.
  97277. */
  97278. readonly isMP3supported: boolean;
  97279. /**
  97280. * Gets whether or not ogg are supported by your browser.
  97281. */
  97282. readonly isOGGsupported: boolean;
  97283. /**
  97284. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97285. * @ignoreNaming
  97286. */
  97287. WarnedWebAudioUnsupported: boolean;
  97288. /**
  97289. * Defines if the audio engine relies on a custom unlocked button.
  97290. * In this case, the embedded button will not be displayed.
  97291. */
  97292. useCustomUnlockedButton: boolean;
  97293. /**
  97294. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97295. */
  97296. readonly unlocked: boolean;
  97297. /**
  97298. * Event raised when audio has been unlocked on the browser.
  97299. */
  97300. onAudioUnlockedObservable: Observable<AudioEngine>;
  97301. /**
  97302. * Event raised when audio has been locked on the browser.
  97303. */
  97304. onAudioLockedObservable: Observable<AudioEngine>;
  97305. /**
  97306. * Flags the audio engine in Locked state.
  97307. * This happens due to new browser policies preventing audio to autoplay.
  97308. */
  97309. lock(): void;
  97310. /**
  97311. * Unlocks the audio engine once a user action has been done on the dom.
  97312. * This is helpful to resume play once browser policies have been satisfied.
  97313. */
  97314. unlock(): void;
  97315. }
  97316. /**
  97317. * This represents the default audio engine used in babylon.
  97318. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97320. */
  97321. export class AudioEngine implements IAudioEngine {
  97322. private _audioContext;
  97323. private _audioContextInitialized;
  97324. private _muteButton;
  97325. private _hostElement;
  97326. /**
  97327. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97328. */
  97329. canUseWebAudio: boolean;
  97330. /**
  97331. * The master gain node defines the global audio volume of your audio engine.
  97332. */
  97333. masterGain: GainNode;
  97334. /**
  97335. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97336. * @ignoreNaming
  97337. */
  97338. WarnedWebAudioUnsupported: boolean;
  97339. /**
  97340. * Gets whether or not mp3 are supported by your browser.
  97341. */
  97342. isMP3supported: boolean;
  97343. /**
  97344. * Gets whether or not ogg are supported by your browser.
  97345. */
  97346. isOGGsupported: boolean;
  97347. /**
  97348. * Gets whether audio has been unlocked on the device.
  97349. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97350. * a user interaction has happened.
  97351. */
  97352. unlocked: boolean;
  97353. /**
  97354. * Defines if the audio engine relies on a custom unlocked button.
  97355. * In this case, the embedded button will not be displayed.
  97356. */
  97357. useCustomUnlockedButton: boolean;
  97358. /**
  97359. * Event raised when audio has been unlocked on the browser.
  97360. */
  97361. onAudioUnlockedObservable: Observable<AudioEngine>;
  97362. /**
  97363. * Event raised when audio has been locked on the browser.
  97364. */
  97365. onAudioLockedObservable: Observable<AudioEngine>;
  97366. /**
  97367. * Gets the current AudioContext if available.
  97368. */
  97369. readonly audioContext: Nullable<AudioContext>;
  97370. private _connectedAnalyser;
  97371. /**
  97372. * Instantiates a new audio engine.
  97373. *
  97374. * There should be only one per page as some browsers restrict the number
  97375. * of audio contexts you can create.
  97376. * @param hostElement defines the host element where to display the mute icon if necessary
  97377. */
  97378. constructor(hostElement?: Nullable<HTMLElement>);
  97379. /**
  97380. * Flags the audio engine in Locked state.
  97381. * This happens due to new browser policies preventing audio to autoplay.
  97382. */
  97383. lock(): void;
  97384. /**
  97385. * Unlocks the audio engine once a user action has been done on the dom.
  97386. * This is helpful to resume play once browser policies have been satisfied.
  97387. */
  97388. unlock(): void;
  97389. private _resumeAudioContext;
  97390. private _initializeAudioContext;
  97391. private _tryToRun;
  97392. private _triggerRunningState;
  97393. private _triggerSuspendedState;
  97394. private _displayMuteButton;
  97395. private _moveButtonToTopLeft;
  97396. private _onResize;
  97397. private _hideMuteButton;
  97398. /**
  97399. * Destroy and release the resources associated with the audio ccontext.
  97400. */
  97401. dispose(): void;
  97402. /**
  97403. * Gets the global volume sets on the master gain.
  97404. * @returns the global volume if set or -1 otherwise
  97405. */
  97406. getGlobalVolume(): number;
  97407. /**
  97408. * Sets the global volume of your experience (sets on the master gain).
  97409. * @param newVolume Defines the new global volume of the application
  97410. */
  97411. setGlobalVolume(newVolume: number): void;
  97412. /**
  97413. * Connect the audio engine to an audio analyser allowing some amazing
  97414. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97416. * @param analyser The analyser to connect to the engine
  97417. */
  97418. connectToAnalyser(analyser: Analyser): void;
  97419. }
  97420. }
  97421. declare module BABYLON {
  97422. /**
  97423. * Interface used to present a loading screen while loading a scene
  97424. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97425. */
  97426. export interface ILoadingScreen {
  97427. /**
  97428. * Function called to display the loading screen
  97429. */
  97430. displayLoadingUI: () => void;
  97431. /**
  97432. * Function called to hide the loading screen
  97433. */
  97434. hideLoadingUI: () => void;
  97435. /**
  97436. * Gets or sets the color to use for the background
  97437. */
  97438. loadingUIBackgroundColor: string;
  97439. /**
  97440. * Gets or sets the text to display while loading
  97441. */
  97442. loadingUIText: string;
  97443. }
  97444. /**
  97445. * Class used for the default loading screen
  97446. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97447. */
  97448. export class DefaultLoadingScreen implements ILoadingScreen {
  97449. private _renderingCanvas;
  97450. private _loadingText;
  97451. private _loadingDivBackgroundColor;
  97452. private _loadingDiv;
  97453. private _loadingTextDiv;
  97454. /** Gets or sets the logo url to use for the default loading screen */
  97455. static DefaultLogoUrl: string;
  97456. /** Gets or sets the spinner url to use for the default loading screen */
  97457. static DefaultSpinnerUrl: string;
  97458. /**
  97459. * Creates a new default loading screen
  97460. * @param _renderingCanvas defines the canvas used to render the scene
  97461. * @param _loadingText defines the default text to display
  97462. * @param _loadingDivBackgroundColor defines the default background color
  97463. */
  97464. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97465. /**
  97466. * Function called to display the loading screen
  97467. */
  97468. displayLoadingUI(): void;
  97469. /**
  97470. * Function called to hide the loading screen
  97471. */
  97472. hideLoadingUI(): void;
  97473. /**
  97474. * Gets or sets the text to display while loading
  97475. */
  97476. loadingUIText: string;
  97477. /**
  97478. * Gets or sets the color to use for the background
  97479. */
  97480. loadingUIBackgroundColor: string;
  97481. private _resizeLoadingUI;
  97482. }
  97483. }
  97484. declare module BABYLON {
  97485. /**
  97486. * Interface for any object that can request an animation frame
  97487. */
  97488. export interface ICustomAnimationFrameRequester {
  97489. /**
  97490. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97491. */
  97492. renderFunction?: Function;
  97493. /**
  97494. * Called to request the next frame to render to
  97495. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97496. */
  97497. requestAnimationFrame: Function;
  97498. /**
  97499. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97500. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97501. */
  97502. requestID?: number;
  97503. }
  97504. }
  97505. declare module BABYLON {
  97506. /**
  97507. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97508. */
  97509. export class PerformanceMonitor {
  97510. private _enabled;
  97511. private _rollingFrameTime;
  97512. private _lastFrameTimeMs;
  97513. /**
  97514. * constructor
  97515. * @param frameSampleSize The number of samples required to saturate the sliding window
  97516. */
  97517. constructor(frameSampleSize?: number);
  97518. /**
  97519. * Samples current frame
  97520. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97521. */
  97522. sampleFrame(timeMs?: number): void;
  97523. /**
  97524. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97525. */
  97526. readonly averageFrameTime: number;
  97527. /**
  97528. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97529. */
  97530. readonly averageFrameTimeVariance: number;
  97531. /**
  97532. * Returns the frame time of the most recent frame
  97533. */
  97534. readonly instantaneousFrameTime: number;
  97535. /**
  97536. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97537. */
  97538. readonly averageFPS: number;
  97539. /**
  97540. * Returns the average framerate in frames per second using the most recent frame time
  97541. */
  97542. readonly instantaneousFPS: number;
  97543. /**
  97544. * Returns true if enough samples have been taken to completely fill the sliding window
  97545. */
  97546. readonly isSaturated: boolean;
  97547. /**
  97548. * Enables contributions to the sliding window sample set
  97549. */
  97550. enable(): void;
  97551. /**
  97552. * Disables contributions to the sliding window sample set
  97553. * Samples will not be interpolated over the disabled period
  97554. */
  97555. disable(): void;
  97556. /**
  97557. * Returns true if sampling is enabled
  97558. */
  97559. readonly isEnabled: boolean;
  97560. /**
  97561. * Resets performance monitor
  97562. */
  97563. reset(): void;
  97564. }
  97565. /**
  97566. * RollingAverage
  97567. *
  97568. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97569. */
  97570. export class RollingAverage {
  97571. /**
  97572. * Current average
  97573. */
  97574. average: number;
  97575. /**
  97576. * Current variance
  97577. */
  97578. variance: number;
  97579. protected _samples: Array<number>;
  97580. protected _sampleCount: number;
  97581. protected _pos: number;
  97582. protected _m2: number;
  97583. /**
  97584. * constructor
  97585. * @param length The number of samples required to saturate the sliding window
  97586. */
  97587. constructor(length: number);
  97588. /**
  97589. * Adds a sample to the sample set
  97590. * @param v The sample value
  97591. */
  97592. add(v: number): void;
  97593. /**
  97594. * Returns previously added values or null if outside of history or outside the sliding window domain
  97595. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97596. * @return Value previously recorded with add() or null if outside of range
  97597. */
  97598. history(i: number): number;
  97599. /**
  97600. * Returns true if enough samples have been taken to completely fill the sliding window
  97601. * @return true if sample-set saturated
  97602. */
  97603. isSaturated(): boolean;
  97604. /**
  97605. * Resets the rolling average (equivalent to 0 samples taken so far)
  97606. */
  97607. reset(): void;
  97608. /**
  97609. * Wraps a value around the sample range boundaries
  97610. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97611. * @return Wrapped position in sample range
  97612. */
  97613. protected _wrapPosition(i: number): number;
  97614. }
  97615. }
  97616. declare module BABYLON {
  97617. /**
  97618. * Defines the interface used by display changed events
  97619. */
  97620. export interface IDisplayChangedEventArgs {
  97621. /** Gets the vrDisplay object (if any) */
  97622. vrDisplay: Nullable<any>;
  97623. /** Gets a boolean indicating if webVR is supported */
  97624. vrSupported: boolean;
  97625. }
  97626. /**
  97627. * Defines the interface used by objects containing a viewport (like a camera)
  97628. */
  97629. interface IViewportOwnerLike {
  97630. /**
  97631. * Gets or sets the viewport
  97632. */
  97633. viewport: IViewportLike;
  97634. }
  97635. /**
  97636. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97637. */
  97638. export class Engine extends ThinEngine {
  97639. /** Defines that alpha blending is disabled */
  97640. static readonly ALPHA_DISABLE: number;
  97641. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97642. static readonly ALPHA_ADD: number;
  97643. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97644. static readonly ALPHA_COMBINE: number;
  97645. /** Defines that alpha blending to DEST - SRC * DEST */
  97646. static readonly ALPHA_SUBTRACT: number;
  97647. /** Defines that alpha blending to SRC * DEST */
  97648. static readonly ALPHA_MULTIPLY: number;
  97649. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97650. static readonly ALPHA_MAXIMIZED: number;
  97651. /** Defines that alpha blending to SRC + DEST */
  97652. static readonly ALPHA_ONEONE: number;
  97653. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97654. static readonly ALPHA_PREMULTIPLIED: number;
  97655. /**
  97656. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97657. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97658. */
  97659. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97660. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97661. static readonly ALPHA_INTERPOLATE: number;
  97662. /**
  97663. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97664. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97665. */
  97666. static readonly ALPHA_SCREENMODE: number;
  97667. /** Defines that the ressource is not delayed*/
  97668. static readonly DELAYLOADSTATE_NONE: number;
  97669. /** Defines that the ressource was successfully delay loaded */
  97670. static readonly DELAYLOADSTATE_LOADED: number;
  97671. /** Defines that the ressource is currently delay loading */
  97672. static readonly DELAYLOADSTATE_LOADING: number;
  97673. /** Defines that the ressource is delayed and has not started loading */
  97674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97676. static readonly NEVER: number;
  97677. /** 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 */
  97678. static readonly ALWAYS: number;
  97679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97680. static readonly LESS: number;
  97681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97682. static readonly EQUAL: number;
  97683. /** 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 */
  97684. static readonly LEQUAL: number;
  97685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97686. static readonly GREATER: number;
  97687. /** 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 */
  97688. static readonly GEQUAL: number;
  97689. /** 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 */
  97690. static readonly NOTEQUAL: number;
  97691. /** Passed to stencilOperation to specify that stencil value must be kept */
  97692. static readonly KEEP: number;
  97693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97694. static readonly REPLACE: number;
  97695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97696. static readonly INCR: number;
  97697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97698. static readonly DECR: number;
  97699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97700. static readonly INVERT: number;
  97701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97702. static readonly INCR_WRAP: number;
  97703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97704. static readonly DECR_WRAP: number;
  97705. /** Texture is not repeating outside of 0..1 UVs */
  97706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97707. /** Texture is repeating outside of 0..1 UVs */
  97708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97709. /** Texture is repeating and mirrored */
  97710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97711. /** ALPHA */
  97712. static readonly TEXTUREFORMAT_ALPHA: number;
  97713. /** LUMINANCE */
  97714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97715. /** LUMINANCE_ALPHA */
  97716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97717. /** RGB */
  97718. static readonly TEXTUREFORMAT_RGB: number;
  97719. /** RGBA */
  97720. static readonly TEXTUREFORMAT_RGBA: number;
  97721. /** RED */
  97722. static readonly TEXTUREFORMAT_RED: number;
  97723. /** RED (2nd reference) */
  97724. static readonly TEXTUREFORMAT_R: number;
  97725. /** RG */
  97726. static readonly TEXTUREFORMAT_RG: number;
  97727. /** RED_INTEGER */
  97728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97729. /** RED_INTEGER (2nd reference) */
  97730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97731. /** RG_INTEGER */
  97732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97733. /** RGB_INTEGER */
  97734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97735. /** RGBA_INTEGER */
  97736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97737. /** UNSIGNED_BYTE */
  97738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97739. /** UNSIGNED_BYTE (2nd reference) */
  97740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97741. /** FLOAT */
  97742. static readonly TEXTURETYPE_FLOAT: number;
  97743. /** HALF_FLOAT */
  97744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97745. /** BYTE */
  97746. static readonly TEXTURETYPE_BYTE: number;
  97747. /** SHORT */
  97748. static readonly TEXTURETYPE_SHORT: number;
  97749. /** UNSIGNED_SHORT */
  97750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97751. /** INT */
  97752. static readonly TEXTURETYPE_INT: number;
  97753. /** UNSIGNED_INT */
  97754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97755. /** UNSIGNED_SHORT_4_4_4_4 */
  97756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97757. /** UNSIGNED_SHORT_5_5_5_1 */
  97758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97759. /** UNSIGNED_SHORT_5_6_5 */
  97760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97761. /** UNSIGNED_INT_2_10_10_10_REV */
  97762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97763. /** UNSIGNED_INT_24_8 */
  97764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97765. /** UNSIGNED_INT_10F_11F_11F_REV */
  97766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97767. /** UNSIGNED_INT_5_9_9_9_REV */
  97768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97771. /** nearest is mag = nearest and min = nearest and mip = linear */
  97772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97774. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97775. /** Trilinear is mag = linear and min = linear and mip = linear */
  97776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97777. /** nearest is mag = nearest and min = nearest and mip = linear */
  97778. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97779. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97780. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97781. /** Trilinear is mag = linear and min = linear and mip = linear */
  97782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97783. /** mag = nearest and min = nearest and mip = nearest */
  97784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97785. /** mag = nearest and min = linear and mip = nearest */
  97786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97787. /** mag = nearest and min = linear and mip = linear */
  97788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97789. /** mag = nearest and min = linear and mip = none */
  97790. static readonly TEXTURE_NEAREST_LINEAR: number;
  97791. /** mag = nearest and min = nearest and mip = none */
  97792. static readonly TEXTURE_NEAREST_NEAREST: number;
  97793. /** mag = linear and min = nearest and mip = nearest */
  97794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97795. /** mag = linear and min = nearest and mip = linear */
  97796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97797. /** mag = linear and min = linear and mip = none */
  97798. static readonly TEXTURE_LINEAR_LINEAR: number;
  97799. /** mag = linear and min = nearest and mip = none */
  97800. static readonly TEXTURE_LINEAR_NEAREST: number;
  97801. /** Explicit coordinates mode */
  97802. static readonly TEXTURE_EXPLICIT_MODE: number;
  97803. /** Spherical coordinates mode */
  97804. static readonly TEXTURE_SPHERICAL_MODE: number;
  97805. /** Planar coordinates mode */
  97806. static readonly TEXTURE_PLANAR_MODE: number;
  97807. /** Cubic coordinates mode */
  97808. static readonly TEXTURE_CUBIC_MODE: number;
  97809. /** Projection coordinates mode */
  97810. static readonly TEXTURE_PROJECTION_MODE: number;
  97811. /** Skybox coordinates mode */
  97812. static readonly TEXTURE_SKYBOX_MODE: number;
  97813. /** Inverse Cubic coordinates mode */
  97814. static readonly TEXTURE_INVCUBIC_MODE: number;
  97815. /** Equirectangular coordinates mode */
  97816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97817. /** Equirectangular Fixed coordinates mode */
  97818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97819. /** Equirectangular Fixed Mirrored coordinates mode */
  97820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97822. static readonly SCALEMODE_FLOOR: number;
  97823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97824. static readonly SCALEMODE_NEAREST: number;
  97825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97826. static readonly SCALEMODE_CEILING: number;
  97827. /**
  97828. * Returns the current npm package of the sdk
  97829. */
  97830. static readonly NpmPackage: string;
  97831. /**
  97832. * Returns the current version of the framework
  97833. */
  97834. static readonly Version: string;
  97835. /** Gets the list of created engines */
  97836. static readonly Instances: Engine[];
  97837. /**
  97838. * Gets the latest created engine
  97839. */
  97840. static readonly LastCreatedEngine: Nullable<Engine>;
  97841. /**
  97842. * Gets the latest created scene
  97843. */
  97844. static readonly LastCreatedScene: Nullable<Scene>;
  97845. /**
  97846. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97847. * @param flag defines which part of the materials must be marked as dirty
  97848. * @param predicate defines a predicate used to filter which materials should be affected
  97849. */
  97850. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97851. /**
  97852. * Method called to create the default loading screen.
  97853. * This can be overriden in your own app.
  97854. * @param canvas The rendering canvas element
  97855. * @returns The loading screen
  97856. */
  97857. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97858. /**
  97859. * Method called to create the default rescale post process on each engine.
  97860. */
  97861. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97862. /**
  97863. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97864. **/
  97865. enableOfflineSupport: boolean;
  97866. /**
  97867. * 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)
  97868. **/
  97869. disableManifestCheck: boolean;
  97870. /**
  97871. * Gets the list of created scenes
  97872. */
  97873. scenes: Scene[];
  97874. /**
  97875. * Event raised when a new scene is created
  97876. */
  97877. onNewSceneAddedObservable: Observable<Scene>;
  97878. /**
  97879. * Gets the list of created postprocesses
  97880. */
  97881. postProcesses: PostProcess[];
  97882. /**
  97883. * Gets a boolean indicating if the pointer is currently locked
  97884. */
  97885. isPointerLock: boolean;
  97886. /**
  97887. * Observable event triggered each time the rendering canvas is resized
  97888. */
  97889. onResizeObservable: Observable<Engine>;
  97890. /**
  97891. * Observable event triggered each time the canvas loses focus
  97892. */
  97893. onCanvasBlurObservable: Observable<Engine>;
  97894. /**
  97895. * Observable event triggered each time the canvas gains focus
  97896. */
  97897. onCanvasFocusObservable: Observable<Engine>;
  97898. /**
  97899. * Observable event triggered each time the canvas receives pointerout event
  97900. */
  97901. onCanvasPointerOutObservable: Observable<PointerEvent>;
  97902. /**
  97903. * Observable event triggered before each texture is initialized
  97904. */
  97905. onBeforeTextureInitObservable: Observable<Texture>;
  97906. /**
  97907. * Observable raised when the engine begins a new frame
  97908. */
  97909. onBeginFrameObservable: Observable<Engine>;
  97910. /**
  97911. * If set, will be used to request the next animation frame for the render loop
  97912. */
  97913. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  97914. /**
  97915. * Observable raised when the engine ends the current frame
  97916. */
  97917. onEndFrameObservable: Observable<Engine>;
  97918. /**
  97919. * Observable raised when the engine is about to compile a shader
  97920. */
  97921. onBeforeShaderCompilationObservable: Observable<Engine>;
  97922. /**
  97923. * Observable raised when the engine has jsut compiled a shader
  97924. */
  97925. onAfterShaderCompilationObservable: Observable<Engine>;
  97926. /**
  97927. * Gets the audio engine
  97928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97929. * @ignorenaming
  97930. */
  97931. static audioEngine: IAudioEngine;
  97932. /**
  97933. * Default AudioEngine factory responsible of creating the Audio Engine.
  97934. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  97935. */
  97936. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  97937. /**
  97938. * Default offline support factory responsible of creating a tool used to store data locally.
  97939. * By default, this will create a Database object if the workload has been embedded.
  97940. */
  97941. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  97942. private _loadingScreen;
  97943. private _pointerLockRequested;
  97944. private _dummyFramebuffer;
  97945. private _rescalePostProcess;
  97946. /** @hidden */
  97947. protected _alphaMode: number;
  97948. /** @hidden */
  97949. protected _alphaEquation: number;
  97950. private _deterministicLockstep;
  97951. private _lockstepMaxSteps;
  97952. protected readonly _supportsHardwareTextureRescaling: boolean;
  97953. private _fps;
  97954. private _deltaTime;
  97955. /**
  97956. * Turn this value on if you want to pause FPS computation when in background
  97957. */
  97958. disablePerformanceMonitorInBackground: boolean;
  97959. private _performanceMonitor;
  97960. /**
  97961. * Gets the performance monitor attached to this engine
  97962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  97963. */
  97964. readonly performanceMonitor: PerformanceMonitor;
  97965. private _onFocus;
  97966. private _onBlur;
  97967. private _onCanvasPointerOut;
  97968. private _onCanvasBlur;
  97969. private _onCanvasFocus;
  97970. private _onFullscreenChange;
  97971. private _onPointerLockChange;
  97972. /**
  97973. * Creates a new engine
  97974. * @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
  97975. * @param antialias defines enable antialiasing (default: false)
  97976. * @param options defines further options to be sent to the getContext() function
  97977. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97978. */
  97979. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97980. /**
  97981. * Gets current aspect ratio
  97982. * @param viewportOwner defines the camera to use to get the aspect ratio
  97983. * @param useScreen defines if screen size must be used (or the current render target if any)
  97984. * @returns a number defining the aspect ratio
  97985. */
  97986. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  97987. /**
  97988. * Gets current screen aspect ratio
  97989. * @returns a number defining the aspect ratio
  97990. */
  97991. getScreenAspectRatio(): number;
  97992. /**
  97993. * Gets host document
  97994. * @returns the host document object
  97995. */
  97996. getHostDocument(): Document;
  97997. /**
  97998. * Gets the client rect of the HTML canvas attached with the current webGL context
  97999. * @returns a client rectanglee
  98000. */
  98001. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98002. /**
  98003. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98004. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98005. * @returns true if engine is in deterministic lock step mode
  98006. */
  98007. isDeterministicLockStep(): boolean;
  98008. /**
  98009. * Gets the max steps when engine is running in deterministic lock step
  98010. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98011. * @returns the max steps
  98012. */
  98013. getLockstepMaxSteps(): number;
  98014. /**
  98015. * Force the mipmap generation for the given render target texture
  98016. * @param texture defines the render target texture to use
  98017. */
  98018. generateMipMapsForCubemap(texture: InternalTexture): void;
  98019. /** States */
  98020. /**
  98021. * Set various states to the webGL context
  98022. * @param culling defines backface culling state
  98023. * @param zOffset defines the value to apply to zOffset (0 by default)
  98024. * @param force defines if states must be applied even if cache is up to date
  98025. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98026. */
  98027. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98028. /**
  98029. * Set the z offset to apply to current rendering
  98030. * @param value defines the offset to apply
  98031. */
  98032. setZOffset(value: number): void;
  98033. /**
  98034. * Gets the current value of the zOffset
  98035. * @returns the current zOffset state
  98036. */
  98037. getZOffset(): number;
  98038. /**
  98039. * Enable or disable depth buffering
  98040. * @param enable defines the state to set
  98041. */
  98042. setDepthBuffer(enable: boolean): void;
  98043. /**
  98044. * Gets a boolean indicating if depth writing is enabled
  98045. * @returns the current depth writing state
  98046. */
  98047. getDepthWrite(): boolean;
  98048. /**
  98049. * Enable or disable depth writing
  98050. * @param enable defines the state to set
  98051. */
  98052. setDepthWrite(enable: boolean): void;
  98053. /**
  98054. * Enable or disable color writing
  98055. * @param enable defines the state to set
  98056. */
  98057. setColorWrite(enable: boolean): void;
  98058. /**
  98059. * Gets a boolean indicating if color writing is enabled
  98060. * @returns the current color writing state
  98061. */
  98062. getColorWrite(): boolean;
  98063. /**
  98064. * Sets alpha constants used by some alpha blending modes
  98065. * @param r defines the red component
  98066. * @param g defines the green component
  98067. * @param b defines the blue component
  98068. * @param a defines the alpha component
  98069. */
  98070. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98071. /**
  98072. * Sets the current alpha mode
  98073. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98074. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98075. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98076. */
  98077. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98078. /**
  98079. * Gets the current alpha mode
  98080. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98081. * @returns the current alpha mode
  98082. */
  98083. getAlphaMode(): number;
  98084. /**
  98085. * Sets the current alpha equation
  98086. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98087. */
  98088. setAlphaEquation(equation: number): void;
  98089. /**
  98090. * Gets the current alpha equation.
  98091. * @returns the current alpha equation
  98092. */
  98093. getAlphaEquation(): number;
  98094. /**
  98095. * Gets a boolean indicating if stencil buffer is enabled
  98096. * @returns the current stencil buffer state
  98097. */
  98098. getStencilBuffer(): boolean;
  98099. /**
  98100. * Enable or disable the stencil buffer
  98101. * @param enable defines if the stencil buffer must be enabled or disabled
  98102. */
  98103. setStencilBuffer(enable: boolean): void;
  98104. /**
  98105. * Gets the current stencil mask
  98106. * @returns a number defining the new stencil mask to use
  98107. */
  98108. getStencilMask(): number;
  98109. /**
  98110. * Sets the current stencil mask
  98111. * @param mask defines the new stencil mask to use
  98112. */
  98113. setStencilMask(mask: number): void;
  98114. /**
  98115. * Gets the current stencil function
  98116. * @returns a number defining the stencil function to use
  98117. */
  98118. getStencilFunction(): number;
  98119. /**
  98120. * Gets the current stencil reference value
  98121. * @returns a number defining the stencil reference value to use
  98122. */
  98123. getStencilFunctionReference(): number;
  98124. /**
  98125. * Gets the current stencil mask
  98126. * @returns a number defining the stencil mask to use
  98127. */
  98128. getStencilFunctionMask(): number;
  98129. /**
  98130. * Sets the current stencil function
  98131. * @param stencilFunc defines the new stencil function to use
  98132. */
  98133. setStencilFunction(stencilFunc: number): void;
  98134. /**
  98135. * Sets the current stencil reference
  98136. * @param reference defines the new stencil reference to use
  98137. */
  98138. setStencilFunctionReference(reference: number): void;
  98139. /**
  98140. * Sets the current stencil mask
  98141. * @param mask defines the new stencil mask to use
  98142. */
  98143. setStencilFunctionMask(mask: number): void;
  98144. /**
  98145. * Gets the current stencil operation when stencil fails
  98146. * @returns a number defining stencil operation to use when stencil fails
  98147. */
  98148. getStencilOperationFail(): number;
  98149. /**
  98150. * Gets the current stencil operation when depth fails
  98151. * @returns a number defining stencil operation to use when depth fails
  98152. */
  98153. getStencilOperationDepthFail(): number;
  98154. /**
  98155. * Gets the current stencil operation when stencil passes
  98156. * @returns a number defining stencil operation to use when stencil passes
  98157. */
  98158. getStencilOperationPass(): number;
  98159. /**
  98160. * Sets the stencil operation to use when stencil fails
  98161. * @param operation defines the stencil operation to use when stencil fails
  98162. */
  98163. setStencilOperationFail(operation: number): void;
  98164. /**
  98165. * Sets the stencil operation to use when depth fails
  98166. * @param operation defines the stencil operation to use when depth fails
  98167. */
  98168. setStencilOperationDepthFail(operation: number): void;
  98169. /**
  98170. * Sets the stencil operation to use when stencil passes
  98171. * @param operation defines the stencil operation to use when stencil passes
  98172. */
  98173. setStencilOperationPass(operation: number): void;
  98174. /**
  98175. * Sets a boolean indicating if the dithering state is enabled or disabled
  98176. * @param value defines the dithering state
  98177. */
  98178. setDitheringState(value: boolean): void;
  98179. /**
  98180. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98181. * @param value defines the rasterizer state
  98182. */
  98183. setRasterizerState(value: boolean): void;
  98184. /**
  98185. * Gets the current depth function
  98186. * @returns a number defining the depth function
  98187. */
  98188. getDepthFunction(): Nullable<number>;
  98189. /**
  98190. * Sets the current depth function
  98191. * @param depthFunc defines the function to use
  98192. */
  98193. setDepthFunction(depthFunc: number): void;
  98194. /**
  98195. * Sets the current depth function to GREATER
  98196. */
  98197. setDepthFunctionToGreater(): void;
  98198. /**
  98199. * Sets the current depth function to GEQUAL
  98200. */
  98201. setDepthFunctionToGreaterOrEqual(): void;
  98202. /**
  98203. * Sets the current depth function to LESS
  98204. */
  98205. setDepthFunctionToLess(): void;
  98206. /**
  98207. * Sets the current depth function to LEQUAL
  98208. */
  98209. setDepthFunctionToLessOrEqual(): void;
  98210. private _cachedStencilBuffer;
  98211. private _cachedStencilFunction;
  98212. private _cachedStencilMask;
  98213. private _cachedStencilOperationPass;
  98214. private _cachedStencilOperationFail;
  98215. private _cachedStencilOperationDepthFail;
  98216. private _cachedStencilReference;
  98217. /**
  98218. * Caches the the state of the stencil buffer
  98219. */
  98220. cacheStencilState(): void;
  98221. /**
  98222. * Restores the state of the stencil buffer
  98223. */
  98224. restoreStencilState(): void;
  98225. /**
  98226. * Directly set the WebGL Viewport
  98227. * @param x defines the x coordinate of the viewport (in screen space)
  98228. * @param y defines the y coordinate of the viewport (in screen space)
  98229. * @param width defines the width of the viewport (in screen space)
  98230. * @param height defines the height of the viewport (in screen space)
  98231. * @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
  98232. */
  98233. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98234. /**
  98235. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98236. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98237. * @param y defines the y-coordinate of the corner of the clear rectangle
  98238. * @param width defines the width of the clear rectangle
  98239. * @param height defines the height of the clear rectangle
  98240. * @param clearColor defines the clear color
  98241. */
  98242. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98243. /**
  98244. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98245. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98246. * @param y defines the y-coordinate of the corner of the clear rectangle
  98247. * @param width defines the width of the clear rectangle
  98248. * @param height defines the height of the clear rectangle
  98249. */
  98250. enableScissor(x: number, y: number, width: number, height: number): void;
  98251. /**
  98252. * Disable previously set scissor test rectangle
  98253. */
  98254. disableScissor(): void;
  98255. /**
  98256. * Initializes a webVR display and starts listening to display change events
  98257. * The onVRDisplayChangedObservable will be notified upon these changes
  98258. * @returns The onVRDisplayChangedObservable
  98259. */
  98260. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98261. /** @hidden */
  98262. _prepareVRComponent(): void;
  98263. /** @hidden */
  98264. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98265. /** @hidden */
  98266. _submitVRFrame(): void;
  98267. /**
  98268. * Call this function to leave webVR mode
  98269. * Will do nothing if webVR is not supported or if there is no webVR device
  98270. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98271. */
  98272. disableVR(): void;
  98273. /**
  98274. * Gets a boolean indicating that the system is in VR mode and is presenting
  98275. * @returns true if VR mode is engaged
  98276. */
  98277. isVRPresenting(): boolean;
  98278. /** @hidden */
  98279. _requestVRFrame(): void;
  98280. /** @hidden */
  98281. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98282. /**
  98283. * Gets the source code of the vertex shader associated with a specific webGL program
  98284. * @param program defines the program to use
  98285. * @returns a string containing the source code of the vertex shader associated with the program
  98286. */
  98287. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98288. /**
  98289. * Gets the source code of the fragment shader associated with a specific webGL program
  98290. * @param program defines the program to use
  98291. * @returns a string containing the source code of the fragment shader associated with the program
  98292. */
  98293. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98294. /**
  98295. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98296. * @param x defines the x coordinate of the rectangle where pixels must be read
  98297. * @param y defines the y coordinate of the rectangle where pixels must be read
  98298. * @param width defines the width of the rectangle where pixels must be read
  98299. * @param height defines the height of the rectangle where pixels must be read
  98300. * @returns a Uint8Array containing RGBA colors
  98301. */
  98302. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98303. /**
  98304. * Sets a depth stencil texture from a render target to the according uniform.
  98305. * @param channel The texture channel
  98306. * @param uniform The uniform to set
  98307. * @param texture The render target texture containing the depth stencil texture to apply
  98308. */
  98309. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98310. /**
  98311. * Sets a texture to the webGL context from a postprocess
  98312. * @param channel defines the channel to use
  98313. * @param postProcess defines the source postprocess
  98314. */
  98315. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98316. /**
  98317. * Binds the output of the passed in post process to the texture channel specified
  98318. * @param channel The channel the texture should be bound to
  98319. * @param postProcess The post process which's output should be bound
  98320. */
  98321. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98322. /** @hidden */
  98323. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98324. protected _rebuildBuffers(): void;
  98325. _renderLoop(): void;
  98326. /**
  98327. * Toggle full screen mode
  98328. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98329. */
  98330. switchFullscreen(requestPointerLock: boolean): void;
  98331. /**
  98332. * Enters full screen mode
  98333. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98334. */
  98335. enterFullscreen(requestPointerLock: boolean): void;
  98336. /**
  98337. * Exits full screen mode
  98338. */
  98339. exitFullscreen(): void;
  98340. /**
  98341. * Enters Pointerlock mode
  98342. */
  98343. enterPointerlock(): void;
  98344. /**
  98345. * Exits Pointerlock mode
  98346. */
  98347. exitPointerlock(): void;
  98348. /**
  98349. * Begin a new frame
  98350. */
  98351. beginFrame(): void;
  98352. /**
  98353. * Enf the current frame
  98354. */
  98355. endFrame(): void;
  98356. resize(): void;
  98357. /**
  98358. * Set the compressed texture format to use, based on the formats you have, and the formats
  98359. * supported by the hardware / browser.
  98360. *
  98361. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98362. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98363. * to API arguments needed to compressed textures. This puts the burden on the container
  98364. * generator to house the arcane code for determining these for current & future formats.
  98365. *
  98366. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98367. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98368. *
  98369. * Note: The result of this call is not taken into account when a texture is base64.
  98370. *
  98371. * @param formatsAvailable defines the list of those format families you have created
  98372. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98373. *
  98374. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98375. * @returns The extension selected.
  98376. */
  98377. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98378. /**
  98379. * Force a specific size of the canvas
  98380. * @param width defines the new canvas' width
  98381. * @param height defines the new canvas' height
  98382. */
  98383. setSize(width: number, height: number): void;
  98384. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98385. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98386. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98387. _releaseTexture(texture: InternalTexture): void;
  98388. /**
  98389. * @hidden
  98390. * Rescales a texture
  98391. * @param source input texutre
  98392. * @param destination destination texture
  98393. * @param scene scene to use to render the resize
  98394. * @param internalFormat format to use when resizing
  98395. * @param onComplete callback to be called when resize has completed
  98396. */
  98397. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98398. /**
  98399. * Gets the current framerate
  98400. * @returns a number representing the framerate
  98401. */
  98402. getFps(): number;
  98403. /**
  98404. * Gets the time spent between current and previous frame
  98405. * @returns a number representing the delta time in ms
  98406. */
  98407. getDeltaTime(): number;
  98408. private _measureFps;
  98409. /**
  98410. * Creates a new render target texture
  98411. * @param size defines the size of the texture
  98412. * @param options defines the options used to create the texture
  98413. * @returns a new render target texture stored in an InternalTexture
  98414. */
  98415. createRenderTargetTexture(size: number | {
  98416. width: number;
  98417. height: number;
  98418. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98419. /**
  98420. * Updates the sample count of a render target texture
  98421. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98422. * @param texture defines the texture to update
  98423. * @param samples defines the sample count to set
  98424. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98425. */
  98426. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98427. /** @hidden */
  98428. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98429. dispose(): void;
  98430. private _disableTouchAction;
  98431. /**
  98432. * Display the loading screen
  98433. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98434. */
  98435. displayLoadingUI(): void;
  98436. /**
  98437. * Hide the loading screen
  98438. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98439. */
  98440. hideLoadingUI(): void;
  98441. /**
  98442. * Gets the current loading screen object
  98443. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98444. */
  98445. /**
  98446. * Sets the current loading screen object
  98447. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98448. */
  98449. loadingScreen: ILoadingScreen;
  98450. /**
  98451. * Sets the current loading screen text
  98452. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98453. */
  98454. loadingUIText: string;
  98455. /**
  98456. * Sets the current loading screen background color
  98457. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98458. */
  98459. loadingUIBackgroundColor: string;
  98460. /** Pointerlock and fullscreen */
  98461. /**
  98462. * Ask the browser to promote the current element to pointerlock mode
  98463. * @param element defines the DOM element to promote
  98464. */
  98465. static _RequestPointerlock(element: HTMLElement): void;
  98466. /**
  98467. * Asks the browser to exit pointerlock mode
  98468. */
  98469. static _ExitPointerlock(): void;
  98470. /**
  98471. * Ask the browser to promote the current element to fullscreen rendering mode
  98472. * @param element defines the DOM element to promote
  98473. */
  98474. static _RequestFullscreen(element: HTMLElement): void;
  98475. /**
  98476. * Asks the browser to exit fullscreen mode
  98477. */
  98478. static _ExitFullscreen(): void;
  98479. }
  98480. }
  98481. declare module BABYLON {
  98482. /**
  98483. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98484. * during the life time of the application.
  98485. */
  98486. export class EngineStore {
  98487. /** Gets the list of created engines */
  98488. static Instances: Engine[];
  98489. /** @hidden */
  98490. static _LastCreatedScene: Nullable<Scene>;
  98491. /**
  98492. * Gets the latest created engine
  98493. */
  98494. static readonly LastCreatedEngine: Nullable<Engine>;
  98495. /**
  98496. * Gets the latest created scene
  98497. */
  98498. static readonly LastCreatedScene: Nullable<Scene>;
  98499. /**
  98500. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98501. * @ignorenaming
  98502. */
  98503. static UseFallbackTexture: boolean;
  98504. /**
  98505. * Texture content used if a texture cannot loaded
  98506. * @ignorenaming
  98507. */
  98508. static FallbackTexture: string;
  98509. }
  98510. }
  98511. declare module BABYLON {
  98512. /**
  98513. * Helper class that provides a small promise polyfill
  98514. */
  98515. export class PromisePolyfill {
  98516. /**
  98517. * Static function used to check if the polyfill is required
  98518. * If this is the case then the function will inject the polyfill to window.Promise
  98519. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98520. */
  98521. static Apply(force?: boolean): void;
  98522. }
  98523. }
  98524. declare module BABYLON {
  98525. /**
  98526. * Interface for screenshot methods with describe argument called `size` as object with options
  98527. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98528. */
  98529. export interface IScreenshotSize {
  98530. /**
  98531. * number in pixels for canvas height
  98532. */
  98533. height?: number;
  98534. /**
  98535. * multiplier allowing render at a higher or lower resolution
  98536. * If value is defined then height and width will be ignored and taken from camera
  98537. */
  98538. precision?: number;
  98539. /**
  98540. * number in pixels for canvas width
  98541. */
  98542. width?: number;
  98543. }
  98544. }
  98545. declare module BABYLON {
  98546. interface IColor4Like {
  98547. r: float;
  98548. g: float;
  98549. b: float;
  98550. a: float;
  98551. }
  98552. /**
  98553. * Class containing a set of static utilities functions
  98554. */
  98555. export class Tools {
  98556. /**
  98557. * Gets or sets the base URL to use to load assets
  98558. */
  98559. static BaseUrl: string;
  98560. /**
  98561. * Enable/Disable Custom HTTP Request Headers globally.
  98562. * default = false
  98563. * @see CustomRequestHeaders
  98564. */
  98565. static UseCustomRequestHeaders: boolean;
  98566. /**
  98567. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98568. * i.e. when loading files, where the server/service expects an Authorization header
  98569. */
  98570. static CustomRequestHeaders: {
  98571. [key: string]: string;
  98572. };
  98573. /**
  98574. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98575. */
  98576. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98577. /**
  98578. * Default behaviour for cors in the application.
  98579. * It can be a string if the expected behavior is identical in the entire app.
  98580. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98581. */
  98582. static CorsBehavior: string | ((url: string | string[]) => string);
  98583. /**
  98584. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98585. * @ignorenaming
  98586. */
  98587. static UseFallbackTexture: boolean;
  98588. /**
  98589. * Use this object to register external classes like custom textures or material
  98590. * to allow the laoders to instantiate them
  98591. */
  98592. static RegisteredExternalClasses: {
  98593. [key: string]: Object;
  98594. };
  98595. /**
  98596. * Texture content used if a texture cannot loaded
  98597. * @ignorenaming
  98598. */
  98599. static fallbackTexture: string;
  98600. /**
  98601. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98602. * @param u defines the coordinate on X axis
  98603. * @param v defines the coordinate on Y axis
  98604. * @param width defines the width of the source data
  98605. * @param height defines the height of the source data
  98606. * @param pixels defines the source byte array
  98607. * @param color defines the output color
  98608. */
  98609. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98610. /**
  98611. * Interpolates between a and b via alpha
  98612. * @param a The lower value (returned when alpha = 0)
  98613. * @param b The upper value (returned when alpha = 1)
  98614. * @param alpha The interpolation-factor
  98615. * @return The mixed value
  98616. */
  98617. static Mix(a: number, b: number, alpha: number): number;
  98618. /**
  98619. * Tries to instantiate a new object from a given class name
  98620. * @param className defines the class name to instantiate
  98621. * @returns the new object or null if the system was not able to do the instantiation
  98622. */
  98623. static Instantiate(className: string): any;
  98624. /**
  98625. * Provides a slice function that will work even on IE
  98626. * @param data defines the array to slice
  98627. * @param start defines the start of the data (optional)
  98628. * @param end defines the end of the data (optional)
  98629. * @returns the new sliced array
  98630. */
  98631. static Slice<T>(data: T, start?: number, end?: number): T;
  98632. /**
  98633. * Polyfill for setImmediate
  98634. * @param action defines the action to execute after the current execution block
  98635. */
  98636. static SetImmediate(action: () => void): void;
  98637. /**
  98638. * Function indicating if a number is an exponent of 2
  98639. * @param value defines the value to test
  98640. * @returns true if the value is an exponent of 2
  98641. */
  98642. static IsExponentOfTwo(value: number): boolean;
  98643. private static _tmpFloatArray;
  98644. /**
  98645. * Returns the nearest 32-bit single precision float representation of a Number
  98646. * @param value A Number. If the parameter is of a different type, it will get converted
  98647. * to a number or to NaN if it cannot be converted
  98648. * @returns number
  98649. */
  98650. static FloatRound(value: number): number;
  98651. /**
  98652. * Extracts the filename from a path
  98653. * @param path defines the path to use
  98654. * @returns the filename
  98655. */
  98656. static GetFilename(path: string): string;
  98657. /**
  98658. * Extracts the "folder" part of a path (everything before the filename).
  98659. * @param uri The URI to extract the info from
  98660. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98661. * @returns The "folder" part of the path
  98662. */
  98663. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98664. /**
  98665. * Extracts text content from a DOM element hierarchy
  98666. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98667. */
  98668. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98669. /**
  98670. * Convert an angle in radians to degrees
  98671. * @param angle defines the angle to convert
  98672. * @returns the angle in degrees
  98673. */
  98674. static ToDegrees(angle: number): number;
  98675. /**
  98676. * Convert an angle in degrees to radians
  98677. * @param angle defines the angle to convert
  98678. * @returns the angle in radians
  98679. */
  98680. static ToRadians(angle: number): number;
  98681. /**
  98682. * Encode a buffer to a base64 string
  98683. * @param buffer defines the buffer to encode
  98684. * @returns the encoded string
  98685. */
  98686. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98687. /**
  98688. * Returns an array if obj is not an array
  98689. * @param obj defines the object to evaluate as an array
  98690. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98691. * @returns either obj directly if obj is an array or a new array containing obj
  98692. */
  98693. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98694. /**
  98695. * Gets the pointer prefix to use
  98696. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98697. */
  98698. static GetPointerPrefix(): string;
  98699. /**
  98700. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98701. * @param url define the url we are trying
  98702. * @param element define the dom element where to configure the cors policy
  98703. */
  98704. static SetCorsBehavior(url: string | string[], element: {
  98705. crossOrigin: string | null;
  98706. }): void;
  98707. /**
  98708. * Removes unwanted characters from an url
  98709. * @param url defines the url to clean
  98710. * @returns the cleaned url
  98711. */
  98712. static CleanUrl(url: string): string;
  98713. /**
  98714. * Gets or sets a function used to pre-process url before using them to load assets
  98715. */
  98716. static PreprocessUrl: (url: string) => string;
  98717. /**
  98718. * Loads an image as an HTMLImageElement.
  98719. * @param input url string, ArrayBuffer, or Blob to load
  98720. * @param onLoad callback called when the image successfully loads
  98721. * @param onError callback called when the image fails to load
  98722. * @param offlineProvider offline provider for caching
  98723. * @returns the HTMLImageElement of the loaded image
  98724. */
  98725. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98726. /**
  98727. * Loads a file
  98728. * @param url url string, ArrayBuffer, or Blob to load
  98729. * @param onSuccess callback called when the file successfully loads
  98730. * @param onProgress callback called while file is loading (if the server supports this mode)
  98731. * @param offlineProvider defines the offline provider for caching
  98732. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98733. * @param onError callback called when the file fails to load
  98734. * @returns a file request object
  98735. */
  98736. 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;
  98737. /**
  98738. * Loads a file from a url
  98739. * @param url the file url to load
  98740. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98741. */
  98742. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98743. /**
  98744. * Load a script (identified by an url). When the url returns, the
  98745. * content of this file is added into a new script element, attached to the DOM (body element)
  98746. * @param scriptUrl defines the url of the script to laod
  98747. * @param onSuccess defines the callback called when the script is loaded
  98748. * @param onError defines the callback to call if an error occurs
  98749. * @param scriptId defines the id of the script element
  98750. */
  98751. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98752. /**
  98753. * Load an asynchronous script (identified by an url). When the url returns, the
  98754. * content of this file is added into a new script element, attached to the DOM (body element)
  98755. * @param scriptUrl defines the url of the script to laod
  98756. * @param scriptId defines the id of the script element
  98757. * @returns a promise request object
  98758. */
  98759. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98760. /**
  98761. * Loads a file from a blob
  98762. * @param fileToLoad defines the blob to use
  98763. * @param callback defines the callback to call when data is loaded
  98764. * @param progressCallback defines the callback to call during loading process
  98765. * @returns a file request object
  98766. */
  98767. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98768. /**
  98769. * Loads a file
  98770. * @param fileToLoad defines the file to load
  98771. * @param callback defines the callback to call when data is loaded
  98772. * @param progressCallBack defines the callback to call during loading process
  98773. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98774. * @returns a file request object
  98775. */
  98776. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98777. /**
  98778. * Creates a data url from a given string content
  98779. * @param content defines the content to convert
  98780. * @returns the new data url link
  98781. */
  98782. static FileAsURL(content: string): string;
  98783. /**
  98784. * Format the given number to a specific decimal format
  98785. * @param value defines the number to format
  98786. * @param decimals defines the number of decimals to use
  98787. * @returns the formatted string
  98788. */
  98789. static Format(value: number, decimals?: number): string;
  98790. /**
  98791. * Tries to copy an object by duplicating every property
  98792. * @param source defines the source object
  98793. * @param destination defines the target object
  98794. * @param doNotCopyList defines a list of properties to avoid
  98795. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98796. */
  98797. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98798. /**
  98799. * Gets a boolean indicating if the given object has no own property
  98800. * @param obj defines the object to test
  98801. * @returns true if object has no own property
  98802. */
  98803. static IsEmpty(obj: any): boolean;
  98804. /**
  98805. * Function used to register events at window level
  98806. * @param windowElement defines the Window object to use
  98807. * @param events defines the events to register
  98808. */
  98809. static RegisterTopRootEvents(windowElement: Window, events: {
  98810. name: string;
  98811. handler: Nullable<(e: FocusEvent) => any>;
  98812. }[]): void;
  98813. /**
  98814. * Function used to unregister events from window level
  98815. * @param windowElement defines the Window object to use
  98816. * @param events defines the events to unregister
  98817. */
  98818. static UnregisterTopRootEvents(windowElement: Window, events: {
  98819. name: string;
  98820. handler: Nullable<(e: FocusEvent) => any>;
  98821. }[]): void;
  98822. /**
  98823. * @ignore
  98824. */
  98825. static _ScreenshotCanvas: HTMLCanvasElement;
  98826. /**
  98827. * Dumps the current bound framebuffer
  98828. * @param width defines the rendering width
  98829. * @param height defines the rendering height
  98830. * @param engine defines the hosting engine
  98831. * @param successCallback defines the callback triggered once the data are available
  98832. * @param mimeType defines the mime type of the result
  98833. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98834. */
  98835. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98836. /**
  98837. * Converts the canvas data to blob.
  98838. * This acts as a polyfill for browsers not supporting the to blob function.
  98839. * @param canvas Defines the canvas to extract the data from
  98840. * @param successCallback Defines the callback triggered once the data are available
  98841. * @param mimeType Defines the mime type of the result
  98842. */
  98843. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98844. /**
  98845. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98846. * @param successCallback defines the callback triggered once the data are available
  98847. * @param mimeType defines the mime type of the result
  98848. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98849. */
  98850. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98851. /**
  98852. * Downloads a blob in the browser
  98853. * @param blob defines the blob to download
  98854. * @param fileName defines the name of the downloaded file
  98855. */
  98856. static Download(blob: Blob, fileName: string): void;
  98857. /**
  98858. * Captures a screenshot of the current rendering
  98859. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98860. * @param engine defines the rendering engine
  98861. * @param camera defines the source camera
  98862. * @param size This parameter can be set to a single number or to an object with the
  98863. * following (optional) properties: precision, width, height. If a single number is passed,
  98864. * it will be used for both width and height. If an object is passed, the screenshot size
  98865. * will be derived from the parameters. The precision property is a multiplier allowing
  98866. * rendering at a higher or lower resolution
  98867. * @param successCallback defines the callback receives a single parameter which contains the
  98868. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98869. * src parameter of an <img> to display it
  98870. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98871. * Check your browser for supported MIME types
  98872. */
  98873. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98874. /**
  98875. * Captures a screenshot of the current rendering
  98876. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98877. * @param engine defines the rendering engine
  98878. * @param camera defines the source camera
  98879. * @param size This parameter can be set to a single number or to an object with the
  98880. * following (optional) properties: precision, width, height. If a single number is passed,
  98881. * it will be used for both width and height. If an object is passed, the screenshot size
  98882. * will be derived from the parameters. The precision property is a multiplier allowing
  98883. * rendering at a higher or lower resolution
  98884. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98885. * Check your browser for supported MIME types
  98886. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98887. * to the src parameter of an <img> to display it
  98888. */
  98889. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98890. /**
  98891. * Generates an image screenshot from the specified camera.
  98892. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98893. * @param engine The engine to use for rendering
  98894. * @param camera The camera to use for rendering
  98895. * @param size This parameter can be set to a single number or to an object with the
  98896. * following (optional) properties: precision, width, height. If a single number is passed,
  98897. * it will be used for both width and height. If an object is passed, the screenshot size
  98898. * will be derived from the parameters. The precision property is a multiplier allowing
  98899. * rendering at a higher or lower resolution
  98900. * @param successCallback The callback receives a single parameter which contains the
  98901. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98902. * src parameter of an <img> to display it
  98903. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98904. * Check your browser for supported MIME types
  98905. * @param samples Texture samples (default: 1)
  98906. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98907. * @param fileName A name for for the downloaded file.
  98908. */
  98909. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98910. /**
  98911. * Generates an image screenshot from the specified camera.
  98912. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98913. * @param engine The engine to use for rendering
  98914. * @param camera The camera to use for rendering
  98915. * @param size This parameter can be set to a single number or to an object with the
  98916. * following (optional) properties: precision, width, height. If a single number is passed,
  98917. * it will be used for both width and height. If an object is passed, the screenshot size
  98918. * will be derived from the parameters. The precision property is a multiplier allowing
  98919. * rendering at a higher or lower resolution
  98920. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98921. * Check your browser for supported MIME types
  98922. * @param samples Texture samples (default: 1)
  98923. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98924. * @param fileName A name for for the downloaded file.
  98925. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98926. * to the src parameter of an <img> to display it
  98927. */
  98928. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  98929. /**
  98930. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98931. * Be aware Math.random() could cause collisions, but:
  98932. * "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"
  98933. * @returns a pseudo random id
  98934. */
  98935. static RandomId(): string;
  98936. /**
  98937. * Test if the given uri is a base64 string
  98938. * @param uri The uri to test
  98939. * @return True if the uri is a base64 string or false otherwise
  98940. */
  98941. static IsBase64(uri: string): boolean;
  98942. /**
  98943. * Decode the given base64 uri.
  98944. * @param uri The uri to decode
  98945. * @return The decoded base64 data.
  98946. */
  98947. static DecodeBase64(uri: string): ArrayBuffer;
  98948. /**
  98949. * Gets the absolute url.
  98950. * @param url the input url
  98951. * @return the absolute url
  98952. */
  98953. static GetAbsoluteUrl(url: string): string;
  98954. /**
  98955. * No log
  98956. */
  98957. static readonly NoneLogLevel: number;
  98958. /**
  98959. * Only message logs
  98960. */
  98961. static readonly MessageLogLevel: number;
  98962. /**
  98963. * Only warning logs
  98964. */
  98965. static readonly WarningLogLevel: number;
  98966. /**
  98967. * Only error logs
  98968. */
  98969. static readonly ErrorLogLevel: number;
  98970. /**
  98971. * All logs
  98972. */
  98973. static readonly AllLogLevel: number;
  98974. /**
  98975. * Gets a value indicating the number of loading errors
  98976. * @ignorenaming
  98977. */
  98978. static readonly errorsCount: number;
  98979. /**
  98980. * Callback called when a new log is added
  98981. */
  98982. static OnNewCacheEntry: (entry: string) => void;
  98983. /**
  98984. * Log a message to the console
  98985. * @param message defines the message to log
  98986. */
  98987. static Log(message: string): void;
  98988. /**
  98989. * Write a warning message to the console
  98990. * @param message defines the message to log
  98991. */
  98992. static Warn(message: string): void;
  98993. /**
  98994. * Write an error message to the console
  98995. * @param message defines the message to log
  98996. */
  98997. static Error(message: string): void;
  98998. /**
  98999. * Gets current log cache (list of logs)
  99000. */
  99001. static readonly LogCache: string;
  99002. /**
  99003. * Clears the log cache
  99004. */
  99005. static ClearLogCache(): void;
  99006. /**
  99007. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99008. */
  99009. static LogLevels: number;
  99010. /**
  99011. * Checks if the window object exists
  99012. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99013. */
  99014. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99015. /**
  99016. * No performance log
  99017. */
  99018. static readonly PerformanceNoneLogLevel: number;
  99019. /**
  99020. * Use user marks to log performance
  99021. */
  99022. static readonly PerformanceUserMarkLogLevel: number;
  99023. /**
  99024. * Log performance to the console
  99025. */
  99026. static readonly PerformanceConsoleLogLevel: number;
  99027. private static _performance;
  99028. /**
  99029. * Sets the current performance log level
  99030. */
  99031. static PerformanceLogLevel: number;
  99032. private static _StartPerformanceCounterDisabled;
  99033. private static _EndPerformanceCounterDisabled;
  99034. private static _StartUserMark;
  99035. private static _EndUserMark;
  99036. private static _StartPerformanceConsole;
  99037. private static _EndPerformanceConsole;
  99038. /**
  99039. * Starts a performance counter
  99040. */
  99041. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99042. /**
  99043. * Ends a specific performance coutner
  99044. */
  99045. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99046. /**
  99047. * Gets either window.performance.now() if supported or Date.now() else
  99048. */
  99049. static readonly Now: number;
  99050. /**
  99051. * This method will return the name of the class used to create the instance of the given object.
  99052. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99053. * @param object the object to get the class name from
  99054. * @param isType defines if the object is actually a type
  99055. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99056. */
  99057. static GetClassName(object: any, isType?: boolean): string;
  99058. /**
  99059. * Gets the first element of an array satisfying a given predicate
  99060. * @param array defines the array to browse
  99061. * @param predicate defines the predicate to use
  99062. * @returns null if not found or the element
  99063. */
  99064. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99065. /**
  99066. * This method will return the name of the full name of the class, including its owning module (if any).
  99067. * 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).
  99068. * @param object the object to get the class name from
  99069. * @param isType defines if the object is actually a type
  99070. * @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.
  99071. * @ignorenaming
  99072. */
  99073. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99074. /**
  99075. * Returns a promise that resolves after the given amount of time.
  99076. * @param delay Number of milliseconds to delay
  99077. * @returns Promise that resolves after the given amount of time
  99078. */
  99079. static DelayAsync(delay: number): Promise<void>;
  99080. }
  99081. /**
  99082. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99083. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99084. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99085. * @param name The name of the class, case should be preserved
  99086. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99087. */
  99088. export function className(name: string, module?: string): (target: Object) => void;
  99089. /**
  99090. * An implementation of a loop for asynchronous functions.
  99091. */
  99092. export class AsyncLoop {
  99093. /**
  99094. * Defines the number of iterations for the loop
  99095. */
  99096. iterations: number;
  99097. /**
  99098. * Defines the current index of the loop.
  99099. */
  99100. index: number;
  99101. private _done;
  99102. private _fn;
  99103. private _successCallback;
  99104. /**
  99105. * Constructor.
  99106. * @param iterations the number of iterations.
  99107. * @param func the function to run each iteration
  99108. * @param successCallback the callback that will be called upon succesful execution
  99109. * @param offset starting offset.
  99110. */
  99111. constructor(
  99112. /**
  99113. * Defines the number of iterations for the loop
  99114. */
  99115. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99116. /**
  99117. * Execute the next iteration. Must be called after the last iteration was finished.
  99118. */
  99119. executeNext(): void;
  99120. /**
  99121. * Break the loop and run the success callback.
  99122. */
  99123. breakLoop(): void;
  99124. /**
  99125. * Create and run an async loop.
  99126. * @param iterations the number of iterations.
  99127. * @param fn the function to run each iteration
  99128. * @param successCallback the callback that will be called upon succesful execution
  99129. * @param offset starting offset.
  99130. * @returns the created async loop object
  99131. */
  99132. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99133. /**
  99134. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99135. * @param iterations total number of iterations
  99136. * @param syncedIterations number of synchronous iterations in each async iteration.
  99137. * @param fn the function to call each iteration.
  99138. * @param callback a success call back that will be called when iterating stops.
  99139. * @param breakFunction a break condition (optional)
  99140. * @param timeout timeout settings for the setTimeout function. default - 0.
  99141. * @returns the created async loop object
  99142. */
  99143. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99144. }
  99145. }
  99146. declare module BABYLON {
  99147. /**
  99148. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99149. * The underlying implementation relies on an associative array to ensure the best performances.
  99150. * The value can be anything including 'null' but except 'undefined'
  99151. */
  99152. export class StringDictionary<T> {
  99153. /**
  99154. * This will clear this dictionary and copy the content from the 'source' one.
  99155. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99156. * @param source the dictionary to take the content from and copy to this dictionary
  99157. */
  99158. copyFrom(source: StringDictionary<T>): void;
  99159. /**
  99160. * Get a value based from its key
  99161. * @param key the given key to get the matching value from
  99162. * @return the value if found, otherwise undefined is returned
  99163. */
  99164. get(key: string): T | undefined;
  99165. /**
  99166. * Get a value from its key or add it if it doesn't exist.
  99167. * This method will ensure you that a given key/data will be present in the dictionary.
  99168. * @param key the given key to get the matching value from
  99169. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99170. * The factory will only be invoked if there's no data for the given key.
  99171. * @return the value corresponding to the key.
  99172. */
  99173. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99174. /**
  99175. * Get a value from its key if present in the dictionary otherwise add it
  99176. * @param key the key to get the value from
  99177. * @param val if there's no such key/value pair in the dictionary add it with this value
  99178. * @return the value corresponding to the key
  99179. */
  99180. getOrAdd(key: string, val: T): T;
  99181. /**
  99182. * Check if there's a given key in the dictionary
  99183. * @param key the key to check for
  99184. * @return true if the key is present, false otherwise
  99185. */
  99186. contains(key: string): boolean;
  99187. /**
  99188. * Add a new key and its corresponding value
  99189. * @param key the key to add
  99190. * @param value the value corresponding to the key
  99191. * @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
  99192. */
  99193. add(key: string, value: T): boolean;
  99194. /**
  99195. * Update a specific value associated to a key
  99196. * @param key defines the key to use
  99197. * @param value defines the value to store
  99198. * @returns true if the value was updated (or false if the key was not found)
  99199. */
  99200. set(key: string, value: T): boolean;
  99201. /**
  99202. * Get the element of the given key and remove it from the dictionary
  99203. * @param key defines the key to search
  99204. * @returns the value associated with the key or null if not found
  99205. */
  99206. getAndRemove(key: string): Nullable<T>;
  99207. /**
  99208. * Remove a key/value from the dictionary.
  99209. * @param key the key to remove
  99210. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99211. */
  99212. remove(key: string): boolean;
  99213. /**
  99214. * Clear the whole content of the dictionary
  99215. */
  99216. clear(): void;
  99217. /**
  99218. * Gets the current count
  99219. */
  99220. readonly count: number;
  99221. /**
  99222. * Execute a callback on each key/val of the dictionary.
  99223. * Note that you can remove any element in this dictionary in the callback implementation
  99224. * @param callback the callback to execute on a given key/value pair
  99225. */
  99226. forEach(callback: (key: string, val: T) => void): void;
  99227. /**
  99228. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99229. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99230. * Note that you can remove any element in this dictionary in the callback implementation
  99231. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99232. * @returns the first item
  99233. */
  99234. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99235. private _count;
  99236. private _data;
  99237. }
  99238. }
  99239. declare module BABYLON {
  99240. /** @hidden */
  99241. export interface ICollisionCoordinator {
  99242. createCollider(): Collider;
  99243. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99244. init(scene: Scene): void;
  99245. }
  99246. /** @hidden */
  99247. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99248. private _scene;
  99249. private _scaledPosition;
  99250. private _scaledVelocity;
  99251. private _finalPosition;
  99252. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99253. createCollider(): Collider;
  99254. init(scene: Scene): void;
  99255. private _collideWithWorld;
  99256. }
  99257. }
  99258. declare module BABYLON {
  99259. /**
  99260. * Class used to manage all inputs for the scene.
  99261. */
  99262. export class InputManager {
  99263. /** The distance in pixel that you have to move to prevent some events */
  99264. static DragMovementThreshold: number;
  99265. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99266. static LongPressDelay: number;
  99267. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99268. static DoubleClickDelay: number;
  99269. /** If you need to check double click without raising a single click at first click, enable this flag */
  99270. static ExclusiveDoubleClickMode: boolean;
  99271. private _wheelEventName;
  99272. private _onPointerMove;
  99273. private _onPointerDown;
  99274. private _onPointerUp;
  99275. private _initClickEvent;
  99276. private _initActionManager;
  99277. private _delayedSimpleClick;
  99278. private _delayedSimpleClickTimeout;
  99279. private _previousDelayedSimpleClickTimeout;
  99280. private _meshPickProceed;
  99281. private _previousButtonPressed;
  99282. private _currentPickResult;
  99283. private _previousPickResult;
  99284. private _totalPointersPressed;
  99285. private _doubleClickOccured;
  99286. private _pointerOverMesh;
  99287. private _pickedDownMesh;
  99288. private _pickedUpMesh;
  99289. private _pointerX;
  99290. private _pointerY;
  99291. private _unTranslatedPointerX;
  99292. private _unTranslatedPointerY;
  99293. private _startingPointerPosition;
  99294. private _previousStartingPointerPosition;
  99295. private _startingPointerTime;
  99296. private _previousStartingPointerTime;
  99297. private _pointerCaptures;
  99298. private _onKeyDown;
  99299. private _onKeyUp;
  99300. private _onCanvasFocusObserver;
  99301. private _onCanvasBlurObserver;
  99302. private _scene;
  99303. /**
  99304. * Creates a new InputManager
  99305. * @param scene defines the hosting scene
  99306. */
  99307. constructor(scene: Scene);
  99308. /**
  99309. * Gets the mesh that is currently under the pointer
  99310. */
  99311. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99312. /**
  99313. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99314. */
  99315. readonly unTranslatedPointer: Vector2;
  99316. /**
  99317. * Gets or sets the current on-screen X position of the pointer
  99318. */
  99319. pointerX: number;
  99320. /**
  99321. * Gets or sets the current on-screen Y position of the pointer
  99322. */
  99323. pointerY: number;
  99324. private _updatePointerPosition;
  99325. private _processPointerMove;
  99326. private _setRayOnPointerInfo;
  99327. private _checkPrePointerObservable;
  99328. /**
  99329. * Use this method to simulate a pointer move on a mesh
  99330. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99331. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99332. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99333. */
  99334. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99335. /**
  99336. * Use this method to simulate a pointer down on a mesh
  99337. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99338. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99339. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99340. */
  99341. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99342. private _processPointerDown;
  99343. /** @hidden */
  99344. _isPointerSwiping(): boolean;
  99345. /**
  99346. * Use this method to simulate a pointer up on a mesh
  99347. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99348. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99349. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99350. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99351. */
  99352. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99353. private _processPointerUp;
  99354. /**
  99355. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99356. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99357. * @returns true if the pointer was captured
  99358. */
  99359. isPointerCaptured(pointerId?: number): boolean;
  99360. /**
  99361. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99362. * @param attachUp defines if you want to attach events to pointerup
  99363. * @param attachDown defines if you want to attach events to pointerdown
  99364. * @param attachMove defines if you want to attach events to pointermove
  99365. */
  99366. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99367. /**
  99368. * Detaches all event handlers
  99369. */
  99370. detachControl(): void;
  99371. /**
  99372. * Force the value of meshUnderPointer
  99373. * @param mesh defines the mesh to use
  99374. */
  99375. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99376. /**
  99377. * Gets the mesh under the pointer
  99378. * @returns a Mesh or null if no mesh is under the pointer
  99379. */
  99380. getPointerOverMesh(): Nullable<AbstractMesh>;
  99381. }
  99382. }
  99383. declare module BABYLON {
  99384. /**
  99385. * Helper class used to generate session unique ID
  99386. */
  99387. export class UniqueIdGenerator {
  99388. private static _UniqueIdCounter;
  99389. /**
  99390. * Gets an unique (relatively to the current scene) Id
  99391. */
  99392. static readonly UniqueId: number;
  99393. }
  99394. }
  99395. declare module BABYLON {
  99396. /**
  99397. * This class defines the direct association between an animation and a target
  99398. */
  99399. export class TargetedAnimation {
  99400. /**
  99401. * Animation to perform
  99402. */
  99403. animation: Animation;
  99404. /**
  99405. * Target to animate
  99406. */
  99407. target: any;
  99408. /**
  99409. * Serialize the object
  99410. * @returns the JSON object representing the current entity
  99411. */
  99412. serialize(): any;
  99413. }
  99414. /**
  99415. * Use this class to create coordinated animations on multiple targets
  99416. */
  99417. export class AnimationGroup implements IDisposable {
  99418. /** The name of the animation group */
  99419. name: string;
  99420. private _scene;
  99421. private _targetedAnimations;
  99422. private _animatables;
  99423. private _from;
  99424. private _to;
  99425. private _isStarted;
  99426. private _isPaused;
  99427. private _speedRatio;
  99428. private _loopAnimation;
  99429. /**
  99430. * Gets or sets the unique id of the node
  99431. */
  99432. uniqueId: number;
  99433. /**
  99434. * This observable will notify when one animation have ended
  99435. */
  99436. onAnimationEndObservable: Observable<TargetedAnimation>;
  99437. /**
  99438. * Observer raised when one animation loops
  99439. */
  99440. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99441. /**
  99442. * This observable will notify when all animations have ended.
  99443. */
  99444. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99445. /**
  99446. * This observable will notify when all animations have paused.
  99447. */
  99448. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99449. /**
  99450. * This observable will notify when all animations are playing.
  99451. */
  99452. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99453. /**
  99454. * Gets the first frame
  99455. */
  99456. readonly from: number;
  99457. /**
  99458. * Gets the last frame
  99459. */
  99460. readonly to: number;
  99461. /**
  99462. * Define if the animations are started
  99463. */
  99464. readonly isStarted: boolean;
  99465. /**
  99466. * Gets a value indicating that the current group is playing
  99467. */
  99468. readonly isPlaying: boolean;
  99469. /**
  99470. * Gets or sets the speed ratio to use for all animations
  99471. */
  99472. /**
  99473. * Gets or sets the speed ratio to use for all animations
  99474. */
  99475. speedRatio: number;
  99476. /**
  99477. * Gets or sets if all animations should loop or not
  99478. */
  99479. loopAnimation: boolean;
  99480. /**
  99481. * Gets the targeted animations for this animation group
  99482. */
  99483. readonly targetedAnimations: Array<TargetedAnimation>;
  99484. /**
  99485. * returning the list of animatables controlled by this animation group.
  99486. */
  99487. readonly animatables: Array<Animatable>;
  99488. /**
  99489. * Instantiates a new Animation Group.
  99490. * This helps managing several animations at once.
  99491. * @see http://doc.babylonjs.com/how_to/group
  99492. * @param name Defines the name of the group
  99493. * @param scene Defines the scene the group belongs to
  99494. */
  99495. constructor(
  99496. /** The name of the animation group */
  99497. name: string, scene?: Nullable<Scene>);
  99498. /**
  99499. * Add an animation (with its target) in the group
  99500. * @param animation defines the animation we want to add
  99501. * @param target defines the target of the animation
  99502. * @returns the TargetedAnimation object
  99503. */
  99504. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99505. /**
  99506. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99507. * It can add constant keys at begin or end
  99508. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99509. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99510. * @returns the animation group
  99511. */
  99512. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99513. /**
  99514. * Start all animations on given targets
  99515. * @param loop defines if animations must loop
  99516. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99517. * @param from defines the from key (optional)
  99518. * @param to defines the to key (optional)
  99519. * @returns the current animation group
  99520. */
  99521. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99522. /**
  99523. * Pause all animations
  99524. * @returns the animation group
  99525. */
  99526. pause(): AnimationGroup;
  99527. /**
  99528. * Play all animations to initial state
  99529. * This function will start() the animations if they were not started or will restart() them if they were paused
  99530. * @param loop defines if animations must loop
  99531. * @returns the animation group
  99532. */
  99533. play(loop?: boolean): AnimationGroup;
  99534. /**
  99535. * Reset all animations to initial state
  99536. * @returns the animation group
  99537. */
  99538. reset(): AnimationGroup;
  99539. /**
  99540. * Restart animations from key 0
  99541. * @returns the animation group
  99542. */
  99543. restart(): AnimationGroup;
  99544. /**
  99545. * Stop all animations
  99546. * @returns the animation group
  99547. */
  99548. stop(): AnimationGroup;
  99549. /**
  99550. * Set animation weight for all animatables
  99551. * @param weight defines the weight to use
  99552. * @return the animationGroup
  99553. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99554. */
  99555. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99556. /**
  99557. * Synchronize and normalize all animatables with a source animatable
  99558. * @param root defines the root animatable to synchronize with
  99559. * @return the animationGroup
  99560. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99561. */
  99562. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99563. /**
  99564. * Goes to a specific frame in this animation group
  99565. * @param frame the frame number to go to
  99566. * @return the animationGroup
  99567. */
  99568. goToFrame(frame: number): AnimationGroup;
  99569. /**
  99570. * Dispose all associated resources
  99571. */
  99572. dispose(): void;
  99573. private _checkAnimationGroupEnded;
  99574. /**
  99575. * Clone the current animation group and returns a copy
  99576. * @param newName defines the name of the new group
  99577. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99578. * @returns the new aniamtion group
  99579. */
  99580. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99581. /**
  99582. * Serializes the animationGroup to an object
  99583. * @returns Serialized object
  99584. */
  99585. serialize(): any;
  99586. /**
  99587. * Returns a new AnimationGroup object parsed from the source provided.
  99588. * @param parsedAnimationGroup defines the source
  99589. * @param scene defines the scene that will receive the animationGroup
  99590. * @returns a new AnimationGroup
  99591. */
  99592. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99593. /**
  99594. * Returns the string "AnimationGroup"
  99595. * @returns "AnimationGroup"
  99596. */
  99597. getClassName(): string;
  99598. /**
  99599. * Creates a detailled string about the object
  99600. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99601. * @returns a string representing the object
  99602. */
  99603. toString(fullDetails?: boolean): string;
  99604. }
  99605. }
  99606. declare module BABYLON {
  99607. /**
  99608. * Define an interface for all classes that will hold resources
  99609. */
  99610. export interface IDisposable {
  99611. /**
  99612. * Releases all held resources
  99613. */
  99614. dispose(): void;
  99615. }
  99616. /** Interface defining initialization parameters for Scene class */
  99617. export interface SceneOptions {
  99618. /**
  99619. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99620. * It will improve performance when the number of geometries becomes important.
  99621. */
  99622. useGeometryUniqueIdsMap?: boolean;
  99623. /**
  99624. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99625. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99626. */
  99627. useMaterialMeshMap?: boolean;
  99628. /**
  99629. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99630. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99631. */
  99632. useClonedMeshhMap?: boolean;
  99633. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99634. virtual?: boolean;
  99635. }
  99636. /**
  99637. * Represents a scene to be rendered by the engine.
  99638. * @see http://doc.babylonjs.com/features/scene
  99639. */
  99640. export class Scene extends AbstractScene implements IAnimatable {
  99641. /** The fog is deactivated */
  99642. static readonly FOGMODE_NONE: number;
  99643. /** The fog density is following an exponential function */
  99644. static readonly FOGMODE_EXP: number;
  99645. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99646. static readonly FOGMODE_EXP2: number;
  99647. /** The fog density is following a linear function. */
  99648. static readonly FOGMODE_LINEAR: number;
  99649. /**
  99650. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99652. */
  99653. static MinDeltaTime: number;
  99654. /**
  99655. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99656. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99657. */
  99658. static MaxDeltaTime: number;
  99659. /**
  99660. * Factory used to create the default material.
  99661. * @param name The name of the material to create
  99662. * @param scene The scene to create the material for
  99663. * @returns The default material
  99664. */
  99665. static DefaultMaterialFactory(scene: Scene): Material;
  99666. /**
  99667. * Factory used to create the a collision coordinator.
  99668. * @returns The collision coordinator
  99669. */
  99670. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99671. /** @hidden */
  99672. _inputManager: InputManager;
  99673. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99674. cameraToUseForPointers: Nullable<Camera>;
  99675. /** @hidden */
  99676. readonly _isScene: boolean;
  99677. /**
  99678. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99679. */
  99680. autoClear: boolean;
  99681. /**
  99682. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99683. */
  99684. autoClearDepthAndStencil: boolean;
  99685. /**
  99686. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99687. */
  99688. clearColor: Color4;
  99689. /**
  99690. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99691. */
  99692. ambientColor: Color3;
  99693. /**
  99694. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99695. * It should only be one of the following (if not the default embedded one):
  99696. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99697. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99698. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99699. * The material properties need to be setup according to the type of texture in use.
  99700. */
  99701. environmentBRDFTexture: BaseTexture;
  99702. /** @hidden */
  99703. protected _environmentTexture: Nullable<BaseTexture>;
  99704. /**
  99705. * Texture used in all pbr material as the reflection texture.
  99706. * As in the majority of the scene they are the same (exception for multi room and so on),
  99707. * this is easier to reference from here than from all the materials.
  99708. */
  99709. /**
  99710. * Texture used in all pbr material as the reflection texture.
  99711. * As in the majority of the scene they are the same (exception for multi room and so on),
  99712. * this is easier to set here than in all the materials.
  99713. */
  99714. environmentTexture: Nullable<BaseTexture>;
  99715. /** @hidden */
  99716. protected _environmentIntensity: number;
  99717. /**
  99718. * Intensity of the environment in all pbr material.
  99719. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99720. * As in the majority of the scene they are the same (exception for multi room and so on),
  99721. * this is easier to reference from here than from all the materials.
  99722. */
  99723. /**
  99724. * Intensity of the environment in all pbr material.
  99725. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99726. * As in the majority of the scene they are the same (exception for multi room and so on),
  99727. * this is easier to set here than in all the materials.
  99728. */
  99729. environmentIntensity: number;
  99730. /** @hidden */
  99731. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99732. /**
  99733. * Default image processing configuration used either in the rendering
  99734. * Forward main pass or through the imageProcessingPostProcess if present.
  99735. * As in the majority of the scene they are the same (exception for multi camera),
  99736. * this is easier to reference from here than from all the materials and post process.
  99737. *
  99738. * No setter as we it is a shared configuration, you can set the values instead.
  99739. */
  99740. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99741. private _forceWireframe;
  99742. /**
  99743. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99744. */
  99745. forceWireframe: boolean;
  99746. private _forcePointsCloud;
  99747. /**
  99748. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99749. */
  99750. forcePointsCloud: boolean;
  99751. /**
  99752. * Gets or sets the active clipplane 1
  99753. */
  99754. clipPlane: Nullable<Plane>;
  99755. /**
  99756. * Gets or sets the active clipplane 2
  99757. */
  99758. clipPlane2: Nullable<Plane>;
  99759. /**
  99760. * Gets or sets the active clipplane 3
  99761. */
  99762. clipPlane3: Nullable<Plane>;
  99763. /**
  99764. * Gets or sets the active clipplane 4
  99765. */
  99766. clipPlane4: Nullable<Plane>;
  99767. /**
  99768. * Gets or sets a boolean indicating if animations are enabled
  99769. */
  99770. animationsEnabled: boolean;
  99771. private _animationPropertiesOverride;
  99772. /**
  99773. * Gets or sets the animation properties override
  99774. */
  99775. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99776. /**
  99777. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99778. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99779. */
  99780. useConstantAnimationDeltaTime: boolean;
  99781. /**
  99782. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99783. * Please note that it requires to run a ray cast through the scene on every frame
  99784. */
  99785. constantlyUpdateMeshUnderPointer: boolean;
  99786. /**
  99787. * Defines the HTML cursor to use when hovering over interactive elements
  99788. */
  99789. hoverCursor: string;
  99790. /**
  99791. * Defines the HTML default cursor to use (empty by default)
  99792. */
  99793. defaultCursor: string;
  99794. /**
  99795. * This is used to call preventDefault() on pointer down
  99796. * in order to block unwanted artifacts like system double clicks
  99797. */
  99798. preventDefaultOnPointerDown: boolean;
  99799. /**
  99800. * This is used to call preventDefault() on pointer up
  99801. * in order to block unwanted artifacts like system double clicks
  99802. */
  99803. preventDefaultOnPointerUp: boolean;
  99804. /**
  99805. * Gets or sets user defined metadata
  99806. */
  99807. metadata: any;
  99808. /**
  99809. * For internal use only. Please do not use.
  99810. */
  99811. reservedDataStore: any;
  99812. /**
  99813. * Gets the name of the plugin used to load this scene (null by default)
  99814. */
  99815. loadingPluginName: string;
  99816. /**
  99817. * Use this array to add regular expressions used to disable offline support for specific urls
  99818. */
  99819. disableOfflineSupportExceptionRules: RegExp[];
  99820. /**
  99821. * An event triggered when the scene is disposed.
  99822. */
  99823. onDisposeObservable: Observable<Scene>;
  99824. private _onDisposeObserver;
  99825. /** Sets a function to be executed when this scene is disposed. */
  99826. onDispose: () => void;
  99827. /**
  99828. * An event triggered before rendering the scene (right after animations and physics)
  99829. */
  99830. onBeforeRenderObservable: Observable<Scene>;
  99831. private _onBeforeRenderObserver;
  99832. /** Sets a function to be executed before rendering this scene */
  99833. beforeRender: Nullable<() => void>;
  99834. /**
  99835. * An event triggered after rendering the scene
  99836. */
  99837. onAfterRenderObservable: Observable<Scene>;
  99838. /**
  99839. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99840. */
  99841. onAfterRenderCameraObservable: Observable<Camera>;
  99842. private _onAfterRenderObserver;
  99843. /** Sets a function to be executed after rendering this scene */
  99844. afterRender: Nullable<() => void>;
  99845. /**
  99846. * An event triggered before animating the scene
  99847. */
  99848. onBeforeAnimationsObservable: Observable<Scene>;
  99849. /**
  99850. * An event triggered after animations processing
  99851. */
  99852. onAfterAnimationsObservable: Observable<Scene>;
  99853. /**
  99854. * An event triggered before draw calls are ready to be sent
  99855. */
  99856. onBeforeDrawPhaseObservable: Observable<Scene>;
  99857. /**
  99858. * An event triggered after draw calls have been sent
  99859. */
  99860. onAfterDrawPhaseObservable: Observable<Scene>;
  99861. /**
  99862. * An event triggered when the scene is ready
  99863. */
  99864. onReadyObservable: Observable<Scene>;
  99865. /**
  99866. * An event triggered before rendering a camera
  99867. */
  99868. onBeforeCameraRenderObservable: Observable<Camera>;
  99869. private _onBeforeCameraRenderObserver;
  99870. /** Sets a function to be executed before rendering a camera*/
  99871. beforeCameraRender: () => void;
  99872. /**
  99873. * An event triggered after rendering a camera
  99874. */
  99875. onAfterCameraRenderObservable: Observable<Camera>;
  99876. private _onAfterCameraRenderObserver;
  99877. /** Sets a function to be executed after rendering a camera*/
  99878. afterCameraRender: () => void;
  99879. /**
  99880. * An event triggered when active meshes evaluation is about to start
  99881. */
  99882. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  99883. /**
  99884. * An event triggered when active meshes evaluation is done
  99885. */
  99886. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  99887. /**
  99888. * An event triggered when particles rendering is about to start
  99889. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99890. */
  99891. onBeforeParticlesRenderingObservable: Observable<Scene>;
  99892. /**
  99893. * An event triggered when particles rendering is done
  99894. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99895. */
  99896. onAfterParticlesRenderingObservable: Observable<Scene>;
  99897. /**
  99898. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99899. */
  99900. onDataLoadedObservable: Observable<Scene>;
  99901. /**
  99902. * An event triggered when a camera is created
  99903. */
  99904. onNewCameraAddedObservable: Observable<Camera>;
  99905. /**
  99906. * An event triggered when a camera is removed
  99907. */
  99908. onCameraRemovedObservable: Observable<Camera>;
  99909. /**
  99910. * An event triggered when a light is created
  99911. */
  99912. onNewLightAddedObservable: Observable<Light>;
  99913. /**
  99914. * An event triggered when a light is removed
  99915. */
  99916. onLightRemovedObservable: Observable<Light>;
  99917. /**
  99918. * An event triggered when a geometry is created
  99919. */
  99920. onNewGeometryAddedObservable: Observable<Geometry>;
  99921. /**
  99922. * An event triggered when a geometry is removed
  99923. */
  99924. onGeometryRemovedObservable: Observable<Geometry>;
  99925. /**
  99926. * An event triggered when a transform node is created
  99927. */
  99928. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  99929. /**
  99930. * An event triggered when a transform node is removed
  99931. */
  99932. onTransformNodeRemovedObservable: Observable<TransformNode>;
  99933. /**
  99934. * An event triggered when a mesh is created
  99935. */
  99936. onNewMeshAddedObservable: Observable<AbstractMesh>;
  99937. /**
  99938. * An event triggered when a mesh is removed
  99939. */
  99940. onMeshRemovedObservable: Observable<AbstractMesh>;
  99941. /**
  99942. * An event triggered when a skeleton is created
  99943. */
  99944. onNewSkeletonAddedObservable: Observable<Skeleton>;
  99945. /**
  99946. * An event triggered when a skeleton is removed
  99947. */
  99948. onSkeletonRemovedObservable: Observable<Skeleton>;
  99949. /**
  99950. * An event triggered when a material is created
  99951. */
  99952. onNewMaterialAddedObservable: Observable<Material>;
  99953. /**
  99954. * An event triggered when a material is removed
  99955. */
  99956. onMaterialRemovedObservable: Observable<Material>;
  99957. /**
  99958. * An event triggered when a texture is created
  99959. */
  99960. onNewTextureAddedObservable: Observable<BaseTexture>;
  99961. /**
  99962. * An event triggered when a texture is removed
  99963. */
  99964. onTextureRemovedObservable: Observable<BaseTexture>;
  99965. /**
  99966. * An event triggered when render targets are about to be rendered
  99967. * Can happen multiple times per frame.
  99968. */
  99969. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  99970. /**
  99971. * An event triggered when render targets were rendered.
  99972. * Can happen multiple times per frame.
  99973. */
  99974. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  99975. /**
  99976. * An event triggered before calculating deterministic simulation step
  99977. */
  99978. onBeforeStepObservable: Observable<Scene>;
  99979. /**
  99980. * An event triggered after calculating deterministic simulation step
  99981. */
  99982. onAfterStepObservable: Observable<Scene>;
  99983. /**
  99984. * An event triggered when the activeCamera property is updated
  99985. */
  99986. onActiveCameraChanged: Observable<Scene>;
  99987. /**
  99988. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  99989. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99990. * 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)
  99991. */
  99992. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99993. /**
  99994. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  99995. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99996. * 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)
  99997. */
  99998. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99999. /**
  100000. * This Observable will when a mesh has been imported into the scene.
  100001. */
  100002. onMeshImportedObservable: Observable<AbstractMesh>;
  100003. /**
  100004. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100005. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100006. */
  100007. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100008. /** @hidden */
  100009. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100010. /**
  100011. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100012. */
  100013. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100014. /**
  100015. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100016. */
  100017. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100018. /**
  100019. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100020. */
  100021. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100022. /** Callback called when a pointer move is detected */
  100023. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100024. /** Callback called when a pointer down is detected */
  100025. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100026. /** Callback called when a pointer up is detected */
  100027. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100028. /** Callback called when a pointer pick is detected */
  100029. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100030. /**
  100031. * 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).
  100032. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100033. */
  100034. onPrePointerObservable: Observable<PointerInfoPre>;
  100035. /**
  100036. * Observable event triggered each time an input event is received from the rendering canvas
  100037. */
  100038. onPointerObservable: Observable<PointerInfo>;
  100039. /**
  100040. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100041. */
  100042. readonly unTranslatedPointer: Vector2;
  100043. /**
  100044. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100045. */
  100046. static DragMovementThreshold: number;
  100047. /**
  100048. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100049. */
  100050. static LongPressDelay: number;
  100051. /**
  100052. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100053. */
  100054. static DoubleClickDelay: number;
  100055. /** If you need to check double click without raising a single click at first click, enable this flag */
  100056. static ExclusiveDoubleClickMode: boolean;
  100057. /** @hidden */
  100058. _mirroredCameraPosition: Nullable<Vector3>;
  100059. /**
  100060. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100061. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100062. */
  100063. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100064. /**
  100065. * Observable event triggered each time an keyboard event is received from the hosting window
  100066. */
  100067. onKeyboardObservable: Observable<KeyboardInfo>;
  100068. private _useRightHandedSystem;
  100069. /**
  100070. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100071. */
  100072. useRightHandedSystem: boolean;
  100073. private _timeAccumulator;
  100074. private _currentStepId;
  100075. private _currentInternalStep;
  100076. /**
  100077. * Sets the step Id used by deterministic lock step
  100078. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100079. * @param newStepId defines the step Id
  100080. */
  100081. setStepId(newStepId: number): void;
  100082. /**
  100083. * Gets the step Id used by deterministic lock step
  100084. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100085. * @returns the step Id
  100086. */
  100087. getStepId(): number;
  100088. /**
  100089. * Gets the internal step used by deterministic lock step
  100090. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100091. * @returns the internal step
  100092. */
  100093. getInternalStep(): number;
  100094. private _fogEnabled;
  100095. /**
  100096. * Gets or sets a boolean indicating if fog is enabled on this scene
  100097. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100098. * (Default is true)
  100099. */
  100100. fogEnabled: boolean;
  100101. private _fogMode;
  100102. /**
  100103. * Gets or sets the fog mode to use
  100104. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100105. * | mode | value |
  100106. * | --- | --- |
  100107. * | FOGMODE_NONE | 0 |
  100108. * | FOGMODE_EXP | 1 |
  100109. * | FOGMODE_EXP2 | 2 |
  100110. * | FOGMODE_LINEAR | 3 |
  100111. */
  100112. fogMode: number;
  100113. /**
  100114. * Gets or sets the fog color to use
  100115. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100116. * (Default is Color3(0.2, 0.2, 0.3))
  100117. */
  100118. fogColor: Color3;
  100119. /**
  100120. * Gets or sets the fog density to use
  100121. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100122. * (Default is 0.1)
  100123. */
  100124. fogDensity: number;
  100125. /**
  100126. * Gets or sets the fog start distance to use
  100127. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100128. * (Default is 0)
  100129. */
  100130. fogStart: number;
  100131. /**
  100132. * Gets or sets the fog end distance to use
  100133. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100134. * (Default is 1000)
  100135. */
  100136. fogEnd: number;
  100137. private _shadowsEnabled;
  100138. /**
  100139. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100140. */
  100141. shadowsEnabled: boolean;
  100142. private _lightsEnabled;
  100143. /**
  100144. * Gets or sets a boolean indicating if lights are enabled on this scene
  100145. */
  100146. lightsEnabled: boolean;
  100147. /** All of the active cameras added to this scene. */
  100148. activeCameras: Camera[];
  100149. /** @hidden */
  100150. _activeCamera: Nullable<Camera>;
  100151. /** Gets or sets the current active camera */
  100152. activeCamera: Nullable<Camera>;
  100153. private _defaultMaterial;
  100154. /** The default material used on meshes when no material is affected */
  100155. /** The default material used on meshes when no material is affected */
  100156. defaultMaterial: Material;
  100157. private _texturesEnabled;
  100158. /**
  100159. * Gets or sets a boolean indicating if textures are enabled on this scene
  100160. */
  100161. texturesEnabled: boolean;
  100162. /**
  100163. * Gets or sets a boolean indicating if particles are enabled on this scene
  100164. */
  100165. particlesEnabled: boolean;
  100166. /**
  100167. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100168. */
  100169. spritesEnabled: boolean;
  100170. private _skeletonsEnabled;
  100171. /**
  100172. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100173. */
  100174. skeletonsEnabled: boolean;
  100175. /**
  100176. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100177. */
  100178. lensFlaresEnabled: boolean;
  100179. /**
  100180. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100181. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100182. */
  100183. collisionsEnabled: boolean;
  100184. private _collisionCoordinator;
  100185. /** @hidden */
  100186. readonly collisionCoordinator: ICollisionCoordinator;
  100187. /**
  100188. * Defines the gravity applied to this scene (used only for collisions)
  100189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100190. */
  100191. gravity: Vector3;
  100192. /**
  100193. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100194. */
  100195. postProcessesEnabled: boolean;
  100196. /**
  100197. * The list of postprocesses added to the scene
  100198. */
  100199. postProcesses: PostProcess[];
  100200. /**
  100201. * Gets the current postprocess manager
  100202. */
  100203. postProcessManager: PostProcessManager;
  100204. /**
  100205. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100206. */
  100207. renderTargetsEnabled: boolean;
  100208. /**
  100209. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100210. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100211. */
  100212. dumpNextRenderTargets: boolean;
  100213. /**
  100214. * The list of user defined render targets added to the scene
  100215. */
  100216. customRenderTargets: RenderTargetTexture[];
  100217. /**
  100218. * Defines if texture loading must be delayed
  100219. * If true, textures will only be loaded when they need to be rendered
  100220. */
  100221. useDelayedTextureLoading: boolean;
  100222. /**
  100223. * Gets the list of meshes imported to the scene through SceneLoader
  100224. */
  100225. importedMeshesFiles: String[];
  100226. /**
  100227. * Gets or sets a boolean indicating if probes are enabled on this scene
  100228. */
  100229. probesEnabled: boolean;
  100230. /**
  100231. * Gets or sets the current offline provider to use to store scene data
  100232. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100233. */
  100234. offlineProvider: IOfflineProvider;
  100235. /**
  100236. * Gets or sets the action manager associated with the scene
  100237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100238. */
  100239. actionManager: AbstractActionManager;
  100240. private _meshesForIntersections;
  100241. /**
  100242. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100243. */
  100244. proceduralTexturesEnabled: boolean;
  100245. private _engine;
  100246. private _totalVertices;
  100247. /** @hidden */
  100248. _activeIndices: PerfCounter;
  100249. /** @hidden */
  100250. _activeParticles: PerfCounter;
  100251. /** @hidden */
  100252. _activeBones: PerfCounter;
  100253. private _animationRatio;
  100254. /** @hidden */
  100255. _animationTimeLast: number;
  100256. /** @hidden */
  100257. _animationTime: number;
  100258. /**
  100259. * Gets or sets a general scale for animation speed
  100260. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100261. */
  100262. animationTimeScale: number;
  100263. /** @hidden */
  100264. _cachedMaterial: Nullable<Material>;
  100265. /** @hidden */
  100266. _cachedEffect: Nullable<Effect>;
  100267. /** @hidden */
  100268. _cachedVisibility: Nullable<number>;
  100269. private _renderId;
  100270. private _frameId;
  100271. private _executeWhenReadyTimeoutId;
  100272. private _intermediateRendering;
  100273. private _viewUpdateFlag;
  100274. private _projectionUpdateFlag;
  100275. /** @hidden */
  100276. _toBeDisposed: Nullable<IDisposable>[];
  100277. private _activeRequests;
  100278. /** @hidden */
  100279. _pendingData: any[];
  100280. private _isDisposed;
  100281. /**
  100282. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100283. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100284. */
  100285. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100286. private _activeMeshes;
  100287. private _processedMaterials;
  100288. private _renderTargets;
  100289. /** @hidden */
  100290. _activeParticleSystems: SmartArray<IParticleSystem>;
  100291. private _activeSkeletons;
  100292. private _softwareSkinnedMeshes;
  100293. private _renderingManager;
  100294. /** @hidden */
  100295. _activeAnimatables: Animatable[];
  100296. private _transformMatrix;
  100297. private _sceneUbo;
  100298. /** @hidden */
  100299. _viewMatrix: Matrix;
  100300. private _projectionMatrix;
  100301. /** @hidden */
  100302. _forcedViewPosition: Nullable<Vector3>;
  100303. /** @hidden */
  100304. _frustumPlanes: Plane[];
  100305. /**
  100306. * Gets the list of frustum planes (built from the active camera)
  100307. */
  100308. readonly frustumPlanes: Plane[];
  100309. /**
  100310. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100311. * This is useful if there are more lights that the maximum simulteanous authorized
  100312. */
  100313. requireLightSorting: boolean;
  100314. /** @hidden */
  100315. readonly useMaterialMeshMap: boolean;
  100316. /** @hidden */
  100317. readonly useClonedMeshhMap: boolean;
  100318. private _externalData;
  100319. private _uid;
  100320. /**
  100321. * @hidden
  100322. * Backing store of defined scene components.
  100323. */
  100324. _components: ISceneComponent[];
  100325. /**
  100326. * @hidden
  100327. * Backing store of defined scene components.
  100328. */
  100329. _serializableComponents: ISceneSerializableComponent[];
  100330. /**
  100331. * List of components to register on the next registration step.
  100332. */
  100333. private _transientComponents;
  100334. /**
  100335. * Registers the transient components if needed.
  100336. */
  100337. private _registerTransientComponents;
  100338. /**
  100339. * @hidden
  100340. * Add a component to the scene.
  100341. * Note that the ccomponent could be registered on th next frame if this is called after
  100342. * the register component stage.
  100343. * @param component Defines the component to add to the scene
  100344. */
  100345. _addComponent(component: ISceneComponent): void;
  100346. /**
  100347. * @hidden
  100348. * Gets a component from the scene.
  100349. * @param name defines the name of the component to retrieve
  100350. * @returns the component or null if not present
  100351. */
  100352. _getComponent(name: string): Nullable<ISceneComponent>;
  100353. /**
  100354. * @hidden
  100355. * Defines the actions happening before camera updates.
  100356. */
  100357. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100358. /**
  100359. * @hidden
  100360. * Defines the actions happening before clear the canvas.
  100361. */
  100362. _beforeClearStage: Stage<SimpleStageAction>;
  100363. /**
  100364. * @hidden
  100365. * Defines the actions when collecting render targets for the frame.
  100366. */
  100367. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100368. /**
  100369. * @hidden
  100370. * Defines the actions happening for one camera in the frame.
  100371. */
  100372. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100373. /**
  100374. * @hidden
  100375. * Defines the actions happening during the per mesh ready checks.
  100376. */
  100377. _isReadyForMeshStage: Stage<MeshStageAction>;
  100378. /**
  100379. * @hidden
  100380. * Defines the actions happening before evaluate active mesh checks.
  100381. */
  100382. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100383. /**
  100384. * @hidden
  100385. * Defines the actions happening during the evaluate sub mesh checks.
  100386. */
  100387. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100388. /**
  100389. * @hidden
  100390. * Defines the actions happening during the active mesh stage.
  100391. */
  100392. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100393. /**
  100394. * @hidden
  100395. * Defines the actions happening during the per camera render target step.
  100396. */
  100397. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100398. /**
  100399. * @hidden
  100400. * Defines the actions happening just before the active camera is drawing.
  100401. */
  100402. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100403. /**
  100404. * @hidden
  100405. * Defines the actions happening just before a render target is drawing.
  100406. */
  100407. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100408. /**
  100409. * @hidden
  100410. * Defines the actions happening just before a rendering group is drawing.
  100411. */
  100412. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100413. /**
  100414. * @hidden
  100415. * Defines the actions happening just before a mesh is drawing.
  100416. */
  100417. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100418. /**
  100419. * @hidden
  100420. * Defines the actions happening just after a mesh has been drawn.
  100421. */
  100422. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100423. /**
  100424. * @hidden
  100425. * Defines the actions happening just after a rendering group has been drawn.
  100426. */
  100427. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100428. /**
  100429. * @hidden
  100430. * Defines the actions happening just after the active camera has been drawn.
  100431. */
  100432. _afterCameraDrawStage: Stage<CameraStageAction>;
  100433. /**
  100434. * @hidden
  100435. * Defines the actions happening just after a render target has been drawn.
  100436. */
  100437. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100438. /**
  100439. * @hidden
  100440. * Defines the actions happening just after rendering all cameras and computing intersections.
  100441. */
  100442. _afterRenderStage: Stage<SimpleStageAction>;
  100443. /**
  100444. * @hidden
  100445. * Defines the actions happening when a pointer move event happens.
  100446. */
  100447. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100448. /**
  100449. * @hidden
  100450. * Defines the actions happening when a pointer down event happens.
  100451. */
  100452. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100453. /**
  100454. * @hidden
  100455. * Defines the actions happening when a pointer up event happens.
  100456. */
  100457. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100458. /**
  100459. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100460. */
  100461. private geometriesByUniqueId;
  100462. /**
  100463. * Creates a new Scene
  100464. * @param engine defines the engine to use to render this scene
  100465. * @param options defines the scene options
  100466. */
  100467. constructor(engine: Engine, options?: SceneOptions);
  100468. /**
  100469. * Gets a string idenfifying the name of the class
  100470. * @returns "Scene" string
  100471. */
  100472. getClassName(): string;
  100473. private _defaultMeshCandidates;
  100474. /**
  100475. * @hidden
  100476. */
  100477. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100478. private _defaultSubMeshCandidates;
  100479. /**
  100480. * @hidden
  100481. */
  100482. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100483. /**
  100484. * Sets the default candidate providers for the scene.
  100485. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100486. * and getCollidingSubMeshCandidates to their default function
  100487. */
  100488. setDefaultCandidateProviders(): void;
  100489. /**
  100490. * Gets the mesh that is currently under the pointer
  100491. */
  100492. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100493. /**
  100494. * Gets or sets the current on-screen X position of the pointer
  100495. */
  100496. pointerX: number;
  100497. /**
  100498. * Gets or sets the current on-screen Y position of the pointer
  100499. */
  100500. pointerY: number;
  100501. /**
  100502. * Gets the cached material (ie. the latest rendered one)
  100503. * @returns the cached material
  100504. */
  100505. getCachedMaterial(): Nullable<Material>;
  100506. /**
  100507. * Gets the cached effect (ie. the latest rendered one)
  100508. * @returns the cached effect
  100509. */
  100510. getCachedEffect(): Nullable<Effect>;
  100511. /**
  100512. * Gets the cached visibility state (ie. the latest rendered one)
  100513. * @returns the cached visibility state
  100514. */
  100515. getCachedVisibility(): Nullable<number>;
  100516. /**
  100517. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100518. * @param material defines the current material
  100519. * @param effect defines the current effect
  100520. * @param visibility defines the current visibility state
  100521. * @returns true if one parameter is not cached
  100522. */
  100523. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100524. /**
  100525. * Gets the engine associated with the scene
  100526. * @returns an Engine
  100527. */
  100528. getEngine(): Engine;
  100529. /**
  100530. * Gets the total number of vertices rendered per frame
  100531. * @returns the total number of vertices rendered per frame
  100532. */
  100533. getTotalVertices(): number;
  100534. /**
  100535. * Gets the performance counter for total vertices
  100536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100537. */
  100538. readonly totalVerticesPerfCounter: PerfCounter;
  100539. /**
  100540. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100541. * @returns the total number of active indices rendered per frame
  100542. */
  100543. getActiveIndices(): number;
  100544. /**
  100545. * Gets the performance counter for active indices
  100546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100547. */
  100548. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100549. /**
  100550. * Gets the total number of active particles rendered per frame
  100551. * @returns the total number of active particles rendered per frame
  100552. */
  100553. getActiveParticles(): number;
  100554. /**
  100555. * Gets the performance counter for active particles
  100556. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100557. */
  100558. readonly activeParticlesPerfCounter: PerfCounter;
  100559. /**
  100560. * Gets the total number of active bones rendered per frame
  100561. * @returns the total number of active bones rendered per frame
  100562. */
  100563. getActiveBones(): number;
  100564. /**
  100565. * Gets the performance counter for active bones
  100566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100567. */
  100568. readonly activeBonesPerfCounter: PerfCounter;
  100569. /**
  100570. * Gets the array of active meshes
  100571. * @returns an array of AbstractMesh
  100572. */
  100573. getActiveMeshes(): SmartArray<AbstractMesh>;
  100574. /**
  100575. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100576. * @returns a number
  100577. */
  100578. getAnimationRatio(): number;
  100579. /**
  100580. * Gets an unique Id for the current render phase
  100581. * @returns a number
  100582. */
  100583. getRenderId(): number;
  100584. /**
  100585. * Gets an unique Id for the current frame
  100586. * @returns a number
  100587. */
  100588. getFrameId(): number;
  100589. /** Call this function if you want to manually increment the render Id*/
  100590. incrementRenderId(): void;
  100591. private _createUbo;
  100592. /**
  100593. * Use this method to simulate a pointer move on a mesh
  100594. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100595. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100596. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100597. * @returns the current scene
  100598. */
  100599. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100600. /**
  100601. * Use this method to simulate a pointer down on a mesh
  100602. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100603. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100604. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100605. * @returns the current scene
  100606. */
  100607. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100608. /**
  100609. * Use this method to simulate a pointer up on a mesh
  100610. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100611. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100612. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100613. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100614. * @returns the current scene
  100615. */
  100616. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100617. /**
  100618. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100619. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100620. * @returns true if the pointer was captured
  100621. */
  100622. isPointerCaptured(pointerId?: number): boolean;
  100623. /**
  100624. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100625. * @param attachUp defines if you want to attach events to pointerup
  100626. * @param attachDown defines if you want to attach events to pointerdown
  100627. * @param attachMove defines if you want to attach events to pointermove
  100628. */
  100629. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100630. /** Detaches all event handlers*/
  100631. detachControl(): void;
  100632. /**
  100633. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100634. * Delay loaded resources are not taking in account
  100635. * @return true if all required resources are ready
  100636. */
  100637. isReady(): boolean;
  100638. /** Resets all cached information relative to material (including effect and visibility) */
  100639. resetCachedMaterial(): void;
  100640. /**
  100641. * Registers a function to be called before every frame render
  100642. * @param func defines the function to register
  100643. */
  100644. registerBeforeRender(func: () => void): void;
  100645. /**
  100646. * Unregisters a function called before every frame render
  100647. * @param func defines the function to unregister
  100648. */
  100649. unregisterBeforeRender(func: () => void): void;
  100650. /**
  100651. * Registers a function to be called after every frame render
  100652. * @param func defines the function to register
  100653. */
  100654. registerAfterRender(func: () => void): void;
  100655. /**
  100656. * Unregisters a function called after every frame render
  100657. * @param func defines the function to unregister
  100658. */
  100659. unregisterAfterRender(func: () => void): void;
  100660. private _executeOnceBeforeRender;
  100661. /**
  100662. * The provided function will run before render once and will be disposed afterwards.
  100663. * A timeout delay can be provided so that the function will be executed in N ms.
  100664. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100665. * @param func The function to be executed.
  100666. * @param timeout optional delay in ms
  100667. */
  100668. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100669. /** @hidden */
  100670. _addPendingData(data: any): void;
  100671. /** @hidden */
  100672. _removePendingData(data: any): void;
  100673. /**
  100674. * Returns the number of items waiting to be loaded
  100675. * @returns the number of items waiting to be loaded
  100676. */
  100677. getWaitingItemsCount(): number;
  100678. /**
  100679. * Returns a boolean indicating if the scene is still loading data
  100680. */
  100681. readonly isLoading: boolean;
  100682. /**
  100683. * Registers a function to be executed when the scene is ready
  100684. * @param {Function} func - the function to be executed
  100685. */
  100686. executeWhenReady(func: () => void): void;
  100687. /**
  100688. * Returns a promise that resolves when the scene is ready
  100689. * @returns A promise that resolves when the scene is ready
  100690. */
  100691. whenReadyAsync(): Promise<void>;
  100692. /** @hidden */
  100693. _checkIsReady(): void;
  100694. /**
  100695. * Gets all animatable attached to the scene
  100696. */
  100697. readonly animatables: Animatable[];
  100698. /**
  100699. * Resets the last animation time frame.
  100700. * Useful to override when animations start running when loading a scene for the first time.
  100701. */
  100702. resetLastAnimationTimeFrame(): void;
  100703. /**
  100704. * Gets the current view matrix
  100705. * @returns a Matrix
  100706. */
  100707. getViewMatrix(): Matrix;
  100708. /**
  100709. * Gets the current projection matrix
  100710. * @returns a Matrix
  100711. */
  100712. getProjectionMatrix(): Matrix;
  100713. /**
  100714. * Gets the current transform matrix
  100715. * @returns a Matrix made of View * Projection
  100716. */
  100717. getTransformMatrix(): Matrix;
  100718. /**
  100719. * Sets the current transform matrix
  100720. * @param viewL defines the View matrix to use
  100721. * @param projectionL defines the Projection matrix to use
  100722. * @param viewR defines the right View matrix to use (if provided)
  100723. * @param projectionR defines the right Projection matrix to use (if provided)
  100724. */
  100725. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100726. /**
  100727. * Gets the uniform buffer used to store scene data
  100728. * @returns a UniformBuffer
  100729. */
  100730. getSceneUniformBuffer(): UniformBuffer;
  100731. /**
  100732. * Gets an unique (relatively to the current scene) Id
  100733. * @returns an unique number for the scene
  100734. */
  100735. getUniqueId(): number;
  100736. /**
  100737. * Add a mesh to the list of scene's meshes
  100738. * @param newMesh defines the mesh to add
  100739. * @param recursive if all child meshes should also be added to the scene
  100740. */
  100741. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100742. /**
  100743. * Remove a mesh for the list of scene's meshes
  100744. * @param toRemove defines the mesh to remove
  100745. * @param recursive if all child meshes should also be removed from the scene
  100746. * @returns the index where the mesh was in the mesh list
  100747. */
  100748. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100749. /**
  100750. * Add a transform node to the list of scene's transform nodes
  100751. * @param newTransformNode defines the transform node to add
  100752. */
  100753. addTransformNode(newTransformNode: TransformNode): void;
  100754. /**
  100755. * Remove a transform node for the list of scene's transform nodes
  100756. * @param toRemove defines the transform node to remove
  100757. * @returns the index where the transform node was in the transform node list
  100758. */
  100759. removeTransformNode(toRemove: TransformNode): number;
  100760. /**
  100761. * Remove a skeleton for the list of scene's skeletons
  100762. * @param toRemove defines the skeleton to remove
  100763. * @returns the index where the skeleton was in the skeleton list
  100764. */
  100765. removeSkeleton(toRemove: Skeleton): number;
  100766. /**
  100767. * Remove a morph target for the list of scene's morph targets
  100768. * @param toRemove defines the morph target to remove
  100769. * @returns the index where the morph target was in the morph target list
  100770. */
  100771. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100772. /**
  100773. * Remove a light for the list of scene's lights
  100774. * @param toRemove defines the light to remove
  100775. * @returns the index where the light was in the light list
  100776. */
  100777. removeLight(toRemove: Light): number;
  100778. /**
  100779. * Remove a camera for the list of scene's cameras
  100780. * @param toRemove defines the camera to remove
  100781. * @returns the index where the camera was in the camera list
  100782. */
  100783. removeCamera(toRemove: Camera): number;
  100784. /**
  100785. * Remove a particle system for the list of scene's particle systems
  100786. * @param toRemove defines the particle system to remove
  100787. * @returns the index where the particle system was in the particle system list
  100788. */
  100789. removeParticleSystem(toRemove: IParticleSystem): number;
  100790. /**
  100791. * Remove a animation for the list of scene's animations
  100792. * @param toRemove defines the animation to remove
  100793. * @returns the index where the animation was in the animation list
  100794. */
  100795. removeAnimation(toRemove: Animation): number;
  100796. /**
  100797. * Will stop the animation of the given target
  100798. * @param target - the target
  100799. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100800. * @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)
  100801. */
  100802. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100803. /**
  100804. * Removes the given animation group from this scene.
  100805. * @param toRemove The animation group to remove
  100806. * @returns The index of the removed animation group
  100807. */
  100808. removeAnimationGroup(toRemove: AnimationGroup): number;
  100809. /**
  100810. * Removes the given multi-material from this scene.
  100811. * @param toRemove The multi-material to remove
  100812. * @returns The index of the removed multi-material
  100813. */
  100814. removeMultiMaterial(toRemove: MultiMaterial): number;
  100815. /**
  100816. * Removes the given material from this scene.
  100817. * @param toRemove The material to remove
  100818. * @returns The index of the removed material
  100819. */
  100820. removeMaterial(toRemove: Material): number;
  100821. /**
  100822. * Removes the given action manager from this scene.
  100823. * @param toRemove The action manager to remove
  100824. * @returns The index of the removed action manager
  100825. */
  100826. removeActionManager(toRemove: AbstractActionManager): number;
  100827. /**
  100828. * Removes the given texture from this scene.
  100829. * @param toRemove The texture to remove
  100830. * @returns The index of the removed texture
  100831. */
  100832. removeTexture(toRemove: BaseTexture): number;
  100833. /**
  100834. * Adds the given light to this scene
  100835. * @param newLight The light to add
  100836. */
  100837. addLight(newLight: Light): void;
  100838. /**
  100839. * Sorts the list list based on light priorities
  100840. */
  100841. sortLightsByPriority(): void;
  100842. /**
  100843. * Adds the given camera to this scene
  100844. * @param newCamera The camera to add
  100845. */
  100846. addCamera(newCamera: Camera): void;
  100847. /**
  100848. * Adds the given skeleton to this scene
  100849. * @param newSkeleton The skeleton to add
  100850. */
  100851. addSkeleton(newSkeleton: Skeleton): void;
  100852. /**
  100853. * Adds the given particle system to this scene
  100854. * @param newParticleSystem The particle system to add
  100855. */
  100856. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100857. /**
  100858. * Adds the given animation to this scene
  100859. * @param newAnimation The animation to add
  100860. */
  100861. addAnimation(newAnimation: Animation): void;
  100862. /**
  100863. * Adds the given animation group to this scene.
  100864. * @param newAnimationGroup The animation group to add
  100865. */
  100866. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100867. /**
  100868. * Adds the given multi-material to this scene
  100869. * @param newMultiMaterial The multi-material to add
  100870. */
  100871. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100872. /**
  100873. * Adds the given material to this scene
  100874. * @param newMaterial The material to add
  100875. */
  100876. addMaterial(newMaterial: Material): void;
  100877. /**
  100878. * Adds the given morph target to this scene
  100879. * @param newMorphTargetManager The morph target to add
  100880. */
  100881. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  100882. /**
  100883. * Adds the given geometry to this scene
  100884. * @param newGeometry The geometry to add
  100885. */
  100886. addGeometry(newGeometry: Geometry): void;
  100887. /**
  100888. * Adds the given action manager to this scene
  100889. * @param newActionManager The action manager to add
  100890. */
  100891. addActionManager(newActionManager: AbstractActionManager): void;
  100892. /**
  100893. * Adds the given texture to this scene.
  100894. * @param newTexture The texture to add
  100895. */
  100896. addTexture(newTexture: BaseTexture): void;
  100897. /**
  100898. * Switch active camera
  100899. * @param newCamera defines the new active camera
  100900. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  100901. */
  100902. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  100903. /**
  100904. * sets the active camera of the scene using its ID
  100905. * @param id defines the camera's ID
  100906. * @return the new active camera or null if none found.
  100907. */
  100908. setActiveCameraByID(id: string): Nullable<Camera>;
  100909. /**
  100910. * sets the active camera of the scene using its name
  100911. * @param name defines the camera's name
  100912. * @returns the new active camera or null if none found.
  100913. */
  100914. setActiveCameraByName(name: string): Nullable<Camera>;
  100915. /**
  100916. * get an animation group using its name
  100917. * @param name defines the material's name
  100918. * @return the animation group or null if none found.
  100919. */
  100920. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100921. /**
  100922. * Get a material using its unique id
  100923. * @param uniqueId defines the material's unique id
  100924. * @return the material or null if none found.
  100925. */
  100926. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100927. /**
  100928. * get a material using its id
  100929. * @param id defines the material's ID
  100930. * @return the material or null if none found.
  100931. */
  100932. getMaterialByID(id: string): Nullable<Material>;
  100933. /**
  100934. * Gets a the last added material using a given id
  100935. * @param id defines the material's ID
  100936. * @return the last material with the given id or null if none found.
  100937. */
  100938. getLastMaterialByID(id: string): Nullable<Material>;
  100939. /**
  100940. * Gets a material using its name
  100941. * @param name defines the material's name
  100942. * @return the material or null if none found.
  100943. */
  100944. getMaterialByName(name: string): Nullable<Material>;
  100945. /**
  100946. * Get a texture using its unique id
  100947. * @param uniqueId defines the texture's unique id
  100948. * @return the texture or null if none found.
  100949. */
  100950. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  100951. /**
  100952. * Gets a camera using its id
  100953. * @param id defines the id to look for
  100954. * @returns the camera or null if not found
  100955. */
  100956. getCameraByID(id: string): Nullable<Camera>;
  100957. /**
  100958. * Gets a camera using its unique id
  100959. * @param uniqueId defines the unique id to look for
  100960. * @returns the camera or null if not found
  100961. */
  100962. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  100963. /**
  100964. * Gets a camera using its name
  100965. * @param name defines the camera's name
  100966. * @return the camera or null if none found.
  100967. */
  100968. getCameraByName(name: string): Nullable<Camera>;
  100969. /**
  100970. * Gets a bone using its id
  100971. * @param id defines the bone's id
  100972. * @return the bone or null if not found
  100973. */
  100974. getBoneByID(id: string): Nullable<Bone>;
  100975. /**
  100976. * Gets a bone using its id
  100977. * @param name defines the bone's name
  100978. * @return the bone or null if not found
  100979. */
  100980. getBoneByName(name: string): Nullable<Bone>;
  100981. /**
  100982. * Gets a light node using its name
  100983. * @param name defines the the light's name
  100984. * @return the light or null if none found.
  100985. */
  100986. getLightByName(name: string): Nullable<Light>;
  100987. /**
  100988. * Gets a light node using its id
  100989. * @param id defines the light's id
  100990. * @return the light or null if none found.
  100991. */
  100992. getLightByID(id: string): Nullable<Light>;
  100993. /**
  100994. * Gets a light node using its scene-generated unique ID
  100995. * @param uniqueId defines the light's unique id
  100996. * @return the light or null if none found.
  100997. */
  100998. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  100999. /**
  101000. * Gets a particle system by id
  101001. * @param id defines the particle system id
  101002. * @return the corresponding system or null if none found
  101003. */
  101004. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101005. /**
  101006. * Gets a geometry using its ID
  101007. * @param id defines the geometry's id
  101008. * @return the geometry or null if none found.
  101009. */
  101010. getGeometryByID(id: string): Nullable<Geometry>;
  101011. private _getGeometryByUniqueID;
  101012. /**
  101013. * Add a new geometry to this scene
  101014. * @param geometry defines the geometry to be added to the scene.
  101015. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101016. * @return a boolean defining if the geometry was added or not
  101017. */
  101018. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101019. /**
  101020. * Removes an existing geometry
  101021. * @param geometry defines the geometry to be removed from the scene
  101022. * @return a boolean defining if the geometry was removed or not
  101023. */
  101024. removeGeometry(geometry: Geometry): boolean;
  101025. /**
  101026. * Gets the list of geometries attached to the scene
  101027. * @returns an array of Geometry
  101028. */
  101029. getGeometries(): Geometry[];
  101030. /**
  101031. * Gets the first added mesh found of a given ID
  101032. * @param id defines the id to search for
  101033. * @return the mesh found or null if not found at all
  101034. */
  101035. getMeshByID(id: string): Nullable<AbstractMesh>;
  101036. /**
  101037. * Gets a list of meshes using their id
  101038. * @param id defines the id to search for
  101039. * @returns a list of meshes
  101040. */
  101041. getMeshesByID(id: string): Array<AbstractMesh>;
  101042. /**
  101043. * Gets the first added transform node found of a given ID
  101044. * @param id defines the id to search for
  101045. * @return the found transform node or null if not found at all.
  101046. */
  101047. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101048. /**
  101049. * Gets a transform node with its auto-generated unique id
  101050. * @param uniqueId efines the unique id to search for
  101051. * @return the found transform node or null if not found at all.
  101052. */
  101053. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101054. /**
  101055. * Gets a list of transform nodes using their id
  101056. * @param id defines the id to search for
  101057. * @returns a list of transform nodes
  101058. */
  101059. getTransformNodesByID(id: string): Array<TransformNode>;
  101060. /**
  101061. * Gets a mesh with its auto-generated unique id
  101062. * @param uniqueId defines the unique id to search for
  101063. * @return the found mesh or null if not found at all.
  101064. */
  101065. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101066. /**
  101067. * Gets a the last added mesh using a given id
  101068. * @param id defines the id to search for
  101069. * @return the found mesh or null if not found at all.
  101070. */
  101071. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101072. /**
  101073. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101074. * @param id defines the id to search for
  101075. * @return the found node or null if not found at all
  101076. */
  101077. getLastEntryByID(id: string): Nullable<Node>;
  101078. /**
  101079. * Gets a node (Mesh, Camera, Light) using a given id
  101080. * @param id defines the id to search for
  101081. * @return the found node or null if not found at all
  101082. */
  101083. getNodeByID(id: string): Nullable<Node>;
  101084. /**
  101085. * Gets a node (Mesh, Camera, Light) using a given name
  101086. * @param name defines the name to search for
  101087. * @return the found node or null if not found at all.
  101088. */
  101089. getNodeByName(name: string): Nullable<Node>;
  101090. /**
  101091. * Gets a mesh using a given name
  101092. * @param name defines the name to search for
  101093. * @return the found mesh or null if not found at all.
  101094. */
  101095. getMeshByName(name: string): Nullable<AbstractMesh>;
  101096. /**
  101097. * Gets a transform node using a given name
  101098. * @param name defines the name to search for
  101099. * @return the found transform node or null if not found at all.
  101100. */
  101101. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101102. /**
  101103. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101104. * @param id defines the id to search for
  101105. * @return the found skeleton or null if not found at all.
  101106. */
  101107. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101108. /**
  101109. * Gets a skeleton using a given auto generated unique id
  101110. * @param uniqueId defines the unique id to search for
  101111. * @return the found skeleton or null if not found at all.
  101112. */
  101113. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101114. /**
  101115. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101116. * @param id defines the id to search for
  101117. * @return the found skeleton or null if not found at all.
  101118. */
  101119. getSkeletonById(id: string): Nullable<Skeleton>;
  101120. /**
  101121. * Gets a skeleton using a given name
  101122. * @param name defines the name to search for
  101123. * @return the found skeleton or null if not found at all.
  101124. */
  101125. getSkeletonByName(name: string): Nullable<Skeleton>;
  101126. /**
  101127. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101128. * @param id defines the id to search for
  101129. * @return the found morph target manager or null if not found at all.
  101130. */
  101131. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101132. /**
  101133. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101134. * @param id defines the id to search for
  101135. * @return the found morph target or null if not found at all.
  101136. */
  101137. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101138. /**
  101139. * Gets a boolean indicating if the given mesh is active
  101140. * @param mesh defines the mesh to look for
  101141. * @returns true if the mesh is in the active list
  101142. */
  101143. isActiveMesh(mesh: AbstractMesh): boolean;
  101144. /**
  101145. * Return a unique id as a string which can serve as an identifier for the scene
  101146. */
  101147. readonly uid: string;
  101148. /**
  101149. * Add an externaly attached data from its key.
  101150. * This method call will fail and return false, if such key already exists.
  101151. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101152. * @param key the unique key that identifies the data
  101153. * @param data the data object to associate to the key for this Engine instance
  101154. * @return true if no such key were already present and the data was added successfully, false otherwise
  101155. */
  101156. addExternalData<T>(key: string, data: T): boolean;
  101157. /**
  101158. * Get an externaly attached data from its key
  101159. * @param key the unique key that identifies the data
  101160. * @return the associated data, if present (can be null), or undefined if not present
  101161. */
  101162. getExternalData<T>(key: string): Nullable<T>;
  101163. /**
  101164. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101165. * @param key the unique key that identifies the data
  101166. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101167. * @return the associated data, can be null if the factory returned null.
  101168. */
  101169. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101170. /**
  101171. * Remove an externaly attached data from the Engine instance
  101172. * @param key the unique key that identifies the data
  101173. * @return true if the data was successfully removed, false if it doesn't exist
  101174. */
  101175. removeExternalData(key: string): boolean;
  101176. private _evaluateSubMesh;
  101177. /**
  101178. * Clear the processed materials smart array preventing retention point in material dispose.
  101179. */
  101180. freeProcessedMaterials(): void;
  101181. private _preventFreeActiveMeshesAndRenderingGroups;
  101182. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101183. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101184. * when disposing several meshes in a row or a hierarchy of meshes.
  101185. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101186. */
  101187. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101188. /**
  101189. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101190. */
  101191. freeActiveMeshes(): void;
  101192. /**
  101193. * Clear the info related to rendering groups preventing retention points during dispose.
  101194. */
  101195. freeRenderingGroups(): void;
  101196. /** @hidden */
  101197. _isInIntermediateRendering(): boolean;
  101198. /**
  101199. * Lambda returning the list of potentially active meshes.
  101200. */
  101201. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101202. /**
  101203. * Lambda returning the list of potentially active sub meshes.
  101204. */
  101205. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101206. /**
  101207. * Lambda returning the list of potentially intersecting sub meshes.
  101208. */
  101209. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101210. /**
  101211. * Lambda returning the list of potentially colliding sub meshes.
  101212. */
  101213. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101214. private _activeMeshesFrozen;
  101215. /**
  101216. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101217. * @returns the current scene
  101218. */
  101219. freezeActiveMeshes(): Scene;
  101220. /**
  101221. * Use this function to restart evaluating active meshes on every frame
  101222. * @returns the current scene
  101223. */
  101224. unfreezeActiveMeshes(): Scene;
  101225. private _evaluateActiveMeshes;
  101226. private _activeMesh;
  101227. /**
  101228. * Update the transform matrix to update from the current active camera
  101229. * @param force defines a boolean used to force the update even if cache is up to date
  101230. */
  101231. updateTransformMatrix(force?: boolean): void;
  101232. private _bindFrameBuffer;
  101233. /** @hidden */
  101234. _allowPostProcessClearColor: boolean;
  101235. /** @hidden */
  101236. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101237. private _processSubCameras;
  101238. private _checkIntersections;
  101239. /** @hidden */
  101240. _advancePhysicsEngineStep(step: number): void;
  101241. /**
  101242. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101243. */
  101244. getDeterministicFrameTime: () => number;
  101245. /** @hidden */
  101246. _animate(): void;
  101247. /** Execute all animations (for a frame) */
  101248. animate(): void;
  101249. /**
  101250. * Render the scene
  101251. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101252. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101253. */
  101254. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101255. /**
  101256. * Freeze all materials
  101257. * A frozen material will not be updatable but should be faster to render
  101258. */
  101259. freezeMaterials(): void;
  101260. /**
  101261. * Unfreeze all materials
  101262. * A frozen material will not be updatable but should be faster to render
  101263. */
  101264. unfreezeMaterials(): void;
  101265. /**
  101266. * Releases all held ressources
  101267. */
  101268. dispose(): void;
  101269. /**
  101270. * Gets if the scene is already disposed
  101271. */
  101272. readonly isDisposed: boolean;
  101273. /**
  101274. * Call this function to reduce memory footprint of the scene.
  101275. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101276. */
  101277. clearCachedVertexData(): void;
  101278. /**
  101279. * This function will remove the local cached buffer data from texture.
  101280. * It will save memory but will prevent the texture from being rebuilt
  101281. */
  101282. cleanCachedTextureBuffer(): void;
  101283. /**
  101284. * Get the world extend vectors with an optional filter
  101285. *
  101286. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101287. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101288. */
  101289. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101290. min: Vector3;
  101291. max: Vector3;
  101292. };
  101293. /**
  101294. * Creates a ray that can be used to pick in the scene
  101295. * @param x defines the x coordinate of the origin (on-screen)
  101296. * @param y defines the y coordinate of the origin (on-screen)
  101297. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101298. * @param camera defines the camera to use for the picking
  101299. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101300. * @returns a Ray
  101301. */
  101302. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101303. /**
  101304. * Creates a ray that can be used to pick in the scene
  101305. * @param x defines the x coordinate of the origin (on-screen)
  101306. * @param y defines the y coordinate of the origin (on-screen)
  101307. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101308. * @param result defines the ray where to store the picking ray
  101309. * @param camera defines the camera to use for the picking
  101310. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101311. * @returns the current scene
  101312. */
  101313. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101314. /**
  101315. * Creates a ray that can be used to pick in the scene
  101316. * @param x defines the x coordinate of the origin (on-screen)
  101317. * @param y defines the y coordinate of the origin (on-screen)
  101318. * @param camera defines the camera to use for the picking
  101319. * @returns a Ray
  101320. */
  101321. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101322. /**
  101323. * Creates a ray that can be used to pick in the scene
  101324. * @param x defines the x coordinate of the origin (on-screen)
  101325. * @param y defines the y coordinate of the origin (on-screen)
  101326. * @param result defines the ray where to store the picking ray
  101327. * @param camera defines the camera to use for the picking
  101328. * @returns the current scene
  101329. */
  101330. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101331. /** Launch a ray to try to pick a mesh in the scene
  101332. * @param x position on screen
  101333. * @param y position on screen
  101334. * @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
  101335. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101336. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101337. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101338. * @returns a PickingInfo
  101339. */
  101340. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101341. /** Use the given ray to pick a mesh in the scene
  101342. * @param ray The ray to use to pick meshes
  101343. * @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
  101344. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101345. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101346. * @returns a PickingInfo
  101347. */
  101348. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101349. /**
  101350. * Launch a ray to try to pick a mesh in the scene
  101351. * @param x X position on screen
  101352. * @param y Y position on screen
  101353. * @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
  101354. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101355. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101356. * @returns an array of PickingInfo
  101357. */
  101358. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101359. /**
  101360. * Launch a ray to try to pick a mesh in the scene
  101361. * @param ray Ray to use
  101362. * @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
  101363. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101364. * @returns an array of PickingInfo
  101365. */
  101366. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101367. /**
  101368. * Force the value of meshUnderPointer
  101369. * @param mesh defines the mesh to use
  101370. */
  101371. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101372. /**
  101373. * Gets the mesh under the pointer
  101374. * @returns a Mesh or null if no mesh is under the pointer
  101375. */
  101376. getPointerOverMesh(): Nullable<AbstractMesh>;
  101377. /** @hidden */
  101378. _rebuildGeometries(): void;
  101379. /** @hidden */
  101380. _rebuildTextures(): void;
  101381. private _getByTags;
  101382. /**
  101383. * Get a list of meshes by tags
  101384. * @param tagsQuery defines the tags query to use
  101385. * @param forEach defines a predicate used to filter results
  101386. * @returns an array of Mesh
  101387. */
  101388. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101389. /**
  101390. * Get a list of cameras by tags
  101391. * @param tagsQuery defines the tags query to use
  101392. * @param forEach defines a predicate used to filter results
  101393. * @returns an array of Camera
  101394. */
  101395. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101396. /**
  101397. * Get a list of lights by tags
  101398. * @param tagsQuery defines the tags query to use
  101399. * @param forEach defines a predicate used to filter results
  101400. * @returns an array of Light
  101401. */
  101402. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101403. /**
  101404. * Get a list of materials by tags
  101405. * @param tagsQuery defines the tags query to use
  101406. * @param forEach defines a predicate used to filter results
  101407. * @returns an array of Material
  101408. */
  101409. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101410. /**
  101411. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101412. * This allowed control for front to back rendering or reversly depending of the special needs.
  101413. *
  101414. * @param renderingGroupId The rendering group id corresponding to its index
  101415. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101416. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101417. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101418. */
  101419. 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;
  101420. /**
  101421. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101422. *
  101423. * @param renderingGroupId The rendering group id corresponding to its index
  101424. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101425. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101426. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101427. */
  101428. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101429. /**
  101430. * Gets the current auto clear configuration for one rendering group of the rendering
  101431. * manager.
  101432. * @param index the rendering group index to get the information for
  101433. * @returns The auto clear setup for the requested rendering group
  101434. */
  101435. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101436. private _blockMaterialDirtyMechanism;
  101437. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101438. blockMaterialDirtyMechanism: boolean;
  101439. /**
  101440. * Will flag all materials as dirty to trigger new shader compilation
  101441. * @param flag defines the flag used to specify which material part must be marked as dirty
  101442. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101443. */
  101444. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101445. /** @hidden */
  101446. _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;
  101447. /** @hidden */
  101448. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101449. }
  101450. }
  101451. declare module BABYLON {
  101452. /**
  101453. * Set of assets to keep when moving a scene into an asset container.
  101454. */
  101455. export class KeepAssets extends AbstractScene {
  101456. }
  101457. /**
  101458. * Container with a set of assets that can be added or removed from a scene.
  101459. */
  101460. export class AssetContainer extends AbstractScene {
  101461. /**
  101462. * The scene the AssetContainer belongs to.
  101463. */
  101464. scene: Scene;
  101465. /**
  101466. * Instantiates an AssetContainer.
  101467. * @param scene The scene the AssetContainer belongs to.
  101468. */
  101469. constructor(scene: Scene);
  101470. /**
  101471. * Adds all the assets from the container to the scene.
  101472. */
  101473. addAllToScene(): void;
  101474. /**
  101475. * Removes all the assets in the container from the scene
  101476. */
  101477. removeAllFromScene(): void;
  101478. /**
  101479. * Disposes all the assets in the container
  101480. */
  101481. dispose(): void;
  101482. private _moveAssets;
  101483. /**
  101484. * Removes all the assets contained in the scene and adds them to the container.
  101485. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101486. */
  101487. moveAllFromScene(keepAssets?: KeepAssets): void;
  101488. /**
  101489. * 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.
  101490. * @returns the root mesh
  101491. */
  101492. createRootMesh(): Mesh;
  101493. }
  101494. }
  101495. declare module BABYLON {
  101496. /**
  101497. * Defines how the parser contract is defined.
  101498. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101499. */
  101500. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101501. /**
  101502. * Defines how the individual parser contract is defined.
  101503. * These parser can parse an individual asset
  101504. */
  101505. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101506. /**
  101507. * Base class of the scene acting as a container for the different elements composing a scene.
  101508. * This class is dynamically extended by the different components of the scene increasing
  101509. * flexibility and reducing coupling
  101510. */
  101511. export abstract class AbstractScene {
  101512. /**
  101513. * Stores the list of available parsers in the application.
  101514. */
  101515. private static _BabylonFileParsers;
  101516. /**
  101517. * Stores the list of available individual parsers in the application.
  101518. */
  101519. private static _IndividualBabylonFileParsers;
  101520. /**
  101521. * Adds a parser in the list of available ones
  101522. * @param name Defines the name of the parser
  101523. * @param parser Defines the parser to add
  101524. */
  101525. static AddParser(name: string, parser: BabylonFileParser): void;
  101526. /**
  101527. * Gets a general parser from the list of avaialble ones
  101528. * @param name Defines the name of the parser
  101529. * @returns the requested parser or null
  101530. */
  101531. static GetParser(name: string): Nullable<BabylonFileParser>;
  101532. /**
  101533. * Adds n individual parser in the list of available ones
  101534. * @param name Defines the name of the parser
  101535. * @param parser Defines the parser to add
  101536. */
  101537. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101538. /**
  101539. * Gets an individual parser from the list of avaialble ones
  101540. * @param name Defines the name of the parser
  101541. * @returns the requested parser or null
  101542. */
  101543. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101544. /**
  101545. * Parser json data and populate both a scene and its associated container object
  101546. * @param jsonData Defines the data to parse
  101547. * @param scene Defines the scene to parse the data for
  101548. * @param container Defines the container attached to the parsing sequence
  101549. * @param rootUrl Defines the root url of the data
  101550. */
  101551. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101552. /**
  101553. * Gets the list of root nodes (ie. nodes with no parent)
  101554. */
  101555. rootNodes: Node[];
  101556. /** All of the cameras added to this scene
  101557. * @see http://doc.babylonjs.com/babylon101/cameras
  101558. */
  101559. cameras: Camera[];
  101560. /**
  101561. * All of the lights added to this scene
  101562. * @see http://doc.babylonjs.com/babylon101/lights
  101563. */
  101564. lights: Light[];
  101565. /**
  101566. * All of the (abstract) meshes added to this scene
  101567. */
  101568. meshes: AbstractMesh[];
  101569. /**
  101570. * The list of skeletons added to the scene
  101571. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101572. */
  101573. skeletons: Skeleton[];
  101574. /**
  101575. * All of the particle systems added to this scene
  101576. * @see http://doc.babylonjs.com/babylon101/particles
  101577. */
  101578. particleSystems: IParticleSystem[];
  101579. /**
  101580. * Gets a list of Animations associated with the scene
  101581. */
  101582. animations: Animation[];
  101583. /**
  101584. * All of the animation groups added to this scene
  101585. * @see http://doc.babylonjs.com/how_to/group
  101586. */
  101587. animationGroups: AnimationGroup[];
  101588. /**
  101589. * All of the multi-materials added to this scene
  101590. * @see http://doc.babylonjs.com/how_to/multi_materials
  101591. */
  101592. multiMaterials: MultiMaterial[];
  101593. /**
  101594. * All of the materials added to this scene
  101595. * In the context of a Scene, it is not supposed to be modified manually.
  101596. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101597. * Note also that the order of the Material wihin the array is not significant and might change.
  101598. * @see http://doc.babylonjs.com/babylon101/materials
  101599. */
  101600. materials: Material[];
  101601. /**
  101602. * The list of morph target managers added to the scene
  101603. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101604. */
  101605. morphTargetManagers: MorphTargetManager[];
  101606. /**
  101607. * The list of geometries used in the scene.
  101608. */
  101609. geometries: Geometry[];
  101610. /**
  101611. * All of the tranform nodes added to this scene
  101612. * In the context of a Scene, it is not supposed to be modified manually.
  101613. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101614. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101615. * @see http://doc.babylonjs.com/how_to/transformnode
  101616. */
  101617. transformNodes: TransformNode[];
  101618. /**
  101619. * ActionManagers available on the scene.
  101620. */
  101621. actionManagers: AbstractActionManager[];
  101622. /**
  101623. * Textures to keep.
  101624. */
  101625. textures: BaseTexture[];
  101626. /**
  101627. * Environment texture for the scene
  101628. */
  101629. environmentTexture: Nullable<BaseTexture>;
  101630. }
  101631. }
  101632. declare module BABYLON {
  101633. /**
  101634. * Interface used to define options for Sound class
  101635. */
  101636. export interface ISoundOptions {
  101637. /**
  101638. * Does the sound autoplay once loaded.
  101639. */
  101640. autoplay?: boolean;
  101641. /**
  101642. * Does the sound loop after it finishes playing once.
  101643. */
  101644. loop?: boolean;
  101645. /**
  101646. * Sound's volume
  101647. */
  101648. volume?: number;
  101649. /**
  101650. * Is it a spatial sound?
  101651. */
  101652. spatialSound?: boolean;
  101653. /**
  101654. * Maximum distance to hear that sound
  101655. */
  101656. maxDistance?: number;
  101657. /**
  101658. * Uses user defined attenuation function
  101659. */
  101660. useCustomAttenuation?: boolean;
  101661. /**
  101662. * Define the roll off factor of spatial sounds.
  101663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101664. */
  101665. rolloffFactor?: number;
  101666. /**
  101667. * Define the reference distance the sound should be heard perfectly.
  101668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101669. */
  101670. refDistance?: number;
  101671. /**
  101672. * Define the distance attenuation model the sound will follow.
  101673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101674. */
  101675. distanceModel?: string;
  101676. /**
  101677. * Defines the playback speed (1 by default)
  101678. */
  101679. playbackRate?: number;
  101680. /**
  101681. * Defines if the sound is from a streaming source
  101682. */
  101683. streaming?: boolean;
  101684. /**
  101685. * Defines an optional length (in seconds) inside the sound file
  101686. */
  101687. length?: number;
  101688. /**
  101689. * Defines an optional offset (in seconds) inside the sound file
  101690. */
  101691. offset?: number;
  101692. /**
  101693. * If true, URLs will not be required to state the audio file codec to use.
  101694. */
  101695. skipCodecCheck?: boolean;
  101696. }
  101697. /**
  101698. * Defines a sound that can be played in the application.
  101699. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101701. */
  101702. export class Sound {
  101703. /**
  101704. * The name of the sound in the scene.
  101705. */
  101706. name: string;
  101707. /**
  101708. * Does the sound autoplay once loaded.
  101709. */
  101710. autoplay: boolean;
  101711. /**
  101712. * Does the sound loop after it finishes playing once.
  101713. */
  101714. loop: boolean;
  101715. /**
  101716. * Does the sound use a custom attenuation curve to simulate the falloff
  101717. * happening when the source gets further away from the camera.
  101718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101719. */
  101720. useCustomAttenuation: boolean;
  101721. /**
  101722. * The sound track id this sound belongs to.
  101723. */
  101724. soundTrackId: number;
  101725. /**
  101726. * Is this sound currently played.
  101727. */
  101728. isPlaying: boolean;
  101729. /**
  101730. * Is this sound currently paused.
  101731. */
  101732. isPaused: boolean;
  101733. /**
  101734. * Does this sound enables spatial sound.
  101735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101736. */
  101737. spatialSound: boolean;
  101738. /**
  101739. * Define the reference distance the sound should be heard perfectly.
  101740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101741. */
  101742. refDistance: number;
  101743. /**
  101744. * Define the roll off factor of spatial sounds.
  101745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101746. */
  101747. rolloffFactor: number;
  101748. /**
  101749. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101751. */
  101752. maxDistance: number;
  101753. /**
  101754. * Define the distance attenuation model the sound will follow.
  101755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101756. */
  101757. distanceModel: string;
  101758. /**
  101759. * @hidden
  101760. * Back Compat
  101761. **/
  101762. onended: () => any;
  101763. /**
  101764. * Observable event when the current playing sound finishes.
  101765. */
  101766. onEndedObservable: Observable<Sound>;
  101767. private _panningModel;
  101768. private _playbackRate;
  101769. private _streaming;
  101770. private _startTime;
  101771. private _startOffset;
  101772. private _position;
  101773. /** @hidden */
  101774. _positionInEmitterSpace: boolean;
  101775. private _localDirection;
  101776. private _volume;
  101777. private _isReadyToPlay;
  101778. private _isDirectional;
  101779. private _readyToPlayCallback;
  101780. private _audioBuffer;
  101781. private _soundSource;
  101782. private _streamingSource;
  101783. private _soundPanner;
  101784. private _soundGain;
  101785. private _inputAudioNode;
  101786. private _outputAudioNode;
  101787. private _coneInnerAngle;
  101788. private _coneOuterAngle;
  101789. private _coneOuterGain;
  101790. private _scene;
  101791. private _connectedTransformNode;
  101792. private _customAttenuationFunction;
  101793. private _registerFunc;
  101794. private _isOutputConnected;
  101795. private _htmlAudioElement;
  101796. private _urlType;
  101797. private _length?;
  101798. private _offset?;
  101799. /** @hidden */
  101800. static _SceneComponentInitialization: (scene: Scene) => void;
  101801. /**
  101802. * Create a sound and attach it to a scene
  101803. * @param name Name of your sound
  101804. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101805. * @param scene defines the scene the sound belongs to
  101806. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101807. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101808. */
  101809. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101810. /**
  101811. * Release the sound and its associated resources
  101812. */
  101813. dispose(): void;
  101814. /**
  101815. * Gets if the sounds is ready to be played or not.
  101816. * @returns true if ready, otherwise false
  101817. */
  101818. isReady(): boolean;
  101819. private _soundLoaded;
  101820. /**
  101821. * Sets the data of the sound from an audiobuffer
  101822. * @param audioBuffer The audioBuffer containing the data
  101823. */
  101824. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101825. /**
  101826. * Updates the current sounds options such as maxdistance, loop...
  101827. * @param options A JSON object containing values named as the object properties
  101828. */
  101829. updateOptions(options: ISoundOptions): void;
  101830. private _createSpatialParameters;
  101831. private _updateSpatialParameters;
  101832. /**
  101833. * Switch the panning model to HRTF:
  101834. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101836. */
  101837. switchPanningModelToHRTF(): void;
  101838. /**
  101839. * Switch the panning model to Equal Power:
  101840. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101842. */
  101843. switchPanningModelToEqualPower(): void;
  101844. private _switchPanningModel;
  101845. /**
  101846. * Connect this sound to a sound track audio node like gain...
  101847. * @param soundTrackAudioNode the sound track audio node to connect to
  101848. */
  101849. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101850. /**
  101851. * Transform this sound into a directional source
  101852. * @param coneInnerAngle Size of the inner cone in degree
  101853. * @param coneOuterAngle Size of the outer cone in degree
  101854. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101855. */
  101856. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101857. /**
  101858. * Gets or sets the inner angle for the directional cone.
  101859. */
  101860. /**
  101861. * Gets or sets the inner angle for the directional cone.
  101862. */
  101863. directionalConeInnerAngle: number;
  101864. /**
  101865. * Gets or sets the outer angle for the directional cone.
  101866. */
  101867. /**
  101868. * Gets or sets the outer angle for the directional cone.
  101869. */
  101870. directionalConeOuterAngle: number;
  101871. /**
  101872. * Sets the position of the emitter if spatial sound is enabled
  101873. * @param newPosition Defines the new posisiton
  101874. */
  101875. setPosition(newPosition: Vector3): void;
  101876. /**
  101877. * Sets the local direction of the emitter if spatial sound is enabled
  101878. * @param newLocalDirection Defines the new local direction
  101879. */
  101880. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  101881. private _updateDirection;
  101882. /** @hidden */
  101883. updateDistanceFromListener(): void;
  101884. /**
  101885. * Sets a new custom attenuation function for the sound.
  101886. * @param callback Defines the function used for the attenuation
  101887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101888. */
  101889. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  101890. /**
  101891. * Play the sound
  101892. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101893. * @param offset (optional) Start the sound at a specific time in seconds
  101894. * @param length (optional) Sound duration (in seconds)
  101895. */
  101896. play(time?: number, offset?: number, length?: number): void;
  101897. private _onended;
  101898. /**
  101899. * Stop the sound
  101900. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  101901. */
  101902. stop(time?: number): void;
  101903. /**
  101904. * Put the sound in pause
  101905. */
  101906. pause(): void;
  101907. /**
  101908. * Sets a dedicated volume for this sounds
  101909. * @param newVolume Define the new volume of the sound
  101910. * @param time Define time for gradual change to new volume
  101911. */
  101912. setVolume(newVolume: number, time?: number): void;
  101913. /**
  101914. * Set the sound play back rate
  101915. * @param newPlaybackRate Define the playback rate the sound should be played at
  101916. */
  101917. setPlaybackRate(newPlaybackRate: number): void;
  101918. /**
  101919. * Gets the volume of the sound.
  101920. * @returns the volume of the sound
  101921. */
  101922. getVolume(): number;
  101923. /**
  101924. * Attach the sound to a dedicated mesh
  101925. * @param transformNode The transform node to connect the sound with
  101926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101927. */
  101928. attachToMesh(transformNode: TransformNode): void;
  101929. /**
  101930. * Detach the sound from the previously attached mesh
  101931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101932. */
  101933. detachFromMesh(): void;
  101934. private _onRegisterAfterWorldMatrixUpdate;
  101935. /**
  101936. * Clone the current sound in the scene.
  101937. * @returns the new sound clone
  101938. */
  101939. clone(): Nullable<Sound>;
  101940. /**
  101941. * Gets the current underlying audio buffer containing the data
  101942. * @returns the audio buffer
  101943. */
  101944. getAudioBuffer(): Nullable<AudioBuffer>;
  101945. /**
  101946. * Serializes the Sound in a JSON representation
  101947. * @returns the JSON representation of the sound
  101948. */
  101949. serialize(): any;
  101950. /**
  101951. * Parse a JSON representation of a sound to innstantiate in a given scene
  101952. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  101953. * @param scene Define the scene the new parsed sound should be created in
  101954. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  101955. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  101956. * @returns the newly parsed sound
  101957. */
  101958. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  101959. }
  101960. }
  101961. declare module BABYLON {
  101962. /**
  101963. * This defines an action helpful to play a defined sound on a triggered action.
  101964. */
  101965. export class PlaySoundAction extends Action {
  101966. private _sound;
  101967. /**
  101968. * Instantiate the action
  101969. * @param triggerOptions defines the trigger options
  101970. * @param sound defines the sound to play
  101971. * @param condition defines the trigger related conditions
  101972. */
  101973. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101974. /** @hidden */
  101975. _prepare(): void;
  101976. /**
  101977. * Execute the action and play the sound.
  101978. */
  101979. execute(): void;
  101980. /**
  101981. * Serializes the actions and its related information.
  101982. * @param parent defines the object to serialize in
  101983. * @returns the serialized object
  101984. */
  101985. serialize(parent: any): any;
  101986. }
  101987. /**
  101988. * This defines an action helpful to stop a defined sound on a triggered action.
  101989. */
  101990. export class StopSoundAction extends Action {
  101991. private _sound;
  101992. /**
  101993. * Instantiate the action
  101994. * @param triggerOptions defines the trigger options
  101995. * @param sound defines the sound to stop
  101996. * @param condition defines the trigger related conditions
  101997. */
  101998. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101999. /** @hidden */
  102000. _prepare(): void;
  102001. /**
  102002. * Execute the action and stop the sound.
  102003. */
  102004. execute(): void;
  102005. /**
  102006. * Serializes the actions and its related information.
  102007. * @param parent defines the object to serialize in
  102008. * @returns the serialized object
  102009. */
  102010. serialize(parent: any): any;
  102011. }
  102012. }
  102013. declare module BABYLON {
  102014. /**
  102015. * This defines an action responsible to change the value of a property
  102016. * by interpolating between its current value and the newly set one once triggered.
  102017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102018. */
  102019. export class InterpolateValueAction extends Action {
  102020. /**
  102021. * Defines the path of the property where the value should be interpolated
  102022. */
  102023. propertyPath: string;
  102024. /**
  102025. * Defines the target value at the end of the interpolation.
  102026. */
  102027. value: any;
  102028. /**
  102029. * Defines the time it will take for the property to interpolate to the value.
  102030. */
  102031. duration: number;
  102032. /**
  102033. * Defines if the other scene animations should be stopped when the action has been triggered
  102034. */
  102035. stopOtherAnimations?: boolean;
  102036. /**
  102037. * Defines a callback raised once the interpolation animation has been done.
  102038. */
  102039. onInterpolationDone?: () => void;
  102040. /**
  102041. * Observable triggered once the interpolation animation has been done.
  102042. */
  102043. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102044. private _target;
  102045. private _effectiveTarget;
  102046. private _property;
  102047. /**
  102048. * Instantiate the action
  102049. * @param triggerOptions defines the trigger options
  102050. * @param target defines the object containing the value to interpolate
  102051. * @param propertyPath defines the path to the property in the target object
  102052. * @param value defines the target value at the end of the interpolation
  102053. * @param duration deines the time it will take for the property to interpolate to the value.
  102054. * @param condition defines the trigger related conditions
  102055. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102056. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102057. */
  102058. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102059. /** @hidden */
  102060. _prepare(): void;
  102061. /**
  102062. * Execute the action starts the value interpolation.
  102063. */
  102064. execute(): void;
  102065. /**
  102066. * Serializes the actions and its related information.
  102067. * @param parent defines the object to serialize in
  102068. * @returns the serialized object
  102069. */
  102070. serialize(parent: any): any;
  102071. }
  102072. }
  102073. declare module BABYLON {
  102074. /**
  102075. * Options allowed during the creation of a sound track.
  102076. */
  102077. export interface ISoundTrackOptions {
  102078. /**
  102079. * The volume the sound track should take during creation
  102080. */
  102081. volume?: number;
  102082. /**
  102083. * Define if the sound track is the main sound track of the scene
  102084. */
  102085. mainTrack?: boolean;
  102086. }
  102087. /**
  102088. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102089. * It will be also used in a future release to apply effects on a specific track.
  102090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102091. */
  102092. export class SoundTrack {
  102093. /**
  102094. * The unique identifier of the sound track in the scene.
  102095. */
  102096. id: number;
  102097. /**
  102098. * The list of sounds included in the sound track.
  102099. */
  102100. soundCollection: Array<Sound>;
  102101. private _outputAudioNode;
  102102. private _scene;
  102103. private _isMainTrack;
  102104. private _connectedAnalyser;
  102105. private _options;
  102106. private _isInitialized;
  102107. /**
  102108. * Creates a new sound track.
  102109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102110. * @param scene Define the scene the sound track belongs to
  102111. * @param options
  102112. */
  102113. constructor(scene: Scene, options?: ISoundTrackOptions);
  102114. private _initializeSoundTrackAudioGraph;
  102115. /**
  102116. * Release the sound track and its associated resources
  102117. */
  102118. dispose(): void;
  102119. /**
  102120. * Adds a sound to this sound track
  102121. * @param sound define the cound to add
  102122. * @ignoreNaming
  102123. */
  102124. AddSound(sound: Sound): void;
  102125. /**
  102126. * Removes a sound to this sound track
  102127. * @param sound define the cound to remove
  102128. * @ignoreNaming
  102129. */
  102130. RemoveSound(sound: Sound): void;
  102131. /**
  102132. * Set a global volume for the full sound track.
  102133. * @param newVolume Define the new volume of the sound track
  102134. */
  102135. setVolume(newVolume: number): void;
  102136. /**
  102137. * Switch the panning model to HRTF:
  102138. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102140. */
  102141. switchPanningModelToHRTF(): void;
  102142. /**
  102143. * Switch the panning model to Equal Power:
  102144. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102146. */
  102147. switchPanningModelToEqualPower(): void;
  102148. /**
  102149. * Connect the sound track to an audio analyser allowing some amazing
  102150. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102152. * @param analyser The analyser to connect to the engine
  102153. */
  102154. connectToAnalyser(analyser: Analyser): void;
  102155. }
  102156. }
  102157. declare module BABYLON {
  102158. interface AbstractScene {
  102159. /**
  102160. * The list of sounds used in the scene.
  102161. */
  102162. sounds: Nullable<Array<Sound>>;
  102163. }
  102164. interface Scene {
  102165. /**
  102166. * @hidden
  102167. * Backing field
  102168. */
  102169. _mainSoundTrack: SoundTrack;
  102170. /**
  102171. * The main sound track played by the scene.
  102172. * It cotains your primary collection of sounds.
  102173. */
  102174. mainSoundTrack: SoundTrack;
  102175. /**
  102176. * The list of sound tracks added to the scene
  102177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102178. */
  102179. soundTracks: Nullable<Array<SoundTrack>>;
  102180. /**
  102181. * Gets a sound using a given name
  102182. * @param name defines the name to search for
  102183. * @return the found sound or null if not found at all.
  102184. */
  102185. getSoundByName(name: string): Nullable<Sound>;
  102186. /**
  102187. * Gets or sets if audio support is enabled
  102188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102189. */
  102190. audioEnabled: boolean;
  102191. /**
  102192. * Gets or sets if audio will be output to headphones
  102193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102194. */
  102195. headphone: boolean;
  102196. /**
  102197. * Gets or sets custom audio listener position provider
  102198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102199. */
  102200. audioListenerPositionProvider: Nullable<() => Vector3>;
  102201. }
  102202. /**
  102203. * Defines the sound scene component responsible to manage any sounds
  102204. * in a given scene.
  102205. */
  102206. export class AudioSceneComponent implements ISceneSerializableComponent {
  102207. /**
  102208. * The component name helpfull to identify the component in the list of scene components.
  102209. */
  102210. readonly name: string;
  102211. /**
  102212. * The scene the component belongs to.
  102213. */
  102214. scene: Scene;
  102215. private _audioEnabled;
  102216. /**
  102217. * Gets whether audio is enabled or not.
  102218. * Please use related enable/disable method to switch state.
  102219. */
  102220. readonly audioEnabled: boolean;
  102221. private _headphone;
  102222. /**
  102223. * Gets whether audio is outputing to headphone or not.
  102224. * Please use the according Switch methods to change output.
  102225. */
  102226. readonly headphone: boolean;
  102227. private _audioListenerPositionProvider;
  102228. /**
  102229. * Gets the current audio listener position provider
  102230. */
  102231. /**
  102232. * Sets a custom listener position for all sounds in the scene
  102233. * By default, this is the position of the first active camera
  102234. */
  102235. audioListenerPositionProvider: Nullable<() => Vector3>;
  102236. /**
  102237. * Creates a new instance of the component for the given scene
  102238. * @param scene Defines the scene to register the component in
  102239. */
  102240. constructor(scene: Scene);
  102241. /**
  102242. * Registers the component in a given scene
  102243. */
  102244. register(): void;
  102245. /**
  102246. * Rebuilds the elements related to this component in case of
  102247. * context lost for instance.
  102248. */
  102249. rebuild(): void;
  102250. /**
  102251. * Serializes the component data to the specified json object
  102252. * @param serializationObject The object to serialize to
  102253. */
  102254. serialize(serializationObject: any): void;
  102255. /**
  102256. * Adds all the elements from the container to the scene
  102257. * @param container the container holding the elements
  102258. */
  102259. addFromContainer(container: AbstractScene): void;
  102260. /**
  102261. * Removes all the elements in the container from the scene
  102262. * @param container contains the elements to remove
  102263. * @param dispose if the removed element should be disposed (default: false)
  102264. */
  102265. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102266. /**
  102267. * Disposes the component and the associated ressources.
  102268. */
  102269. dispose(): void;
  102270. /**
  102271. * Disables audio in the associated scene.
  102272. */
  102273. disableAudio(): void;
  102274. /**
  102275. * Enables audio in the associated scene.
  102276. */
  102277. enableAudio(): void;
  102278. /**
  102279. * Switch audio to headphone output.
  102280. */
  102281. switchAudioModeForHeadphones(): void;
  102282. /**
  102283. * Switch audio to normal speakers.
  102284. */
  102285. switchAudioModeForNormalSpeakers(): void;
  102286. private _afterRender;
  102287. }
  102288. }
  102289. declare module BABYLON {
  102290. /**
  102291. * Wraps one or more Sound objects and selects one with random weight for playback.
  102292. */
  102293. export class WeightedSound {
  102294. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102295. loop: boolean;
  102296. private _coneInnerAngle;
  102297. private _coneOuterAngle;
  102298. private _volume;
  102299. /** A Sound is currently playing. */
  102300. isPlaying: boolean;
  102301. /** A Sound is currently paused. */
  102302. isPaused: boolean;
  102303. private _sounds;
  102304. private _weights;
  102305. private _currentIndex?;
  102306. /**
  102307. * Creates a new WeightedSound from the list of sounds given.
  102308. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102309. * @param sounds Array of Sounds that will be selected from.
  102310. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102311. */
  102312. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102313. /**
  102314. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102315. */
  102316. /**
  102317. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102318. */
  102319. directionalConeInnerAngle: number;
  102320. /**
  102321. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102322. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102323. */
  102324. /**
  102325. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102326. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102327. */
  102328. directionalConeOuterAngle: number;
  102329. /**
  102330. * Playback volume.
  102331. */
  102332. /**
  102333. * Playback volume.
  102334. */
  102335. volume: number;
  102336. private _onended;
  102337. /**
  102338. * Suspend playback
  102339. */
  102340. pause(): void;
  102341. /**
  102342. * Stop playback
  102343. */
  102344. stop(): void;
  102345. /**
  102346. * Start playback.
  102347. * @param startOffset Position the clip head at a specific time in seconds.
  102348. */
  102349. play(startOffset?: number): void;
  102350. }
  102351. }
  102352. declare module BABYLON {
  102353. /**
  102354. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102355. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102356. */
  102357. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102358. /**
  102359. * Gets the name of the behavior.
  102360. */
  102361. readonly name: string;
  102362. /**
  102363. * The easing function used by animations
  102364. */
  102365. static EasingFunction: BackEase;
  102366. /**
  102367. * The easing mode used by animations
  102368. */
  102369. static EasingMode: number;
  102370. /**
  102371. * The duration of the animation, in milliseconds
  102372. */
  102373. transitionDuration: number;
  102374. /**
  102375. * Length of the distance animated by the transition when lower radius is reached
  102376. */
  102377. lowerRadiusTransitionRange: number;
  102378. /**
  102379. * Length of the distance animated by the transition when upper radius is reached
  102380. */
  102381. upperRadiusTransitionRange: number;
  102382. private _autoTransitionRange;
  102383. /**
  102384. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102385. */
  102386. /**
  102387. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102388. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102389. */
  102390. autoTransitionRange: boolean;
  102391. private _attachedCamera;
  102392. private _onAfterCheckInputsObserver;
  102393. private _onMeshTargetChangedObserver;
  102394. /**
  102395. * Initializes the behavior.
  102396. */
  102397. init(): void;
  102398. /**
  102399. * Attaches the behavior to its arc rotate camera.
  102400. * @param camera Defines the camera to attach the behavior to
  102401. */
  102402. attach(camera: ArcRotateCamera): void;
  102403. /**
  102404. * Detaches the behavior from its current arc rotate camera.
  102405. */
  102406. detach(): void;
  102407. private _radiusIsAnimating;
  102408. private _radiusBounceTransition;
  102409. private _animatables;
  102410. private _cachedWheelPrecision;
  102411. /**
  102412. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102413. * @param radiusLimit The limit to check against.
  102414. * @return Bool to indicate if at limit.
  102415. */
  102416. private _isRadiusAtLimit;
  102417. /**
  102418. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102419. * @param radiusDelta The delta by which to animate to. Can be negative.
  102420. */
  102421. private _applyBoundRadiusAnimation;
  102422. /**
  102423. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102424. */
  102425. protected _clearAnimationLocks(): void;
  102426. /**
  102427. * Stops and removes all animations that have been applied to the camera
  102428. */
  102429. stopAllAnimations(): void;
  102430. }
  102431. }
  102432. declare module BABYLON {
  102433. /**
  102434. * 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.
  102435. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102436. */
  102437. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102438. /**
  102439. * Gets the name of the behavior.
  102440. */
  102441. readonly name: string;
  102442. private _mode;
  102443. private _radiusScale;
  102444. private _positionScale;
  102445. private _defaultElevation;
  102446. private _elevationReturnTime;
  102447. private _elevationReturnWaitTime;
  102448. private _zoomStopsAnimation;
  102449. private _framingTime;
  102450. /**
  102451. * The easing function used by animations
  102452. */
  102453. static EasingFunction: ExponentialEase;
  102454. /**
  102455. * The easing mode used by animations
  102456. */
  102457. static EasingMode: number;
  102458. /**
  102459. * Sets the current mode used by the behavior
  102460. */
  102461. /**
  102462. * Gets current mode used by the behavior.
  102463. */
  102464. mode: number;
  102465. /**
  102466. * Sets the scale applied to the radius (1 by default)
  102467. */
  102468. /**
  102469. * Gets the scale applied to the radius
  102470. */
  102471. radiusScale: number;
  102472. /**
  102473. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102474. */
  102475. /**
  102476. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102477. */
  102478. positionScale: number;
  102479. /**
  102480. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102481. * behaviour is triggered, in radians.
  102482. */
  102483. /**
  102484. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102485. * behaviour is triggered, in radians.
  102486. */
  102487. defaultElevation: number;
  102488. /**
  102489. * Sets the time (in milliseconds) taken to return to the default beta position.
  102490. * Negative value indicates camera should not return to default.
  102491. */
  102492. /**
  102493. * Gets the time (in milliseconds) taken to return to the default beta position.
  102494. * Negative value indicates camera should not return to default.
  102495. */
  102496. elevationReturnTime: number;
  102497. /**
  102498. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102499. */
  102500. /**
  102501. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102502. */
  102503. elevationReturnWaitTime: number;
  102504. /**
  102505. * Sets the flag that indicates if user zooming should stop animation.
  102506. */
  102507. /**
  102508. * Gets the flag that indicates if user zooming should stop animation.
  102509. */
  102510. zoomStopsAnimation: boolean;
  102511. /**
  102512. * Sets the transition time when framing the mesh, in milliseconds
  102513. */
  102514. /**
  102515. * Gets the transition time when framing the mesh, in milliseconds
  102516. */
  102517. framingTime: number;
  102518. /**
  102519. * Define if the behavior should automatically change the configured
  102520. * camera limits and sensibilities.
  102521. */
  102522. autoCorrectCameraLimitsAndSensibility: boolean;
  102523. private _onPrePointerObservableObserver;
  102524. private _onAfterCheckInputsObserver;
  102525. private _onMeshTargetChangedObserver;
  102526. private _attachedCamera;
  102527. private _isPointerDown;
  102528. private _lastInteractionTime;
  102529. /**
  102530. * Initializes the behavior.
  102531. */
  102532. init(): void;
  102533. /**
  102534. * Attaches the behavior to its arc rotate camera.
  102535. * @param camera Defines the camera to attach the behavior to
  102536. */
  102537. attach(camera: ArcRotateCamera): void;
  102538. /**
  102539. * Detaches the behavior from its current arc rotate camera.
  102540. */
  102541. detach(): void;
  102542. private _animatables;
  102543. private _betaIsAnimating;
  102544. private _betaTransition;
  102545. private _radiusTransition;
  102546. private _vectorTransition;
  102547. /**
  102548. * Targets the given mesh and updates zoom level accordingly.
  102549. * @param mesh The mesh to target.
  102550. * @param radius Optional. If a cached radius position already exists, overrides default.
  102551. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102552. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102553. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102554. */
  102555. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102556. /**
  102557. * Targets the given mesh with its children and updates zoom level accordingly.
  102558. * @param mesh The mesh to target.
  102559. * @param radius Optional. If a cached radius position already exists, overrides default.
  102560. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102561. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102562. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102563. */
  102564. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102565. /**
  102566. * Targets the given meshes with their children and updates zoom level accordingly.
  102567. * @param meshes The mesh to target.
  102568. * @param radius Optional. If a cached radius position already exists, overrides default.
  102569. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102570. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102571. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102572. */
  102573. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102574. /**
  102575. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102576. * @param minimumWorld Determines the smaller position of the bounding box extend
  102577. * @param maximumWorld Determines the bigger position of the bounding box extend
  102578. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102579. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102580. */
  102581. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102582. /**
  102583. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102584. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102585. * frustum width.
  102586. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102587. * to fully enclose the mesh in the viewing frustum.
  102588. */
  102589. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102590. /**
  102591. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102592. * is automatically returned to its default position (expected to be above ground plane).
  102593. */
  102594. private _maintainCameraAboveGround;
  102595. /**
  102596. * Returns the frustum slope based on the canvas ratio and camera FOV
  102597. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102598. */
  102599. private _getFrustumSlope;
  102600. /**
  102601. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102602. */
  102603. private _clearAnimationLocks;
  102604. /**
  102605. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102606. */
  102607. private _applyUserInteraction;
  102608. /**
  102609. * Stops and removes all animations that have been applied to the camera
  102610. */
  102611. stopAllAnimations(): void;
  102612. /**
  102613. * Gets a value indicating if the user is moving the camera
  102614. */
  102615. readonly isUserIsMoving: boolean;
  102616. /**
  102617. * The camera can move all the way towards the mesh.
  102618. */
  102619. static IgnoreBoundsSizeMode: number;
  102620. /**
  102621. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102622. */
  102623. static FitFrustumSidesMode: number;
  102624. }
  102625. }
  102626. declare module BABYLON {
  102627. /**
  102628. * Base class for Camera Pointer Inputs.
  102629. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102630. * for example usage.
  102631. */
  102632. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102633. /**
  102634. * Defines the camera the input is attached to.
  102635. */
  102636. abstract camera: Camera;
  102637. /**
  102638. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102639. */
  102640. protected _altKey: boolean;
  102641. protected _ctrlKey: boolean;
  102642. protected _metaKey: boolean;
  102643. protected _shiftKey: boolean;
  102644. /**
  102645. * Which mouse buttons were pressed at time of last mouse event.
  102646. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102647. */
  102648. protected _buttonsPressed: number;
  102649. /**
  102650. * Defines the buttons associated with the input to handle camera move.
  102651. */
  102652. buttons: number[];
  102653. /**
  102654. * Attach the input controls to a specific dom element to get the input from.
  102655. * @param element Defines the element the controls should be listened from
  102656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102657. */
  102658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102659. /**
  102660. * Detach the current controls from the specified dom element.
  102661. * @param element Defines the element to stop listening the inputs from
  102662. */
  102663. detachControl(element: Nullable<HTMLElement>): void;
  102664. /**
  102665. * Gets the class name of the current input.
  102666. * @returns the class name
  102667. */
  102668. getClassName(): string;
  102669. /**
  102670. * Get the friendly name associated with the input class.
  102671. * @returns the input friendly name
  102672. */
  102673. getSimpleName(): string;
  102674. /**
  102675. * Called on pointer POINTERDOUBLETAP event.
  102676. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102677. */
  102678. protected onDoubleTap(type: string): void;
  102679. /**
  102680. * Called on pointer POINTERMOVE event if only a single touch is active.
  102681. * Override this method to provide functionality.
  102682. */
  102683. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102684. /**
  102685. * Called on pointer POINTERMOVE event if multiple touches are active.
  102686. * Override this method to provide functionality.
  102687. */
  102688. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102689. /**
  102690. * Called on JS contextmenu event.
  102691. * Override this method to provide functionality.
  102692. */
  102693. protected onContextMenu(evt: PointerEvent): void;
  102694. /**
  102695. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102696. * press.
  102697. * Override this method to provide functionality.
  102698. */
  102699. protected onButtonDown(evt: PointerEvent): void;
  102700. /**
  102701. * Called each time a new POINTERUP event occurs. Ie, for each button
  102702. * release.
  102703. * Override this method to provide functionality.
  102704. */
  102705. protected onButtonUp(evt: PointerEvent): void;
  102706. /**
  102707. * Called when window becomes inactive.
  102708. * Override this method to provide functionality.
  102709. */
  102710. protected onLostFocus(): void;
  102711. private _pointerInput;
  102712. private _observer;
  102713. private _onLostFocus;
  102714. private pointA;
  102715. private pointB;
  102716. }
  102717. }
  102718. declare module BABYLON {
  102719. /**
  102720. * Manage the pointers inputs to control an arc rotate camera.
  102721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102722. */
  102723. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102724. /**
  102725. * Defines the camera the input is attached to.
  102726. */
  102727. camera: ArcRotateCamera;
  102728. /**
  102729. * Gets the class name of the current input.
  102730. * @returns the class name
  102731. */
  102732. getClassName(): string;
  102733. /**
  102734. * Defines the buttons associated with the input to handle camera move.
  102735. */
  102736. buttons: number[];
  102737. /**
  102738. * Defines the pointer angular sensibility along the X axis or how fast is
  102739. * the camera rotating.
  102740. */
  102741. angularSensibilityX: number;
  102742. /**
  102743. * Defines the pointer angular sensibility along the Y axis or how fast is
  102744. * the camera rotating.
  102745. */
  102746. angularSensibilityY: number;
  102747. /**
  102748. * Defines the pointer pinch precision or how fast is the camera zooming.
  102749. */
  102750. pinchPrecision: number;
  102751. /**
  102752. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102753. * from 0.
  102754. * It defines the percentage of current camera.radius to use as delta when
  102755. * pinch zoom is used.
  102756. */
  102757. pinchDeltaPercentage: number;
  102758. /**
  102759. * Defines the pointer panning sensibility or how fast is the camera moving.
  102760. */
  102761. panningSensibility: number;
  102762. /**
  102763. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102764. */
  102765. multiTouchPanning: boolean;
  102766. /**
  102767. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102768. * zoom (pinch) through multitouch.
  102769. */
  102770. multiTouchPanAndZoom: boolean;
  102771. /**
  102772. * Revers pinch action direction.
  102773. */
  102774. pinchInwards: boolean;
  102775. private _isPanClick;
  102776. private _twoFingerActivityCount;
  102777. private _isPinching;
  102778. /**
  102779. * Called on pointer POINTERMOVE event if only a single touch is active.
  102780. */
  102781. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102782. /**
  102783. * Called on pointer POINTERDOUBLETAP event.
  102784. */
  102785. protected onDoubleTap(type: string): void;
  102786. /**
  102787. * Called on pointer POINTERMOVE event if multiple touches are active.
  102788. */
  102789. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102790. /**
  102791. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102792. * press.
  102793. */
  102794. protected onButtonDown(evt: PointerEvent): void;
  102795. /**
  102796. * Called each time a new POINTERUP event occurs. Ie, for each button
  102797. * release.
  102798. */
  102799. protected onButtonUp(evt: PointerEvent): void;
  102800. /**
  102801. * Called when window becomes inactive.
  102802. */
  102803. protected onLostFocus(): void;
  102804. }
  102805. }
  102806. declare module BABYLON {
  102807. /**
  102808. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102810. */
  102811. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102812. /**
  102813. * Defines the camera the input is attached to.
  102814. */
  102815. camera: ArcRotateCamera;
  102816. /**
  102817. * Defines the list of key codes associated with the up action (increase alpha)
  102818. */
  102819. keysUp: number[];
  102820. /**
  102821. * Defines the list of key codes associated with the down action (decrease alpha)
  102822. */
  102823. keysDown: number[];
  102824. /**
  102825. * Defines the list of key codes associated with the left action (increase beta)
  102826. */
  102827. keysLeft: number[];
  102828. /**
  102829. * Defines the list of key codes associated with the right action (decrease beta)
  102830. */
  102831. keysRight: number[];
  102832. /**
  102833. * Defines the list of key codes associated with the reset action.
  102834. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102835. */
  102836. keysReset: number[];
  102837. /**
  102838. * Defines the panning sensibility of the inputs.
  102839. * (How fast is the camera paning)
  102840. */
  102841. panningSensibility: number;
  102842. /**
  102843. * Defines the zooming sensibility of the inputs.
  102844. * (How fast is the camera zooming)
  102845. */
  102846. zoomingSensibility: number;
  102847. /**
  102848. * Defines wether maintaining the alt key down switch the movement mode from
  102849. * orientation to zoom.
  102850. */
  102851. useAltToZoom: boolean;
  102852. /**
  102853. * Rotation speed of the camera
  102854. */
  102855. angularSpeed: number;
  102856. private _keys;
  102857. private _ctrlPressed;
  102858. private _altPressed;
  102859. private _onCanvasBlurObserver;
  102860. private _onKeyboardObserver;
  102861. private _engine;
  102862. private _scene;
  102863. /**
  102864. * Attach the input controls to a specific dom element to get the input from.
  102865. * @param element Defines the element the controls should be listened from
  102866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102867. */
  102868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102869. /**
  102870. * Detach the current controls from the specified dom element.
  102871. * @param element Defines the element to stop listening the inputs from
  102872. */
  102873. detachControl(element: Nullable<HTMLElement>): void;
  102874. /**
  102875. * Update the current camera state depending on the inputs that have been used this frame.
  102876. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102877. */
  102878. checkInputs(): void;
  102879. /**
  102880. * Gets the class name of the current intput.
  102881. * @returns the class name
  102882. */
  102883. getClassName(): string;
  102884. /**
  102885. * Get the friendly name associated with the input class.
  102886. * @returns the input friendly name
  102887. */
  102888. getSimpleName(): string;
  102889. }
  102890. }
  102891. declare module BABYLON {
  102892. /**
  102893. * Manage the mouse wheel inputs to control an arc rotate camera.
  102894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102895. */
  102896. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102897. /**
  102898. * Defines the camera the input is attached to.
  102899. */
  102900. camera: ArcRotateCamera;
  102901. /**
  102902. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102903. */
  102904. wheelPrecision: number;
  102905. /**
  102906. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102907. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102908. */
  102909. wheelDeltaPercentage: number;
  102910. private _wheel;
  102911. private _observer;
  102912. private computeDeltaFromMouseWheelLegacyEvent;
  102913. /**
  102914. * Attach the input controls to a specific dom element to get the input from.
  102915. * @param element Defines the element the controls should be listened from
  102916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102917. */
  102918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102919. /**
  102920. * Detach the current controls from the specified dom element.
  102921. * @param element Defines the element to stop listening the inputs from
  102922. */
  102923. detachControl(element: Nullable<HTMLElement>): void;
  102924. /**
  102925. * Gets the class name of the current intput.
  102926. * @returns the class name
  102927. */
  102928. getClassName(): string;
  102929. /**
  102930. * Get the friendly name associated with the input class.
  102931. * @returns the input friendly name
  102932. */
  102933. getSimpleName(): string;
  102934. }
  102935. }
  102936. declare module BABYLON {
  102937. /**
  102938. * Default Inputs manager for the ArcRotateCamera.
  102939. * It groups all the default supported inputs for ease of use.
  102940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102941. */
  102942. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  102943. /**
  102944. * Instantiates a new ArcRotateCameraInputsManager.
  102945. * @param camera Defines the camera the inputs belong to
  102946. */
  102947. constructor(camera: ArcRotateCamera);
  102948. /**
  102949. * Add mouse wheel input support to the input manager.
  102950. * @returns the current input manager
  102951. */
  102952. addMouseWheel(): ArcRotateCameraInputsManager;
  102953. /**
  102954. * Add pointers input support to the input manager.
  102955. * @returns the current input manager
  102956. */
  102957. addPointers(): ArcRotateCameraInputsManager;
  102958. /**
  102959. * Add keyboard input support to the input manager.
  102960. * @returns the current input manager
  102961. */
  102962. addKeyboard(): ArcRotateCameraInputsManager;
  102963. }
  102964. }
  102965. declare module BABYLON {
  102966. /**
  102967. * This represents an orbital type of camera.
  102968. *
  102969. * 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.
  102970. * 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.
  102971. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  102972. */
  102973. export class ArcRotateCamera extends TargetCamera {
  102974. /**
  102975. * Defines the rotation angle of the camera along the longitudinal axis.
  102976. */
  102977. alpha: number;
  102978. /**
  102979. * Defines the rotation angle of the camera along the latitudinal axis.
  102980. */
  102981. beta: number;
  102982. /**
  102983. * Defines the radius of the camera from it s target point.
  102984. */
  102985. radius: number;
  102986. protected _target: Vector3;
  102987. protected _targetHost: Nullable<AbstractMesh>;
  102988. /**
  102989. * Defines the target point of the camera.
  102990. * The camera looks towards it form the radius distance.
  102991. */
  102992. target: Vector3;
  102993. /**
  102994. * Define the current local position of the camera in the scene
  102995. */
  102996. position: Vector3;
  102997. protected _upVector: Vector3;
  102998. protected _upToYMatrix: Matrix;
  102999. protected _YToUpMatrix: Matrix;
  103000. /**
  103001. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103002. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103003. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103004. */
  103005. upVector: Vector3;
  103006. /**
  103007. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103008. */
  103009. setMatUp(): void;
  103010. /**
  103011. * Current inertia value on the longitudinal axis.
  103012. * The bigger this number the longer it will take for the camera to stop.
  103013. */
  103014. inertialAlphaOffset: number;
  103015. /**
  103016. * Current inertia value on the latitudinal axis.
  103017. * The bigger this number the longer it will take for the camera to stop.
  103018. */
  103019. inertialBetaOffset: number;
  103020. /**
  103021. * Current inertia value on the radius axis.
  103022. * The bigger this number the longer it will take for the camera to stop.
  103023. */
  103024. inertialRadiusOffset: number;
  103025. /**
  103026. * Minimum allowed angle on the longitudinal axis.
  103027. * This can help limiting how the Camera is able to move in the scene.
  103028. */
  103029. lowerAlphaLimit: Nullable<number>;
  103030. /**
  103031. * Maximum allowed angle on the longitudinal axis.
  103032. * This can help limiting how the Camera is able to move in the scene.
  103033. */
  103034. upperAlphaLimit: Nullable<number>;
  103035. /**
  103036. * Minimum allowed angle on the latitudinal axis.
  103037. * This can help limiting how the Camera is able to move in the scene.
  103038. */
  103039. lowerBetaLimit: number;
  103040. /**
  103041. * Maximum allowed angle on the latitudinal axis.
  103042. * This can help limiting how the Camera is able to move in the scene.
  103043. */
  103044. upperBetaLimit: number;
  103045. /**
  103046. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103047. * This can help limiting how the Camera is able to move in the scene.
  103048. */
  103049. lowerRadiusLimit: Nullable<number>;
  103050. /**
  103051. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103052. * This can help limiting how the Camera is able to move in the scene.
  103053. */
  103054. upperRadiusLimit: Nullable<number>;
  103055. /**
  103056. * Defines the current inertia value used during panning of the camera along the X axis.
  103057. */
  103058. inertialPanningX: number;
  103059. /**
  103060. * Defines the current inertia value used during panning of the camera along the Y axis.
  103061. */
  103062. inertialPanningY: number;
  103063. /**
  103064. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103065. * Basically if your fingers moves away from more than this distance you will be considered
  103066. * in pinch mode.
  103067. */
  103068. pinchToPanMaxDistance: number;
  103069. /**
  103070. * Defines the maximum distance the camera can pan.
  103071. * This could help keeping the cammera always in your scene.
  103072. */
  103073. panningDistanceLimit: Nullable<number>;
  103074. /**
  103075. * Defines the target of the camera before paning.
  103076. */
  103077. panningOriginTarget: Vector3;
  103078. /**
  103079. * Defines the value of the inertia used during panning.
  103080. * 0 would mean stop inertia and one would mean no decelleration at all.
  103081. */
  103082. panningInertia: number;
  103083. /**
  103084. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103085. */
  103086. angularSensibilityX: number;
  103087. /**
  103088. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103089. */
  103090. angularSensibilityY: number;
  103091. /**
  103092. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103093. */
  103094. pinchPrecision: number;
  103095. /**
  103096. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103097. * It will be used instead of pinchDeltaPrecision if different from 0.
  103098. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103099. */
  103100. pinchDeltaPercentage: number;
  103101. /**
  103102. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103103. */
  103104. panningSensibility: number;
  103105. /**
  103106. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103107. */
  103108. keysUp: number[];
  103109. /**
  103110. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103111. */
  103112. keysDown: number[];
  103113. /**
  103114. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103115. */
  103116. keysLeft: number[];
  103117. /**
  103118. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103119. */
  103120. keysRight: number[];
  103121. /**
  103122. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103123. */
  103124. wheelPrecision: number;
  103125. /**
  103126. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103127. * It will be used instead of pinchDeltaPrecision if different from 0.
  103128. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103129. */
  103130. wheelDeltaPercentage: number;
  103131. /**
  103132. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103133. */
  103134. zoomOnFactor: number;
  103135. /**
  103136. * Defines a screen offset for the camera position.
  103137. */
  103138. targetScreenOffset: Vector2;
  103139. /**
  103140. * Allows the camera to be completely reversed.
  103141. * If false the camera can not arrive upside down.
  103142. */
  103143. allowUpsideDown: boolean;
  103144. /**
  103145. * Define if double tap/click is used to restore the previously saved state of the camera.
  103146. */
  103147. useInputToRestoreState: boolean;
  103148. /** @hidden */
  103149. _viewMatrix: Matrix;
  103150. /** @hidden */
  103151. _useCtrlForPanning: boolean;
  103152. /** @hidden */
  103153. _panningMouseButton: number;
  103154. /**
  103155. * Defines the input associated to the camera.
  103156. */
  103157. inputs: ArcRotateCameraInputsManager;
  103158. /** @hidden */
  103159. _reset: () => void;
  103160. /**
  103161. * Defines the allowed panning axis.
  103162. */
  103163. panningAxis: Vector3;
  103164. protected _localDirection: Vector3;
  103165. protected _transformedDirection: Vector3;
  103166. private _bouncingBehavior;
  103167. /**
  103168. * Gets the bouncing behavior of the camera if it has been enabled.
  103169. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103170. */
  103171. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103172. /**
  103173. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103174. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103175. */
  103176. useBouncingBehavior: boolean;
  103177. private _framingBehavior;
  103178. /**
  103179. * Gets the framing behavior of the camera if it has been enabled.
  103180. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103181. */
  103182. readonly framingBehavior: Nullable<FramingBehavior>;
  103183. /**
  103184. * Defines if the framing behavior of the camera is enabled on the camera.
  103185. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103186. */
  103187. useFramingBehavior: boolean;
  103188. private _autoRotationBehavior;
  103189. /**
  103190. * Gets the auto rotation behavior of the camera if it has been enabled.
  103191. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103192. */
  103193. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103194. /**
  103195. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103196. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103197. */
  103198. useAutoRotationBehavior: boolean;
  103199. /**
  103200. * Observable triggered when the mesh target has been changed on the camera.
  103201. */
  103202. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103203. /**
  103204. * Event raised when the camera is colliding with a mesh.
  103205. */
  103206. onCollide: (collidedMesh: AbstractMesh) => void;
  103207. /**
  103208. * Defines whether the camera should check collision with the objects oh the scene.
  103209. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103210. */
  103211. checkCollisions: boolean;
  103212. /**
  103213. * Defines the collision radius of the camera.
  103214. * This simulates a sphere around the camera.
  103215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103216. */
  103217. collisionRadius: Vector3;
  103218. protected _collider: Collider;
  103219. protected _previousPosition: Vector3;
  103220. protected _collisionVelocity: Vector3;
  103221. protected _newPosition: Vector3;
  103222. protected _previousAlpha: number;
  103223. protected _previousBeta: number;
  103224. protected _previousRadius: number;
  103225. protected _collisionTriggered: boolean;
  103226. protected _targetBoundingCenter: Nullable<Vector3>;
  103227. private _computationVector;
  103228. /**
  103229. * Instantiates a new ArcRotateCamera in a given scene
  103230. * @param name Defines the name of the camera
  103231. * @param alpha Defines the camera rotation along the logitudinal axis
  103232. * @param beta Defines the camera rotation along the latitudinal axis
  103233. * @param radius Defines the camera distance from its target
  103234. * @param target Defines the camera target
  103235. * @param scene Defines the scene the camera belongs to
  103236. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103237. */
  103238. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103239. /** @hidden */
  103240. _initCache(): void;
  103241. /** @hidden */
  103242. _updateCache(ignoreParentClass?: boolean): void;
  103243. protected _getTargetPosition(): Vector3;
  103244. private _storedAlpha;
  103245. private _storedBeta;
  103246. private _storedRadius;
  103247. private _storedTarget;
  103248. private _storedTargetScreenOffset;
  103249. /**
  103250. * Stores the current state of the camera (alpha, beta, radius and target)
  103251. * @returns the camera itself
  103252. */
  103253. storeState(): Camera;
  103254. /**
  103255. * @hidden
  103256. * Restored camera state. You must call storeState() first
  103257. */
  103258. _restoreStateValues(): boolean;
  103259. /** @hidden */
  103260. _isSynchronizedViewMatrix(): boolean;
  103261. /**
  103262. * Attached controls to the current camera.
  103263. * @param element Defines the element the controls should be listened from
  103264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103265. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103266. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103267. */
  103268. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103269. /**
  103270. * Detach the current controls from the camera.
  103271. * The camera will stop reacting to inputs.
  103272. * @param element Defines the element to stop listening the inputs from
  103273. */
  103274. detachControl(element: HTMLElement): void;
  103275. /** @hidden */
  103276. _checkInputs(): void;
  103277. protected _checkLimits(): void;
  103278. /**
  103279. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103280. */
  103281. rebuildAnglesAndRadius(): void;
  103282. /**
  103283. * Use a position to define the current camera related information like aplha, beta and radius
  103284. * @param position Defines the position to set the camera at
  103285. */
  103286. setPosition(position: Vector3): void;
  103287. /**
  103288. * Defines the target the camera should look at.
  103289. * This will automatically adapt alpha beta and radius to fit within the new target.
  103290. * @param target Defines the new target as a Vector or a mesh
  103291. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103292. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103293. */
  103294. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103295. /** @hidden */
  103296. _getViewMatrix(): Matrix;
  103297. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103298. /**
  103299. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103300. * @param meshes Defines the mesh to zoom on
  103301. * @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)
  103302. */
  103303. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103304. /**
  103305. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103306. * The target will be changed but the radius
  103307. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103308. * @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)
  103309. */
  103310. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103311. min: Vector3;
  103312. max: Vector3;
  103313. distance: number;
  103314. }, doNotUpdateMaxZ?: boolean): void;
  103315. /**
  103316. * @override
  103317. * Override Camera.createRigCamera
  103318. */
  103319. createRigCamera(name: string, cameraIndex: number): Camera;
  103320. /**
  103321. * @hidden
  103322. * @override
  103323. * Override Camera._updateRigCameras
  103324. */
  103325. _updateRigCameras(): void;
  103326. /**
  103327. * Destroy the camera and release the current resources hold by it.
  103328. */
  103329. dispose(): void;
  103330. /**
  103331. * Gets the current object class name.
  103332. * @return the class name
  103333. */
  103334. getClassName(): string;
  103335. }
  103336. }
  103337. declare module BABYLON {
  103338. /**
  103339. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103340. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103341. */
  103342. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103343. /**
  103344. * Gets the name of the behavior.
  103345. */
  103346. readonly name: string;
  103347. private _zoomStopsAnimation;
  103348. private _idleRotationSpeed;
  103349. private _idleRotationWaitTime;
  103350. private _idleRotationSpinupTime;
  103351. /**
  103352. * Sets the flag that indicates if user zooming should stop animation.
  103353. */
  103354. /**
  103355. * Gets the flag that indicates if user zooming should stop animation.
  103356. */
  103357. zoomStopsAnimation: boolean;
  103358. /**
  103359. * Sets the default speed at which the camera rotates around the model.
  103360. */
  103361. /**
  103362. * Gets the default speed at which the camera rotates around the model.
  103363. */
  103364. idleRotationSpeed: number;
  103365. /**
  103366. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103367. */
  103368. /**
  103369. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103370. */
  103371. idleRotationWaitTime: number;
  103372. /**
  103373. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103374. */
  103375. /**
  103376. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103377. */
  103378. idleRotationSpinupTime: number;
  103379. /**
  103380. * Gets a value indicating if the camera is currently rotating because of this behavior
  103381. */
  103382. readonly rotationInProgress: boolean;
  103383. private _onPrePointerObservableObserver;
  103384. private _onAfterCheckInputsObserver;
  103385. private _attachedCamera;
  103386. private _isPointerDown;
  103387. private _lastFrameTime;
  103388. private _lastInteractionTime;
  103389. private _cameraRotationSpeed;
  103390. /**
  103391. * Initializes the behavior.
  103392. */
  103393. init(): void;
  103394. /**
  103395. * Attaches the behavior to its arc rotate camera.
  103396. * @param camera Defines the camera to attach the behavior to
  103397. */
  103398. attach(camera: ArcRotateCamera): void;
  103399. /**
  103400. * Detaches the behavior from its current arc rotate camera.
  103401. */
  103402. detach(): void;
  103403. /**
  103404. * Returns true if user is scrolling.
  103405. * @return true if user is scrolling.
  103406. */
  103407. private _userIsZooming;
  103408. private _lastFrameRadius;
  103409. private _shouldAnimationStopForInteraction;
  103410. /**
  103411. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103412. */
  103413. private _applyUserInteraction;
  103414. private _userIsMoving;
  103415. }
  103416. }
  103417. declare module BABYLON {
  103418. /**
  103419. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103420. */
  103421. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103422. private ui;
  103423. /**
  103424. * The name of the behavior
  103425. */
  103426. name: string;
  103427. /**
  103428. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103429. */
  103430. distanceAwayFromFace: number;
  103431. /**
  103432. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103433. */
  103434. distanceAwayFromBottomOfFace: number;
  103435. private _faceVectors;
  103436. private _target;
  103437. private _scene;
  103438. private _onRenderObserver;
  103439. private _tmpMatrix;
  103440. private _tmpVector;
  103441. /**
  103442. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103443. * @param ui The transform node that should be attched to the mesh
  103444. */
  103445. constructor(ui: TransformNode);
  103446. /**
  103447. * Initializes the behavior
  103448. */
  103449. init(): void;
  103450. private _closestFace;
  103451. private _zeroVector;
  103452. private _lookAtTmpMatrix;
  103453. private _lookAtToRef;
  103454. /**
  103455. * Attaches the AttachToBoxBehavior to the passed in mesh
  103456. * @param target The mesh that the specified node will be attached to
  103457. */
  103458. attach(target: Mesh): void;
  103459. /**
  103460. * Detaches the behavior from the mesh
  103461. */
  103462. detach(): void;
  103463. }
  103464. }
  103465. declare module BABYLON {
  103466. /**
  103467. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103468. */
  103469. export class FadeInOutBehavior implements Behavior<Mesh> {
  103470. /**
  103471. * Time in milliseconds to delay before fading in (Default: 0)
  103472. */
  103473. delay: number;
  103474. /**
  103475. * Time in milliseconds for the mesh to fade in (Default: 300)
  103476. */
  103477. fadeInTime: number;
  103478. private _millisecondsPerFrame;
  103479. private _hovered;
  103480. private _hoverValue;
  103481. private _ownerNode;
  103482. /**
  103483. * Instatiates the FadeInOutBehavior
  103484. */
  103485. constructor();
  103486. /**
  103487. * The name of the behavior
  103488. */
  103489. readonly name: string;
  103490. /**
  103491. * Initializes the behavior
  103492. */
  103493. init(): void;
  103494. /**
  103495. * Attaches the fade behavior on the passed in mesh
  103496. * @param ownerNode The mesh that will be faded in/out once attached
  103497. */
  103498. attach(ownerNode: Mesh): void;
  103499. /**
  103500. * Detaches the behavior from the mesh
  103501. */
  103502. detach(): void;
  103503. /**
  103504. * Triggers the mesh to begin fading in or out
  103505. * @param value if the object should fade in or out (true to fade in)
  103506. */
  103507. fadeIn(value: boolean): void;
  103508. private _update;
  103509. private _setAllVisibility;
  103510. }
  103511. }
  103512. declare module BABYLON {
  103513. /**
  103514. * Class containing a set of static utilities functions for managing Pivots
  103515. * @hidden
  103516. */
  103517. export class PivotTools {
  103518. private static _PivotCached;
  103519. private static _OldPivotPoint;
  103520. private static _PivotTranslation;
  103521. private static _PivotTmpVector;
  103522. /** @hidden */
  103523. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103524. /** @hidden */
  103525. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103526. }
  103527. }
  103528. declare module BABYLON {
  103529. /**
  103530. * Class containing static functions to help procedurally build meshes
  103531. */
  103532. export class PlaneBuilder {
  103533. /**
  103534. * Creates a plane mesh
  103535. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103536. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103537. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103541. * @param name defines the name of the mesh
  103542. * @param options defines the options used to create the mesh
  103543. * @param scene defines the hosting scene
  103544. * @returns the plane mesh
  103545. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103546. */
  103547. static CreatePlane(name: string, options: {
  103548. size?: number;
  103549. width?: number;
  103550. height?: number;
  103551. sideOrientation?: number;
  103552. frontUVs?: Vector4;
  103553. backUVs?: Vector4;
  103554. updatable?: boolean;
  103555. sourcePlane?: Plane;
  103556. }, scene?: Nullable<Scene>): Mesh;
  103557. }
  103558. }
  103559. declare module BABYLON {
  103560. /**
  103561. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103562. */
  103563. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103564. private static _AnyMouseID;
  103565. /**
  103566. * Abstract mesh the behavior is set on
  103567. */
  103568. attachedNode: AbstractMesh;
  103569. private _dragPlane;
  103570. private _scene;
  103571. private _pointerObserver;
  103572. private _beforeRenderObserver;
  103573. private static _planeScene;
  103574. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103575. /**
  103576. * 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)
  103577. */
  103578. maxDragAngle: number;
  103579. /**
  103580. * @hidden
  103581. */
  103582. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103583. /**
  103584. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103585. */
  103586. currentDraggingPointerID: number;
  103587. /**
  103588. * The last position where the pointer hit the drag plane in world space
  103589. */
  103590. lastDragPosition: Vector3;
  103591. /**
  103592. * If the behavior is currently in a dragging state
  103593. */
  103594. dragging: boolean;
  103595. /**
  103596. * 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)
  103597. */
  103598. dragDeltaRatio: number;
  103599. /**
  103600. * If the drag plane orientation should be updated during the dragging (Default: true)
  103601. */
  103602. updateDragPlane: boolean;
  103603. private _debugMode;
  103604. private _moving;
  103605. /**
  103606. * Fires each time the attached mesh is dragged with the pointer
  103607. * * delta between last drag position and current drag position in world space
  103608. * * dragDistance along the drag axis
  103609. * * dragPlaneNormal normal of the current drag plane used during the drag
  103610. * * dragPlanePoint in world space where the drag intersects the drag plane
  103611. */
  103612. onDragObservable: Observable<{
  103613. delta: Vector3;
  103614. dragPlanePoint: Vector3;
  103615. dragPlaneNormal: Vector3;
  103616. dragDistance: number;
  103617. pointerId: number;
  103618. }>;
  103619. /**
  103620. * Fires each time a drag begins (eg. mouse down on mesh)
  103621. */
  103622. onDragStartObservable: Observable<{
  103623. dragPlanePoint: Vector3;
  103624. pointerId: number;
  103625. }>;
  103626. /**
  103627. * Fires each time a drag ends (eg. mouse release after drag)
  103628. */
  103629. onDragEndObservable: Observable<{
  103630. dragPlanePoint: Vector3;
  103631. pointerId: number;
  103632. }>;
  103633. /**
  103634. * If the attached mesh should be moved when dragged
  103635. */
  103636. moveAttached: boolean;
  103637. /**
  103638. * If the drag behavior will react to drag events (Default: true)
  103639. */
  103640. enabled: boolean;
  103641. /**
  103642. * If pointer events should start and release the drag (Default: true)
  103643. */
  103644. startAndReleaseDragOnPointerEvents: boolean;
  103645. /**
  103646. * If camera controls should be detached during the drag
  103647. */
  103648. detachCameraControls: boolean;
  103649. /**
  103650. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103651. */
  103652. useObjectOrienationForDragging: boolean;
  103653. private _options;
  103654. /**
  103655. * Creates a pointer drag behavior that can be attached to a mesh
  103656. * @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)
  103657. */
  103658. constructor(options?: {
  103659. dragAxis?: Vector3;
  103660. dragPlaneNormal?: Vector3;
  103661. });
  103662. /**
  103663. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103664. */
  103665. validateDrag: (targetPosition: Vector3) => boolean;
  103666. /**
  103667. * The name of the behavior
  103668. */
  103669. readonly name: string;
  103670. /**
  103671. * Initializes the behavior
  103672. */
  103673. init(): void;
  103674. private _tmpVector;
  103675. private _alternatePickedPoint;
  103676. private _worldDragAxis;
  103677. private _targetPosition;
  103678. private _attachedElement;
  103679. /**
  103680. * Attaches the drag behavior the passed in mesh
  103681. * @param ownerNode The mesh that will be dragged around once attached
  103682. * @param predicate Predicate to use for pick filtering
  103683. */
  103684. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103685. /**
  103686. * Force relase the drag action by code.
  103687. */
  103688. releaseDrag(): void;
  103689. private _startDragRay;
  103690. private _lastPointerRay;
  103691. /**
  103692. * Simulates the start of a pointer drag event on the behavior
  103693. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103694. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103695. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103696. */
  103697. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103698. private _startDrag;
  103699. private _dragDelta;
  103700. private _moveDrag;
  103701. private _pickWithRayOnDragPlane;
  103702. private _pointA;
  103703. private _pointB;
  103704. private _pointC;
  103705. private _lineA;
  103706. private _lineB;
  103707. private _localAxis;
  103708. private _lookAt;
  103709. private _updateDragPlanePosition;
  103710. /**
  103711. * Detaches the behavior from the mesh
  103712. */
  103713. detach(): void;
  103714. }
  103715. }
  103716. declare module BABYLON {
  103717. /**
  103718. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103719. */
  103720. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103721. private _dragBehaviorA;
  103722. private _dragBehaviorB;
  103723. private _startDistance;
  103724. private _initialScale;
  103725. private _targetScale;
  103726. private _ownerNode;
  103727. private _sceneRenderObserver;
  103728. /**
  103729. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103730. */
  103731. constructor();
  103732. /**
  103733. * The name of the behavior
  103734. */
  103735. readonly name: string;
  103736. /**
  103737. * Initializes the behavior
  103738. */
  103739. init(): void;
  103740. private _getCurrentDistance;
  103741. /**
  103742. * Attaches the scale behavior the passed in mesh
  103743. * @param ownerNode The mesh that will be scaled around once attached
  103744. */
  103745. attach(ownerNode: Mesh): void;
  103746. /**
  103747. * Detaches the behavior from the mesh
  103748. */
  103749. detach(): void;
  103750. }
  103751. }
  103752. declare module BABYLON {
  103753. /**
  103754. * 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
  103755. */
  103756. export class SixDofDragBehavior implements Behavior<Mesh> {
  103757. private static _virtualScene;
  103758. private _ownerNode;
  103759. private _sceneRenderObserver;
  103760. private _scene;
  103761. private _targetPosition;
  103762. private _virtualOriginMesh;
  103763. private _virtualDragMesh;
  103764. private _pointerObserver;
  103765. private _moving;
  103766. private _startingOrientation;
  103767. /**
  103768. * 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)
  103769. */
  103770. private zDragFactor;
  103771. /**
  103772. * If the object should rotate to face the drag origin
  103773. */
  103774. rotateDraggedObject: boolean;
  103775. /**
  103776. * If the behavior is currently in a dragging state
  103777. */
  103778. dragging: boolean;
  103779. /**
  103780. * 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)
  103781. */
  103782. dragDeltaRatio: number;
  103783. /**
  103784. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103785. */
  103786. currentDraggingPointerID: number;
  103787. /**
  103788. * If camera controls should be detached during the drag
  103789. */
  103790. detachCameraControls: boolean;
  103791. /**
  103792. * Fires each time a drag starts
  103793. */
  103794. onDragStartObservable: Observable<{}>;
  103795. /**
  103796. * Fires each time a drag ends (eg. mouse release after drag)
  103797. */
  103798. onDragEndObservable: Observable<{}>;
  103799. /**
  103800. * 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
  103801. */
  103802. constructor();
  103803. /**
  103804. * The name of the behavior
  103805. */
  103806. readonly name: string;
  103807. /**
  103808. * Initializes the behavior
  103809. */
  103810. init(): void;
  103811. /**
  103812. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103813. */
  103814. private readonly _pointerCamera;
  103815. /**
  103816. * Attaches the scale behavior the passed in mesh
  103817. * @param ownerNode The mesh that will be scaled around once attached
  103818. */
  103819. attach(ownerNode: Mesh): void;
  103820. /**
  103821. * Detaches the behavior from the mesh
  103822. */
  103823. detach(): void;
  103824. }
  103825. }
  103826. declare module BABYLON {
  103827. /**
  103828. * Class used to apply inverse kinematics to bones
  103829. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103830. */
  103831. export class BoneIKController {
  103832. private static _tmpVecs;
  103833. private static _tmpQuat;
  103834. private static _tmpMats;
  103835. /**
  103836. * Gets or sets the target mesh
  103837. */
  103838. targetMesh: AbstractMesh;
  103839. /** Gets or sets the mesh used as pole */
  103840. poleTargetMesh: AbstractMesh;
  103841. /**
  103842. * Gets or sets the bone used as pole
  103843. */
  103844. poleTargetBone: Nullable<Bone>;
  103845. /**
  103846. * Gets or sets the target position
  103847. */
  103848. targetPosition: Vector3;
  103849. /**
  103850. * Gets or sets the pole target position
  103851. */
  103852. poleTargetPosition: Vector3;
  103853. /**
  103854. * Gets or sets the pole target local offset
  103855. */
  103856. poleTargetLocalOffset: Vector3;
  103857. /**
  103858. * Gets or sets the pole angle
  103859. */
  103860. poleAngle: number;
  103861. /**
  103862. * Gets or sets the mesh associated with the controller
  103863. */
  103864. mesh: AbstractMesh;
  103865. /**
  103866. * 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)
  103867. */
  103868. slerpAmount: number;
  103869. private _bone1Quat;
  103870. private _bone1Mat;
  103871. private _bone2Ang;
  103872. private _bone1;
  103873. private _bone2;
  103874. private _bone1Length;
  103875. private _bone2Length;
  103876. private _maxAngle;
  103877. private _maxReach;
  103878. private _rightHandedSystem;
  103879. private _bendAxis;
  103880. private _slerping;
  103881. private _adjustRoll;
  103882. /**
  103883. * Gets or sets maximum allowed angle
  103884. */
  103885. maxAngle: number;
  103886. /**
  103887. * Creates a new BoneIKController
  103888. * @param mesh defines the mesh to control
  103889. * @param bone defines the bone to control
  103890. * @param options defines options to set up the controller
  103891. */
  103892. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103893. targetMesh?: AbstractMesh;
  103894. poleTargetMesh?: AbstractMesh;
  103895. poleTargetBone?: Bone;
  103896. poleTargetLocalOffset?: Vector3;
  103897. poleAngle?: number;
  103898. bendAxis?: Vector3;
  103899. maxAngle?: number;
  103900. slerpAmount?: number;
  103901. });
  103902. private _setMaxAngle;
  103903. /**
  103904. * Force the controller to update the bones
  103905. */
  103906. update(): void;
  103907. }
  103908. }
  103909. declare module BABYLON {
  103910. /**
  103911. * Class used to make a bone look toward a point in space
  103912. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  103913. */
  103914. export class BoneLookController {
  103915. private static _tmpVecs;
  103916. private static _tmpQuat;
  103917. private static _tmpMats;
  103918. /**
  103919. * The target Vector3 that the bone will look at
  103920. */
  103921. target: Vector3;
  103922. /**
  103923. * The mesh that the bone is attached to
  103924. */
  103925. mesh: AbstractMesh;
  103926. /**
  103927. * The bone that will be looking to the target
  103928. */
  103929. bone: Bone;
  103930. /**
  103931. * The up axis of the coordinate system that is used when the bone is rotated
  103932. */
  103933. upAxis: Vector3;
  103934. /**
  103935. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  103936. */
  103937. upAxisSpace: Space;
  103938. /**
  103939. * Used to make an adjustment to the yaw of the bone
  103940. */
  103941. adjustYaw: number;
  103942. /**
  103943. * Used to make an adjustment to the pitch of the bone
  103944. */
  103945. adjustPitch: number;
  103946. /**
  103947. * Used to make an adjustment to the roll of the bone
  103948. */
  103949. adjustRoll: number;
  103950. /**
  103951. * 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)
  103952. */
  103953. slerpAmount: number;
  103954. private _minYaw;
  103955. private _maxYaw;
  103956. private _minPitch;
  103957. private _maxPitch;
  103958. private _minYawSin;
  103959. private _minYawCos;
  103960. private _maxYawSin;
  103961. private _maxYawCos;
  103962. private _midYawConstraint;
  103963. private _minPitchTan;
  103964. private _maxPitchTan;
  103965. private _boneQuat;
  103966. private _slerping;
  103967. private _transformYawPitch;
  103968. private _transformYawPitchInv;
  103969. private _firstFrameSkipped;
  103970. private _yawRange;
  103971. private _fowardAxis;
  103972. /**
  103973. * Gets or sets the minimum yaw angle that the bone can look to
  103974. */
  103975. minYaw: number;
  103976. /**
  103977. * Gets or sets the maximum yaw angle that the bone can look to
  103978. */
  103979. maxYaw: number;
  103980. /**
  103981. * Gets or sets the minimum pitch angle that the bone can look to
  103982. */
  103983. minPitch: number;
  103984. /**
  103985. * Gets or sets the maximum pitch angle that the bone can look to
  103986. */
  103987. maxPitch: number;
  103988. /**
  103989. * Create a BoneLookController
  103990. * @param mesh the mesh that the bone belongs to
  103991. * @param bone the bone that will be looking to the target
  103992. * @param target the target Vector3 to look at
  103993. * @param options optional settings:
  103994. * * maxYaw: the maximum angle the bone will yaw to
  103995. * * minYaw: the minimum angle the bone will yaw to
  103996. * * maxPitch: the maximum angle the bone will pitch to
  103997. * * minPitch: the minimum angle the bone will yaw to
  103998. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  103999. * * upAxis: the up axis of the coordinate system
  104000. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104001. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104002. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104003. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104004. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104005. * * adjustRoll: used to make an adjustment to the roll of the bone
  104006. **/
  104007. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104008. maxYaw?: number;
  104009. minYaw?: number;
  104010. maxPitch?: number;
  104011. minPitch?: number;
  104012. slerpAmount?: number;
  104013. upAxis?: Vector3;
  104014. upAxisSpace?: Space;
  104015. yawAxis?: Vector3;
  104016. pitchAxis?: Vector3;
  104017. adjustYaw?: number;
  104018. adjustPitch?: number;
  104019. adjustRoll?: number;
  104020. });
  104021. /**
  104022. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104023. */
  104024. update(): void;
  104025. private _getAngleDiff;
  104026. private _getAngleBetween;
  104027. private _isAngleBetween;
  104028. }
  104029. }
  104030. declare module BABYLON {
  104031. /**
  104032. * Manage the gamepad inputs to control an arc rotate camera.
  104033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104034. */
  104035. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104036. /**
  104037. * Defines the camera the input is attached to.
  104038. */
  104039. camera: ArcRotateCamera;
  104040. /**
  104041. * Defines the gamepad the input is gathering event from.
  104042. */
  104043. gamepad: Nullable<Gamepad>;
  104044. /**
  104045. * Defines the gamepad rotation sensiblity.
  104046. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104047. */
  104048. gamepadRotationSensibility: number;
  104049. /**
  104050. * Defines the gamepad move sensiblity.
  104051. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104052. */
  104053. gamepadMoveSensibility: number;
  104054. private _onGamepadConnectedObserver;
  104055. private _onGamepadDisconnectedObserver;
  104056. /**
  104057. * Attach the input controls to a specific dom element to get the input from.
  104058. * @param element Defines the element the controls should be listened from
  104059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104060. */
  104061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104062. /**
  104063. * Detach the current controls from the specified dom element.
  104064. * @param element Defines the element to stop listening the inputs from
  104065. */
  104066. detachControl(element: Nullable<HTMLElement>): void;
  104067. /**
  104068. * Update the current camera state depending on the inputs that have been used this frame.
  104069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104070. */
  104071. checkInputs(): void;
  104072. /**
  104073. * Gets the class name of the current intput.
  104074. * @returns the class name
  104075. */
  104076. getClassName(): string;
  104077. /**
  104078. * Get the friendly name associated with the input class.
  104079. * @returns the input friendly name
  104080. */
  104081. getSimpleName(): string;
  104082. }
  104083. }
  104084. declare module BABYLON {
  104085. interface ArcRotateCameraInputsManager {
  104086. /**
  104087. * Add orientation input support to the input manager.
  104088. * @returns the current input manager
  104089. */
  104090. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104091. }
  104092. /**
  104093. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104095. */
  104096. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104097. /**
  104098. * Defines the camera the input is attached to.
  104099. */
  104100. camera: ArcRotateCamera;
  104101. /**
  104102. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104103. */
  104104. alphaCorrection: number;
  104105. /**
  104106. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104107. */
  104108. gammaCorrection: number;
  104109. private _alpha;
  104110. private _gamma;
  104111. private _dirty;
  104112. private _deviceOrientationHandler;
  104113. /**
  104114. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104115. */
  104116. constructor();
  104117. /**
  104118. * Attach the input controls to a specific dom element to get the input from.
  104119. * @param element Defines the element the controls should be listened from
  104120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104121. */
  104122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104123. /** @hidden */
  104124. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104125. /**
  104126. * Update the current camera state depending on the inputs that have been used this frame.
  104127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104128. */
  104129. checkInputs(): void;
  104130. /**
  104131. * Detach the current controls from the specified dom element.
  104132. * @param element Defines the element to stop listening the inputs from
  104133. */
  104134. detachControl(element: Nullable<HTMLElement>): void;
  104135. /**
  104136. * Gets the class name of the current intput.
  104137. * @returns the class name
  104138. */
  104139. getClassName(): string;
  104140. /**
  104141. * Get the friendly name associated with the input class.
  104142. * @returns the input friendly name
  104143. */
  104144. getSimpleName(): string;
  104145. }
  104146. }
  104147. declare module BABYLON {
  104148. /**
  104149. * Listen to mouse events to control the camera.
  104150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104151. */
  104152. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104153. /**
  104154. * Defines the camera the input is attached to.
  104155. */
  104156. camera: FlyCamera;
  104157. /**
  104158. * Defines if touch is enabled. (Default is true.)
  104159. */
  104160. touchEnabled: boolean;
  104161. /**
  104162. * Defines the buttons associated with the input to handle camera rotation.
  104163. */
  104164. buttons: number[];
  104165. /**
  104166. * Assign buttons for Yaw control.
  104167. */
  104168. buttonsYaw: number[];
  104169. /**
  104170. * Assign buttons for Pitch control.
  104171. */
  104172. buttonsPitch: number[];
  104173. /**
  104174. * Assign buttons for Roll control.
  104175. */
  104176. buttonsRoll: number[];
  104177. /**
  104178. * Detect if any button is being pressed while mouse is moved.
  104179. * -1 = Mouse locked.
  104180. * 0 = Left button.
  104181. * 1 = Middle Button.
  104182. * 2 = Right Button.
  104183. */
  104184. activeButton: number;
  104185. /**
  104186. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104187. * Higher values reduce its sensitivity.
  104188. */
  104189. angularSensibility: number;
  104190. private _mousemoveCallback;
  104191. private _observer;
  104192. private _rollObserver;
  104193. private previousPosition;
  104194. private noPreventDefault;
  104195. private element;
  104196. /**
  104197. * Listen to mouse events to control the camera.
  104198. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104200. */
  104201. constructor(touchEnabled?: boolean);
  104202. /**
  104203. * Attach the mouse control to the HTML DOM element.
  104204. * @param element Defines the element that listens to the input events.
  104205. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104206. */
  104207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104208. /**
  104209. * Detach the current controls from the specified dom element.
  104210. * @param element Defines the element to stop listening the inputs from
  104211. */
  104212. detachControl(element: Nullable<HTMLElement>): void;
  104213. /**
  104214. * Gets the class name of the current input.
  104215. * @returns the class name.
  104216. */
  104217. getClassName(): string;
  104218. /**
  104219. * Get the friendly name associated with the input class.
  104220. * @returns the input's friendly name.
  104221. */
  104222. getSimpleName(): string;
  104223. private _pointerInput;
  104224. private _onMouseMove;
  104225. /**
  104226. * Rotate camera by mouse offset.
  104227. */
  104228. private rotateCamera;
  104229. }
  104230. }
  104231. declare module BABYLON {
  104232. /**
  104233. * Default Inputs manager for the FlyCamera.
  104234. * It groups all the default supported inputs for ease of use.
  104235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104236. */
  104237. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104238. /**
  104239. * Instantiates a new FlyCameraInputsManager.
  104240. * @param camera Defines the camera the inputs belong to.
  104241. */
  104242. constructor(camera: FlyCamera);
  104243. /**
  104244. * Add keyboard input support to the input manager.
  104245. * @returns the new FlyCameraKeyboardMoveInput().
  104246. */
  104247. addKeyboard(): FlyCameraInputsManager;
  104248. /**
  104249. * Add mouse input support to the input manager.
  104250. * @param touchEnabled Enable touch screen support.
  104251. * @returns the new FlyCameraMouseInput().
  104252. */
  104253. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104254. }
  104255. }
  104256. declare module BABYLON {
  104257. /**
  104258. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104259. * such as in a 3D Space Shooter or a Flight Simulator.
  104260. */
  104261. export class FlyCamera extends TargetCamera {
  104262. /**
  104263. * Define the collision ellipsoid of the camera.
  104264. * This is helpful for simulating a camera body, like a player's body.
  104265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104266. */
  104267. ellipsoid: Vector3;
  104268. /**
  104269. * Define an offset for the position of the ellipsoid around the camera.
  104270. * This can be helpful if the camera is attached away from the player's body center,
  104271. * such as at its head.
  104272. */
  104273. ellipsoidOffset: Vector3;
  104274. /**
  104275. * Enable or disable collisions of the camera with the rest of the scene objects.
  104276. */
  104277. checkCollisions: boolean;
  104278. /**
  104279. * Enable or disable gravity on the camera.
  104280. */
  104281. applyGravity: boolean;
  104282. /**
  104283. * Define the current direction the camera is moving to.
  104284. */
  104285. cameraDirection: Vector3;
  104286. /**
  104287. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104288. * This overrides and empties cameraRotation.
  104289. */
  104290. rotationQuaternion: Quaternion;
  104291. /**
  104292. * Track Roll to maintain the wanted Rolling when looking around.
  104293. */
  104294. _trackRoll: number;
  104295. /**
  104296. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104297. */
  104298. rollCorrect: number;
  104299. /**
  104300. * Mimic a banked turn, Rolling the camera when Yawing.
  104301. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104302. */
  104303. bankedTurn: boolean;
  104304. /**
  104305. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104306. */
  104307. bankedTurnLimit: number;
  104308. /**
  104309. * Value of 0 disables the banked Roll.
  104310. * Value of 1 is equal to the Yaw angle in radians.
  104311. */
  104312. bankedTurnMultiplier: number;
  104313. /**
  104314. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104315. */
  104316. inputs: FlyCameraInputsManager;
  104317. /**
  104318. * Gets the input sensibility for mouse input.
  104319. * Higher values reduce sensitivity.
  104320. */
  104321. /**
  104322. * Sets the input sensibility for a mouse input.
  104323. * Higher values reduce sensitivity.
  104324. */
  104325. angularSensibility: number;
  104326. /**
  104327. * Get the keys for camera movement forward.
  104328. */
  104329. /**
  104330. * Set the keys for camera movement forward.
  104331. */
  104332. keysForward: number[];
  104333. /**
  104334. * Get the keys for camera movement backward.
  104335. */
  104336. keysBackward: number[];
  104337. /**
  104338. * Get the keys for camera movement up.
  104339. */
  104340. /**
  104341. * Set the keys for camera movement up.
  104342. */
  104343. keysUp: number[];
  104344. /**
  104345. * Get the keys for camera movement down.
  104346. */
  104347. /**
  104348. * Set the keys for camera movement down.
  104349. */
  104350. keysDown: number[];
  104351. /**
  104352. * Get the keys for camera movement left.
  104353. */
  104354. /**
  104355. * Set the keys for camera movement left.
  104356. */
  104357. keysLeft: number[];
  104358. /**
  104359. * Set the keys for camera movement right.
  104360. */
  104361. /**
  104362. * Set the keys for camera movement right.
  104363. */
  104364. keysRight: number[];
  104365. /**
  104366. * Event raised when the camera collides with a mesh in the scene.
  104367. */
  104368. onCollide: (collidedMesh: AbstractMesh) => void;
  104369. private _collider;
  104370. private _needMoveForGravity;
  104371. private _oldPosition;
  104372. private _diffPosition;
  104373. private _newPosition;
  104374. /** @hidden */
  104375. _localDirection: Vector3;
  104376. /** @hidden */
  104377. _transformedDirection: Vector3;
  104378. /**
  104379. * Instantiates a FlyCamera.
  104380. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104381. * such as in a 3D Space Shooter or a Flight Simulator.
  104382. * @param name Define the name of the camera in the scene.
  104383. * @param position Define the starting position of the camera in the scene.
  104384. * @param scene Define the scene the camera belongs to.
  104385. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104386. */
  104387. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104388. /**
  104389. * Attach a control to the HTML DOM element.
  104390. * @param element Defines the element that listens to the input events.
  104391. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104392. */
  104393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104394. /**
  104395. * Detach a control from the HTML DOM element.
  104396. * The camera will stop reacting to that input.
  104397. * @param element Defines the element that listens to the input events.
  104398. */
  104399. detachControl(element: HTMLElement): void;
  104400. private _collisionMask;
  104401. /**
  104402. * Get the mask that the camera ignores in collision events.
  104403. */
  104404. /**
  104405. * Set the mask that the camera ignores in collision events.
  104406. */
  104407. collisionMask: number;
  104408. /** @hidden */
  104409. _collideWithWorld(displacement: Vector3): void;
  104410. /** @hidden */
  104411. private _onCollisionPositionChange;
  104412. /** @hidden */
  104413. _checkInputs(): void;
  104414. /** @hidden */
  104415. _decideIfNeedsToMove(): boolean;
  104416. /** @hidden */
  104417. _updatePosition(): void;
  104418. /**
  104419. * Restore the Roll to its target value at the rate specified.
  104420. * @param rate - Higher means slower restoring.
  104421. * @hidden
  104422. */
  104423. restoreRoll(rate: number): void;
  104424. /**
  104425. * Destroy the camera and release the current resources held by it.
  104426. */
  104427. dispose(): void;
  104428. /**
  104429. * Get the current object class name.
  104430. * @returns the class name.
  104431. */
  104432. getClassName(): string;
  104433. }
  104434. }
  104435. declare module BABYLON {
  104436. /**
  104437. * Listen to keyboard events to control the camera.
  104438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104439. */
  104440. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104441. /**
  104442. * Defines the camera the input is attached to.
  104443. */
  104444. camera: FlyCamera;
  104445. /**
  104446. * The list of keyboard keys used to control the forward move of the camera.
  104447. */
  104448. keysForward: number[];
  104449. /**
  104450. * The list of keyboard keys used to control the backward move of the camera.
  104451. */
  104452. keysBackward: number[];
  104453. /**
  104454. * The list of keyboard keys used to control the forward move of the camera.
  104455. */
  104456. keysUp: number[];
  104457. /**
  104458. * The list of keyboard keys used to control the backward move of the camera.
  104459. */
  104460. keysDown: number[];
  104461. /**
  104462. * The list of keyboard keys used to control the right strafe move of the camera.
  104463. */
  104464. keysRight: number[];
  104465. /**
  104466. * The list of keyboard keys used to control the left strafe move of the camera.
  104467. */
  104468. keysLeft: number[];
  104469. private _keys;
  104470. private _onCanvasBlurObserver;
  104471. private _onKeyboardObserver;
  104472. private _engine;
  104473. private _scene;
  104474. /**
  104475. * Attach the input controls to a specific dom element to get the input from.
  104476. * @param element Defines the element the controls should be listened from
  104477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104478. */
  104479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104480. /**
  104481. * Detach the current controls from the specified dom element.
  104482. * @param element Defines the element to stop listening the inputs from
  104483. */
  104484. detachControl(element: Nullable<HTMLElement>): void;
  104485. /**
  104486. * Gets the class name of the current intput.
  104487. * @returns the class name
  104488. */
  104489. getClassName(): string;
  104490. /** @hidden */
  104491. _onLostFocus(e: FocusEvent): void;
  104492. /**
  104493. * Get the friendly name associated with the input class.
  104494. * @returns the input friendly name
  104495. */
  104496. getSimpleName(): string;
  104497. /**
  104498. * Update the current camera state depending on the inputs that have been used this frame.
  104499. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104500. */
  104501. checkInputs(): void;
  104502. }
  104503. }
  104504. declare module BABYLON {
  104505. /**
  104506. * Manage the mouse wheel inputs to control a follow camera.
  104507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104508. */
  104509. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104510. /**
  104511. * Defines the camera the input is attached to.
  104512. */
  104513. camera: FollowCamera;
  104514. /**
  104515. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104516. */
  104517. axisControlRadius: boolean;
  104518. /**
  104519. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104520. */
  104521. axisControlHeight: boolean;
  104522. /**
  104523. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104524. */
  104525. axisControlRotation: boolean;
  104526. /**
  104527. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104528. * relation to mouseWheel events.
  104529. */
  104530. wheelPrecision: number;
  104531. /**
  104532. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104533. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104534. */
  104535. wheelDeltaPercentage: number;
  104536. private _wheel;
  104537. private _observer;
  104538. /**
  104539. * Attach the input controls to a specific dom element to get the input from.
  104540. * @param element Defines the element the controls should be listened from
  104541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104542. */
  104543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104544. /**
  104545. * Detach the current controls from the specified dom element.
  104546. * @param element Defines the element to stop listening the inputs from
  104547. */
  104548. detachControl(element: Nullable<HTMLElement>): void;
  104549. /**
  104550. * Gets the class name of the current intput.
  104551. * @returns the class name
  104552. */
  104553. getClassName(): string;
  104554. /**
  104555. * Get the friendly name associated with the input class.
  104556. * @returns the input friendly name
  104557. */
  104558. getSimpleName(): string;
  104559. }
  104560. }
  104561. declare module BABYLON {
  104562. /**
  104563. * Manage the pointers inputs to control an follow camera.
  104564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104565. */
  104566. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104567. /**
  104568. * Defines the camera the input is attached to.
  104569. */
  104570. camera: FollowCamera;
  104571. /**
  104572. * Gets the class name of the current input.
  104573. * @returns the class name
  104574. */
  104575. getClassName(): string;
  104576. /**
  104577. * Defines the pointer angular sensibility along the X axis or how fast is
  104578. * the camera rotating.
  104579. * A negative number will reverse the axis direction.
  104580. */
  104581. angularSensibilityX: number;
  104582. /**
  104583. * Defines the pointer angular sensibility along the Y axis or how fast is
  104584. * the camera rotating.
  104585. * A negative number will reverse the axis direction.
  104586. */
  104587. angularSensibilityY: number;
  104588. /**
  104589. * Defines the pointer pinch precision or how fast is the camera zooming.
  104590. * A negative number will reverse the axis direction.
  104591. */
  104592. pinchPrecision: number;
  104593. /**
  104594. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104595. * from 0.
  104596. * It defines the percentage of current camera.radius to use as delta when
  104597. * pinch zoom is used.
  104598. */
  104599. pinchDeltaPercentage: number;
  104600. /**
  104601. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104602. */
  104603. axisXControlRadius: boolean;
  104604. /**
  104605. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104606. */
  104607. axisXControlHeight: boolean;
  104608. /**
  104609. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104610. */
  104611. axisXControlRotation: boolean;
  104612. /**
  104613. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104614. */
  104615. axisYControlRadius: boolean;
  104616. /**
  104617. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104618. */
  104619. axisYControlHeight: boolean;
  104620. /**
  104621. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104622. */
  104623. axisYControlRotation: boolean;
  104624. /**
  104625. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104626. */
  104627. axisPinchControlRadius: boolean;
  104628. /**
  104629. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104630. */
  104631. axisPinchControlHeight: boolean;
  104632. /**
  104633. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104634. */
  104635. axisPinchControlRotation: boolean;
  104636. /**
  104637. * Log error messages if basic misconfiguration has occurred.
  104638. */
  104639. warningEnable: boolean;
  104640. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104641. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104642. private _warningCounter;
  104643. private _warning;
  104644. }
  104645. }
  104646. declare module BABYLON {
  104647. /**
  104648. * Default Inputs manager for the FollowCamera.
  104649. * It groups all the default supported inputs for ease of use.
  104650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104651. */
  104652. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104653. /**
  104654. * Instantiates a new FollowCameraInputsManager.
  104655. * @param camera Defines the camera the inputs belong to
  104656. */
  104657. constructor(camera: FollowCamera);
  104658. /**
  104659. * Add keyboard input support to the input manager.
  104660. * @returns the current input manager
  104661. */
  104662. addKeyboard(): FollowCameraInputsManager;
  104663. /**
  104664. * Add mouse wheel input support to the input manager.
  104665. * @returns the current input manager
  104666. */
  104667. addMouseWheel(): FollowCameraInputsManager;
  104668. /**
  104669. * Add pointers input support to the input manager.
  104670. * @returns the current input manager
  104671. */
  104672. addPointers(): FollowCameraInputsManager;
  104673. /**
  104674. * Add orientation input support to the input manager.
  104675. * @returns the current input manager
  104676. */
  104677. addVRDeviceOrientation(): FollowCameraInputsManager;
  104678. }
  104679. }
  104680. declare module BABYLON {
  104681. /**
  104682. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104683. * an arc rotate version arcFollowCamera are available.
  104684. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104685. */
  104686. export class FollowCamera extends TargetCamera {
  104687. /**
  104688. * Distance the follow camera should follow an object at
  104689. */
  104690. radius: number;
  104691. /**
  104692. * Minimum allowed distance of the camera to the axis of rotation
  104693. * (The camera can not get closer).
  104694. * This can help limiting how the Camera is able to move in the scene.
  104695. */
  104696. lowerRadiusLimit: Nullable<number>;
  104697. /**
  104698. * Maximum allowed distance of the camera to the axis of rotation
  104699. * (The camera can not get further).
  104700. * This can help limiting how the Camera is able to move in the scene.
  104701. */
  104702. upperRadiusLimit: Nullable<number>;
  104703. /**
  104704. * Define a rotation offset between the camera and the object it follows
  104705. */
  104706. rotationOffset: number;
  104707. /**
  104708. * Minimum allowed angle to camera position relative to target object.
  104709. * This can help limiting how the Camera is able to move in the scene.
  104710. */
  104711. lowerRotationOffsetLimit: Nullable<number>;
  104712. /**
  104713. * Maximum allowed angle to camera position relative to target object.
  104714. * This can help limiting how the Camera is able to move in the scene.
  104715. */
  104716. upperRotationOffsetLimit: Nullable<number>;
  104717. /**
  104718. * Define a height offset between the camera and the object it follows.
  104719. * It can help following an object from the top (like a car chaing a plane)
  104720. */
  104721. heightOffset: number;
  104722. /**
  104723. * Minimum allowed height of camera position relative to target object.
  104724. * This can help limiting how the Camera is able to move in the scene.
  104725. */
  104726. lowerHeightOffsetLimit: Nullable<number>;
  104727. /**
  104728. * Maximum allowed height of camera position relative to target object.
  104729. * This can help limiting how the Camera is able to move in the scene.
  104730. */
  104731. upperHeightOffsetLimit: Nullable<number>;
  104732. /**
  104733. * Define how fast the camera can accelerate to follow it s target.
  104734. */
  104735. cameraAcceleration: number;
  104736. /**
  104737. * Define the speed limit of the camera following an object.
  104738. */
  104739. maxCameraSpeed: number;
  104740. /**
  104741. * Define the target of the camera.
  104742. */
  104743. lockedTarget: Nullable<AbstractMesh>;
  104744. /**
  104745. * Defines the input associated with the camera.
  104746. */
  104747. inputs: FollowCameraInputsManager;
  104748. /**
  104749. * Instantiates the follow camera.
  104750. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104751. * @param name Define the name of the camera in the scene
  104752. * @param position Define the position of the camera
  104753. * @param scene Define the scene the camera belong to
  104754. * @param lockedTarget Define the target of the camera
  104755. */
  104756. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104757. private _follow;
  104758. /**
  104759. * Attached controls to the current camera.
  104760. * @param element Defines the element the controls should be listened from
  104761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104762. */
  104763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104764. /**
  104765. * Detach the current controls from the camera.
  104766. * The camera will stop reacting to inputs.
  104767. * @param element Defines the element to stop listening the inputs from
  104768. */
  104769. detachControl(element: HTMLElement): void;
  104770. /** @hidden */
  104771. _checkInputs(): void;
  104772. private _checkLimits;
  104773. /**
  104774. * Gets the camera class name.
  104775. * @returns the class name
  104776. */
  104777. getClassName(): string;
  104778. }
  104779. /**
  104780. * Arc Rotate version of the follow camera.
  104781. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104782. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104783. */
  104784. export class ArcFollowCamera extends TargetCamera {
  104785. /** The longitudinal angle of the camera */
  104786. alpha: number;
  104787. /** The latitudinal angle of the camera */
  104788. beta: number;
  104789. /** The radius of the camera from its target */
  104790. radius: number;
  104791. /** Define the camera target (the messh it should follow) */
  104792. target: Nullable<AbstractMesh>;
  104793. private _cartesianCoordinates;
  104794. /**
  104795. * Instantiates a new ArcFollowCamera
  104796. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104797. * @param name Define the name of the camera
  104798. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104799. * @param beta Define the rotation angle of the camera around the elevation axis
  104800. * @param radius Define the radius of the camera from its target point
  104801. * @param target Define the target of the camera
  104802. * @param scene Define the scene the camera belongs to
  104803. */
  104804. constructor(name: string,
  104805. /** The longitudinal angle of the camera */
  104806. alpha: number,
  104807. /** The latitudinal angle of the camera */
  104808. beta: number,
  104809. /** The radius of the camera from its target */
  104810. radius: number,
  104811. /** Define the camera target (the messh it should follow) */
  104812. target: Nullable<AbstractMesh>, scene: Scene);
  104813. private _follow;
  104814. /** @hidden */
  104815. _checkInputs(): void;
  104816. /**
  104817. * Returns the class name of the object.
  104818. * It is mostly used internally for serialization purposes.
  104819. */
  104820. getClassName(): string;
  104821. }
  104822. }
  104823. declare module BABYLON {
  104824. /**
  104825. * Manage the keyboard inputs to control the movement of a follow camera.
  104826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104827. */
  104828. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104829. /**
  104830. * Defines the camera the input is attached to.
  104831. */
  104832. camera: FollowCamera;
  104833. /**
  104834. * Defines the list of key codes associated with the up action (increase heightOffset)
  104835. */
  104836. keysHeightOffsetIncr: number[];
  104837. /**
  104838. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104839. */
  104840. keysHeightOffsetDecr: number[];
  104841. /**
  104842. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104843. */
  104844. keysHeightOffsetModifierAlt: boolean;
  104845. /**
  104846. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104847. */
  104848. keysHeightOffsetModifierCtrl: boolean;
  104849. /**
  104850. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104851. */
  104852. keysHeightOffsetModifierShift: boolean;
  104853. /**
  104854. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104855. */
  104856. keysRotationOffsetIncr: number[];
  104857. /**
  104858. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104859. */
  104860. keysRotationOffsetDecr: number[];
  104861. /**
  104862. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104863. */
  104864. keysRotationOffsetModifierAlt: boolean;
  104865. /**
  104866. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104867. */
  104868. keysRotationOffsetModifierCtrl: boolean;
  104869. /**
  104870. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104871. */
  104872. keysRotationOffsetModifierShift: boolean;
  104873. /**
  104874. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104875. */
  104876. keysRadiusIncr: number[];
  104877. /**
  104878. * Defines the list of key codes associated with the zoom-out action (increase radius)
  104879. */
  104880. keysRadiusDecr: number[];
  104881. /**
  104882. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  104883. */
  104884. keysRadiusModifierAlt: boolean;
  104885. /**
  104886. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  104887. */
  104888. keysRadiusModifierCtrl: boolean;
  104889. /**
  104890. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  104891. */
  104892. keysRadiusModifierShift: boolean;
  104893. /**
  104894. * Defines the rate of change of heightOffset.
  104895. */
  104896. heightSensibility: number;
  104897. /**
  104898. * Defines the rate of change of rotationOffset.
  104899. */
  104900. rotationSensibility: number;
  104901. /**
  104902. * Defines the rate of change of radius.
  104903. */
  104904. radiusSensibility: number;
  104905. private _keys;
  104906. private _ctrlPressed;
  104907. private _altPressed;
  104908. private _shiftPressed;
  104909. private _onCanvasBlurObserver;
  104910. private _onKeyboardObserver;
  104911. private _engine;
  104912. private _scene;
  104913. /**
  104914. * Attach the input controls to a specific dom element to get the input from.
  104915. * @param element Defines the element the controls should be listened from
  104916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104917. */
  104918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104919. /**
  104920. * Detach the current controls from the specified dom element.
  104921. * @param element Defines the element to stop listening the inputs from
  104922. */
  104923. detachControl(element: Nullable<HTMLElement>): void;
  104924. /**
  104925. * Update the current camera state depending on the inputs that have been used this frame.
  104926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104927. */
  104928. checkInputs(): void;
  104929. /**
  104930. * Gets the class name of the current input.
  104931. * @returns the class name
  104932. */
  104933. getClassName(): string;
  104934. /**
  104935. * Get the friendly name associated with the input class.
  104936. * @returns the input friendly name
  104937. */
  104938. getSimpleName(): string;
  104939. /**
  104940. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104941. * allow modification of the heightOffset value.
  104942. */
  104943. private _modifierHeightOffset;
  104944. /**
  104945. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104946. * allow modification of the rotationOffset value.
  104947. */
  104948. private _modifierRotationOffset;
  104949. /**
  104950. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104951. * allow modification of the radius value.
  104952. */
  104953. private _modifierRadius;
  104954. }
  104955. }
  104956. declare module BABYLON {
  104957. interface FreeCameraInputsManager {
  104958. /**
  104959. * @hidden
  104960. */
  104961. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  104962. /**
  104963. * Add orientation input support to the input manager.
  104964. * @returns the current input manager
  104965. */
  104966. addDeviceOrientation(): FreeCameraInputsManager;
  104967. }
  104968. /**
  104969. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  104970. * Screen rotation is taken into account.
  104971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104972. */
  104973. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  104974. private _camera;
  104975. private _screenOrientationAngle;
  104976. private _constantTranform;
  104977. private _screenQuaternion;
  104978. private _alpha;
  104979. private _beta;
  104980. private _gamma;
  104981. /**
  104982. * Can be used to detect if a device orientation sensor is availible on a device
  104983. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  104984. * @returns a promise that will resolve on orientation change
  104985. */
  104986. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  104987. /**
  104988. * @hidden
  104989. */
  104990. _onDeviceOrientationChangedObservable: Observable<void>;
  104991. /**
  104992. * Instantiates a new input
  104993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104994. */
  104995. constructor();
  104996. /**
  104997. * Define the camera controlled by the input.
  104998. */
  104999. camera: FreeCamera;
  105000. /**
  105001. * Attach the input controls to a specific dom element to get the input from.
  105002. * @param element Defines the element the controls should be listened from
  105003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105004. */
  105005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105006. private _orientationChanged;
  105007. private _deviceOrientation;
  105008. /**
  105009. * Detach the current controls from the specified dom element.
  105010. * @param element Defines the element to stop listening the inputs from
  105011. */
  105012. detachControl(element: Nullable<HTMLElement>): void;
  105013. /**
  105014. * Update the current camera state depending on the inputs that have been used this frame.
  105015. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105016. */
  105017. checkInputs(): void;
  105018. /**
  105019. * Gets the class name of the current intput.
  105020. * @returns the class name
  105021. */
  105022. getClassName(): string;
  105023. /**
  105024. * Get the friendly name associated with the input class.
  105025. * @returns the input friendly name
  105026. */
  105027. getSimpleName(): string;
  105028. }
  105029. }
  105030. declare module BABYLON {
  105031. /**
  105032. * Manage the gamepad inputs to control a free camera.
  105033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105034. */
  105035. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105036. /**
  105037. * Define the camera the input is attached to.
  105038. */
  105039. camera: FreeCamera;
  105040. /**
  105041. * Define the Gamepad controlling the input
  105042. */
  105043. gamepad: Nullable<Gamepad>;
  105044. /**
  105045. * Defines the gamepad rotation sensiblity.
  105046. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105047. */
  105048. gamepadAngularSensibility: number;
  105049. /**
  105050. * Defines the gamepad move sensiblity.
  105051. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105052. */
  105053. gamepadMoveSensibility: number;
  105054. private _onGamepadConnectedObserver;
  105055. private _onGamepadDisconnectedObserver;
  105056. private _cameraTransform;
  105057. private _deltaTransform;
  105058. private _vector3;
  105059. private _vector2;
  105060. /**
  105061. * Attach the input controls to a specific dom element to get the input from.
  105062. * @param element Defines the element the controls should be listened from
  105063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105064. */
  105065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105066. /**
  105067. * Detach the current controls from the specified dom element.
  105068. * @param element Defines the element to stop listening the inputs from
  105069. */
  105070. detachControl(element: Nullable<HTMLElement>): void;
  105071. /**
  105072. * Update the current camera state depending on the inputs that have been used this frame.
  105073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105074. */
  105075. checkInputs(): void;
  105076. /**
  105077. * Gets the class name of the current intput.
  105078. * @returns the class name
  105079. */
  105080. getClassName(): string;
  105081. /**
  105082. * Get the friendly name associated with the input class.
  105083. * @returns the input friendly name
  105084. */
  105085. getSimpleName(): string;
  105086. }
  105087. }
  105088. declare module BABYLON {
  105089. /**
  105090. * Defines the potential axis of a Joystick
  105091. */
  105092. export enum JoystickAxis {
  105093. /** X axis */
  105094. X = 0,
  105095. /** Y axis */
  105096. Y = 1,
  105097. /** Z axis */
  105098. Z = 2
  105099. }
  105100. /**
  105101. * Class used to define virtual joystick (used in touch mode)
  105102. */
  105103. export class VirtualJoystick {
  105104. /**
  105105. * Gets or sets a boolean indicating that left and right values must be inverted
  105106. */
  105107. reverseLeftRight: boolean;
  105108. /**
  105109. * Gets or sets a boolean indicating that up and down values must be inverted
  105110. */
  105111. reverseUpDown: boolean;
  105112. /**
  105113. * Gets the offset value for the position (ie. the change of the position value)
  105114. */
  105115. deltaPosition: Vector3;
  105116. /**
  105117. * Gets a boolean indicating if the virtual joystick was pressed
  105118. */
  105119. pressed: boolean;
  105120. /**
  105121. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105122. */
  105123. static Canvas: Nullable<HTMLCanvasElement>;
  105124. private static _globalJoystickIndex;
  105125. private static vjCanvasContext;
  105126. private static vjCanvasWidth;
  105127. private static vjCanvasHeight;
  105128. private static halfWidth;
  105129. private _action;
  105130. private _axisTargetedByLeftAndRight;
  105131. private _axisTargetedByUpAndDown;
  105132. private _joystickSensibility;
  105133. private _inversedSensibility;
  105134. private _joystickPointerID;
  105135. private _joystickColor;
  105136. private _joystickPointerPos;
  105137. private _joystickPreviousPointerPos;
  105138. private _joystickPointerStartPos;
  105139. private _deltaJoystickVector;
  105140. private _leftJoystick;
  105141. private _touches;
  105142. private _onPointerDownHandlerRef;
  105143. private _onPointerMoveHandlerRef;
  105144. private _onPointerUpHandlerRef;
  105145. private _onResize;
  105146. /**
  105147. * Creates a new virtual joystick
  105148. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105149. */
  105150. constructor(leftJoystick?: boolean);
  105151. /**
  105152. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105153. * @param newJoystickSensibility defines the new sensibility
  105154. */
  105155. setJoystickSensibility(newJoystickSensibility: number): void;
  105156. private _onPointerDown;
  105157. private _onPointerMove;
  105158. private _onPointerUp;
  105159. /**
  105160. * Change the color of the virtual joystick
  105161. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105162. */
  105163. setJoystickColor(newColor: string): void;
  105164. /**
  105165. * Defines a callback to call when the joystick is touched
  105166. * @param action defines the callback
  105167. */
  105168. setActionOnTouch(action: () => any): void;
  105169. /**
  105170. * Defines which axis you'd like to control for left & right
  105171. * @param axis defines the axis to use
  105172. */
  105173. setAxisForLeftRight(axis: JoystickAxis): void;
  105174. /**
  105175. * Defines which axis you'd like to control for up & down
  105176. * @param axis defines the axis to use
  105177. */
  105178. setAxisForUpDown(axis: JoystickAxis): void;
  105179. private _drawVirtualJoystick;
  105180. /**
  105181. * Release internal HTML canvas
  105182. */
  105183. releaseCanvas(): void;
  105184. }
  105185. }
  105186. declare module BABYLON {
  105187. interface FreeCameraInputsManager {
  105188. /**
  105189. * Add virtual joystick input support to the input manager.
  105190. * @returns the current input manager
  105191. */
  105192. addVirtualJoystick(): FreeCameraInputsManager;
  105193. }
  105194. /**
  105195. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105197. */
  105198. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105199. /**
  105200. * Defines the camera the input is attached to.
  105201. */
  105202. camera: FreeCamera;
  105203. private _leftjoystick;
  105204. private _rightjoystick;
  105205. /**
  105206. * Gets the left stick of the virtual joystick.
  105207. * @returns The virtual Joystick
  105208. */
  105209. getLeftJoystick(): VirtualJoystick;
  105210. /**
  105211. * Gets the right stick of the virtual joystick.
  105212. * @returns The virtual Joystick
  105213. */
  105214. getRightJoystick(): VirtualJoystick;
  105215. /**
  105216. * Update the current camera state depending on the inputs that have been used this frame.
  105217. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105218. */
  105219. checkInputs(): void;
  105220. /**
  105221. * Attach the input controls to a specific dom element to get the input from.
  105222. * @param element Defines the element the controls should be listened from
  105223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105224. */
  105225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105226. /**
  105227. * Detach the current controls from the specified dom element.
  105228. * @param element Defines the element to stop listening the inputs from
  105229. */
  105230. detachControl(element: Nullable<HTMLElement>): void;
  105231. /**
  105232. * Gets the class name of the current intput.
  105233. * @returns the class name
  105234. */
  105235. getClassName(): string;
  105236. /**
  105237. * Get the friendly name associated with the input class.
  105238. * @returns the input friendly name
  105239. */
  105240. getSimpleName(): string;
  105241. }
  105242. }
  105243. declare module BABYLON {
  105244. /**
  105245. * This represents a FPS type of camera controlled by touch.
  105246. * This is like a universal camera minus the Gamepad controls.
  105247. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105248. */
  105249. export class TouchCamera extends FreeCamera {
  105250. /**
  105251. * Defines the touch sensibility for rotation.
  105252. * The higher the faster.
  105253. */
  105254. touchAngularSensibility: number;
  105255. /**
  105256. * Defines the touch sensibility for move.
  105257. * The higher the faster.
  105258. */
  105259. touchMoveSensibility: number;
  105260. /**
  105261. * Instantiates a new touch camera.
  105262. * This represents a FPS type of camera controlled by touch.
  105263. * This is like a universal camera minus the Gamepad controls.
  105264. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105265. * @param name Define the name of the camera in the scene
  105266. * @param position Define the start position of the camera in the scene
  105267. * @param scene Define the scene the camera belongs to
  105268. */
  105269. constructor(name: string, position: Vector3, scene: Scene);
  105270. /**
  105271. * Gets the current object class name.
  105272. * @return the class name
  105273. */
  105274. getClassName(): string;
  105275. /** @hidden */
  105276. _setupInputs(): void;
  105277. }
  105278. }
  105279. declare module BABYLON {
  105280. /**
  105281. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105282. * being tilted forward or back and left or right.
  105283. */
  105284. export class DeviceOrientationCamera extends FreeCamera {
  105285. private _initialQuaternion;
  105286. private _quaternionCache;
  105287. private _tmpDragQuaternion;
  105288. private _disablePointerInputWhenUsingDeviceOrientation;
  105289. /**
  105290. * Creates a new device orientation camera
  105291. * @param name The name of the camera
  105292. * @param position The start position camera
  105293. * @param scene The scene the camera belongs to
  105294. */
  105295. constructor(name: string, position: Vector3, scene: Scene);
  105296. /**
  105297. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105298. */
  105299. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105300. private _dragFactor;
  105301. /**
  105302. * Enabled turning on the y axis when the orientation sensor is active
  105303. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105304. */
  105305. enableHorizontalDragging(dragFactor?: number): void;
  105306. /**
  105307. * Gets the current instance class name ("DeviceOrientationCamera").
  105308. * This helps avoiding instanceof at run time.
  105309. * @returns the class name
  105310. */
  105311. getClassName(): string;
  105312. /**
  105313. * @hidden
  105314. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105315. */
  105316. _checkInputs(): void;
  105317. /**
  105318. * Reset the camera to its default orientation on the specified axis only.
  105319. * @param axis The axis to reset
  105320. */
  105321. resetToCurrentRotation(axis?: Axis): void;
  105322. }
  105323. }
  105324. declare module BABYLON {
  105325. /**
  105326. * Defines supported buttons for XBox360 compatible gamepads
  105327. */
  105328. export enum Xbox360Button {
  105329. /** A */
  105330. A = 0,
  105331. /** B */
  105332. B = 1,
  105333. /** X */
  105334. X = 2,
  105335. /** Y */
  105336. Y = 3,
  105337. /** Start */
  105338. Start = 4,
  105339. /** Back */
  105340. Back = 5,
  105341. /** Left button */
  105342. LB = 6,
  105343. /** Right button */
  105344. RB = 7,
  105345. /** Left stick */
  105346. LeftStick = 8,
  105347. /** Right stick */
  105348. RightStick = 9
  105349. }
  105350. /** Defines values for XBox360 DPad */
  105351. export enum Xbox360Dpad {
  105352. /** Up */
  105353. Up = 0,
  105354. /** Down */
  105355. Down = 1,
  105356. /** Left */
  105357. Left = 2,
  105358. /** Right */
  105359. Right = 3
  105360. }
  105361. /**
  105362. * Defines a XBox360 gamepad
  105363. */
  105364. export class Xbox360Pad extends Gamepad {
  105365. private _leftTrigger;
  105366. private _rightTrigger;
  105367. private _onlefttriggerchanged;
  105368. private _onrighttriggerchanged;
  105369. private _onbuttondown;
  105370. private _onbuttonup;
  105371. private _ondpaddown;
  105372. private _ondpadup;
  105373. /** Observable raised when a button is pressed */
  105374. onButtonDownObservable: Observable<Xbox360Button>;
  105375. /** Observable raised when a button is released */
  105376. onButtonUpObservable: Observable<Xbox360Button>;
  105377. /** Observable raised when a pad is pressed */
  105378. onPadDownObservable: Observable<Xbox360Dpad>;
  105379. /** Observable raised when a pad is released */
  105380. onPadUpObservable: Observable<Xbox360Dpad>;
  105381. private _buttonA;
  105382. private _buttonB;
  105383. private _buttonX;
  105384. private _buttonY;
  105385. private _buttonBack;
  105386. private _buttonStart;
  105387. private _buttonLB;
  105388. private _buttonRB;
  105389. private _buttonLeftStick;
  105390. private _buttonRightStick;
  105391. private _dPadUp;
  105392. private _dPadDown;
  105393. private _dPadLeft;
  105394. private _dPadRight;
  105395. private _isXboxOnePad;
  105396. /**
  105397. * Creates a new XBox360 gamepad object
  105398. * @param id defines the id of this gamepad
  105399. * @param index defines its index
  105400. * @param gamepad defines the internal HTML gamepad object
  105401. * @param xboxOne defines if it is a XBox One gamepad
  105402. */
  105403. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105404. /**
  105405. * Defines the callback to call when left trigger is pressed
  105406. * @param callback defines the callback to use
  105407. */
  105408. onlefttriggerchanged(callback: (value: number) => void): void;
  105409. /**
  105410. * Defines the callback to call when right trigger is pressed
  105411. * @param callback defines the callback to use
  105412. */
  105413. onrighttriggerchanged(callback: (value: number) => void): void;
  105414. /**
  105415. * Gets the left trigger value
  105416. */
  105417. /**
  105418. * Sets the left trigger value
  105419. */
  105420. leftTrigger: number;
  105421. /**
  105422. * Gets the right trigger value
  105423. */
  105424. /**
  105425. * Sets the right trigger value
  105426. */
  105427. rightTrigger: number;
  105428. /**
  105429. * Defines the callback to call when a button is pressed
  105430. * @param callback defines the callback to use
  105431. */
  105432. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105433. /**
  105434. * Defines the callback to call when a button is released
  105435. * @param callback defines the callback to use
  105436. */
  105437. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105438. /**
  105439. * Defines the callback to call when a pad is pressed
  105440. * @param callback defines the callback to use
  105441. */
  105442. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105443. /**
  105444. * Defines the callback to call when a pad is released
  105445. * @param callback defines the callback to use
  105446. */
  105447. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105448. private _setButtonValue;
  105449. private _setDPadValue;
  105450. /**
  105451. * Gets the value of the `A` button
  105452. */
  105453. /**
  105454. * Sets the value of the `A` button
  105455. */
  105456. buttonA: number;
  105457. /**
  105458. * Gets the value of the `B` button
  105459. */
  105460. /**
  105461. * Sets the value of the `B` button
  105462. */
  105463. buttonB: number;
  105464. /**
  105465. * Gets the value of the `X` button
  105466. */
  105467. /**
  105468. * Sets the value of the `X` button
  105469. */
  105470. buttonX: number;
  105471. /**
  105472. * Gets the value of the `Y` button
  105473. */
  105474. /**
  105475. * Sets the value of the `Y` button
  105476. */
  105477. buttonY: number;
  105478. /**
  105479. * Gets the value of the `Start` button
  105480. */
  105481. /**
  105482. * Sets the value of the `Start` button
  105483. */
  105484. buttonStart: number;
  105485. /**
  105486. * Gets the value of the `Back` button
  105487. */
  105488. /**
  105489. * Sets the value of the `Back` button
  105490. */
  105491. buttonBack: number;
  105492. /**
  105493. * Gets the value of the `Left` button
  105494. */
  105495. /**
  105496. * Sets the value of the `Left` button
  105497. */
  105498. buttonLB: number;
  105499. /**
  105500. * Gets the value of the `Right` button
  105501. */
  105502. /**
  105503. * Sets the value of the `Right` button
  105504. */
  105505. buttonRB: number;
  105506. /**
  105507. * Gets the value of the Left joystick
  105508. */
  105509. /**
  105510. * Sets the value of the Left joystick
  105511. */
  105512. buttonLeftStick: number;
  105513. /**
  105514. * Gets the value of the Right joystick
  105515. */
  105516. /**
  105517. * Sets the value of the Right joystick
  105518. */
  105519. buttonRightStick: number;
  105520. /**
  105521. * Gets the value of D-pad up
  105522. */
  105523. /**
  105524. * Sets the value of D-pad up
  105525. */
  105526. dPadUp: number;
  105527. /**
  105528. * Gets the value of D-pad down
  105529. */
  105530. /**
  105531. * Sets the value of D-pad down
  105532. */
  105533. dPadDown: number;
  105534. /**
  105535. * Gets the value of D-pad left
  105536. */
  105537. /**
  105538. * Sets the value of D-pad left
  105539. */
  105540. dPadLeft: number;
  105541. /**
  105542. * Gets the value of D-pad right
  105543. */
  105544. /**
  105545. * Sets the value of D-pad right
  105546. */
  105547. dPadRight: number;
  105548. /**
  105549. * Force the gamepad to synchronize with device values
  105550. */
  105551. update(): void;
  105552. /**
  105553. * Disposes the gamepad
  105554. */
  105555. dispose(): void;
  105556. }
  105557. }
  105558. declare module BABYLON {
  105559. /**
  105560. * Defines supported buttons for DualShock compatible gamepads
  105561. */
  105562. export enum DualShockButton {
  105563. /** Cross */
  105564. Cross = 0,
  105565. /** Circle */
  105566. Circle = 1,
  105567. /** Square */
  105568. Square = 2,
  105569. /** Triangle */
  105570. Triangle = 3,
  105571. /** Options */
  105572. Options = 4,
  105573. /** Share */
  105574. Share = 5,
  105575. /** L1 */
  105576. L1 = 6,
  105577. /** R1 */
  105578. R1 = 7,
  105579. /** Left stick */
  105580. LeftStick = 8,
  105581. /** Right stick */
  105582. RightStick = 9
  105583. }
  105584. /** Defines values for DualShock DPad */
  105585. export enum DualShockDpad {
  105586. /** Up */
  105587. Up = 0,
  105588. /** Down */
  105589. Down = 1,
  105590. /** Left */
  105591. Left = 2,
  105592. /** Right */
  105593. Right = 3
  105594. }
  105595. /**
  105596. * Defines a DualShock gamepad
  105597. */
  105598. export class DualShockPad extends Gamepad {
  105599. private _leftTrigger;
  105600. private _rightTrigger;
  105601. private _onlefttriggerchanged;
  105602. private _onrighttriggerchanged;
  105603. private _onbuttondown;
  105604. private _onbuttonup;
  105605. private _ondpaddown;
  105606. private _ondpadup;
  105607. /** Observable raised when a button is pressed */
  105608. onButtonDownObservable: Observable<DualShockButton>;
  105609. /** Observable raised when a button is released */
  105610. onButtonUpObservable: Observable<DualShockButton>;
  105611. /** Observable raised when a pad is pressed */
  105612. onPadDownObservable: Observable<DualShockDpad>;
  105613. /** Observable raised when a pad is released */
  105614. onPadUpObservable: Observable<DualShockDpad>;
  105615. private _buttonCross;
  105616. private _buttonCircle;
  105617. private _buttonSquare;
  105618. private _buttonTriangle;
  105619. private _buttonShare;
  105620. private _buttonOptions;
  105621. private _buttonL1;
  105622. private _buttonR1;
  105623. private _buttonLeftStick;
  105624. private _buttonRightStick;
  105625. private _dPadUp;
  105626. private _dPadDown;
  105627. private _dPadLeft;
  105628. private _dPadRight;
  105629. /**
  105630. * Creates a new DualShock gamepad object
  105631. * @param id defines the id of this gamepad
  105632. * @param index defines its index
  105633. * @param gamepad defines the internal HTML gamepad object
  105634. */
  105635. constructor(id: string, index: number, gamepad: any);
  105636. /**
  105637. * Defines the callback to call when left trigger is pressed
  105638. * @param callback defines the callback to use
  105639. */
  105640. onlefttriggerchanged(callback: (value: number) => void): void;
  105641. /**
  105642. * Defines the callback to call when right trigger is pressed
  105643. * @param callback defines the callback to use
  105644. */
  105645. onrighttriggerchanged(callback: (value: number) => void): void;
  105646. /**
  105647. * Gets the left trigger value
  105648. */
  105649. /**
  105650. * Sets the left trigger value
  105651. */
  105652. leftTrigger: number;
  105653. /**
  105654. * Gets the right trigger value
  105655. */
  105656. /**
  105657. * Sets the right trigger value
  105658. */
  105659. rightTrigger: number;
  105660. /**
  105661. * Defines the callback to call when a button is pressed
  105662. * @param callback defines the callback to use
  105663. */
  105664. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105665. /**
  105666. * Defines the callback to call when a button is released
  105667. * @param callback defines the callback to use
  105668. */
  105669. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105670. /**
  105671. * Defines the callback to call when a pad is pressed
  105672. * @param callback defines the callback to use
  105673. */
  105674. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105675. /**
  105676. * Defines the callback to call when a pad is released
  105677. * @param callback defines the callback to use
  105678. */
  105679. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105680. private _setButtonValue;
  105681. private _setDPadValue;
  105682. /**
  105683. * Gets the value of the `Cross` button
  105684. */
  105685. /**
  105686. * Sets the value of the `Cross` button
  105687. */
  105688. buttonCross: number;
  105689. /**
  105690. * Gets the value of the `Circle` button
  105691. */
  105692. /**
  105693. * Sets the value of the `Circle` button
  105694. */
  105695. buttonCircle: number;
  105696. /**
  105697. * Gets the value of the `Square` button
  105698. */
  105699. /**
  105700. * Sets the value of the `Square` button
  105701. */
  105702. buttonSquare: number;
  105703. /**
  105704. * Gets the value of the `Triangle` button
  105705. */
  105706. /**
  105707. * Sets the value of the `Triangle` button
  105708. */
  105709. buttonTriangle: number;
  105710. /**
  105711. * Gets the value of the `Options` button
  105712. */
  105713. /**
  105714. * Sets the value of the `Options` button
  105715. */
  105716. buttonOptions: number;
  105717. /**
  105718. * Gets the value of the `Share` button
  105719. */
  105720. /**
  105721. * Sets the value of the `Share` button
  105722. */
  105723. buttonShare: number;
  105724. /**
  105725. * Gets the value of the `L1` button
  105726. */
  105727. /**
  105728. * Sets the value of the `L1` button
  105729. */
  105730. buttonL1: number;
  105731. /**
  105732. * Gets the value of the `R1` button
  105733. */
  105734. /**
  105735. * Sets the value of the `R1` button
  105736. */
  105737. buttonR1: number;
  105738. /**
  105739. * Gets the value of the Left joystick
  105740. */
  105741. /**
  105742. * Sets the value of the Left joystick
  105743. */
  105744. buttonLeftStick: number;
  105745. /**
  105746. * Gets the value of the Right joystick
  105747. */
  105748. /**
  105749. * Sets the value of the Right joystick
  105750. */
  105751. buttonRightStick: number;
  105752. /**
  105753. * Gets the value of D-pad up
  105754. */
  105755. /**
  105756. * Sets the value of D-pad up
  105757. */
  105758. dPadUp: number;
  105759. /**
  105760. * Gets the value of D-pad down
  105761. */
  105762. /**
  105763. * Sets the value of D-pad down
  105764. */
  105765. dPadDown: number;
  105766. /**
  105767. * Gets the value of D-pad left
  105768. */
  105769. /**
  105770. * Sets the value of D-pad left
  105771. */
  105772. dPadLeft: number;
  105773. /**
  105774. * Gets the value of D-pad right
  105775. */
  105776. /**
  105777. * Sets the value of D-pad right
  105778. */
  105779. dPadRight: number;
  105780. /**
  105781. * Force the gamepad to synchronize with device values
  105782. */
  105783. update(): void;
  105784. /**
  105785. * Disposes the gamepad
  105786. */
  105787. dispose(): void;
  105788. }
  105789. }
  105790. declare module BABYLON {
  105791. /**
  105792. * Manager for handling gamepads
  105793. */
  105794. export class GamepadManager {
  105795. private _scene?;
  105796. private _babylonGamepads;
  105797. private _oneGamepadConnected;
  105798. /** @hidden */
  105799. _isMonitoring: boolean;
  105800. private _gamepadEventSupported;
  105801. private _gamepadSupport;
  105802. /**
  105803. * observable to be triggered when the gamepad controller has been connected
  105804. */
  105805. onGamepadConnectedObservable: Observable<Gamepad>;
  105806. /**
  105807. * observable to be triggered when the gamepad controller has been disconnected
  105808. */
  105809. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105810. private _onGamepadConnectedEvent;
  105811. private _onGamepadDisconnectedEvent;
  105812. /**
  105813. * Initializes the gamepad manager
  105814. * @param _scene BabylonJS scene
  105815. */
  105816. constructor(_scene?: Scene | undefined);
  105817. /**
  105818. * The gamepads in the game pad manager
  105819. */
  105820. readonly gamepads: Gamepad[];
  105821. /**
  105822. * Get the gamepad controllers based on type
  105823. * @param type The type of gamepad controller
  105824. * @returns Nullable gamepad
  105825. */
  105826. getGamepadByType(type?: number): Nullable<Gamepad>;
  105827. /**
  105828. * Disposes the gamepad manager
  105829. */
  105830. dispose(): void;
  105831. private _addNewGamepad;
  105832. private _startMonitoringGamepads;
  105833. private _stopMonitoringGamepads;
  105834. /** @hidden */
  105835. _checkGamepadsStatus(): void;
  105836. private _updateGamepadObjects;
  105837. }
  105838. }
  105839. declare module BABYLON {
  105840. interface Scene {
  105841. /** @hidden */
  105842. _gamepadManager: Nullable<GamepadManager>;
  105843. /**
  105844. * Gets the gamepad manager associated with the scene
  105845. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105846. */
  105847. gamepadManager: GamepadManager;
  105848. }
  105849. /**
  105850. * Interface representing a free camera inputs manager
  105851. */
  105852. interface FreeCameraInputsManager {
  105853. /**
  105854. * Adds gamepad input support to the FreeCameraInputsManager.
  105855. * @returns the FreeCameraInputsManager
  105856. */
  105857. addGamepad(): FreeCameraInputsManager;
  105858. }
  105859. /**
  105860. * Interface representing an arc rotate camera inputs manager
  105861. */
  105862. interface ArcRotateCameraInputsManager {
  105863. /**
  105864. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105865. * @returns the camera inputs manager
  105866. */
  105867. addGamepad(): ArcRotateCameraInputsManager;
  105868. }
  105869. /**
  105870. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  105871. */
  105872. export class GamepadSystemSceneComponent implements ISceneComponent {
  105873. /**
  105874. * The component name helpfull to identify the component in the list of scene components.
  105875. */
  105876. readonly name: string;
  105877. /**
  105878. * The scene the component belongs to.
  105879. */
  105880. scene: Scene;
  105881. /**
  105882. * Creates a new instance of the component for the given scene
  105883. * @param scene Defines the scene to register the component in
  105884. */
  105885. constructor(scene: Scene);
  105886. /**
  105887. * Registers the component in a given scene
  105888. */
  105889. register(): void;
  105890. /**
  105891. * Rebuilds the elements related to this component in case of
  105892. * context lost for instance.
  105893. */
  105894. rebuild(): void;
  105895. /**
  105896. * Disposes the component and the associated ressources
  105897. */
  105898. dispose(): void;
  105899. private _beforeCameraUpdate;
  105900. }
  105901. }
  105902. declare module BABYLON {
  105903. /**
  105904. * 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,
  105905. * which still works and will still be found in many Playgrounds.
  105906. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105907. */
  105908. export class UniversalCamera extends TouchCamera {
  105909. /**
  105910. * Defines the gamepad rotation sensiblity.
  105911. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105912. */
  105913. gamepadAngularSensibility: number;
  105914. /**
  105915. * Defines the gamepad move sensiblity.
  105916. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105917. */
  105918. gamepadMoveSensibility: number;
  105919. /**
  105920. * 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,
  105921. * which still works and will still be found in many Playgrounds.
  105922. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105923. * @param name Define the name of the camera in the scene
  105924. * @param position Define the start position of the camera in the scene
  105925. * @param scene Define the scene the camera belongs to
  105926. */
  105927. constructor(name: string, position: Vector3, scene: Scene);
  105928. /**
  105929. * Gets the current object class name.
  105930. * @return the class name
  105931. */
  105932. getClassName(): string;
  105933. }
  105934. }
  105935. declare module BABYLON {
  105936. /**
  105937. * This represents a FPS type of camera. This is only here for back compat purpose.
  105938. * Please use the UniversalCamera instead as both are identical.
  105939. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105940. */
  105941. export class GamepadCamera extends UniversalCamera {
  105942. /**
  105943. * Instantiates a new Gamepad Camera
  105944. * This represents a FPS type of camera. This is only here for back compat purpose.
  105945. * Please use the UniversalCamera instead as both are identical.
  105946. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105947. * @param name Define the name of the camera in the scene
  105948. * @param position Define the start position of the camera in the scene
  105949. * @param scene Define the scene the camera belongs to
  105950. */
  105951. constructor(name: string, position: Vector3, scene: Scene);
  105952. /**
  105953. * Gets the current object class name.
  105954. * @return the class name
  105955. */
  105956. getClassName(): string;
  105957. }
  105958. }
  105959. declare module BABYLON {
  105960. /** @hidden */
  105961. export var passPixelShader: {
  105962. name: string;
  105963. shader: string;
  105964. };
  105965. }
  105966. declare module BABYLON {
  105967. /** @hidden */
  105968. export var passCubePixelShader: {
  105969. name: string;
  105970. shader: string;
  105971. };
  105972. }
  105973. declare module BABYLON {
  105974. /**
  105975. * PassPostProcess which produces an output the same as it's input
  105976. */
  105977. export class PassPostProcess extends PostProcess {
  105978. /**
  105979. * Creates the PassPostProcess
  105980. * @param name The name of the effect.
  105981. * @param options The required width/height ratio to downsize to before computing the render pass.
  105982. * @param camera The camera to apply the render pass to.
  105983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105984. * @param engine The engine which the post process will be applied. (default: current engine)
  105985. * @param reusable If the post process can be reused on the same frame. (default: false)
  105986. * @param textureType The type of texture to be used when performing the post processing.
  105987. * @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)
  105988. */
  105989. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105990. }
  105991. /**
  105992. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105993. */
  105994. export class PassCubePostProcess extends PostProcess {
  105995. private _face;
  105996. /**
  105997. * Gets or sets the cube face to display.
  105998. * * 0 is +X
  105999. * * 1 is -X
  106000. * * 2 is +Y
  106001. * * 3 is -Y
  106002. * * 4 is +Z
  106003. * * 5 is -Z
  106004. */
  106005. face: number;
  106006. /**
  106007. * Creates the PassCubePostProcess
  106008. * @param name The name of the effect.
  106009. * @param options The required width/height ratio to downsize to before computing the render pass.
  106010. * @param camera The camera to apply the render pass to.
  106011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106012. * @param engine The engine which the post process will be applied. (default: current engine)
  106013. * @param reusable If the post process can be reused on the same frame. (default: false)
  106014. * @param textureType The type of texture to be used when performing the post processing.
  106015. * @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)
  106016. */
  106017. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106018. }
  106019. }
  106020. declare module BABYLON {
  106021. /** @hidden */
  106022. export var anaglyphPixelShader: {
  106023. name: string;
  106024. shader: string;
  106025. };
  106026. }
  106027. declare module BABYLON {
  106028. /**
  106029. * Postprocess used to generate anaglyphic rendering
  106030. */
  106031. export class AnaglyphPostProcess extends PostProcess {
  106032. private _passedProcess;
  106033. /**
  106034. * Creates a new AnaglyphPostProcess
  106035. * @param name defines postprocess name
  106036. * @param options defines creation options or target ratio scale
  106037. * @param rigCameras defines cameras using this postprocess
  106038. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106039. * @param engine defines hosting engine
  106040. * @param reusable defines if the postprocess will be reused multiple times per frame
  106041. */
  106042. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106043. }
  106044. }
  106045. declare module BABYLON {
  106046. /**
  106047. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106048. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106049. */
  106050. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106051. /**
  106052. * Creates a new AnaglyphArcRotateCamera
  106053. * @param name defines camera name
  106054. * @param alpha defines alpha angle (in radians)
  106055. * @param beta defines beta angle (in radians)
  106056. * @param radius defines radius
  106057. * @param target defines camera target
  106058. * @param interaxialDistance defines distance between each color axis
  106059. * @param scene defines the hosting scene
  106060. */
  106061. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106062. /**
  106063. * Gets camera class name
  106064. * @returns AnaglyphArcRotateCamera
  106065. */
  106066. getClassName(): string;
  106067. }
  106068. }
  106069. declare module BABYLON {
  106070. /**
  106071. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106072. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106073. */
  106074. export class AnaglyphFreeCamera extends FreeCamera {
  106075. /**
  106076. * Creates a new AnaglyphFreeCamera
  106077. * @param name defines camera name
  106078. * @param position defines initial position
  106079. * @param interaxialDistance defines distance between each color axis
  106080. * @param scene defines the hosting scene
  106081. */
  106082. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106083. /**
  106084. * Gets camera class name
  106085. * @returns AnaglyphFreeCamera
  106086. */
  106087. getClassName(): string;
  106088. }
  106089. }
  106090. declare module BABYLON {
  106091. /**
  106092. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106093. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106094. */
  106095. export class AnaglyphGamepadCamera extends GamepadCamera {
  106096. /**
  106097. * Creates a new AnaglyphGamepadCamera
  106098. * @param name defines camera name
  106099. * @param position defines initial position
  106100. * @param interaxialDistance defines distance between each color axis
  106101. * @param scene defines the hosting scene
  106102. */
  106103. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106104. /**
  106105. * Gets camera class name
  106106. * @returns AnaglyphGamepadCamera
  106107. */
  106108. getClassName(): string;
  106109. }
  106110. }
  106111. declare module BABYLON {
  106112. /**
  106113. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106114. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106115. */
  106116. export class AnaglyphUniversalCamera extends UniversalCamera {
  106117. /**
  106118. * Creates a new AnaglyphUniversalCamera
  106119. * @param name defines camera name
  106120. * @param position defines initial position
  106121. * @param interaxialDistance defines distance between each color axis
  106122. * @param scene defines the hosting scene
  106123. */
  106124. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106125. /**
  106126. * Gets camera class name
  106127. * @returns AnaglyphUniversalCamera
  106128. */
  106129. getClassName(): string;
  106130. }
  106131. }
  106132. declare module BABYLON {
  106133. /** @hidden */
  106134. export var stereoscopicInterlacePixelShader: {
  106135. name: string;
  106136. shader: string;
  106137. };
  106138. }
  106139. declare module BABYLON {
  106140. /**
  106141. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106142. */
  106143. export class StereoscopicInterlacePostProcess extends PostProcess {
  106144. private _stepSize;
  106145. private _passedProcess;
  106146. /**
  106147. * Initializes a StereoscopicInterlacePostProcess
  106148. * @param name The name of the effect.
  106149. * @param rigCameras The rig cameras to be appled to the post process
  106150. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106152. * @param engine The engine which the post process will be applied. (default: current engine)
  106153. * @param reusable If the post process can be reused on the same frame. (default: false)
  106154. */
  106155. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106156. }
  106157. }
  106158. declare module BABYLON {
  106159. /**
  106160. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106161. * @see http://doc.babylonjs.com/features/cameras
  106162. */
  106163. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106164. /**
  106165. * Creates a new StereoscopicArcRotateCamera
  106166. * @param name defines camera name
  106167. * @param alpha defines alpha angle (in radians)
  106168. * @param beta defines beta angle (in radians)
  106169. * @param radius defines radius
  106170. * @param target defines camera target
  106171. * @param interaxialDistance defines distance between each color axis
  106172. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106173. * @param scene defines the hosting scene
  106174. */
  106175. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106176. /**
  106177. * Gets camera class name
  106178. * @returns StereoscopicArcRotateCamera
  106179. */
  106180. getClassName(): string;
  106181. }
  106182. }
  106183. declare module BABYLON {
  106184. /**
  106185. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106186. * @see http://doc.babylonjs.com/features/cameras
  106187. */
  106188. export class StereoscopicFreeCamera extends FreeCamera {
  106189. /**
  106190. * Creates a new StereoscopicFreeCamera
  106191. * @param name defines camera name
  106192. * @param position defines initial position
  106193. * @param interaxialDistance defines distance between each color axis
  106194. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106195. * @param scene defines the hosting scene
  106196. */
  106197. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106198. /**
  106199. * Gets camera class name
  106200. * @returns StereoscopicFreeCamera
  106201. */
  106202. getClassName(): string;
  106203. }
  106204. }
  106205. declare module BABYLON {
  106206. /**
  106207. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106208. * @see http://doc.babylonjs.com/features/cameras
  106209. */
  106210. export class StereoscopicGamepadCamera extends GamepadCamera {
  106211. /**
  106212. * Creates a new StereoscopicGamepadCamera
  106213. * @param name defines camera name
  106214. * @param position defines initial position
  106215. * @param interaxialDistance defines distance between each color axis
  106216. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106217. * @param scene defines the hosting scene
  106218. */
  106219. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106220. /**
  106221. * Gets camera class name
  106222. * @returns StereoscopicGamepadCamera
  106223. */
  106224. getClassName(): string;
  106225. }
  106226. }
  106227. declare module BABYLON {
  106228. /**
  106229. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106230. * @see http://doc.babylonjs.com/features/cameras
  106231. */
  106232. export class StereoscopicUniversalCamera extends UniversalCamera {
  106233. /**
  106234. * Creates a new StereoscopicUniversalCamera
  106235. * @param name defines camera name
  106236. * @param position defines initial position
  106237. * @param interaxialDistance defines distance between each color axis
  106238. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106239. * @param scene defines the hosting scene
  106240. */
  106241. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106242. /**
  106243. * Gets camera class name
  106244. * @returns StereoscopicUniversalCamera
  106245. */
  106246. getClassName(): string;
  106247. }
  106248. }
  106249. declare module BABYLON {
  106250. /**
  106251. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106252. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106253. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106254. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106255. */
  106256. export class VirtualJoysticksCamera extends FreeCamera {
  106257. /**
  106258. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106259. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106260. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106261. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106262. * @param name Define the name of the camera in the scene
  106263. * @param position Define the start position of the camera in the scene
  106264. * @param scene Define the scene the camera belongs to
  106265. */
  106266. constructor(name: string, position: Vector3, scene: Scene);
  106267. /**
  106268. * Gets the current object class name.
  106269. * @return the class name
  106270. */
  106271. getClassName(): string;
  106272. }
  106273. }
  106274. declare module BABYLON {
  106275. /**
  106276. * This represents all the required metrics to create a VR camera.
  106277. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106278. */
  106279. export class VRCameraMetrics {
  106280. /**
  106281. * Define the horizontal resolution off the screen.
  106282. */
  106283. hResolution: number;
  106284. /**
  106285. * Define the vertical resolution off the screen.
  106286. */
  106287. vResolution: number;
  106288. /**
  106289. * Define the horizontal screen size.
  106290. */
  106291. hScreenSize: number;
  106292. /**
  106293. * Define the vertical screen size.
  106294. */
  106295. vScreenSize: number;
  106296. /**
  106297. * Define the vertical screen center position.
  106298. */
  106299. vScreenCenter: number;
  106300. /**
  106301. * Define the distance of the eyes to the screen.
  106302. */
  106303. eyeToScreenDistance: number;
  106304. /**
  106305. * Define the distance between both lenses
  106306. */
  106307. lensSeparationDistance: number;
  106308. /**
  106309. * Define the distance between both viewer's eyes.
  106310. */
  106311. interpupillaryDistance: number;
  106312. /**
  106313. * Define the distortion factor of the VR postprocess.
  106314. * Please, touch with care.
  106315. */
  106316. distortionK: number[];
  106317. /**
  106318. * Define the chromatic aberration correction factors for the VR post process.
  106319. */
  106320. chromaAbCorrection: number[];
  106321. /**
  106322. * Define the scale factor of the post process.
  106323. * The smaller the better but the slower.
  106324. */
  106325. postProcessScaleFactor: number;
  106326. /**
  106327. * Define an offset for the lens center.
  106328. */
  106329. lensCenterOffset: number;
  106330. /**
  106331. * Define if the current vr camera should compensate the distortion of the lense or not.
  106332. */
  106333. compensateDistortion: boolean;
  106334. /**
  106335. * Defines if multiview should be enabled when rendering (Default: false)
  106336. */
  106337. multiviewEnabled: boolean;
  106338. /**
  106339. * Gets the rendering aspect ratio based on the provided resolutions.
  106340. */
  106341. readonly aspectRatio: number;
  106342. /**
  106343. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106344. */
  106345. readonly aspectRatioFov: number;
  106346. /**
  106347. * @hidden
  106348. */
  106349. readonly leftHMatrix: Matrix;
  106350. /**
  106351. * @hidden
  106352. */
  106353. readonly rightHMatrix: Matrix;
  106354. /**
  106355. * @hidden
  106356. */
  106357. readonly leftPreViewMatrix: Matrix;
  106358. /**
  106359. * @hidden
  106360. */
  106361. readonly rightPreViewMatrix: Matrix;
  106362. /**
  106363. * Get the default VRMetrics based on the most generic setup.
  106364. * @returns the default vr metrics
  106365. */
  106366. static GetDefault(): VRCameraMetrics;
  106367. }
  106368. }
  106369. declare module BABYLON {
  106370. /** @hidden */
  106371. export var vrDistortionCorrectionPixelShader: {
  106372. name: string;
  106373. shader: string;
  106374. };
  106375. }
  106376. declare module BABYLON {
  106377. /**
  106378. * VRDistortionCorrectionPostProcess used for mobile VR
  106379. */
  106380. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106381. private _isRightEye;
  106382. private _distortionFactors;
  106383. private _postProcessScaleFactor;
  106384. private _lensCenterOffset;
  106385. private _scaleIn;
  106386. private _scaleFactor;
  106387. private _lensCenter;
  106388. /**
  106389. * Initializes the VRDistortionCorrectionPostProcess
  106390. * @param name The name of the effect.
  106391. * @param camera The camera to apply the render pass to.
  106392. * @param isRightEye If this is for the right eye distortion
  106393. * @param vrMetrics All the required metrics for the VR camera
  106394. */
  106395. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106396. }
  106397. }
  106398. declare module BABYLON {
  106399. /**
  106400. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106401. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106402. */
  106403. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106404. /**
  106405. * Creates a new VRDeviceOrientationArcRotateCamera
  106406. * @param name defines camera name
  106407. * @param alpha defines the camera rotation along the logitudinal axis
  106408. * @param beta defines the camera rotation along the latitudinal axis
  106409. * @param radius defines the camera distance from its target
  106410. * @param target defines the camera target
  106411. * @param scene defines the scene the camera belongs to
  106412. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106413. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106414. */
  106415. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106416. /**
  106417. * Gets camera class name
  106418. * @returns VRDeviceOrientationArcRotateCamera
  106419. */
  106420. getClassName(): string;
  106421. }
  106422. }
  106423. declare module BABYLON {
  106424. /**
  106425. * Camera used to simulate VR rendering (based on FreeCamera)
  106426. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106427. */
  106428. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106429. /**
  106430. * Creates a new VRDeviceOrientationFreeCamera
  106431. * @param name defines camera name
  106432. * @param position defines the start position of the camera
  106433. * @param scene defines the scene the camera belongs to
  106434. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106435. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106436. */
  106437. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106438. /**
  106439. * Gets camera class name
  106440. * @returns VRDeviceOrientationFreeCamera
  106441. */
  106442. getClassName(): string;
  106443. }
  106444. }
  106445. declare module BABYLON {
  106446. /**
  106447. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106448. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106449. */
  106450. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106451. /**
  106452. * Creates a new VRDeviceOrientationGamepadCamera
  106453. * @param name defines camera name
  106454. * @param position defines the start position of the camera
  106455. * @param scene defines the scene the camera belongs to
  106456. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106457. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106458. */
  106459. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106460. /**
  106461. * Gets camera class name
  106462. * @returns VRDeviceOrientationGamepadCamera
  106463. */
  106464. getClassName(): string;
  106465. }
  106466. }
  106467. declare module BABYLON {
  106468. /**
  106469. * Base class of materials working in push mode in babylon JS
  106470. * @hidden
  106471. */
  106472. export class PushMaterial extends Material {
  106473. protected _activeEffect: Effect;
  106474. protected _normalMatrix: Matrix;
  106475. /**
  106476. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106477. * This means that the material can keep using a previous shader while a new one is being compiled.
  106478. * This is mostly used when shader parallel compilation is supported (true by default)
  106479. */
  106480. allowShaderHotSwapping: boolean;
  106481. constructor(name: string, scene: Scene);
  106482. getEffect(): Effect;
  106483. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106484. /**
  106485. * Binds the given world matrix to the active effect
  106486. *
  106487. * @param world the matrix to bind
  106488. */
  106489. bindOnlyWorldMatrix(world: Matrix): void;
  106490. /**
  106491. * Binds the given normal matrix to the active effect
  106492. *
  106493. * @param normalMatrix the matrix to bind
  106494. */
  106495. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106496. bind(world: Matrix, mesh?: Mesh): void;
  106497. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106498. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106499. }
  106500. }
  106501. declare module BABYLON {
  106502. /**
  106503. * This groups all the flags used to control the materials channel.
  106504. */
  106505. export class MaterialFlags {
  106506. private static _DiffuseTextureEnabled;
  106507. /**
  106508. * Are diffuse textures enabled in the application.
  106509. */
  106510. static DiffuseTextureEnabled: boolean;
  106511. private static _AmbientTextureEnabled;
  106512. /**
  106513. * Are ambient textures enabled in the application.
  106514. */
  106515. static AmbientTextureEnabled: boolean;
  106516. private static _OpacityTextureEnabled;
  106517. /**
  106518. * Are opacity textures enabled in the application.
  106519. */
  106520. static OpacityTextureEnabled: boolean;
  106521. private static _ReflectionTextureEnabled;
  106522. /**
  106523. * Are reflection textures enabled in the application.
  106524. */
  106525. static ReflectionTextureEnabled: boolean;
  106526. private static _EmissiveTextureEnabled;
  106527. /**
  106528. * Are emissive textures enabled in the application.
  106529. */
  106530. static EmissiveTextureEnabled: boolean;
  106531. private static _SpecularTextureEnabled;
  106532. /**
  106533. * Are specular textures enabled in the application.
  106534. */
  106535. static SpecularTextureEnabled: boolean;
  106536. private static _BumpTextureEnabled;
  106537. /**
  106538. * Are bump textures enabled in the application.
  106539. */
  106540. static BumpTextureEnabled: boolean;
  106541. private static _LightmapTextureEnabled;
  106542. /**
  106543. * Are lightmap textures enabled in the application.
  106544. */
  106545. static LightmapTextureEnabled: boolean;
  106546. private static _RefractionTextureEnabled;
  106547. /**
  106548. * Are refraction textures enabled in the application.
  106549. */
  106550. static RefractionTextureEnabled: boolean;
  106551. private static _ColorGradingTextureEnabled;
  106552. /**
  106553. * Are color grading textures enabled in the application.
  106554. */
  106555. static ColorGradingTextureEnabled: boolean;
  106556. private static _FresnelEnabled;
  106557. /**
  106558. * Are fresnels enabled in the application.
  106559. */
  106560. static FresnelEnabled: boolean;
  106561. private static _ClearCoatTextureEnabled;
  106562. /**
  106563. * Are clear coat textures enabled in the application.
  106564. */
  106565. static ClearCoatTextureEnabled: boolean;
  106566. private static _ClearCoatBumpTextureEnabled;
  106567. /**
  106568. * Are clear coat bump textures enabled in the application.
  106569. */
  106570. static ClearCoatBumpTextureEnabled: boolean;
  106571. private static _ClearCoatTintTextureEnabled;
  106572. /**
  106573. * Are clear coat tint textures enabled in the application.
  106574. */
  106575. static ClearCoatTintTextureEnabled: boolean;
  106576. private static _SheenTextureEnabled;
  106577. /**
  106578. * Are sheen textures enabled in the application.
  106579. */
  106580. static SheenTextureEnabled: boolean;
  106581. private static _AnisotropicTextureEnabled;
  106582. /**
  106583. * Are anisotropic textures enabled in the application.
  106584. */
  106585. static AnisotropicTextureEnabled: boolean;
  106586. private static _ThicknessTextureEnabled;
  106587. /**
  106588. * Are thickness textures enabled in the application.
  106589. */
  106590. static ThicknessTextureEnabled: boolean;
  106591. }
  106592. }
  106593. declare module BABYLON {
  106594. /** @hidden */
  106595. export var defaultFragmentDeclaration: {
  106596. name: string;
  106597. shader: string;
  106598. };
  106599. }
  106600. declare module BABYLON {
  106601. /** @hidden */
  106602. export var defaultUboDeclaration: {
  106603. name: string;
  106604. shader: string;
  106605. };
  106606. }
  106607. declare module BABYLON {
  106608. /** @hidden */
  106609. export var lightFragmentDeclaration: {
  106610. name: string;
  106611. shader: string;
  106612. };
  106613. }
  106614. declare module BABYLON {
  106615. /** @hidden */
  106616. export var lightUboDeclaration: {
  106617. name: string;
  106618. shader: string;
  106619. };
  106620. }
  106621. declare module BABYLON {
  106622. /** @hidden */
  106623. export var lightsFragmentFunctions: {
  106624. name: string;
  106625. shader: string;
  106626. };
  106627. }
  106628. declare module BABYLON {
  106629. /** @hidden */
  106630. export var shadowsFragmentFunctions: {
  106631. name: string;
  106632. shader: string;
  106633. };
  106634. }
  106635. declare module BABYLON {
  106636. /** @hidden */
  106637. export var fresnelFunction: {
  106638. name: string;
  106639. shader: string;
  106640. };
  106641. }
  106642. declare module BABYLON {
  106643. /** @hidden */
  106644. export var reflectionFunction: {
  106645. name: string;
  106646. shader: string;
  106647. };
  106648. }
  106649. declare module BABYLON {
  106650. /** @hidden */
  106651. export var bumpFragmentFunctions: {
  106652. name: string;
  106653. shader: string;
  106654. };
  106655. }
  106656. declare module BABYLON {
  106657. /** @hidden */
  106658. export var logDepthDeclaration: {
  106659. name: string;
  106660. shader: string;
  106661. };
  106662. }
  106663. declare module BABYLON {
  106664. /** @hidden */
  106665. export var bumpFragment: {
  106666. name: string;
  106667. shader: string;
  106668. };
  106669. }
  106670. declare module BABYLON {
  106671. /** @hidden */
  106672. export var depthPrePass: {
  106673. name: string;
  106674. shader: string;
  106675. };
  106676. }
  106677. declare module BABYLON {
  106678. /** @hidden */
  106679. export var lightFragment: {
  106680. name: string;
  106681. shader: string;
  106682. };
  106683. }
  106684. declare module BABYLON {
  106685. /** @hidden */
  106686. export var logDepthFragment: {
  106687. name: string;
  106688. shader: string;
  106689. };
  106690. }
  106691. declare module BABYLON {
  106692. /** @hidden */
  106693. export var defaultPixelShader: {
  106694. name: string;
  106695. shader: string;
  106696. };
  106697. }
  106698. declare module BABYLON {
  106699. /** @hidden */
  106700. export var defaultVertexDeclaration: {
  106701. name: string;
  106702. shader: string;
  106703. };
  106704. }
  106705. declare module BABYLON {
  106706. /** @hidden */
  106707. export var bumpVertexDeclaration: {
  106708. name: string;
  106709. shader: string;
  106710. };
  106711. }
  106712. declare module BABYLON {
  106713. /** @hidden */
  106714. export var bumpVertex: {
  106715. name: string;
  106716. shader: string;
  106717. };
  106718. }
  106719. declare module BABYLON {
  106720. /** @hidden */
  106721. export var fogVertex: {
  106722. name: string;
  106723. shader: string;
  106724. };
  106725. }
  106726. declare module BABYLON {
  106727. /** @hidden */
  106728. export var shadowsVertex: {
  106729. name: string;
  106730. shader: string;
  106731. };
  106732. }
  106733. declare module BABYLON {
  106734. /** @hidden */
  106735. export var pointCloudVertex: {
  106736. name: string;
  106737. shader: string;
  106738. };
  106739. }
  106740. declare module BABYLON {
  106741. /** @hidden */
  106742. export var logDepthVertex: {
  106743. name: string;
  106744. shader: string;
  106745. };
  106746. }
  106747. declare module BABYLON {
  106748. /** @hidden */
  106749. export var defaultVertexShader: {
  106750. name: string;
  106751. shader: string;
  106752. };
  106753. }
  106754. declare module BABYLON {
  106755. /** @hidden */
  106756. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106757. MAINUV1: boolean;
  106758. MAINUV2: boolean;
  106759. DIFFUSE: boolean;
  106760. DIFFUSEDIRECTUV: number;
  106761. AMBIENT: boolean;
  106762. AMBIENTDIRECTUV: number;
  106763. OPACITY: boolean;
  106764. OPACITYDIRECTUV: number;
  106765. OPACITYRGB: boolean;
  106766. REFLECTION: boolean;
  106767. EMISSIVE: boolean;
  106768. EMISSIVEDIRECTUV: number;
  106769. SPECULAR: boolean;
  106770. SPECULARDIRECTUV: number;
  106771. BUMP: boolean;
  106772. BUMPDIRECTUV: number;
  106773. PARALLAX: boolean;
  106774. PARALLAXOCCLUSION: boolean;
  106775. SPECULAROVERALPHA: boolean;
  106776. CLIPPLANE: boolean;
  106777. CLIPPLANE2: boolean;
  106778. CLIPPLANE3: boolean;
  106779. CLIPPLANE4: boolean;
  106780. ALPHATEST: boolean;
  106781. DEPTHPREPASS: boolean;
  106782. ALPHAFROMDIFFUSE: boolean;
  106783. POINTSIZE: boolean;
  106784. FOG: boolean;
  106785. SPECULARTERM: boolean;
  106786. DIFFUSEFRESNEL: boolean;
  106787. OPACITYFRESNEL: boolean;
  106788. REFLECTIONFRESNEL: boolean;
  106789. REFRACTIONFRESNEL: boolean;
  106790. EMISSIVEFRESNEL: boolean;
  106791. FRESNEL: boolean;
  106792. NORMAL: boolean;
  106793. UV1: boolean;
  106794. UV2: boolean;
  106795. VERTEXCOLOR: boolean;
  106796. VERTEXALPHA: boolean;
  106797. NUM_BONE_INFLUENCERS: number;
  106798. BonesPerMesh: number;
  106799. BONETEXTURE: boolean;
  106800. INSTANCES: boolean;
  106801. GLOSSINESS: boolean;
  106802. ROUGHNESS: boolean;
  106803. EMISSIVEASILLUMINATION: boolean;
  106804. LINKEMISSIVEWITHDIFFUSE: boolean;
  106805. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106806. LIGHTMAP: boolean;
  106807. LIGHTMAPDIRECTUV: number;
  106808. OBJECTSPACE_NORMALMAP: boolean;
  106809. USELIGHTMAPASSHADOWMAP: boolean;
  106810. REFLECTIONMAP_3D: boolean;
  106811. REFLECTIONMAP_SPHERICAL: boolean;
  106812. REFLECTIONMAP_PLANAR: boolean;
  106813. REFLECTIONMAP_CUBIC: boolean;
  106814. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106815. REFLECTIONMAP_PROJECTION: boolean;
  106816. REFLECTIONMAP_SKYBOX: boolean;
  106817. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106818. REFLECTIONMAP_EXPLICIT: boolean;
  106819. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106820. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106821. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106822. INVERTCUBICMAP: boolean;
  106823. LOGARITHMICDEPTH: boolean;
  106824. REFRACTION: boolean;
  106825. REFRACTIONMAP_3D: boolean;
  106826. REFLECTIONOVERALPHA: boolean;
  106827. TWOSIDEDLIGHTING: boolean;
  106828. SHADOWFLOAT: boolean;
  106829. MORPHTARGETS: boolean;
  106830. MORPHTARGETS_NORMAL: boolean;
  106831. MORPHTARGETS_TANGENT: boolean;
  106832. MORPHTARGETS_UV: boolean;
  106833. NUM_MORPH_INFLUENCERS: number;
  106834. NONUNIFORMSCALING: boolean;
  106835. PREMULTIPLYALPHA: boolean;
  106836. IMAGEPROCESSING: boolean;
  106837. VIGNETTE: boolean;
  106838. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106839. VIGNETTEBLENDMODEOPAQUE: boolean;
  106840. TONEMAPPING: boolean;
  106841. TONEMAPPING_ACES: boolean;
  106842. CONTRAST: boolean;
  106843. COLORCURVES: boolean;
  106844. COLORGRADING: boolean;
  106845. COLORGRADING3D: boolean;
  106846. SAMPLER3DGREENDEPTH: boolean;
  106847. SAMPLER3DBGRMAP: boolean;
  106848. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106849. MULTIVIEW: boolean;
  106850. /**
  106851. * If the reflection texture on this material is in linear color space
  106852. * @hidden
  106853. */
  106854. IS_REFLECTION_LINEAR: boolean;
  106855. /**
  106856. * If the refraction texture on this material is in linear color space
  106857. * @hidden
  106858. */
  106859. IS_REFRACTION_LINEAR: boolean;
  106860. EXPOSURE: boolean;
  106861. constructor();
  106862. setReflectionMode(modeToEnable: string): void;
  106863. }
  106864. /**
  106865. * This is the default material used in Babylon. It is the best trade off between quality
  106866. * and performances.
  106867. * @see http://doc.babylonjs.com/babylon101/materials
  106868. */
  106869. export class StandardMaterial extends PushMaterial {
  106870. private _diffuseTexture;
  106871. /**
  106872. * The basic texture of the material as viewed under a light.
  106873. */
  106874. diffuseTexture: Nullable<BaseTexture>;
  106875. private _ambientTexture;
  106876. /**
  106877. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106878. */
  106879. ambientTexture: Nullable<BaseTexture>;
  106880. private _opacityTexture;
  106881. /**
  106882. * Define the transparency of the material from a texture.
  106883. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106884. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106885. */
  106886. opacityTexture: Nullable<BaseTexture>;
  106887. private _reflectionTexture;
  106888. /**
  106889. * Define the texture used to display the reflection.
  106890. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106891. */
  106892. reflectionTexture: Nullable<BaseTexture>;
  106893. private _emissiveTexture;
  106894. /**
  106895. * Define texture of the material as if self lit.
  106896. * This will be mixed in the final result even in the absence of light.
  106897. */
  106898. emissiveTexture: Nullable<BaseTexture>;
  106899. private _specularTexture;
  106900. /**
  106901. * Define how the color and intensity of the highlight given by the light in the material.
  106902. */
  106903. specularTexture: Nullable<BaseTexture>;
  106904. private _bumpTexture;
  106905. /**
  106906. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106907. * 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.
  106908. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106909. */
  106910. bumpTexture: Nullable<BaseTexture>;
  106911. private _lightmapTexture;
  106912. /**
  106913. * Complex lighting can be computationally expensive to compute at runtime.
  106914. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106915. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106916. */
  106917. lightmapTexture: Nullable<BaseTexture>;
  106918. private _refractionTexture;
  106919. /**
  106920. * Define the texture used to display the refraction.
  106921. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106922. */
  106923. refractionTexture: Nullable<BaseTexture>;
  106924. /**
  106925. * The color of the material lit by the environmental background lighting.
  106926. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106927. */
  106928. ambientColor: Color3;
  106929. /**
  106930. * The basic color of the material as viewed under a light.
  106931. */
  106932. diffuseColor: Color3;
  106933. /**
  106934. * Define how the color and intensity of the highlight given by the light in the material.
  106935. */
  106936. specularColor: Color3;
  106937. /**
  106938. * Define the color of the material as if self lit.
  106939. * This will be mixed in the final result even in the absence of light.
  106940. */
  106941. emissiveColor: Color3;
  106942. /**
  106943. * Defines how sharp are the highlights in the material.
  106944. * The bigger the value the sharper giving a more glossy feeling to the result.
  106945. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106946. */
  106947. specularPower: number;
  106948. private _useAlphaFromDiffuseTexture;
  106949. /**
  106950. * Does the transparency come from the diffuse texture alpha channel.
  106951. */
  106952. useAlphaFromDiffuseTexture: boolean;
  106953. private _useEmissiveAsIllumination;
  106954. /**
  106955. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106956. */
  106957. useEmissiveAsIllumination: boolean;
  106958. private _linkEmissiveWithDiffuse;
  106959. /**
  106960. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106961. * the emissive level when the final color is close to one.
  106962. */
  106963. linkEmissiveWithDiffuse: boolean;
  106964. private _useSpecularOverAlpha;
  106965. /**
  106966. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106967. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106968. */
  106969. useSpecularOverAlpha: boolean;
  106970. private _useReflectionOverAlpha;
  106971. /**
  106972. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106973. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106974. */
  106975. useReflectionOverAlpha: boolean;
  106976. private _disableLighting;
  106977. /**
  106978. * Does lights from the scene impacts this material.
  106979. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106980. */
  106981. disableLighting: boolean;
  106982. private _useObjectSpaceNormalMap;
  106983. /**
  106984. * Allows using an object space normal map (instead of tangent space).
  106985. */
  106986. useObjectSpaceNormalMap: boolean;
  106987. private _useParallax;
  106988. /**
  106989. * Is parallax enabled or not.
  106990. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106991. */
  106992. useParallax: boolean;
  106993. private _useParallaxOcclusion;
  106994. /**
  106995. * Is parallax occlusion enabled or not.
  106996. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106997. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106998. */
  106999. useParallaxOcclusion: boolean;
  107000. /**
  107001. * 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.
  107002. */
  107003. parallaxScaleBias: number;
  107004. private _roughness;
  107005. /**
  107006. * Helps to define how blurry the reflections should appears in the material.
  107007. */
  107008. roughness: number;
  107009. /**
  107010. * In case of refraction, define the value of the index of refraction.
  107011. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107012. */
  107013. indexOfRefraction: number;
  107014. /**
  107015. * Invert the refraction texture alongside the y axis.
  107016. * It can be useful with procedural textures or probe for instance.
  107017. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107018. */
  107019. invertRefractionY: boolean;
  107020. /**
  107021. * Defines the alpha limits in alpha test mode.
  107022. */
  107023. alphaCutOff: number;
  107024. private _useLightmapAsShadowmap;
  107025. /**
  107026. * In case of light mapping, define whether the map contains light or shadow informations.
  107027. */
  107028. useLightmapAsShadowmap: boolean;
  107029. private _diffuseFresnelParameters;
  107030. /**
  107031. * Define the diffuse fresnel parameters of the material.
  107032. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107033. */
  107034. diffuseFresnelParameters: FresnelParameters;
  107035. private _opacityFresnelParameters;
  107036. /**
  107037. * Define the opacity fresnel parameters of the material.
  107038. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107039. */
  107040. opacityFresnelParameters: FresnelParameters;
  107041. private _reflectionFresnelParameters;
  107042. /**
  107043. * Define the reflection fresnel parameters of the material.
  107044. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107045. */
  107046. reflectionFresnelParameters: FresnelParameters;
  107047. private _refractionFresnelParameters;
  107048. /**
  107049. * Define the refraction fresnel parameters of the material.
  107050. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107051. */
  107052. refractionFresnelParameters: FresnelParameters;
  107053. private _emissiveFresnelParameters;
  107054. /**
  107055. * Define the emissive fresnel parameters of the material.
  107056. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107057. */
  107058. emissiveFresnelParameters: FresnelParameters;
  107059. private _useReflectionFresnelFromSpecular;
  107060. /**
  107061. * If true automatically deducts the fresnels values from the material specularity.
  107062. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107063. */
  107064. useReflectionFresnelFromSpecular: boolean;
  107065. private _useGlossinessFromSpecularMapAlpha;
  107066. /**
  107067. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107068. */
  107069. useGlossinessFromSpecularMapAlpha: boolean;
  107070. private _maxSimultaneousLights;
  107071. /**
  107072. * Defines the maximum number of lights that can be used in the material
  107073. */
  107074. maxSimultaneousLights: number;
  107075. private _invertNormalMapX;
  107076. /**
  107077. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107078. */
  107079. invertNormalMapX: boolean;
  107080. private _invertNormalMapY;
  107081. /**
  107082. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107083. */
  107084. invertNormalMapY: boolean;
  107085. private _twoSidedLighting;
  107086. /**
  107087. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107088. */
  107089. twoSidedLighting: boolean;
  107090. /**
  107091. * Default configuration related to image processing available in the standard Material.
  107092. */
  107093. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107094. /**
  107095. * Gets the image processing configuration used either in this material.
  107096. */
  107097. /**
  107098. * Sets the Default image processing configuration used either in the this material.
  107099. *
  107100. * If sets to null, the scene one is in use.
  107101. */
  107102. imageProcessingConfiguration: ImageProcessingConfiguration;
  107103. /**
  107104. * Keep track of the image processing observer to allow dispose and replace.
  107105. */
  107106. private _imageProcessingObserver;
  107107. /**
  107108. * Attaches a new image processing configuration to the Standard Material.
  107109. * @param configuration
  107110. */
  107111. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107112. /**
  107113. * Gets wether the color curves effect is enabled.
  107114. */
  107115. /**
  107116. * Sets wether the color curves effect is enabled.
  107117. */
  107118. cameraColorCurvesEnabled: boolean;
  107119. /**
  107120. * Gets wether the color grading effect is enabled.
  107121. */
  107122. /**
  107123. * Gets wether the color grading effect is enabled.
  107124. */
  107125. cameraColorGradingEnabled: boolean;
  107126. /**
  107127. * Gets wether tonemapping is enabled or not.
  107128. */
  107129. /**
  107130. * Sets wether tonemapping is enabled or not
  107131. */
  107132. cameraToneMappingEnabled: boolean;
  107133. /**
  107134. * The camera exposure used on this material.
  107135. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107136. * This corresponds to a photographic exposure.
  107137. */
  107138. /**
  107139. * The camera exposure used on this material.
  107140. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107141. * This corresponds to a photographic exposure.
  107142. */
  107143. cameraExposure: number;
  107144. /**
  107145. * Gets The camera contrast used on this material.
  107146. */
  107147. /**
  107148. * Sets The camera contrast used on this material.
  107149. */
  107150. cameraContrast: number;
  107151. /**
  107152. * Gets the Color Grading 2D Lookup Texture.
  107153. */
  107154. /**
  107155. * Sets the Color Grading 2D Lookup Texture.
  107156. */
  107157. cameraColorGradingTexture: Nullable<BaseTexture>;
  107158. /**
  107159. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107160. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107161. * 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;
  107162. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107163. */
  107164. /**
  107165. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107166. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107167. * 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;
  107168. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107169. */
  107170. cameraColorCurves: Nullable<ColorCurves>;
  107171. /**
  107172. * Custom callback helping to override the default shader used in the material.
  107173. */
  107174. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107175. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107176. protected _worldViewProjectionMatrix: Matrix;
  107177. protected _globalAmbientColor: Color3;
  107178. protected _useLogarithmicDepth: boolean;
  107179. protected _rebuildInParallel: boolean;
  107180. /**
  107181. * Instantiates a new standard material.
  107182. * This is the default material used in Babylon. It is the best trade off between quality
  107183. * and performances.
  107184. * @see http://doc.babylonjs.com/babylon101/materials
  107185. * @param name Define the name of the material in the scene
  107186. * @param scene Define the scene the material belong to
  107187. */
  107188. constructor(name: string, scene: Scene);
  107189. /**
  107190. * Gets a boolean indicating that current material needs to register RTT
  107191. */
  107192. readonly hasRenderTargetTextures: boolean;
  107193. /**
  107194. * Gets the current class name of the material e.g. "StandardMaterial"
  107195. * Mainly use in serialization.
  107196. * @returns the class name
  107197. */
  107198. getClassName(): string;
  107199. /**
  107200. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107201. * You can try switching to logarithmic depth.
  107202. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107203. */
  107204. useLogarithmicDepth: boolean;
  107205. /**
  107206. * Specifies if the material will require alpha blending
  107207. * @returns a boolean specifying if alpha blending is needed
  107208. */
  107209. needAlphaBlending(): boolean;
  107210. /**
  107211. * Specifies if this material should be rendered in alpha test mode
  107212. * @returns a boolean specifying if an alpha test is needed.
  107213. */
  107214. needAlphaTesting(): boolean;
  107215. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107216. /**
  107217. * Get the texture used for alpha test purpose.
  107218. * @returns the diffuse texture in case of the standard material.
  107219. */
  107220. getAlphaTestTexture(): Nullable<BaseTexture>;
  107221. /**
  107222. * Get if the submesh is ready to be used and all its information available.
  107223. * Child classes can use it to update shaders
  107224. * @param mesh defines the mesh to check
  107225. * @param subMesh defines which submesh to check
  107226. * @param useInstances specifies that instances should be used
  107227. * @returns a boolean indicating that the submesh is ready or not
  107228. */
  107229. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107230. /**
  107231. * Builds the material UBO layouts.
  107232. * Used internally during the effect preparation.
  107233. */
  107234. buildUniformLayout(): void;
  107235. /**
  107236. * Unbinds the material from the mesh
  107237. */
  107238. unbind(): void;
  107239. /**
  107240. * Binds the submesh to this material by preparing the effect and shader to draw
  107241. * @param world defines the world transformation matrix
  107242. * @param mesh defines the mesh containing the submesh
  107243. * @param subMesh defines the submesh to bind the material to
  107244. */
  107245. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107246. /**
  107247. * Get the list of animatables in the material.
  107248. * @returns the list of animatables object used in the material
  107249. */
  107250. getAnimatables(): IAnimatable[];
  107251. /**
  107252. * Gets the active textures from the material
  107253. * @returns an array of textures
  107254. */
  107255. getActiveTextures(): BaseTexture[];
  107256. /**
  107257. * Specifies if the material uses a texture
  107258. * @param texture defines the texture to check against the material
  107259. * @returns a boolean specifying if the material uses the texture
  107260. */
  107261. hasTexture(texture: BaseTexture): boolean;
  107262. /**
  107263. * Disposes the material
  107264. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107265. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107266. */
  107267. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107268. /**
  107269. * Makes a duplicate of the material, and gives it a new name
  107270. * @param name defines the new name for the duplicated material
  107271. * @returns the cloned material
  107272. */
  107273. clone(name: string): StandardMaterial;
  107274. /**
  107275. * Serializes this material in a JSON representation
  107276. * @returns the serialized material object
  107277. */
  107278. serialize(): any;
  107279. /**
  107280. * Creates a standard material from parsed material data
  107281. * @param source defines the JSON representation of the material
  107282. * @param scene defines the hosting scene
  107283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107284. * @returns a new standard material
  107285. */
  107286. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107287. /**
  107288. * Are diffuse textures enabled in the application.
  107289. */
  107290. static DiffuseTextureEnabled: boolean;
  107291. /**
  107292. * Are ambient textures enabled in the application.
  107293. */
  107294. static AmbientTextureEnabled: boolean;
  107295. /**
  107296. * Are opacity textures enabled in the application.
  107297. */
  107298. static OpacityTextureEnabled: boolean;
  107299. /**
  107300. * Are reflection textures enabled in the application.
  107301. */
  107302. static ReflectionTextureEnabled: boolean;
  107303. /**
  107304. * Are emissive textures enabled in the application.
  107305. */
  107306. static EmissiveTextureEnabled: boolean;
  107307. /**
  107308. * Are specular textures enabled in the application.
  107309. */
  107310. static SpecularTextureEnabled: boolean;
  107311. /**
  107312. * Are bump textures enabled in the application.
  107313. */
  107314. static BumpTextureEnabled: boolean;
  107315. /**
  107316. * Are lightmap textures enabled in the application.
  107317. */
  107318. static LightmapTextureEnabled: boolean;
  107319. /**
  107320. * Are refraction textures enabled in the application.
  107321. */
  107322. static RefractionTextureEnabled: boolean;
  107323. /**
  107324. * Are color grading textures enabled in the application.
  107325. */
  107326. static ColorGradingTextureEnabled: boolean;
  107327. /**
  107328. * Are fresnels enabled in the application.
  107329. */
  107330. static FresnelEnabled: boolean;
  107331. }
  107332. }
  107333. declare module BABYLON {
  107334. /** @hidden */
  107335. export var imageProcessingPixelShader: {
  107336. name: string;
  107337. shader: string;
  107338. };
  107339. }
  107340. declare module BABYLON {
  107341. /**
  107342. * ImageProcessingPostProcess
  107343. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107344. */
  107345. export class ImageProcessingPostProcess extends PostProcess {
  107346. /**
  107347. * Default configuration related to image processing available in the PBR Material.
  107348. */
  107349. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107350. /**
  107351. * Gets the image processing configuration used either in this material.
  107352. */
  107353. /**
  107354. * Sets the Default image processing configuration used either in the this material.
  107355. *
  107356. * If sets to null, the scene one is in use.
  107357. */
  107358. imageProcessingConfiguration: ImageProcessingConfiguration;
  107359. /**
  107360. * Keep track of the image processing observer to allow dispose and replace.
  107361. */
  107362. private _imageProcessingObserver;
  107363. /**
  107364. * Attaches a new image processing configuration to the PBR Material.
  107365. * @param configuration
  107366. */
  107367. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107368. /**
  107369. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107370. */
  107371. /**
  107372. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107373. */
  107374. colorCurves: Nullable<ColorCurves>;
  107375. /**
  107376. * Gets wether the color curves effect is enabled.
  107377. */
  107378. /**
  107379. * Sets wether the color curves effect is enabled.
  107380. */
  107381. colorCurvesEnabled: boolean;
  107382. /**
  107383. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107384. */
  107385. /**
  107386. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107387. */
  107388. colorGradingTexture: Nullable<BaseTexture>;
  107389. /**
  107390. * Gets wether the color grading effect is enabled.
  107391. */
  107392. /**
  107393. * Gets wether the color grading effect is enabled.
  107394. */
  107395. colorGradingEnabled: boolean;
  107396. /**
  107397. * Gets exposure used in the effect.
  107398. */
  107399. /**
  107400. * Sets exposure used in the effect.
  107401. */
  107402. exposure: number;
  107403. /**
  107404. * Gets wether tonemapping is enabled or not.
  107405. */
  107406. /**
  107407. * Sets wether tonemapping is enabled or not
  107408. */
  107409. toneMappingEnabled: boolean;
  107410. /**
  107411. * Gets the type of tone mapping effect.
  107412. */
  107413. /**
  107414. * Sets the type of tone mapping effect.
  107415. */
  107416. toneMappingType: number;
  107417. /**
  107418. * Gets contrast used in the effect.
  107419. */
  107420. /**
  107421. * Sets contrast used in the effect.
  107422. */
  107423. contrast: number;
  107424. /**
  107425. * Gets Vignette stretch size.
  107426. */
  107427. /**
  107428. * Sets Vignette stretch size.
  107429. */
  107430. vignetteStretch: number;
  107431. /**
  107432. * Gets Vignette centre X Offset.
  107433. */
  107434. /**
  107435. * Sets Vignette centre X Offset.
  107436. */
  107437. vignetteCentreX: number;
  107438. /**
  107439. * Gets Vignette centre Y Offset.
  107440. */
  107441. /**
  107442. * Sets Vignette centre Y Offset.
  107443. */
  107444. vignetteCentreY: number;
  107445. /**
  107446. * Gets Vignette weight or intensity of the vignette effect.
  107447. */
  107448. /**
  107449. * Sets Vignette weight or intensity of the vignette effect.
  107450. */
  107451. vignetteWeight: number;
  107452. /**
  107453. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107454. * if vignetteEnabled is set to true.
  107455. */
  107456. /**
  107457. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107458. * if vignetteEnabled is set to true.
  107459. */
  107460. vignetteColor: Color4;
  107461. /**
  107462. * Gets Camera field of view used by the Vignette effect.
  107463. */
  107464. /**
  107465. * Sets Camera field of view used by the Vignette effect.
  107466. */
  107467. vignetteCameraFov: number;
  107468. /**
  107469. * Gets the vignette blend mode allowing different kind of effect.
  107470. */
  107471. /**
  107472. * Sets the vignette blend mode allowing different kind of effect.
  107473. */
  107474. vignetteBlendMode: number;
  107475. /**
  107476. * Gets wether the vignette effect is enabled.
  107477. */
  107478. /**
  107479. * Sets wether the vignette effect is enabled.
  107480. */
  107481. vignetteEnabled: boolean;
  107482. private _fromLinearSpace;
  107483. /**
  107484. * Gets wether the input of the processing is in Gamma or Linear Space.
  107485. */
  107486. /**
  107487. * Sets wether the input of the processing is in Gamma or Linear Space.
  107488. */
  107489. fromLinearSpace: boolean;
  107490. /**
  107491. * Defines cache preventing GC.
  107492. */
  107493. private _defines;
  107494. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107495. /**
  107496. * "ImageProcessingPostProcess"
  107497. * @returns "ImageProcessingPostProcess"
  107498. */
  107499. getClassName(): string;
  107500. protected _updateParameters(): void;
  107501. dispose(camera?: Camera): void;
  107502. }
  107503. }
  107504. declare module BABYLON {
  107505. /**
  107506. * Class containing static functions to help procedurally build meshes
  107507. */
  107508. export class GroundBuilder {
  107509. /**
  107510. * Creates a ground mesh
  107511. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107512. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107514. * @param name defines the name of the mesh
  107515. * @param options defines the options used to create the mesh
  107516. * @param scene defines the hosting scene
  107517. * @returns the ground mesh
  107518. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107519. */
  107520. static CreateGround(name: string, options: {
  107521. width?: number;
  107522. height?: number;
  107523. subdivisions?: number;
  107524. subdivisionsX?: number;
  107525. subdivisionsY?: number;
  107526. updatable?: boolean;
  107527. }, scene: any): Mesh;
  107528. /**
  107529. * Creates a tiled ground mesh
  107530. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107531. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107532. * * 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
  107533. * * 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
  107534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107535. * @param name defines the name of the mesh
  107536. * @param options defines the options used to create the mesh
  107537. * @param scene defines the hosting scene
  107538. * @returns the tiled ground mesh
  107539. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107540. */
  107541. static CreateTiledGround(name: string, options: {
  107542. xmin: number;
  107543. zmin: number;
  107544. xmax: number;
  107545. zmax: number;
  107546. subdivisions?: {
  107547. w: number;
  107548. h: number;
  107549. };
  107550. precision?: {
  107551. w: number;
  107552. h: number;
  107553. };
  107554. updatable?: boolean;
  107555. }, scene?: Nullable<Scene>): Mesh;
  107556. /**
  107557. * Creates a ground mesh from a height map
  107558. * * The parameter `url` sets the URL of the height map image resource.
  107559. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107560. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107561. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107562. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107563. * * 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.
  107564. * * 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).
  107565. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107567. * @param name defines the name of the mesh
  107568. * @param url defines the url to the height map
  107569. * @param options defines the options used to create the mesh
  107570. * @param scene defines the hosting scene
  107571. * @returns the ground mesh
  107572. * @see https://doc.babylonjs.com/babylon101/height_map
  107573. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107574. */
  107575. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107576. width?: number;
  107577. height?: number;
  107578. subdivisions?: number;
  107579. minHeight?: number;
  107580. maxHeight?: number;
  107581. colorFilter?: Color3;
  107582. alphaFilter?: number;
  107583. updatable?: boolean;
  107584. onReady?: (mesh: GroundMesh) => void;
  107585. }, scene?: Nullable<Scene>): GroundMesh;
  107586. }
  107587. }
  107588. declare module BABYLON {
  107589. /**
  107590. * Class containing static functions to help procedurally build meshes
  107591. */
  107592. export class TorusBuilder {
  107593. /**
  107594. * Creates a torus mesh
  107595. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107596. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107597. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107601. * @param name defines the name of the mesh
  107602. * @param options defines the options used to create the mesh
  107603. * @param scene defines the hosting scene
  107604. * @returns the torus mesh
  107605. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107606. */
  107607. static CreateTorus(name: string, options: {
  107608. diameter?: number;
  107609. thickness?: number;
  107610. tessellation?: number;
  107611. updatable?: boolean;
  107612. sideOrientation?: number;
  107613. frontUVs?: Vector4;
  107614. backUVs?: Vector4;
  107615. }, scene: any): Mesh;
  107616. }
  107617. }
  107618. declare module BABYLON {
  107619. /**
  107620. * Class containing static functions to help procedurally build meshes
  107621. */
  107622. export class CylinderBuilder {
  107623. /**
  107624. * Creates a cylinder or a cone mesh
  107625. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107626. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107627. * * 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.
  107628. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107629. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107630. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107631. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107632. * * 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).
  107633. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107634. * * 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).
  107635. * * 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
  107636. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107637. * * 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
  107638. * * 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.
  107639. * * If `enclose` is false, a ring surface is one element.
  107640. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107641. * * 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
  107642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107645. * @param name defines the name of the mesh
  107646. * @param options defines the options used to create the mesh
  107647. * @param scene defines the hosting scene
  107648. * @returns the cylinder mesh
  107649. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107650. */
  107651. static CreateCylinder(name: string, options: {
  107652. height?: number;
  107653. diameterTop?: number;
  107654. diameterBottom?: number;
  107655. diameter?: number;
  107656. tessellation?: number;
  107657. subdivisions?: number;
  107658. arc?: number;
  107659. faceColors?: Color4[];
  107660. faceUV?: Vector4[];
  107661. updatable?: boolean;
  107662. hasRings?: boolean;
  107663. enclose?: boolean;
  107664. cap?: number;
  107665. sideOrientation?: number;
  107666. frontUVs?: Vector4;
  107667. backUVs?: Vector4;
  107668. }, scene: any): Mesh;
  107669. }
  107670. }
  107671. declare module BABYLON {
  107672. /**
  107673. * Options to modify the vr teleportation behavior.
  107674. */
  107675. export interface VRTeleportationOptions {
  107676. /**
  107677. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107678. */
  107679. floorMeshName?: string;
  107680. /**
  107681. * A list of meshes to be used as the teleportation floor. (default: empty)
  107682. */
  107683. floorMeshes?: Mesh[];
  107684. }
  107685. /**
  107686. * Options to modify the vr experience helper's behavior.
  107687. */
  107688. export interface VRExperienceHelperOptions extends WebVROptions {
  107689. /**
  107690. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107691. */
  107692. createDeviceOrientationCamera?: boolean;
  107693. /**
  107694. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107695. */
  107696. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107697. /**
  107698. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107699. */
  107700. laserToggle?: boolean;
  107701. /**
  107702. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107703. */
  107704. floorMeshes?: Mesh[];
  107705. /**
  107706. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107707. */
  107708. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107709. }
  107710. /**
  107711. * Event containing information after VR has been entered
  107712. */
  107713. export class OnAfterEnteringVRObservableEvent {
  107714. /**
  107715. * If entering vr was successful
  107716. */
  107717. success: boolean;
  107718. }
  107719. /**
  107720. * Helps to quickly add VR support to an existing scene.
  107721. * See http://doc.babylonjs.com/how_to/webvr_helper
  107722. */
  107723. export class VRExperienceHelper {
  107724. /** Options to modify the vr experience helper's behavior. */
  107725. webVROptions: VRExperienceHelperOptions;
  107726. private _scene;
  107727. private _position;
  107728. private _btnVR;
  107729. private _btnVRDisplayed;
  107730. private _webVRsupported;
  107731. private _webVRready;
  107732. private _webVRrequesting;
  107733. private _webVRpresenting;
  107734. private _hasEnteredVR;
  107735. private _fullscreenVRpresenting;
  107736. private _canvas;
  107737. private _webVRCamera;
  107738. private _vrDeviceOrientationCamera;
  107739. private _deviceOrientationCamera;
  107740. private _existingCamera;
  107741. private _onKeyDown;
  107742. private _onVrDisplayPresentChange;
  107743. private _onVRDisplayChanged;
  107744. private _onVRRequestPresentStart;
  107745. private _onVRRequestPresentComplete;
  107746. /**
  107747. * 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)
  107748. */
  107749. enableGazeEvenWhenNoPointerLock: boolean;
  107750. /**
  107751. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107752. */
  107753. exitVROnDoubleTap: boolean;
  107754. /**
  107755. * Observable raised right before entering VR.
  107756. */
  107757. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107758. /**
  107759. * Observable raised when entering VR has completed.
  107760. */
  107761. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107762. /**
  107763. * Observable raised when exiting VR.
  107764. */
  107765. onExitingVRObservable: Observable<VRExperienceHelper>;
  107766. /**
  107767. * Observable raised when controller mesh is loaded.
  107768. */
  107769. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107770. /** Return this.onEnteringVRObservable
  107771. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107772. */
  107773. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107774. /** Return this.onExitingVRObservable
  107775. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107776. */
  107777. readonly onExitingVR: Observable<VRExperienceHelper>;
  107778. /** Return this.onControllerMeshLoadedObservable
  107779. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107780. */
  107781. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107782. private _rayLength;
  107783. private _useCustomVRButton;
  107784. private _teleportationRequested;
  107785. private _teleportActive;
  107786. private _floorMeshName;
  107787. private _floorMeshesCollection;
  107788. private _rotationAllowed;
  107789. private _teleportBackwardsVector;
  107790. private _teleportationTarget;
  107791. private _isDefaultTeleportationTarget;
  107792. private _postProcessMove;
  107793. private _teleportationFillColor;
  107794. private _teleportationBorderColor;
  107795. private _rotationAngle;
  107796. private _haloCenter;
  107797. private _cameraGazer;
  107798. private _padSensibilityUp;
  107799. private _padSensibilityDown;
  107800. private _leftController;
  107801. private _rightController;
  107802. /**
  107803. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107804. */
  107805. onNewMeshSelected: Observable<AbstractMesh>;
  107806. /**
  107807. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107808. * This observable will provide the mesh and the controller used to select the mesh
  107809. */
  107810. onMeshSelectedWithController: Observable<{
  107811. mesh: AbstractMesh;
  107812. controller: WebVRController;
  107813. }>;
  107814. /**
  107815. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107816. */
  107817. onNewMeshPicked: Observable<PickingInfo>;
  107818. private _circleEase;
  107819. /**
  107820. * Observable raised before camera teleportation
  107821. */
  107822. onBeforeCameraTeleport: Observable<Vector3>;
  107823. /**
  107824. * Observable raised after camera teleportation
  107825. */
  107826. onAfterCameraTeleport: Observable<Vector3>;
  107827. /**
  107828. * Observable raised when current selected mesh gets unselected
  107829. */
  107830. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107831. private _raySelectionPredicate;
  107832. /**
  107833. * To be optionaly changed by user to define custom ray selection
  107834. */
  107835. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107836. /**
  107837. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107838. */
  107839. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107840. /**
  107841. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107842. */
  107843. teleportationEnabled: boolean;
  107844. private _defaultHeight;
  107845. private _teleportationInitialized;
  107846. private _interactionsEnabled;
  107847. private _interactionsRequested;
  107848. private _displayGaze;
  107849. private _displayLaserPointer;
  107850. /**
  107851. * The mesh used to display where the user is going to teleport.
  107852. */
  107853. /**
  107854. * Sets the mesh to be used to display where the user is going to teleport.
  107855. */
  107856. teleportationTarget: Mesh;
  107857. /**
  107858. * 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
  107859. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107860. * See http://doc.babylonjs.com/resources/baking_transformations
  107861. */
  107862. gazeTrackerMesh: Mesh;
  107863. /**
  107864. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107865. */
  107866. updateGazeTrackerScale: boolean;
  107867. /**
  107868. * If the gaze trackers color should be updated when selecting meshes
  107869. */
  107870. updateGazeTrackerColor: boolean;
  107871. /**
  107872. * If the controller laser color should be updated when selecting meshes
  107873. */
  107874. updateControllerLaserColor: boolean;
  107875. /**
  107876. * The gaze tracking mesh corresponding to the left controller
  107877. */
  107878. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  107879. /**
  107880. * The gaze tracking mesh corresponding to the right controller
  107881. */
  107882. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  107883. /**
  107884. * If the ray of the gaze should be displayed.
  107885. */
  107886. /**
  107887. * Sets if the ray of the gaze should be displayed.
  107888. */
  107889. displayGaze: boolean;
  107890. /**
  107891. * If the ray of the LaserPointer should be displayed.
  107892. */
  107893. /**
  107894. * Sets if the ray of the LaserPointer should be displayed.
  107895. */
  107896. displayLaserPointer: boolean;
  107897. /**
  107898. * The deviceOrientationCamera used as the camera when not in VR.
  107899. */
  107900. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  107901. /**
  107902. * Based on the current WebVR support, returns the current VR camera used.
  107903. */
  107904. readonly currentVRCamera: Nullable<Camera>;
  107905. /**
  107906. * The webVRCamera which is used when in VR.
  107907. */
  107908. readonly webVRCamera: WebVRFreeCamera;
  107909. /**
  107910. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  107911. */
  107912. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  107913. /**
  107914. * The html button that is used to trigger entering into VR.
  107915. */
  107916. readonly vrButton: Nullable<HTMLButtonElement>;
  107917. private readonly _teleportationRequestInitiated;
  107918. /**
  107919. * Defines wether or not Pointer lock should be requested when switching to
  107920. * full screen.
  107921. */
  107922. requestPointerLockOnFullScreen: boolean;
  107923. /**
  107924. * Instantiates a VRExperienceHelper.
  107925. * Helps to quickly add VR support to an existing scene.
  107926. * @param scene The scene the VRExperienceHelper belongs to.
  107927. * @param webVROptions Options to modify the vr experience helper's behavior.
  107928. */
  107929. constructor(scene: Scene,
  107930. /** Options to modify the vr experience helper's behavior. */
  107931. webVROptions?: VRExperienceHelperOptions);
  107932. private _onDefaultMeshLoaded;
  107933. private _onResize;
  107934. private _onFullscreenChange;
  107935. /**
  107936. * Gets a value indicating if we are currently in VR mode.
  107937. */
  107938. readonly isInVRMode: boolean;
  107939. private onVrDisplayPresentChange;
  107940. private onVRDisplayChanged;
  107941. private moveButtonToBottomRight;
  107942. private displayVRButton;
  107943. private updateButtonVisibility;
  107944. private _cachedAngularSensibility;
  107945. /**
  107946. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  107947. * Otherwise, will use the fullscreen API.
  107948. */
  107949. enterVR(): void;
  107950. /**
  107951. * Attempt to exit VR, or fullscreen.
  107952. */
  107953. exitVR(): void;
  107954. /**
  107955. * The position of the vr experience helper.
  107956. */
  107957. /**
  107958. * Sets the position of the vr experience helper.
  107959. */
  107960. position: Vector3;
  107961. /**
  107962. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  107963. */
  107964. enableInteractions(): void;
  107965. private readonly _noControllerIsActive;
  107966. private beforeRender;
  107967. private _isTeleportationFloor;
  107968. /**
  107969. * Adds a floor mesh to be used for teleportation.
  107970. * @param floorMesh the mesh to be used for teleportation.
  107971. */
  107972. addFloorMesh(floorMesh: Mesh): void;
  107973. /**
  107974. * Removes a floor mesh from being used for teleportation.
  107975. * @param floorMesh the mesh to be removed.
  107976. */
  107977. removeFloorMesh(floorMesh: Mesh): void;
  107978. /**
  107979. * Enables interactions and teleportation using the VR controllers and gaze.
  107980. * @param vrTeleportationOptions options to modify teleportation behavior.
  107981. */
  107982. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  107983. private _onNewGamepadConnected;
  107984. private _tryEnableInteractionOnController;
  107985. private _onNewGamepadDisconnected;
  107986. private _enableInteractionOnController;
  107987. private _checkTeleportWithRay;
  107988. private _checkRotate;
  107989. private _checkTeleportBackwards;
  107990. private _enableTeleportationOnController;
  107991. private _createTeleportationCircles;
  107992. private _displayTeleportationTarget;
  107993. private _hideTeleportationTarget;
  107994. private _rotateCamera;
  107995. private _moveTeleportationSelectorTo;
  107996. private _workingVector;
  107997. private _workingQuaternion;
  107998. private _workingMatrix;
  107999. /**
  108000. * Teleports the users feet to the desired location
  108001. * @param location The location where the user's feet should be placed
  108002. */
  108003. teleportCamera(location: Vector3): void;
  108004. private _convertNormalToDirectionOfRay;
  108005. private _castRayAndSelectObject;
  108006. private _notifySelectedMeshUnselected;
  108007. /**
  108008. * Sets the color of the laser ray from the vr controllers.
  108009. * @param color new color for the ray.
  108010. */
  108011. changeLaserColor(color: Color3): void;
  108012. /**
  108013. * Sets the color of the ray from the vr headsets gaze.
  108014. * @param color new color for the ray.
  108015. */
  108016. changeGazeColor(color: Color3): void;
  108017. /**
  108018. * Exits VR and disposes of the vr experience helper
  108019. */
  108020. dispose(): void;
  108021. /**
  108022. * Gets the name of the VRExperienceHelper class
  108023. * @returns "VRExperienceHelper"
  108024. */
  108025. getClassName(): string;
  108026. }
  108027. }
  108028. declare module BABYLON {
  108029. /**
  108030. * Manages an XRSession to work with Babylon's engine
  108031. * @see https://doc.babylonjs.com/how_to/webxr
  108032. */
  108033. export class WebXRSessionManager implements IDisposable {
  108034. private scene;
  108035. /**
  108036. * Fires every time a new xrFrame arrives which can be used to update the camera
  108037. */
  108038. onXRFrameObservable: Observable<any>;
  108039. /**
  108040. * Fires when the xr session is ended either by the device or manually done
  108041. */
  108042. onXRSessionEnded: Observable<any>;
  108043. /**
  108044. * Underlying xr session
  108045. */
  108046. session: XRSession;
  108047. /**
  108048. * Type of reference space used when creating the session
  108049. */
  108050. referenceSpace: XRReferenceSpace;
  108051. /** @hidden */
  108052. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108053. /**
  108054. * Current XR frame
  108055. */
  108056. currentFrame: Nullable<XRFrame>;
  108057. private _xrNavigator;
  108058. private baseLayer;
  108059. /**
  108060. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108061. * @param scene The scene which the session should be created for
  108062. */
  108063. constructor(scene: Scene);
  108064. /**
  108065. * Initializes the manager
  108066. * After initialization enterXR can be called to start an XR session
  108067. * @returns Promise which resolves after it is initialized
  108068. */
  108069. initializeAsync(): Promise<void>;
  108070. /**
  108071. * Initializes an xr session
  108072. * @param xrSessionMode mode to initialize
  108073. * @returns a promise which will resolve once the session has been initialized
  108074. */
  108075. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108076. /**
  108077. * Sets the reference space on the xr session
  108078. * @param referenceSpace space to set
  108079. * @returns a promise that will resolve once the reference space has been set
  108080. */
  108081. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108082. /**
  108083. * Updates the render state of the session
  108084. * @param state state to set
  108085. * @returns a promise that resolves once the render state has been updated
  108086. */
  108087. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108088. /**
  108089. * Starts rendering to the xr layer
  108090. * @returns a promise that will resolve once rendering has started
  108091. */
  108092. startRenderingToXRAsync(): Promise<void>;
  108093. /**
  108094. * Stops the xrSession and restores the renderloop
  108095. * @returns Promise which resolves after it exits XR
  108096. */
  108097. exitXRAsync(): Promise<unknown>;
  108098. /**
  108099. * Checks if a session would be supported for the creation options specified
  108100. * @param sessionMode session mode to check if supported eg. immersive-vr
  108101. * @returns true if supported
  108102. */
  108103. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108104. /**
  108105. * @hidden
  108106. * Converts the render layer of xrSession to a render target
  108107. * @param session session to create render target for
  108108. * @param scene scene the new render target should be created for
  108109. */
  108110. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108111. /**
  108112. * Disposes of the session manager
  108113. */
  108114. dispose(): void;
  108115. }
  108116. }
  108117. declare module BABYLON {
  108118. /**
  108119. * WebXR Camera which holds the views for the xrSession
  108120. * @see https://doc.babylonjs.com/how_to/webxr
  108121. */
  108122. export class WebXRCamera extends FreeCamera {
  108123. private static _TmpMatrix;
  108124. /**
  108125. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108126. * @param name the name of the camera
  108127. * @param scene the scene to add the camera to
  108128. */
  108129. constructor(name: string, scene: Scene);
  108130. private _updateNumberOfRigCameras;
  108131. /** @hidden */
  108132. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108133. /**
  108134. * Updates the cameras position from the current pose information of the XR session
  108135. * @param xrSessionManager the session containing pose information
  108136. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108137. */
  108138. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108139. }
  108140. }
  108141. declare module BABYLON {
  108142. /**
  108143. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108144. */
  108145. export class WebXRManagedOutputCanvas implements IDisposable {
  108146. private helper;
  108147. private _canvas;
  108148. /**
  108149. * xrpresent context of the canvas which can be used to display/mirror xr content
  108150. */
  108151. canvasContext: WebGLRenderingContext;
  108152. /**
  108153. * xr layer for the canvas
  108154. */
  108155. xrLayer: Nullable<XRWebGLLayer>;
  108156. /**
  108157. * Initializes the xr layer for the session
  108158. * @param xrSession xr session
  108159. * @returns a promise that will resolve once the XR Layer has been created
  108160. */
  108161. initializeXRLayerAsync(xrSession: any): any;
  108162. /**
  108163. * Initializes the canvas to be added/removed upon entering/exiting xr
  108164. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108165. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108166. */
  108167. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108168. /**
  108169. * Disposes of the object
  108170. */
  108171. dispose(): void;
  108172. private _setManagedOutputCanvas;
  108173. private _addCanvas;
  108174. private _removeCanvas;
  108175. }
  108176. }
  108177. declare module BABYLON {
  108178. /**
  108179. * States of the webXR experience
  108180. */
  108181. export enum WebXRState {
  108182. /**
  108183. * Transitioning to being in XR mode
  108184. */
  108185. ENTERING_XR = 0,
  108186. /**
  108187. * Transitioning to non XR mode
  108188. */
  108189. EXITING_XR = 1,
  108190. /**
  108191. * In XR mode and presenting
  108192. */
  108193. IN_XR = 2,
  108194. /**
  108195. * Not entered XR mode
  108196. */
  108197. NOT_IN_XR = 3
  108198. }
  108199. /**
  108200. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108201. * @see https://doc.babylonjs.com/how_to/webxr
  108202. */
  108203. export class WebXRExperienceHelper implements IDisposable {
  108204. private scene;
  108205. /**
  108206. * 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
  108207. */
  108208. container: AbstractMesh;
  108209. /**
  108210. * Camera used to render xr content
  108211. */
  108212. camera: WebXRCamera;
  108213. /**
  108214. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108215. */
  108216. state: WebXRState;
  108217. private _setState;
  108218. private static _TmpVector;
  108219. /**
  108220. * Fires when the state of the experience helper has changed
  108221. */
  108222. onStateChangedObservable: Observable<WebXRState>;
  108223. /** Session manager used to keep track of xr session */
  108224. sessionManager: WebXRSessionManager;
  108225. private _nonVRCamera;
  108226. private _originalSceneAutoClear;
  108227. private _supported;
  108228. /**
  108229. * Creates the experience helper
  108230. * @param scene the scene to attach the experience helper to
  108231. * @returns a promise for the experience helper
  108232. */
  108233. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108234. /**
  108235. * Creates a WebXRExperienceHelper
  108236. * @param scene The scene the helper should be created in
  108237. */
  108238. private constructor();
  108239. /**
  108240. * Exits XR mode and returns the scene to its original state
  108241. * @returns promise that resolves after xr mode has exited
  108242. */
  108243. exitXRAsync(): Promise<unknown>;
  108244. /**
  108245. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108246. * @param sessionCreationOptions options for the XR session
  108247. * @param referenceSpaceType frame of reference of the XR session
  108248. * @param outputCanvas the output canvas that will be used to enter XR mode
  108249. * @returns promise that resolves after xr mode has entered
  108250. */
  108251. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108252. /**
  108253. * Updates the global position of the camera by moving the camera's container
  108254. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108255. * @param position The desired global position of the camera
  108256. */
  108257. setPositionOfCameraUsingContainer(position: Vector3): void;
  108258. /**
  108259. * Rotates the xr camera by rotating the camera's container around the camera's position
  108260. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108261. * @param rotation the desired quaternion rotation to apply to the camera
  108262. */
  108263. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108264. /**
  108265. * Disposes of the experience helper
  108266. */
  108267. dispose(): void;
  108268. }
  108269. }
  108270. declare module BABYLON {
  108271. /**
  108272. * Button which can be used to enter a different mode of XR
  108273. */
  108274. export class WebXREnterExitUIButton {
  108275. /** button element */
  108276. element: HTMLElement;
  108277. /** XR initialization options for the button */
  108278. sessionMode: XRSessionMode;
  108279. /** Reference space type */
  108280. referenceSpaceType: XRReferenceSpaceType;
  108281. /**
  108282. * Creates a WebXREnterExitUIButton
  108283. * @param element button element
  108284. * @param sessionMode XR initialization session mode
  108285. * @param referenceSpaceType the type of reference space to be used
  108286. */
  108287. constructor(
  108288. /** button element */
  108289. element: HTMLElement,
  108290. /** XR initialization options for the button */
  108291. sessionMode: XRSessionMode,
  108292. /** Reference space type */
  108293. referenceSpaceType: XRReferenceSpaceType);
  108294. /**
  108295. * Overwritable function which can be used to update the button's visuals when the state changes
  108296. * @param activeButton the current active button in the UI
  108297. */
  108298. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108299. }
  108300. /**
  108301. * Options to create the webXR UI
  108302. */
  108303. export class WebXREnterExitUIOptions {
  108304. /**
  108305. * Context to enter xr with
  108306. */
  108307. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108308. /**
  108309. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108310. */
  108311. customButtons?: Array<WebXREnterExitUIButton>;
  108312. }
  108313. /**
  108314. * UI to allow the user to enter/exit XR mode
  108315. */
  108316. export class WebXREnterExitUI implements IDisposable {
  108317. private scene;
  108318. private _overlay;
  108319. private _buttons;
  108320. private _activeButton;
  108321. /**
  108322. * Fired every time the active button is changed.
  108323. *
  108324. * When xr is entered via a button that launches xr that button will be the callback parameter
  108325. *
  108326. * When exiting xr the callback parameter will be null)
  108327. */
  108328. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108329. /**
  108330. * Creates UI to allow the user to enter/exit XR mode
  108331. * @param scene the scene to add the ui to
  108332. * @param helper the xr experience helper to enter/exit xr with
  108333. * @param options options to configure the UI
  108334. * @returns the created ui
  108335. */
  108336. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108337. private constructor();
  108338. private _updateButtons;
  108339. /**
  108340. * Disposes of the object
  108341. */
  108342. dispose(): void;
  108343. }
  108344. }
  108345. declare module BABYLON {
  108346. /**
  108347. * Represents an XR input
  108348. */
  108349. export class WebXRController {
  108350. private scene;
  108351. /** The underlying input source for the controller */
  108352. inputSource: XRInputSource;
  108353. private parentContainer;
  108354. /**
  108355. * 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
  108356. */
  108357. grip?: AbstractMesh;
  108358. /**
  108359. * Pointer which can be used to select objects or attach a visible laser to
  108360. */
  108361. pointer: AbstractMesh;
  108362. /**
  108363. * Event that fires when the controller is removed/disposed
  108364. */
  108365. onDisposeObservable: Observable<{}>;
  108366. private _tmpMatrix;
  108367. private _tmpQuaternion;
  108368. private _tmpVector;
  108369. /**
  108370. * Creates the controller
  108371. * @see https://doc.babylonjs.com/how_to/webxr
  108372. * @param scene the scene which the controller should be associated to
  108373. * @param inputSource the underlying input source for the controller
  108374. * @param parentContainer parent that the controller meshes should be children of
  108375. */
  108376. constructor(scene: Scene,
  108377. /** The underlying input source for the controller */
  108378. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108379. /**
  108380. * Updates the controller pose based on the given XRFrame
  108381. * @param xrFrame xr frame to update the pose with
  108382. * @param referenceSpace reference space to use
  108383. */
  108384. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108385. /**
  108386. * Gets a world space ray coming from the controller
  108387. * @param result the resulting ray
  108388. */
  108389. getWorldPointerRayToRef(result: Ray): void;
  108390. /**
  108391. * Disposes of the object
  108392. */
  108393. dispose(): void;
  108394. }
  108395. }
  108396. declare module BABYLON {
  108397. /**
  108398. * XR input used to track XR inputs such as controllers/rays
  108399. */
  108400. export class WebXRInput implements IDisposable {
  108401. /**
  108402. * Base experience the input listens to
  108403. */
  108404. baseExperience: WebXRExperienceHelper;
  108405. /**
  108406. * XR controllers being tracked
  108407. */
  108408. controllers: Array<WebXRController>;
  108409. private _frameObserver;
  108410. private _stateObserver;
  108411. /**
  108412. * Event when a controller has been connected/added
  108413. */
  108414. onControllerAddedObservable: Observable<WebXRController>;
  108415. /**
  108416. * Event when a controller has been removed/disconnected
  108417. */
  108418. onControllerRemovedObservable: Observable<WebXRController>;
  108419. /**
  108420. * Initializes the WebXRInput
  108421. * @param baseExperience experience helper which the input should be created for
  108422. */
  108423. constructor(
  108424. /**
  108425. * Base experience the input listens to
  108426. */
  108427. baseExperience: WebXRExperienceHelper);
  108428. private _onInputSourcesChange;
  108429. private _addAndRemoveControllers;
  108430. /**
  108431. * Disposes of the object
  108432. */
  108433. dispose(): void;
  108434. }
  108435. }
  108436. declare module BABYLON {
  108437. /**
  108438. * Enables teleportation
  108439. */
  108440. export class WebXRControllerTeleportation {
  108441. private _teleportationFillColor;
  108442. private _teleportationBorderColor;
  108443. private _tmpRay;
  108444. private _tmpVector;
  108445. /**
  108446. * Creates a WebXRControllerTeleportation
  108447. * @param input input manager to add teleportation to
  108448. * @param floorMeshes floormeshes which can be teleported to
  108449. */
  108450. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108451. }
  108452. }
  108453. declare module BABYLON {
  108454. /**
  108455. * Handles pointer input automatically for the pointer of XR controllers
  108456. */
  108457. export class WebXRControllerPointerSelection {
  108458. private static _idCounter;
  108459. private _tmpRay;
  108460. /**
  108461. * Creates a WebXRControllerPointerSelection
  108462. * @param input input manager to setup pointer selection
  108463. */
  108464. constructor(input: WebXRInput);
  108465. private _convertNormalToDirectionOfRay;
  108466. private _updatePointerDistance;
  108467. }
  108468. }
  108469. declare module BABYLON {
  108470. /**
  108471. * Class used to represent data loading progression
  108472. */
  108473. export class SceneLoaderProgressEvent {
  108474. /** defines if data length to load can be evaluated */
  108475. readonly lengthComputable: boolean;
  108476. /** defines the loaded data length */
  108477. readonly loaded: number;
  108478. /** defines the data length to load */
  108479. readonly total: number;
  108480. /**
  108481. * Create a new progress event
  108482. * @param lengthComputable defines if data length to load can be evaluated
  108483. * @param loaded defines the loaded data length
  108484. * @param total defines the data length to load
  108485. */
  108486. constructor(
  108487. /** defines if data length to load can be evaluated */
  108488. lengthComputable: boolean,
  108489. /** defines the loaded data length */
  108490. loaded: number,
  108491. /** defines the data length to load */
  108492. total: number);
  108493. /**
  108494. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108495. * @param event defines the source event
  108496. * @returns a new SceneLoaderProgressEvent
  108497. */
  108498. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108499. }
  108500. /**
  108501. * Interface used by SceneLoader plugins to define supported file extensions
  108502. */
  108503. export interface ISceneLoaderPluginExtensions {
  108504. /**
  108505. * Defines the list of supported extensions
  108506. */
  108507. [extension: string]: {
  108508. isBinary: boolean;
  108509. };
  108510. }
  108511. /**
  108512. * Interface used by SceneLoader plugin factory
  108513. */
  108514. export interface ISceneLoaderPluginFactory {
  108515. /**
  108516. * Defines the name of the factory
  108517. */
  108518. name: string;
  108519. /**
  108520. * Function called to create a new plugin
  108521. * @return the new plugin
  108522. */
  108523. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108524. /**
  108525. * Boolean indicating if the plugin can direct load specific data
  108526. */
  108527. canDirectLoad?: (data: string) => boolean;
  108528. }
  108529. /**
  108530. * Interface used to define a SceneLoader plugin
  108531. */
  108532. export interface ISceneLoaderPlugin {
  108533. /**
  108534. * The friendly name of this plugin.
  108535. */
  108536. name: string;
  108537. /**
  108538. * The file extensions supported by this plugin.
  108539. */
  108540. extensions: string | ISceneLoaderPluginExtensions;
  108541. /**
  108542. * Import meshes into a scene.
  108543. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108544. * @param scene The scene to import into
  108545. * @param data The data to import
  108546. * @param rootUrl The root url for scene and resources
  108547. * @param meshes The meshes array to import into
  108548. * @param particleSystems The particle systems array to import into
  108549. * @param skeletons The skeletons array to import into
  108550. * @param onError The callback when import fails
  108551. * @returns True if successful or false otherwise
  108552. */
  108553. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108554. /**
  108555. * Load into a scene.
  108556. * @param scene The scene to load into
  108557. * @param data The data to import
  108558. * @param rootUrl The root url for scene and resources
  108559. * @param onError The callback when import fails
  108560. * @returns true if successful or false otherwise
  108561. */
  108562. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108563. /**
  108564. * The callback that returns true if the data can be directly loaded.
  108565. */
  108566. canDirectLoad?: (data: string) => boolean;
  108567. /**
  108568. * The callback that allows custom handling of the root url based on the response url.
  108569. */
  108570. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108571. /**
  108572. * Load into an asset container.
  108573. * @param scene The scene to load into
  108574. * @param data The data to import
  108575. * @param rootUrl The root url for scene and resources
  108576. * @param onError The callback when import fails
  108577. * @returns The loaded asset container
  108578. */
  108579. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108580. }
  108581. /**
  108582. * Interface used to define an async SceneLoader plugin
  108583. */
  108584. export interface ISceneLoaderPluginAsync {
  108585. /**
  108586. * The friendly name of this plugin.
  108587. */
  108588. name: string;
  108589. /**
  108590. * The file extensions supported by this plugin.
  108591. */
  108592. extensions: string | ISceneLoaderPluginExtensions;
  108593. /**
  108594. * Import meshes into a scene.
  108595. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108596. * @param scene The scene to import into
  108597. * @param data The data to import
  108598. * @param rootUrl The root url for scene and resources
  108599. * @param onProgress The callback when the load progresses
  108600. * @param fileName Defines the name of the file to load
  108601. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108602. */
  108603. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108604. meshes: AbstractMesh[];
  108605. particleSystems: IParticleSystem[];
  108606. skeletons: Skeleton[];
  108607. animationGroups: AnimationGroup[];
  108608. }>;
  108609. /**
  108610. * Load into a scene.
  108611. * @param scene The scene to load into
  108612. * @param data The data to import
  108613. * @param rootUrl The root url for scene and resources
  108614. * @param onProgress The callback when the load progresses
  108615. * @param fileName Defines the name of the file to load
  108616. * @returns Nothing
  108617. */
  108618. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108619. /**
  108620. * The callback that returns true if the data can be directly loaded.
  108621. */
  108622. canDirectLoad?: (data: string) => boolean;
  108623. /**
  108624. * The callback that allows custom handling of the root url based on the response url.
  108625. */
  108626. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108627. /**
  108628. * Load into an asset container.
  108629. * @param scene The scene to load into
  108630. * @param data The data to import
  108631. * @param rootUrl The root url for scene and resources
  108632. * @param onProgress The callback when the load progresses
  108633. * @param fileName Defines the name of the file to load
  108634. * @returns The loaded asset container
  108635. */
  108636. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108637. }
  108638. /**
  108639. * Class used to load scene from various file formats using registered plugins
  108640. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108641. */
  108642. export class SceneLoader {
  108643. /**
  108644. * No logging while loading
  108645. */
  108646. static readonly NO_LOGGING: number;
  108647. /**
  108648. * Minimal logging while loading
  108649. */
  108650. static readonly MINIMAL_LOGGING: number;
  108651. /**
  108652. * Summary logging while loading
  108653. */
  108654. static readonly SUMMARY_LOGGING: number;
  108655. /**
  108656. * Detailled logging while loading
  108657. */
  108658. static readonly DETAILED_LOGGING: number;
  108659. /**
  108660. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108661. */
  108662. static ForceFullSceneLoadingForIncremental: boolean;
  108663. /**
  108664. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108665. */
  108666. static ShowLoadingScreen: boolean;
  108667. /**
  108668. * Defines the current logging level (while loading the scene)
  108669. * @ignorenaming
  108670. */
  108671. static loggingLevel: number;
  108672. /**
  108673. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108674. */
  108675. static CleanBoneMatrixWeights: boolean;
  108676. /**
  108677. * Event raised when a plugin is used to load a scene
  108678. */
  108679. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108680. private static _registeredPlugins;
  108681. private static _getDefaultPlugin;
  108682. private static _getPluginForExtension;
  108683. private static _getPluginForDirectLoad;
  108684. private static _getPluginForFilename;
  108685. private static _getDirectLoad;
  108686. private static _loadData;
  108687. private static _getFileInfo;
  108688. /**
  108689. * Gets a plugin that can load the given extension
  108690. * @param extension defines the extension to load
  108691. * @returns a plugin or null if none works
  108692. */
  108693. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108694. /**
  108695. * Gets a boolean indicating that the given extension can be loaded
  108696. * @param extension defines the extension to load
  108697. * @returns true if the extension is supported
  108698. */
  108699. static IsPluginForExtensionAvailable(extension: string): boolean;
  108700. /**
  108701. * Adds a new plugin to the list of registered plugins
  108702. * @param plugin defines the plugin to add
  108703. */
  108704. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108705. /**
  108706. * Import meshes into a scene
  108707. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108708. * @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)
  108709. * @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)
  108710. * @param scene the instance of BABYLON.Scene to append to
  108711. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108712. * @param onProgress a callback with a progress event for each file being loaded
  108713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108714. * @param pluginExtension the extension used to determine the plugin
  108715. * @returns The loaded plugin
  108716. */
  108717. 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>;
  108718. /**
  108719. * Import meshes into a scene
  108720. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108721. * @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)
  108722. * @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)
  108723. * @param scene the instance of BABYLON.Scene to append to
  108724. * @param onProgress a callback with a progress event for each file being loaded
  108725. * @param pluginExtension the extension used to determine the plugin
  108726. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108727. */
  108728. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108729. meshes: AbstractMesh[];
  108730. particleSystems: IParticleSystem[];
  108731. skeletons: Skeleton[];
  108732. animationGroups: AnimationGroup[];
  108733. }>;
  108734. /**
  108735. * Load a scene
  108736. * @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)
  108737. * @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)
  108738. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108739. * @param onSuccess a callback with the scene when import succeeds
  108740. * @param onProgress a callback with a progress event for each file being loaded
  108741. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108742. * @param pluginExtension the extension used to determine the plugin
  108743. * @returns The loaded plugin
  108744. */
  108745. 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>;
  108746. /**
  108747. * Load a scene
  108748. * @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)
  108749. * @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)
  108750. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108751. * @param onProgress a callback with a progress event for each file being loaded
  108752. * @param pluginExtension the extension used to determine the plugin
  108753. * @returns The loaded scene
  108754. */
  108755. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108756. /**
  108757. * Append a scene
  108758. * @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)
  108759. * @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)
  108760. * @param scene is the instance of BABYLON.Scene to append to
  108761. * @param onSuccess a callback with the scene when import succeeds
  108762. * @param onProgress a callback with a progress event for each file being loaded
  108763. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108764. * @param pluginExtension the extension used to determine the plugin
  108765. * @returns The loaded plugin
  108766. */
  108767. 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>;
  108768. /**
  108769. * Append a scene
  108770. * @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)
  108771. * @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)
  108772. * @param scene is the instance of BABYLON.Scene to append to
  108773. * @param onProgress a callback with a progress event for each file being loaded
  108774. * @param pluginExtension the extension used to determine the plugin
  108775. * @returns The given scene
  108776. */
  108777. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108778. /**
  108779. * Load a scene into an asset container
  108780. * @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)
  108781. * @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)
  108782. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108783. * @param onSuccess a callback with the scene when import succeeds
  108784. * @param onProgress a callback with a progress event for each file being loaded
  108785. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108786. * @param pluginExtension the extension used to determine the plugin
  108787. * @returns The loaded plugin
  108788. */
  108789. 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>;
  108790. /**
  108791. * Load a scene into an asset container
  108792. * @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)
  108793. * @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)
  108794. * @param scene is the instance of Scene to append to
  108795. * @param onProgress a callback with a progress event for each file being loaded
  108796. * @param pluginExtension the extension used to determine the plugin
  108797. * @returns The loaded asset container
  108798. */
  108799. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108800. }
  108801. }
  108802. declare module BABYLON {
  108803. /**
  108804. * Generic Controller
  108805. */
  108806. export class GenericController extends WebVRController {
  108807. /**
  108808. * Base Url for the controller model.
  108809. */
  108810. static readonly MODEL_BASE_URL: string;
  108811. /**
  108812. * File name for the controller model.
  108813. */
  108814. static readonly MODEL_FILENAME: string;
  108815. /**
  108816. * Creates a new GenericController from a gamepad
  108817. * @param vrGamepad the gamepad that the controller should be created from
  108818. */
  108819. constructor(vrGamepad: any);
  108820. /**
  108821. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108822. * @param scene scene in which to add meshes
  108823. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108824. */
  108825. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108826. /**
  108827. * Called once for each button that changed state since the last frame
  108828. * @param buttonIdx Which button index changed
  108829. * @param state New state of the button
  108830. * @param changes Which properties on the state changed since last frame
  108831. */
  108832. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108833. }
  108834. }
  108835. declare module BABYLON {
  108836. /**
  108837. * Defines the WindowsMotionController object that the state of the windows motion controller
  108838. */
  108839. export class WindowsMotionController extends WebVRController {
  108840. /**
  108841. * The base url used to load the left and right controller models
  108842. */
  108843. static MODEL_BASE_URL: string;
  108844. /**
  108845. * The name of the left controller model file
  108846. */
  108847. static MODEL_LEFT_FILENAME: string;
  108848. /**
  108849. * The name of the right controller model file
  108850. */
  108851. static MODEL_RIGHT_FILENAME: string;
  108852. /**
  108853. * The controller name prefix for this controller type
  108854. */
  108855. static readonly GAMEPAD_ID_PREFIX: string;
  108856. /**
  108857. * The controller id pattern for this controller type
  108858. */
  108859. private static readonly GAMEPAD_ID_PATTERN;
  108860. private _loadedMeshInfo;
  108861. private readonly _mapping;
  108862. /**
  108863. * Fired when the trackpad on this controller is clicked
  108864. */
  108865. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108866. /**
  108867. * Fired when the trackpad on this controller is modified
  108868. */
  108869. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108870. /**
  108871. * The current x and y values of this controller's trackpad
  108872. */
  108873. trackpad: StickValues;
  108874. /**
  108875. * Creates a new WindowsMotionController from a gamepad
  108876. * @param vrGamepad the gamepad that the controller should be created from
  108877. */
  108878. constructor(vrGamepad: any);
  108879. /**
  108880. * Fired when the trigger on this controller is modified
  108881. */
  108882. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108883. /**
  108884. * Fired when the menu button on this controller is modified
  108885. */
  108886. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108887. /**
  108888. * Fired when the grip button on this controller is modified
  108889. */
  108890. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108891. /**
  108892. * Fired when the thumbstick button on this controller is modified
  108893. */
  108894. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108895. /**
  108896. * Fired when the touchpad button on this controller is modified
  108897. */
  108898. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108899. /**
  108900. * Fired when the touchpad values on this controller are modified
  108901. */
  108902. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  108903. private _updateTrackpad;
  108904. /**
  108905. * Called once per frame by the engine.
  108906. */
  108907. update(): void;
  108908. /**
  108909. * Called once for each button that changed state since the last frame
  108910. * @param buttonIdx Which button index changed
  108911. * @param state New state of the button
  108912. * @param changes Which properties on the state changed since last frame
  108913. */
  108914. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108915. /**
  108916. * Moves the buttons on the controller mesh based on their current state
  108917. * @param buttonName the name of the button to move
  108918. * @param buttonValue the value of the button which determines the buttons new position
  108919. */
  108920. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108921. /**
  108922. * Moves the axis on the controller mesh based on its current state
  108923. * @param axis the index of the axis
  108924. * @param axisValue the value of the axis which determines the meshes new position
  108925. * @hidden
  108926. */
  108927. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108928. /**
  108929. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108930. * @param scene scene in which to add meshes
  108931. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108932. */
  108933. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  108934. /**
  108935. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  108936. * can be transformed by button presses and axes values, based on this._mapping.
  108937. *
  108938. * @param scene scene in which the meshes exist
  108939. * @param meshes list of meshes that make up the controller model to process
  108940. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  108941. */
  108942. private processModel;
  108943. private createMeshInfo;
  108944. /**
  108945. * Gets the ray of the controller in the direction the controller is pointing
  108946. * @param length the length the resulting ray should be
  108947. * @returns a ray in the direction the controller is pointing
  108948. */
  108949. getForwardRay(length?: number): Ray;
  108950. /**
  108951. * Disposes of the controller
  108952. */
  108953. dispose(): void;
  108954. }
  108955. }
  108956. declare module BABYLON {
  108957. /**
  108958. * Oculus Touch Controller
  108959. */
  108960. export class OculusTouchController extends WebVRController {
  108961. /**
  108962. * Base Url for the controller model.
  108963. */
  108964. static MODEL_BASE_URL: string;
  108965. /**
  108966. * File name for the left controller model.
  108967. */
  108968. static MODEL_LEFT_FILENAME: string;
  108969. /**
  108970. * File name for the right controller model.
  108971. */
  108972. static MODEL_RIGHT_FILENAME: string;
  108973. /**
  108974. * Base Url for the Quest controller model.
  108975. */
  108976. static QUEST_MODEL_BASE_URL: string;
  108977. /**
  108978. * @hidden
  108979. * If the controllers are running on a device that needs the updated Quest controller models
  108980. */
  108981. static _IsQuest: boolean;
  108982. /**
  108983. * Fired when the secondary trigger on this controller is modified
  108984. */
  108985. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108986. /**
  108987. * Fired when the thumb rest on this controller is modified
  108988. */
  108989. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  108990. /**
  108991. * Creates a new OculusTouchController from a gamepad
  108992. * @param vrGamepad the gamepad that the controller should be created from
  108993. */
  108994. constructor(vrGamepad: any);
  108995. /**
  108996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108997. * @param scene scene in which to add meshes
  108998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108999. */
  109000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109001. /**
  109002. * Fired when the A button on this controller is modified
  109003. */
  109004. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109005. /**
  109006. * Fired when the B button on this controller is modified
  109007. */
  109008. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109009. /**
  109010. * Fired when the X button on this controller is modified
  109011. */
  109012. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109013. /**
  109014. * Fired when the Y button on this controller is modified
  109015. */
  109016. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109017. /**
  109018. * Called once for each button that changed state since the last frame
  109019. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109020. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109021. * 2) secondary trigger (same)
  109022. * 3) A (right) X (left), touch, pressed = value
  109023. * 4) B / Y
  109024. * 5) thumb rest
  109025. * @param buttonIdx Which button index changed
  109026. * @param state New state of the button
  109027. * @param changes Which properties on the state changed since last frame
  109028. */
  109029. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109030. }
  109031. }
  109032. declare module BABYLON {
  109033. /**
  109034. * Vive Controller
  109035. */
  109036. export class ViveController extends WebVRController {
  109037. /**
  109038. * Base Url for the controller model.
  109039. */
  109040. static MODEL_BASE_URL: string;
  109041. /**
  109042. * File name for the controller model.
  109043. */
  109044. static MODEL_FILENAME: string;
  109045. /**
  109046. * Creates a new ViveController from a gamepad
  109047. * @param vrGamepad the gamepad that the controller should be created from
  109048. */
  109049. constructor(vrGamepad: any);
  109050. /**
  109051. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109052. * @param scene scene in which to add meshes
  109053. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109054. */
  109055. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109056. /**
  109057. * Fired when the left button on this controller is modified
  109058. */
  109059. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109060. /**
  109061. * Fired when the right button on this controller is modified
  109062. */
  109063. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109064. /**
  109065. * Fired when the menu button on this controller is modified
  109066. */
  109067. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109068. /**
  109069. * Called once for each button that changed state since the last frame
  109070. * Vive mapping:
  109071. * 0: touchpad
  109072. * 1: trigger
  109073. * 2: left AND right buttons
  109074. * 3: menu button
  109075. * @param buttonIdx Which button index changed
  109076. * @param state New state of the button
  109077. * @param changes Which properties on the state changed since last frame
  109078. */
  109079. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109080. }
  109081. }
  109082. declare module BABYLON {
  109083. /**
  109084. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109085. */
  109086. export class WebXRControllerModelLoader {
  109087. /**
  109088. * Creates the WebXRControllerModelLoader
  109089. * @param input xr input that creates the controllers
  109090. */
  109091. constructor(input: WebXRInput);
  109092. }
  109093. }
  109094. declare module BABYLON {
  109095. /**
  109096. * Contains an array of blocks representing the octree
  109097. */
  109098. export interface IOctreeContainer<T> {
  109099. /**
  109100. * Blocks within the octree
  109101. */
  109102. blocks: Array<OctreeBlock<T>>;
  109103. }
  109104. /**
  109105. * Class used to store a cell in an octree
  109106. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109107. */
  109108. export class OctreeBlock<T> {
  109109. /**
  109110. * Gets the content of the current block
  109111. */
  109112. entries: T[];
  109113. /**
  109114. * Gets the list of block children
  109115. */
  109116. blocks: Array<OctreeBlock<T>>;
  109117. private _depth;
  109118. private _maxDepth;
  109119. private _capacity;
  109120. private _minPoint;
  109121. private _maxPoint;
  109122. private _boundingVectors;
  109123. private _creationFunc;
  109124. /**
  109125. * Creates a new block
  109126. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109127. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109128. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109129. * @param depth defines the current depth of this block in the octree
  109130. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109131. * @param creationFunc defines a callback to call when an element is added to the block
  109132. */
  109133. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109134. /**
  109135. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109136. */
  109137. readonly capacity: number;
  109138. /**
  109139. * Gets the minimum vector (in world space) of the block's bounding box
  109140. */
  109141. readonly minPoint: Vector3;
  109142. /**
  109143. * Gets the maximum vector (in world space) of the block's bounding box
  109144. */
  109145. readonly maxPoint: Vector3;
  109146. /**
  109147. * Add a new element to this block
  109148. * @param entry defines the element to add
  109149. */
  109150. addEntry(entry: T): void;
  109151. /**
  109152. * Remove an element from this block
  109153. * @param entry defines the element to remove
  109154. */
  109155. removeEntry(entry: T): void;
  109156. /**
  109157. * Add an array of elements to this block
  109158. * @param entries defines the array of elements to add
  109159. */
  109160. addEntries(entries: T[]): void;
  109161. /**
  109162. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109163. * @param frustumPlanes defines the frustum planes to test
  109164. * @param selection defines the array to store current content if selection is positive
  109165. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109166. */
  109167. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109168. /**
  109169. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109170. * @param sphereCenter defines the bounding sphere center
  109171. * @param sphereRadius defines the bounding sphere radius
  109172. * @param selection defines the array to store current content if selection is positive
  109173. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109174. */
  109175. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109176. /**
  109177. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109178. * @param ray defines the ray to test with
  109179. * @param selection defines the array to store current content if selection is positive
  109180. */
  109181. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109182. /**
  109183. * Subdivide the content into child blocks (this block will then be empty)
  109184. */
  109185. createInnerBlocks(): void;
  109186. /**
  109187. * @hidden
  109188. */
  109189. 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;
  109190. }
  109191. }
  109192. declare module BABYLON {
  109193. /**
  109194. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109195. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109196. */
  109197. export class Octree<T> {
  109198. /** 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.) */
  109199. maxDepth: number;
  109200. /**
  109201. * Blocks within the octree containing objects
  109202. */
  109203. blocks: Array<OctreeBlock<T>>;
  109204. /**
  109205. * Content stored in the octree
  109206. */
  109207. dynamicContent: T[];
  109208. private _maxBlockCapacity;
  109209. private _selectionContent;
  109210. private _creationFunc;
  109211. /**
  109212. * Creates a octree
  109213. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109214. * @param creationFunc function to be used to instatiate the octree
  109215. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109216. * @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.)
  109217. */
  109218. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109219. /** 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.) */
  109220. maxDepth?: number);
  109221. /**
  109222. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109223. * @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);
  109224. * @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);
  109225. * @param entries meshes to be added to the octree blocks
  109226. */
  109227. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109228. /**
  109229. * Adds a mesh to the octree
  109230. * @param entry Mesh to add to the octree
  109231. */
  109232. addMesh(entry: T): void;
  109233. /**
  109234. * Remove an element from the octree
  109235. * @param entry defines the element to remove
  109236. */
  109237. removeMesh(entry: T): void;
  109238. /**
  109239. * Selects an array of meshes within the frustum
  109240. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109241. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109242. * @returns array of meshes within the frustum
  109243. */
  109244. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109245. /**
  109246. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109247. * @param sphereCenter defines the bounding sphere center
  109248. * @param sphereRadius defines the bounding sphere radius
  109249. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109250. * @returns an array of objects that intersect the sphere
  109251. */
  109252. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109253. /**
  109254. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109255. * @param ray defines the ray to test with
  109256. * @returns array of intersected objects
  109257. */
  109258. intersectsRay(ray: Ray): SmartArray<T>;
  109259. /**
  109260. * Adds a mesh into the octree block if it intersects the block
  109261. */
  109262. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109263. /**
  109264. * Adds a submesh into the octree block if it intersects the block
  109265. */
  109266. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109267. }
  109268. }
  109269. declare module BABYLON {
  109270. interface Scene {
  109271. /**
  109272. * @hidden
  109273. * Backing Filed
  109274. */
  109275. _selectionOctree: Octree<AbstractMesh>;
  109276. /**
  109277. * Gets the octree used to boost mesh selection (picking)
  109278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109279. */
  109280. selectionOctree: Octree<AbstractMesh>;
  109281. /**
  109282. * Creates or updates the octree used to boost selection (picking)
  109283. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109284. * @param maxCapacity defines the maximum capacity per leaf
  109285. * @param maxDepth defines the maximum depth of the octree
  109286. * @returns an octree of AbstractMesh
  109287. */
  109288. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109289. }
  109290. interface AbstractMesh {
  109291. /**
  109292. * @hidden
  109293. * Backing Field
  109294. */
  109295. _submeshesOctree: Octree<SubMesh>;
  109296. /**
  109297. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109298. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109299. * @param maxCapacity defines the maximum size of each block (64 by default)
  109300. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109301. * @returns the new octree
  109302. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109303. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109304. */
  109305. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109306. }
  109307. /**
  109308. * Defines the octree scene component responsible to manage any octrees
  109309. * in a given scene.
  109310. */
  109311. export class OctreeSceneComponent {
  109312. /**
  109313. * The component name help to identify the component in the list of scene components.
  109314. */
  109315. readonly name: string;
  109316. /**
  109317. * The scene the component belongs to.
  109318. */
  109319. scene: Scene;
  109320. /**
  109321. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109322. */
  109323. readonly checksIsEnabled: boolean;
  109324. /**
  109325. * Creates a new instance of the component for the given scene
  109326. * @param scene Defines the scene to register the component in
  109327. */
  109328. constructor(scene: Scene);
  109329. /**
  109330. * Registers the component in a given scene
  109331. */
  109332. register(): void;
  109333. /**
  109334. * Return the list of active meshes
  109335. * @returns the list of active meshes
  109336. */
  109337. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109338. /**
  109339. * Return the list of active sub meshes
  109340. * @param mesh The mesh to get the candidates sub meshes from
  109341. * @returns the list of active sub meshes
  109342. */
  109343. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109344. private _tempRay;
  109345. /**
  109346. * Return the list of sub meshes intersecting with a given local ray
  109347. * @param mesh defines the mesh to find the submesh for
  109348. * @param localRay defines the ray in local space
  109349. * @returns the list of intersecting sub meshes
  109350. */
  109351. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109352. /**
  109353. * Return the list of sub meshes colliding with a collider
  109354. * @param mesh defines the mesh to find the submesh for
  109355. * @param collider defines the collider to evaluate the collision against
  109356. * @returns the list of colliding sub meshes
  109357. */
  109358. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109359. /**
  109360. * Rebuilds the elements related to this component in case of
  109361. * context lost for instance.
  109362. */
  109363. rebuild(): void;
  109364. /**
  109365. * Disposes the component and the associated ressources.
  109366. */
  109367. dispose(): void;
  109368. }
  109369. }
  109370. declare module BABYLON {
  109371. /**
  109372. * Renders a layer on top of an existing scene
  109373. */
  109374. export class UtilityLayerRenderer implements IDisposable {
  109375. /** the original scene that will be rendered on top of */
  109376. originalScene: Scene;
  109377. private _pointerCaptures;
  109378. private _lastPointerEvents;
  109379. private static _DefaultUtilityLayer;
  109380. private static _DefaultKeepDepthUtilityLayer;
  109381. private _sharedGizmoLight;
  109382. private _renderCamera;
  109383. /**
  109384. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109385. * @returns the camera that is used when rendering the utility layer
  109386. */
  109387. getRenderCamera(): Nullable<Camera>;
  109388. /**
  109389. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109390. * @param cam the camera that should be used when rendering the utility layer
  109391. */
  109392. setRenderCamera(cam: Nullable<Camera>): void;
  109393. /**
  109394. * @hidden
  109395. * Light which used by gizmos to get light shading
  109396. */
  109397. _getSharedGizmoLight(): HemisphericLight;
  109398. /**
  109399. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109400. */
  109401. pickUtilitySceneFirst: boolean;
  109402. /**
  109403. * 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)
  109404. */
  109405. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109406. /**
  109407. * 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)
  109408. */
  109409. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109410. /**
  109411. * The scene that is rendered on top of the original scene
  109412. */
  109413. utilityLayerScene: Scene;
  109414. /**
  109415. * If the utility layer should automatically be rendered on top of existing scene
  109416. */
  109417. shouldRender: boolean;
  109418. /**
  109419. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109420. */
  109421. onlyCheckPointerDownEvents: boolean;
  109422. /**
  109423. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109424. */
  109425. processAllEvents: boolean;
  109426. /**
  109427. * Observable raised when the pointer move from the utility layer scene to the main scene
  109428. */
  109429. onPointerOutObservable: Observable<number>;
  109430. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109431. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109432. private _afterRenderObserver;
  109433. private _sceneDisposeObserver;
  109434. private _originalPointerObserver;
  109435. /**
  109436. * Instantiates a UtilityLayerRenderer
  109437. * @param originalScene the original scene that will be rendered on top of
  109438. * @param handleEvents boolean indicating if the utility layer should handle events
  109439. */
  109440. constructor(
  109441. /** the original scene that will be rendered on top of */
  109442. originalScene: Scene, handleEvents?: boolean);
  109443. private _notifyObservers;
  109444. /**
  109445. * Renders the utility layers scene on top of the original scene
  109446. */
  109447. render(): void;
  109448. /**
  109449. * Disposes of the renderer
  109450. */
  109451. dispose(): void;
  109452. private _updateCamera;
  109453. }
  109454. }
  109455. declare module BABYLON {
  109456. /**
  109457. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109458. */
  109459. export class Gizmo implements IDisposable {
  109460. /** The utility layer the gizmo will be added to */
  109461. gizmoLayer: UtilityLayerRenderer;
  109462. /**
  109463. * The root mesh of the gizmo
  109464. */
  109465. _rootMesh: Mesh;
  109466. private _attachedMesh;
  109467. /**
  109468. * Ratio for the scale of the gizmo (Default: 1)
  109469. */
  109470. scaleRatio: number;
  109471. /**
  109472. * If a custom mesh has been set (Default: false)
  109473. */
  109474. protected _customMeshSet: boolean;
  109475. /**
  109476. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109477. * * When set, interactions will be enabled
  109478. */
  109479. attachedMesh: Nullable<AbstractMesh>;
  109480. /**
  109481. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109482. * @param mesh The mesh to replace the default mesh of the gizmo
  109483. */
  109484. setCustomMesh(mesh: Mesh): void;
  109485. /**
  109486. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109487. */
  109488. updateGizmoRotationToMatchAttachedMesh: boolean;
  109489. /**
  109490. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109491. */
  109492. updateGizmoPositionToMatchAttachedMesh: boolean;
  109493. /**
  109494. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109495. */
  109496. updateScale: boolean;
  109497. protected _interactionsEnabled: boolean;
  109498. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109499. private _beforeRenderObserver;
  109500. private _tempVector;
  109501. /**
  109502. * Creates a gizmo
  109503. * @param gizmoLayer The utility layer the gizmo will be added to
  109504. */
  109505. constructor(
  109506. /** The utility layer the gizmo will be added to */
  109507. gizmoLayer?: UtilityLayerRenderer);
  109508. /**
  109509. * Updates the gizmo to match the attached mesh's position/rotation
  109510. */
  109511. protected _update(): void;
  109512. /**
  109513. * Disposes of the gizmo
  109514. */
  109515. dispose(): void;
  109516. }
  109517. }
  109518. declare module BABYLON {
  109519. /**
  109520. * Single plane drag gizmo
  109521. */
  109522. export class PlaneDragGizmo extends Gizmo {
  109523. /**
  109524. * Drag behavior responsible for the gizmos dragging interactions
  109525. */
  109526. dragBehavior: PointerDragBehavior;
  109527. private _pointerObserver;
  109528. /**
  109529. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109530. */
  109531. snapDistance: number;
  109532. /**
  109533. * Event that fires each time the gizmo snaps to a new location.
  109534. * * snapDistance is the the change in distance
  109535. */
  109536. onSnapObservable: Observable<{
  109537. snapDistance: number;
  109538. }>;
  109539. private _plane;
  109540. private _coloredMaterial;
  109541. private _hoverMaterial;
  109542. private _isEnabled;
  109543. private _parent;
  109544. /** @hidden */
  109545. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109546. /** @hidden */
  109547. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109548. /**
  109549. * Creates a PlaneDragGizmo
  109550. * @param gizmoLayer The utility layer the gizmo will be added to
  109551. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109552. * @param color The color of the gizmo
  109553. */
  109554. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109555. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109556. /**
  109557. * If the gizmo is enabled
  109558. */
  109559. isEnabled: boolean;
  109560. /**
  109561. * Disposes of the gizmo
  109562. */
  109563. dispose(): void;
  109564. }
  109565. }
  109566. declare module BABYLON {
  109567. /**
  109568. * Gizmo that enables dragging a mesh along 3 axis
  109569. */
  109570. export class PositionGizmo extends Gizmo {
  109571. /**
  109572. * Internal gizmo used for interactions on the x axis
  109573. */
  109574. xGizmo: AxisDragGizmo;
  109575. /**
  109576. * Internal gizmo used for interactions on the y axis
  109577. */
  109578. yGizmo: AxisDragGizmo;
  109579. /**
  109580. * Internal gizmo used for interactions on the z axis
  109581. */
  109582. zGizmo: AxisDragGizmo;
  109583. /**
  109584. * Internal gizmo used for interactions on the yz plane
  109585. */
  109586. xPlaneGizmo: PlaneDragGizmo;
  109587. /**
  109588. * Internal gizmo used for interactions on the xz plane
  109589. */
  109590. yPlaneGizmo: PlaneDragGizmo;
  109591. /**
  109592. * Internal gizmo used for interactions on the xy plane
  109593. */
  109594. zPlaneGizmo: PlaneDragGizmo;
  109595. /**
  109596. * private variables
  109597. */
  109598. private _meshAttached;
  109599. private _updateGizmoRotationToMatchAttachedMesh;
  109600. private _snapDistance;
  109601. private _scaleRatio;
  109602. /** Fires an event when any of it's sub gizmos are dragged */
  109603. onDragStartObservable: Observable<unknown>;
  109604. /** Fires an event when any of it's sub gizmos are released from dragging */
  109605. onDragEndObservable: Observable<unknown>;
  109606. /**
  109607. * If set to true, planar drag is enabled
  109608. */
  109609. private _planarGizmoEnabled;
  109610. attachedMesh: Nullable<AbstractMesh>;
  109611. /**
  109612. * Creates a PositionGizmo
  109613. * @param gizmoLayer The utility layer the gizmo will be added to
  109614. */
  109615. constructor(gizmoLayer?: UtilityLayerRenderer);
  109616. /**
  109617. * If the planar drag gizmo is enabled
  109618. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109619. */
  109620. planarGizmoEnabled: boolean;
  109621. updateGizmoRotationToMatchAttachedMesh: boolean;
  109622. /**
  109623. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109624. */
  109625. snapDistance: number;
  109626. /**
  109627. * Ratio for the scale of the gizmo (Default: 1)
  109628. */
  109629. scaleRatio: number;
  109630. /**
  109631. * Disposes of the gizmo
  109632. */
  109633. dispose(): void;
  109634. /**
  109635. * CustomMeshes are not supported by this gizmo
  109636. * @param mesh The mesh to replace the default mesh of the gizmo
  109637. */
  109638. setCustomMesh(mesh: Mesh): void;
  109639. }
  109640. }
  109641. declare module BABYLON {
  109642. /**
  109643. * Single axis drag gizmo
  109644. */
  109645. export class AxisDragGizmo extends Gizmo {
  109646. /**
  109647. * Drag behavior responsible for the gizmos dragging interactions
  109648. */
  109649. dragBehavior: PointerDragBehavior;
  109650. private _pointerObserver;
  109651. /**
  109652. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109653. */
  109654. snapDistance: number;
  109655. /**
  109656. * Event that fires each time the gizmo snaps to a new location.
  109657. * * snapDistance is the the change in distance
  109658. */
  109659. onSnapObservable: Observable<{
  109660. snapDistance: number;
  109661. }>;
  109662. private _isEnabled;
  109663. private _parent;
  109664. private _arrow;
  109665. private _coloredMaterial;
  109666. private _hoverMaterial;
  109667. /** @hidden */
  109668. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109669. /** @hidden */
  109670. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109671. /**
  109672. * Creates an AxisDragGizmo
  109673. * @param gizmoLayer The utility layer the gizmo will be added to
  109674. * @param dragAxis The axis which the gizmo will be able to drag on
  109675. * @param color The color of the gizmo
  109676. */
  109677. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109678. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109679. /**
  109680. * If the gizmo is enabled
  109681. */
  109682. isEnabled: boolean;
  109683. /**
  109684. * Disposes of the gizmo
  109685. */
  109686. dispose(): void;
  109687. }
  109688. }
  109689. declare module BABYLON.Debug {
  109690. /**
  109691. * The Axes viewer will show 3 axes in a specific point in space
  109692. */
  109693. export class AxesViewer {
  109694. private _xAxis;
  109695. private _yAxis;
  109696. private _zAxis;
  109697. private _scaleLinesFactor;
  109698. private _instanced;
  109699. /**
  109700. * Gets the hosting scene
  109701. */
  109702. scene: Scene;
  109703. /**
  109704. * Gets or sets a number used to scale line length
  109705. */
  109706. scaleLines: number;
  109707. /** Gets the node hierarchy used to render x-axis */
  109708. readonly xAxis: TransformNode;
  109709. /** Gets the node hierarchy used to render y-axis */
  109710. readonly yAxis: TransformNode;
  109711. /** Gets the node hierarchy used to render z-axis */
  109712. readonly zAxis: TransformNode;
  109713. /**
  109714. * Creates a new AxesViewer
  109715. * @param scene defines the hosting scene
  109716. * @param scaleLines defines a number used to scale line length (1 by default)
  109717. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109718. * @param xAxis defines the node hierarchy used to render the x-axis
  109719. * @param yAxis defines the node hierarchy used to render the y-axis
  109720. * @param zAxis defines the node hierarchy used to render the z-axis
  109721. */
  109722. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109723. /**
  109724. * Force the viewer to update
  109725. * @param position defines the position of the viewer
  109726. * @param xaxis defines the x axis of the viewer
  109727. * @param yaxis defines the y axis of the viewer
  109728. * @param zaxis defines the z axis of the viewer
  109729. */
  109730. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109731. /**
  109732. * Creates an instance of this axes viewer.
  109733. * @returns a new axes viewer with instanced meshes
  109734. */
  109735. createInstance(): AxesViewer;
  109736. /** Releases resources */
  109737. dispose(): void;
  109738. private static _SetRenderingGroupId;
  109739. }
  109740. }
  109741. declare module BABYLON.Debug {
  109742. /**
  109743. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109744. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109745. */
  109746. export class BoneAxesViewer extends AxesViewer {
  109747. /**
  109748. * Gets or sets the target mesh where to display the axes viewer
  109749. */
  109750. mesh: Nullable<Mesh>;
  109751. /**
  109752. * Gets or sets the target bone where to display the axes viewer
  109753. */
  109754. bone: Nullable<Bone>;
  109755. /** Gets current position */
  109756. pos: Vector3;
  109757. /** Gets direction of X axis */
  109758. xaxis: Vector3;
  109759. /** Gets direction of Y axis */
  109760. yaxis: Vector3;
  109761. /** Gets direction of Z axis */
  109762. zaxis: Vector3;
  109763. /**
  109764. * Creates a new BoneAxesViewer
  109765. * @param scene defines the hosting scene
  109766. * @param bone defines the target bone
  109767. * @param mesh defines the target mesh
  109768. * @param scaleLines defines a scaling factor for line length (1 by default)
  109769. */
  109770. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109771. /**
  109772. * Force the viewer to update
  109773. */
  109774. update(): void;
  109775. /** Releases resources */
  109776. dispose(): void;
  109777. }
  109778. }
  109779. declare module BABYLON {
  109780. /**
  109781. * Interface used to define scene explorer extensibility option
  109782. */
  109783. export interface IExplorerExtensibilityOption {
  109784. /**
  109785. * Define the option label
  109786. */
  109787. label: string;
  109788. /**
  109789. * Defines the action to execute on click
  109790. */
  109791. action: (entity: any) => void;
  109792. }
  109793. /**
  109794. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109795. */
  109796. export interface IExplorerExtensibilityGroup {
  109797. /**
  109798. * Defines a predicate to test if a given type mut be extended
  109799. */
  109800. predicate: (entity: any) => boolean;
  109801. /**
  109802. * Gets the list of options added to a type
  109803. */
  109804. entries: IExplorerExtensibilityOption[];
  109805. }
  109806. /**
  109807. * Interface used to define the options to use to create the Inspector
  109808. */
  109809. export interface IInspectorOptions {
  109810. /**
  109811. * Display in overlay mode (default: false)
  109812. */
  109813. overlay?: boolean;
  109814. /**
  109815. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109816. */
  109817. globalRoot?: HTMLElement;
  109818. /**
  109819. * Display the Scene explorer
  109820. */
  109821. showExplorer?: boolean;
  109822. /**
  109823. * Display the property inspector
  109824. */
  109825. showInspector?: boolean;
  109826. /**
  109827. * Display in embed mode (both panes on the right)
  109828. */
  109829. embedMode?: boolean;
  109830. /**
  109831. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109832. */
  109833. handleResize?: boolean;
  109834. /**
  109835. * Allow the panes to popup (default: true)
  109836. */
  109837. enablePopup?: boolean;
  109838. /**
  109839. * Allow the panes to be closed by users (default: true)
  109840. */
  109841. enableClose?: boolean;
  109842. /**
  109843. * Optional list of extensibility entries
  109844. */
  109845. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109846. /**
  109847. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109848. */
  109849. inspectorURL?: string;
  109850. }
  109851. interface Scene {
  109852. /**
  109853. * @hidden
  109854. * Backing field
  109855. */
  109856. _debugLayer: DebugLayer;
  109857. /**
  109858. * Gets the debug layer (aka Inspector) associated with the scene
  109859. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109860. */
  109861. debugLayer: DebugLayer;
  109862. }
  109863. /**
  109864. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109865. * what is happening in your scene
  109866. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109867. */
  109868. export class DebugLayer {
  109869. /**
  109870. * Define the url to get the inspector script from.
  109871. * By default it uses the babylonjs CDN.
  109872. * @ignoreNaming
  109873. */
  109874. static InspectorURL: string;
  109875. private _scene;
  109876. private BJSINSPECTOR;
  109877. private _onPropertyChangedObservable?;
  109878. /**
  109879. * Observable triggered when a property is changed through the inspector.
  109880. */
  109881. readonly onPropertyChangedObservable: any;
  109882. /**
  109883. * Instantiates a new debug layer.
  109884. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109885. * what is happening in your scene
  109886. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109887. * @param scene Defines the scene to inspect
  109888. */
  109889. constructor(scene: Scene);
  109890. /** Creates the inspector window. */
  109891. private _createInspector;
  109892. /**
  109893. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  109894. * @param entity defines the entity to select
  109895. * @param lineContainerTitle defines the specific block to highlight
  109896. */
  109897. select(entity: any, lineContainerTitle?: string): void;
  109898. /** Get the inspector from bundle or global */
  109899. private _getGlobalInspector;
  109900. /**
  109901. * Get if the inspector is visible or not.
  109902. * @returns true if visible otherwise, false
  109903. */
  109904. isVisible(): boolean;
  109905. /**
  109906. * Hide the inspector and close its window.
  109907. */
  109908. hide(): void;
  109909. /**
  109910. * Launch the debugLayer.
  109911. * @param config Define the configuration of the inspector
  109912. * @return a promise fulfilled when the debug layer is visible
  109913. */
  109914. show(config?: IInspectorOptions): Promise<DebugLayer>;
  109915. }
  109916. }
  109917. declare module BABYLON {
  109918. /**
  109919. * Class containing static functions to help procedurally build meshes
  109920. */
  109921. export class BoxBuilder {
  109922. /**
  109923. * Creates a box mesh
  109924. * * The parameter `size` sets the size (float) of each box side (default 1)
  109925. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109926. * * 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)
  109927. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109931. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109932. * @param name defines the name of the mesh
  109933. * @param options defines the options used to create the mesh
  109934. * @param scene defines the hosting scene
  109935. * @returns the box mesh
  109936. */
  109937. static CreateBox(name: string, options: {
  109938. size?: number;
  109939. width?: number;
  109940. height?: number;
  109941. depth?: number;
  109942. faceUV?: Vector4[];
  109943. faceColors?: Color4[];
  109944. sideOrientation?: number;
  109945. frontUVs?: Vector4;
  109946. backUVs?: Vector4;
  109947. wrap?: boolean;
  109948. topBaseAt?: number;
  109949. bottomBaseAt?: number;
  109950. updatable?: boolean;
  109951. }, scene?: Nullable<Scene>): Mesh;
  109952. }
  109953. }
  109954. declare module BABYLON {
  109955. /**
  109956. * Class containing static functions to help procedurally build meshes
  109957. */
  109958. export class SphereBuilder {
  109959. /**
  109960. * Creates a sphere mesh
  109961. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109962. * * 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`)
  109963. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109964. * * 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
  109965. * * 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)
  109966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109969. * @param name defines the name of the mesh
  109970. * @param options defines the options used to create the mesh
  109971. * @param scene defines the hosting scene
  109972. * @returns the sphere mesh
  109973. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109974. */
  109975. static CreateSphere(name: string, options: {
  109976. segments?: number;
  109977. diameter?: number;
  109978. diameterX?: number;
  109979. diameterY?: number;
  109980. diameterZ?: number;
  109981. arc?: number;
  109982. slice?: number;
  109983. sideOrientation?: number;
  109984. frontUVs?: Vector4;
  109985. backUVs?: Vector4;
  109986. updatable?: boolean;
  109987. }, scene?: Nullable<Scene>): Mesh;
  109988. }
  109989. }
  109990. declare module BABYLON.Debug {
  109991. /**
  109992. * Used to show the physics impostor around the specific mesh
  109993. */
  109994. export class PhysicsViewer {
  109995. /** @hidden */
  109996. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  109997. /** @hidden */
  109998. protected _meshes: Array<Nullable<AbstractMesh>>;
  109999. /** @hidden */
  110000. protected _scene: Nullable<Scene>;
  110001. /** @hidden */
  110002. protected _numMeshes: number;
  110003. /** @hidden */
  110004. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110005. private _renderFunction;
  110006. private _utilityLayer;
  110007. private _debugBoxMesh;
  110008. private _debugSphereMesh;
  110009. private _debugCylinderMesh;
  110010. private _debugMaterial;
  110011. private _debugMeshMeshes;
  110012. /**
  110013. * Creates a new PhysicsViewer
  110014. * @param scene defines the hosting scene
  110015. */
  110016. constructor(scene: Scene);
  110017. /** @hidden */
  110018. protected _updateDebugMeshes(): void;
  110019. /**
  110020. * Renders a specified physic impostor
  110021. * @param impostor defines the impostor to render
  110022. * @param targetMesh defines the mesh represented by the impostor
  110023. * @returns the new debug mesh used to render the impostor
  110024. */
  110025. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110026. /**
  110027. * Hides a specified physic impostor
  110028. * @param impostor defines the impostor to hide
  110029. */
  110030. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110031. private _getDebugMaterial;
  110032. private _getDebugBoxMesh;
  110033. private _getDebugSphereMesh;
  110034. private _getDebugCylinderMesh;
  110035. private _getDebugMeshMesh;
  110036. private _getDebugMesh;
  110037. /** Releases all resources */
  110038. dispose(): void;
  110039. }
  110040. }
  110041. declare module BABYLON {
  110042. /**
  110043. * Class containing static functions to help procedurally build meshes
  110044. */
  110045. export class LinesBuilder {
  110046. /**
  110047. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110048. * * 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
  110049. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110050. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110051. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110052. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110053. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110054. * * 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
  110055. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110058. * @param name defines the name of the new line system
  110059. * @param options defines the options used to create the line system
  110060. * @param scene defines the hosting scene
  110061. * @returns a new line system mesh
  110062. */
  110063. static CreateLineSystem(name: string, options: {
  110064. lines: Vector3[][];
  110065. updatable?: boolean;
  110066. instance?: Nullable<LinesMesh>;
  110067. colors?: Nullable<Color4[][]>;
  110068. useVertexAlpha?: boolean;
  110069. }, scene: Nullable<Scene>): LinesMesh;
  110070. /**
  110071. * Creates a line mesh
  110072. * 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
  110073. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110074. * * The parameter `points` is an array successive Vector3
  110075. * * 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
  110076. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110077. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110078. * * When updating an instance, remember that only point positions can change, not the number of points
  110079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110081. * @param name defines the name of the new line system
  110082. * @param options defines the options used to create the line system
  110083. * @param scene defines the hosting scene
  110084. * @returns a new line mesh
  110085. */
  110086. static CreateLines(name: string, options: {
  110087. points: Vector3[];
  110088. updatable?: boolean;
  110089. instance?: Nullable<LinesMesh>;
  110090. colors?: Color4[];
  110091. useVertexAlpha?: boolean;
  110092. }, scene?: Nullable<Scene>): LinesMesh;
  110093. /**
  110094. * Creates a dashed line mesh
  110095. * * 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
  110096. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110097. * * The parameter `points` is an array successive Vector3
  110098. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110099. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110100. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110101. * * 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
  110102. * * When updating an instance, remember that only point positions can change, not the number of points
  110103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110104. * @param name defines the name of the mesh
  110105. * @param options defines the options used to create the mesh
  110106. * @param scene defines the hosting scene
  110107. * @returns the dashed line mesh
  110108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110109. */
  110110. static CreateDashedLines(name: string, options: {
  110111. points: Vector3[];
  110112. dashSize?: number;
  110113. gapSize?: number;
  110114. dashNb?: number;
  110115. updatable?: boolean;
  110116. instance?: LinesMesh;
  110117. }, scene?: Nullable<Scene>): LinesMesh;
  110118. }
  110119. }
  110120. declare module BABYLON {
  110121. /**
  110122. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110123. * in order to better appreciate the issue one might have.
  110124. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110125. */
  110126. export class RayHelper {
  110127. /**
  110128. * Defines the ray we are currently tryin to visualize.
  110129. */
  110130. ray: Nullable<Ray>;
  110131. private _renderPoints;
  110132. private _renderLine;
  110133. private _renderFunction;
  110134. private _scene;
  110135. private _updateToMeshFunction;
  110136. private _attachedToMesh;
  110137. private _meshSpaceDirection;
  110138. private _meshSpaceOrigin;
  110139. /**
  110140. * Helper function to create a colored helper in a scene in one line.
  110141. * @param ray Defines the ray we are currently tryin to visualize
  110142. * @param scene Defines the scene the ray is used in
  110143. * @param color Defines the color we want to see the ray in
  110144. * @returns The newly created ray helper.
  110145. */
  110146. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110147. /**
  110148. * Instantiate a new ray helper.
  110149. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110150. * in order to better appreciate the issue one might have.
  110151. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110152. * @param ray Defines the ray we are currently tryin to visualize
  110153. */
  110154. constructor(ray: Ray);
  110155. /**
  110156. * Shows the ray we are willing to debug.
  110157. * @param scene Defines the scene the ray needs to be rendered in
  110158. * @param color Defines the color the ray needs to be rendered in
  110159. */
  110160. show(scene: Scene, color?: Color3): void;
  110161. /**
  110162. * Hides the ray we are debugging.
  110163. */
  110164. hide(): void;
  110165. private _render;
  110166. /**
  110167. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110168. * @param mesh Defines the mesh we want the helper attached to
  110169. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110170. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110171. * @param length Defines the length of the ray
  110172. */
  110173. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110174. /**
  110175. * Detach the ray helper from the mesh it has previously been attached to.
  110176. */
  110177. detachFromMesh(): void;
  110178. private _updateToMesh;
  110179. /**
  110180. * Dispose the helper and release its associated resources.
  110181. */
  110182. dispose(): void;
  110183. }
  110184. }
  110185. declare module BABYLON.Debug {
  110186. /**
  110187. * Class used to render a debug view of a given skeleton
  110188. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110189. */
  110190. export class SkeletonViewer {
  110191. /** defines the skeleton to render */
  110192. skeleton: Skeleton;
  110193. /** defines the mesh attached to the skeleton */
  110194. mesh: AbstractMesh;
  110195. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110196. autoUpdateBonesMatrices: boolean;
  110197. /** defines the rendering group id to use with the viewer */
  110198. renderingGroupId: number;
  110199. /** Gets or sets the color used to render the skeleton */
  110200. color: Color3;
  110201. private _scene;
  110202. private _debugLines;
  110203. private _debugMesh;
  110204. private _isEnabled;
  110205. private _renderFunction;
  110206. private _utilityLayer;
  110207. /**
  110208. * Returns the mesh used to render the bones
  110209. */
  110210. readonly debugMesh: Nullable<LinesMesh>;
  110211. /**
  110212. * Creates a new SkeletonViewer
  110213. * @param skeleton defines the skeleton to render
  110214. * @param mesh defines the mesh attached to the skeleton
  110215. * @param scene defines the hosting scene
  110216. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110217. * @param renderingGroupId defines the rendering group id to use with the viewer
  110218. */
  110219. constructor(
  110220. /** defines the skeleton to render */
  110221. skeleton: Skeleton,
  110222. /** defines the mesh attached to the skeleton */
  110223. mesh: AbstractMesh, scene: Scene,
  110224. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110225. autoUpdateBonesMatrices?: boolean,
  110226. /** defines the rendering group id to use with the viewer */
  110227. renderingGroupId?: number);
  110228. /** Gets or sets a boolean indicating if the viewer is enabled */
  110229. isEnabled: boolean;
  110230. private _getBonePosition;
  110231. private _getLinesForBonesWithLength;
  110232. private _getLinesForBonesNoLength;
  110233. /** Update the viewer to sync with current skeleton state */
  110234. update(): void;
  110235. /** Release associated resources */
  110236. dispose(): void;
  110237. }
  110238. }
  110239. declare module BABYLON {
  110240. /**
  110241. * Options to create the null engine
  110242. */
  110243. export class NullEngineOptions {
  110244. /**
  110245. * Render width (Default: 512)
  110246. */
  110247. renderWidth: number;
  110248. /**
  110249. * Render height (Default: 256)
  110250. */
  110251. renderHeight: number;
  110252. /**
  110253. * Texture size (Default: 512)
  110254. */
  110255. textureSize: number;
  110256. /**
  110257. * If delta time between frames should be constant
  110258. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110259. */
  110260. deterministicLockstep: boolean;
  110261. /**
  110262. * Maximum about of steps between frames (Default: 4)
  110263. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110264. */
  110265. lockstepMaxSteps: number;
  110266. }
  110267. /**
  110268. * The null engine class provides support for headless version of babylon.js.
  110269. * This can be used in server side scenario or for testing purposes
  110270. */
  110271. export class NullEngine extends Engine {
  110272. private _options;
  110273. /**
  110274. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110275. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110276. * @returns true if engine is in deterministic lock step mode
  110277. */
  110278. isDeterministicLockStep(): boolean;
  110279. /**
  110280. * Gets the max steps when engine is running in deterministic lock step
  110281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110282. * @returns the max steps
  110283. */
  110284. getLockstepMaxSteps(): number;
  110285. /**
  110286. * Gets the current hardware scaling level.
  110287. * By default the hardware scaling level is computed from the window device ratio.
  110288. * 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.
  110289. * @returns a number indicating the current hardware scaling level
  110290. */
  110291. getHardwareScalingLevel(): number;
  110292. constructor(options?: NullEngineOptions);
  110293. /**
  110294. * Creates a vertex buffer
  110295. * @param vertices the data for the vertex buffer
  110296. * @returns the new WebGL static buffer
  110297. */
  110298. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110299. /**
  110300. * Creates a new index buffer
  110301. * @param indices defines the content of the index buffer
  110302. * @param updatable defines if the index buffer must be updatable
  110303. * @returns a new webGL buffer
  110304. */
  110305. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110306. /**
  110307. * Clear the current render buffer or the current render target (if any is set up)
  110308. * @param color defines the color to use
  110309. * @param backBuffer defines if the back buffer must be cleared
  110310. * @param depth defines if the depth buffer must be cleared
  110311. * @param stencil defines if the stencil buffer must be cleared
  110312. */
  110313. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110314. /**
  110315. * Gets the current render width
  110316. * @param useScreen defines if screen size must be used (or the current render target if any)
  110317. * @returns a number defining the current render width
  110318. */
  110319. getRenderWidth(useScreen?: boolean): number;
  110320. /**
  110321. * Gets the current render height
  110322. * @param useScreen defines if screen size must be used (or the current render target if any)
  110323. * @returns a number defining the current render height
  110324. */
  110325. getRenderHeight(useScreen?: boolean): number;
  110326. /**
  110327. * Set the WebGL's viewport
  110328. * @param viewport defines the viewport element to be used
  110329. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110330. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110331. */
  110332. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110333. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110334. /**
  110335. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110336. * @param pipelineContext defines the pipeline context to use
  110337. * @param uniformsNames defines the list of uniform names
  110338. * @returns an array of webGL uniform locations
  110339. */
  110340. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110341. /**
  110342. * Gets the lsit of active attributes for a given webGL program
  110343. * @param pipelineContext defines the pipeline context to use
  110344. * @param attributesNames defines the list of attribute names to get
  110345. * @returns an array of indices indicating the offset of each attribute
  110346. */
  110347. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110348. /**
  110349. * Binds an effect to the webGL context
  110350. * @param effect defines the effect to bind
  110351. */
  110352. bindSamplers(effect: Effect): void;
  110353. /**
  110354. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110355. * @param effect defines the effect to activate
  110356. */
  110357. enableEffect(effect: Effect): void;
  110358. /**
  110359. * Set various states to the webGL context
  110360. * @param culling defines backface culling state
  110361. * @param zOffset defines the value to apply to zOffset (0 by default)
  110362. * @param force defines if states must be applied even if cache is up to date
  110363. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110364. */
  110365. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110366. /**
  110367. * Set the value of an uniform to an array of int32
  110368. * @param uniform defines the webGL uniform location where to store the value
  110369. * @param array defines the array of int32 to store
  110370. */
  110371. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110372. /**
  110373. * Set the value of an uniform to an array of int32 (stored as vec2)
  110374. * @param uniform defines the webGL uniform location where to store the value
  110375. * @param array defines the array of int32 to store
  110376. */
  110377. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110378. /**
  110379. * Set the value of an uniform to an array of int32 (stored as vec3)
  110380. * @param uniform defines the webGL uniform location where to store the value
  110381. * @param array defines the array of int32 to store
  110382. */
  110383. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110384. /**
  110385. * Set the value of an uniform to an array of int32 (stored as vec4)
  110386. * @param uniform defines the webGL uniform location where to store the value
  110387. * @param array defines the array of int32 to store
  110388. */
  110389. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110390. /**
  110391. * Set the value of an uniform to an array of float32
  110392. * @param uniform defines the webGL uniform location where to store the value
  110393. * @param array defines the array of float32 to store
  110394. */
  110395. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110396. /**
  110397. * Set the value of an uniform to an array of float32 (stored as vec2)
  110398. * @param uniform defines the webGL uniform location where to store the value
  110399. * @param array defines the array of float32 to store
  110400. */
  110401. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110402. /**
  110403. * Set the value of an uniform to an array of float32 (stored as vec3)
  110404. * @param uniform defines the webGL uniform location where to store the value
  110405. * @param array defines the array of float32 to store
  110406. */
  110407. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110408. /**
  110409. * Set the value of an uniform to an array of float32 (stored as vec4)
  110410. * @param uniform defines the webGL uniform location where to store the value
  110411. * @param array defines the array of float32 to store
  110412. */
  110413. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110414. /**
  110415. * Set the value of an uniform to an array of number
  110416. * @param uniform defines the webGL uniform location where to store the value
  110417. * @param array defines the array of number to store
  110418. */
  110419. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110420. /**
  110421. * Set the value of an uniform to an array of number (stored as vec2)
  110422. * @param uniform defines the webGL uniform location where to store the value
  110423. * @param array defines the array of number to store
  110424. */
  110425. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110426. /**
  110427. * Set the value of an uniform to an array of number (stored as vec3)
  110428. * @param uniform defines the webGL uniform location where to store the value
  110429. * @param array defines the array of number to store
  110430. */
  110431. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110432. /**
  110433. * Set the value of an uniform to an array of number (stored as vec4)
  110434. * @param uniform defines the webGL uniform location where to store the value
  110435. * @param array defines the array of number to store
  110436. */
  110437. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110438. /**
  110439. * Set the value of an uniform to an array of float32 (stored as matrices)
  110440. * @param uniform defines the webGL uniform location where to store the value
  110441. * @param matrices defines the array of float32 to store
  110442. */
  110443. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110444. /**
  110445. * Set the value of an uniform to a matrix (3x3)
  110446. * @param uniform defines the webGL uniform location where to store the value
  110447. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110448. */
  110449. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110450. /**
  110451. * Set the value of an uniform to a matrix (2x2)
  110452. * @param uniform defines the webGL uniform location where to store the value
  110453. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110454. */
  110455. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110456. /**
  110457. * Set the value of an uniform to a number (float)
  110458. * @param uniform defines the webGL uniform location where to store the value
  110459. * @param value defines the float number to store
  110460. */
  110461. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110462. /**
  110463. * Set the value of an uniform to a vec2
  110464. * @param uniform defines the webGL uniform location where to store the value
  110465. * @param x defines the 1st component of the value
  110466. * @param y defines the 2nd component of the value
  110467. */
  110468. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110469. /**
  110470. * Set the value of an uniform to a vec3
  110471. * @param uniform defines the webGL uniform location where to store the value
  110472. * @param x defines the 1st component of the value
  110473. * @param y defines the 2nd component of the value
  110474. * @param z defines the 3rd component of the value
  110475. */
  110476. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110477. /**
  110478. * Set the value of an uniform to a boolean
  110479. * @param uniform defines the webGL uniform location where to store the value
  110480. * @param bool defines the boolean to store
  110481. */
  110482. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110483. /**
  110484. * Set the value of an uniform to a vec4
  110485. * @param uniform defines the webGL uniform location where to store the value
  110486. * @param x defines the 1st component of the value
  110487. * @param y defines the 2nd component of the value
  110488. * @param z defines the 3rd component of the value
  110489. * @param w defines the 4th component of the value
  110490. */
  110491. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110492. /**
  110493. * Sets the current alpha mode
  110494. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110495. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110496. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110497. */
  110498. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110499. /**
  110500. * Bind webGl buffers directly to the webGL context
  110501. * @param vertexBuffers defines the vertex buffer to bind
  110502. * @param indexBuffer defines the index buffer to bind
  110503. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110504. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110505. * @param effect defines the effect associated with the vertex buffer
  110506. */
  110507. bindBuffers(vertexBuffers: {
  110508. [key: string]: VertexBuffer;
  110509. }, indexBuffer: DataBuffer, effect: Effect): void;
  110510. /**
  110511. * Force the entire cache to be cleared
  110512. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110513. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110514. */
  110515. wipeCaches(bruteForce?: boolean): void;
  110516. /**
  110517. * Send a draw order
  110518. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110519. * @param indexStart defines the starting index
  110520. * @param indexCount defines the number of index to draw
  110521. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110522. */
  110523. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110524. /**
  110525. * Draw a list of indexed primitives
  110526. * @param fillMode defines the primitive to use
  110527. * @param indexStart defines the starting index
  110528. * @param indexCount defines the number of index to draw
  110529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110530. */
  110531. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110532. /**
  110533. * Draw a list of unindexed primitives
  110534. * @param fillMode defines the primitive to use
  110535. * @param verticesStart defines the index of first vertex to draw
  110536. * @param verticesCount defines the count of vertices to draw
  110537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110538. */
  110539. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110540. /** @hidden */
  110541. _createTexture(): WebGLTexture;
  110542. /** @hidden */
  110543. _releaseTexture(texture: InternalTexture): void;
  110544. /**
  110545. * Usually called from Texture.ts.
  110546. * Passed information to create a WebGLTexture
  110547. * @param urlArg defines a value which contains one of the following:
  110548. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110549. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110550. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110551. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110552. * @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)
  110553. * @param scene needed for loading to the correct scene
  110554. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110555. * @param onLoad optional callback to be called upon successful completion
  110556. * @param onError optional callback to be called upon failure
  110557. * @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
  110558. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110559. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110560. * @param forcedExtension defines the extension to use to pick the right loader
  110561. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110562. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110563. */
  110564. 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;
  110565. /**
  110566. * Creates a new render target texture
  110567. * @param size defines the size of the texture
  110568. * @param options defines the options used to create the texture
  110569. * @returns a new render target texture stored in an InternalTexture
  110570. */
  110571. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110572. /**
  110573. * Update the sampling mode of a given texture
  110574. * @param samplingMode defines the required sampling mode
  110575. * @param texture defines the texture to update
  110576. */
  110577. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110578. /**
  110579. * Binds the frame buffer to the specified texture.
  110580. * @param texture The texture to render to or null for the default canvas
  110581. * @param faceIndex The face of the texture to render to in case of cube texture
  110582. * @param requiredWidth The width of the target to render to
  110583. * @param requiredHeight The height of the target to render to
  110584. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110585. * @param depthStencilTexture The depth stencil texture to use to render
  110586. * @param lodLevel defines le lod level to bind to the frame buffer
  110587. */
  110588. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110589. /**
  110590. * Unbind the current render target texture from the webGL context
  110591. * @param texture defines the render target texture to unbind
  110592. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110593. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110594. */
  110595. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110596. /**
  110597. * Creates a dynamic vertex buffer
  110598. * @param vertices the data for the dynamic vertex buffer
  110599. * @returns the new WebGL dynamic buffer
  110600. */
  110601. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110602. /**
  110603. * Update the content of a dynamic texture
  110604. * @param texture defines the texture to update
  110605. * @param canvas defines the canvas containing the source
  110606. * @param invertY defines if data must be stored with Y axis inverted
  110607. * @param premulAlpha defines if alpha is stored as premultiplied
  110608. * @param format defines the format of the data
  110609. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110610. */
  110611. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110612. /**
  110613. * Gets a boolean indicating if all created effects are ready
  110614. * @returns true if all effects are ready
  110615. */
  110616. areAllEffectsReady(): boolean;
  110617. /**
  110618. * @hidden
  110619. * Get the current error code of the webGL context
  110620. * @returns the error code
  110621. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110622. */
  110623. getError(): number;
  110624. /** @hidden */
  110625. _getUnpackAlignement(): number;
  110626. /** @hidden */
  110627. _unpackFlipY(value: boolean): void;
  110628. /**
  110629. * Update a dynamic index buffer
  110630. * @param indexBuffer defines the target index buffer
  110631. * @param indices defines the data to update
  110632. * @param offset defines the offset in the target index buffer where update should start
  110633. */
  110634. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110635. /**
  110636. * Updates a dynamic vertex buffer.
  110637. * @param vertexBuffer the vertex buffer to update
  110638. * @param vertices the data used to update the vertex buffer
  110639. * @param byteOffset the byte offset of the data (optional)
  110640. * @param byteLength the byte length of the data (optional)
  110641. */
  110642. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110643. /** @hidden */
  110644. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110645. /** @hidden */
  110646. _bindTexture(channel: number, texture: InternalTexture): void;
  110647. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110648. /**
  110649. * 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
  110650. */
  110651. releaseEffects(): void;
  110652. displayLoadingUI(): void;
  110653. hideLoadingUI(): void;
  110654. /** @hidden */
  110655. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110656. /** @hidden */
  110657. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110658. /** @hidden */
  110659. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110660. /** @hidden */
  110661. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110662. }
  110663. }
  110664. declare module BABYLON {
  110665. /** @hidden */
  110666. export class _OcclusionDataStorage {
  110667. /** @hidden */
  110668. occlusionInternalRetryCounter: number;
  110669. /** @hidden */
  110670. isOcclusionQueryInProgress: boolean;
  110671. /** @hidden */
  110672. isOccluded: boolean;
  110673. /** @hidden */
  110674. occlusionRetryCount: number;
  110675. /** @hidden */
  110676. occlusionType: number;
  110677. /** @hidden */
  110678. occlusionQueryAlgorithmType: number;
  110679. }
  110680. interface Engine {
  110681. /**
  110682. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110683. * @return the new query
  110684. */
  110685. createQuery(): WebGLQuery;
  110686. /**
  110687. * Delete and release a webGL query
  110688. * @param query defines the query to delete
  110689. * @return the current engine
  110690. */
  110691. deleteQuery(query: WebGLQuery): Engine;
  110692. /**
  110693. * Check if a given query has resolved and got its value
  110694. * @param query defines the query to check
  110695. * @returns true if the query got its value
  110696. */
  110697. isQueryResultAvailable(query: WebGLQuery): boolean;
  110698. /**
  110699. * Gets the value of a given query
  110700. * @param query defines the query to check
  110701. * @returns the value of the query
  110702. */
  110703. getQueryResult(query: WebGLQuery): number;
  110704. /**
  110705. * Initiates an occlusion query
  110706. * @param algorithmType defines the algorithm to use
  110707. * @param query defines the query to use
  110708. * @returns the current engine
  110709. * @see http://doc.babylonjs.com/features/occlusionquery
  110710. */
  110711. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110712. /**
  110713. * Ends an occlusion query
  110714. * @see http://doc.babylonjs.com/features/occlusionquery
  110715. * @param algorithmType defines the algorithm to use
  110716. * @returns the current engine
  110717. */
  110718. endOcclusionQuery(algorithmType: number): Engine;
  110719. /**
  110720. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110721. * Please note that only one query can be issued at a time
  110722. * @returns a time token used to track the time span
  110723. */
  110724. startTimeQuery(): Nullable<_TimeToken>;
  110725. /**
  110726. * Ends a time query
  110727. * @param token defines the token used to measure the time span
  110728. * @returns the time spent (in ns)
  110729. */
  110730. endTimeQuery(token: _TimeToken): int;
  110731. /** @hidden */
  110732. _currentNonTimestampToken: Nullable<_TimeToken>;
  110733. /** @hidden */
  110734. _createTimeQuery(): WebGLQuery;
  110735. /** @hidden */
  110736. _deleteTimeQuery(query: WebGLQuery): void;
  110737. /** @hidden */
  110738. _getGlAlgorithmType(algorithmType: number): number;
  110739. /** @hidden */
  110740. _getTimeQueryResult(query: WebGLQuery): any;
  110741. /** @hidden */
  110742. _getTimeQueryAvailability(query: WebGLQuery): any;
  110743. }
  110744. interface AbstractMesh {
  110745. /**
  110746. * Backing filed
  110747. * @hidden
  110748. */
  110749. __occlusionDataStorage: _OcclusionDataStorage;
  110750. /**
  110751. * Access property
  110752. * @hidden
  110753. */
  110754. _occlusionDataStorage: _OcclusionDataStorage;
  110755. /**
  110756. * 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.
  110757. * The default value is -1 which means don't break the query and wait till the result
  110758. * @see http://doc.babylonjs.com/features/occlusionquery
  110759. */
  110760. occlusionRetryCount: number;
  110761. /**
  110762. * 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:
  110763. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110764. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110765. * * 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.
  110766. * @see http://doc.babylonjs.com/features/occlusionquery
  110767. */
  110768. occlusionType: number;
  110769. /**
  110770. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110771. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110772. * * 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.
  110773. * @see http://doc.babylonjs.com/features/occlusionquery
  110774. */
  110775. occlusionQueryAlgorithmType: number;
  110776. /**
  110777. * 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
  110778. * @see http://doc.babylonjs.com/features/occlusionquery
  110779. */
  110780. isOccluded: boolean;
  110781. /**
  110782. * Flag to check the progress status of the query
  110783. * @see http://doc.babylonjs.com/features/occlusionquery
  110784. */
  110785. isOcclusionQueryInProgress: boolean;
  110786. }
  110787. }
  110788. declare module BABYLON {
  110789. /** @hidden */
  110790. export var _forceTransformFeedbackToBundle: boolean;
  110791. interface Engine {
  110792. /**
  110793. * Creates a webGL transform feedback object
  110794. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110795. * @returns the webGL transform feedback object
  110796. */
  110797. createTransformFeedback(): WebGLTransformFeedback;
  110798. /**
  110799. * Delete a webGL transform feedback object
  110800. * @param value defines the webGL transform feedback object to delete
  110801. */
  110802. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110803. /**
  110804. * Bind a webGL transform feedback object to the webgl context
  110805. * @param value defines the webGL transform feedback object to bind
  110806. */
  110807. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110808. /**
  110809. * Begins a transform feedback operation
  110810. * @param usePoints defines if points or triangles must be used
  110811. */
  110812. beginTransformFeedback(usePoints: boolean): void;
  110813. /**
  110814. * Ends a transform feedback operation
  110815. */
  110816. endTransformFeedback(): void;
  110817. /**
  110818. * Specify the varyings to use with transform feedback
  110819. * @param program defines the associated webGL program
  110820. * @param value defines the list of strings representing the varying names
  110821. */
  110822. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110823. /**
  110824. * Bind a webGL buffer for a transform feedback operation
  110825. * @param value defines the webGL buffer to bind
  110826. */
  110827. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110828. }
  110829. }
  110830. declare module BABYLON {
  110831. /**
  110832. * Creation options of the multi render target texture.
  110833. */
  110834. export interface IMultiRenderTargetOptions {
  110835. /**
  110836. * Define if the texture needs to create mip maps after render.
  110837. */
  110838. generateMipMaps?: boolean;
  110839. /**
  110840. * Define the types of all the draw buffers we want to create
  110841. */
  110842. types?: number[];
  110843. /**
  110844. * Define the sampling modes of all the draw buffers we want to create
  110845. */
  110846. samplingModes?: number[];
  110847. /**
  110848. * Define if a depth buffer is required
  110849. */
  110850. generateDepthBuffer?: boolean;
  110851. /**
  110852. * Define if a stencil buffer is required
  110853. */
  110854. generateStencilBuffer?: boolean;
  110855. /**
  110856. * Define if a depth texture is required instead of a depth buffer
  110857. */
  110858. generateDepthTexture?: boolean;
  110859. /**
  110860. * Define the number of desired draw buffers
  110861. */
  110862. textureCount?: number;
  110863. /**
  110864. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110865. */
  110866. doNotChangeAspectRatio?: boolean;
  110867. /**
  110868. * Define the default type of the buffers we are creating
  110869. */
  110870. defaultType?: number;
  110871. }
  110872. /**
  110873. * A multi render target, like a render target provides the ability to render to a texture.
  110874. * Unlike the render target, it can render to several draw buffers in one draw.
  110875. * This is specially interesting in deferred rendering or for any effects requiring more than
  110876. * just one color from a single pass.
  110877. */
  110878. export class MultiRenderTarget extends RenderTargetTexture {
  110879. private _internalTextures;
  110880. private _textures;
  110881. private _multiRenderTargetOptions;
  110882. /**
  110883. * Get if draw buffers are currently supported by the used hardware and browser.
  110884. */
  110885. readonly isSupported: boolean;
  110886. /**
  110887. * Get the list of textures generated by the multi render target.
  110888. */
  110889. readonly textures: Texture[];
  110890. /**
  110891. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  110892. */
  110893. readonly depthTexture: Texture;
  110894. /**
  110895. * Set the wrapping mode on U of all the textures we are rendering to.
  110896. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110897. */
  110898. wrapU: number;
  110899. /**
  110900. * Set the wrapping mode on V of all the textures we are rendering to.
  110901. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110902. */
  110903. wrapV: number;
  110904. /**
  110905. * Instantiate a new multi render target texture.
  110906. * A multi render target, like a render target provides the ability to render to a texture.
  110907. * Unlike the render target, it can render to several draw buffers in one draw.
  110908. * This is specially interesting in deferred rendering or for any effects requiring more than
  110909. * just one color from a single pass.
  110910. * @param name Define the name of the texture
  110911. * @param size Define the size of the buffers to render to
  110912. * @param count Define the number of target we are rendering into
  110913. * @param scene Define the scene the texture belongs to
  110914. * @param options Define the options used to create the multi render target
  110915. */
  110916. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  110917. /** @hidden */
  110918. _rebuild(): void;
  110919. private _createInternalTextures;
  110920. private _createTextures;
  110921. /**
  110922. * Define the number of samples used if MSAA is enabled.
  110923. */
  110924. samples: number;
  110925. /**
  110926. * Resize all the textures in the multi render target.
  110927. * Be carrefull as it will recreate all the data in the new texture.
  110928. * @param size Define the new size
  110929. */
  110930. resize(size: any): void;
  110931. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110932. /**
  110933. * Dispose the render targets and their associated resources
  110934. */
  110935. dispose(): void;
  110936. /**
  110937. * Release all the underlying texture used as draw buffers.
  110938. */
  110939. releaseInternalTextures(): void;
  110940. }
  110941. }
  110942. declare module BABYLON {
  110943. interface ThinEngine {
  110944. /**
  110945. * Unbind a list of render target textures from the webGL context
  110946. * This is used only when drawBuffer extension or webGL2 are active
  110947. * @param textures defines the render target textures to unbind
  110948. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110949. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110950. */
  110951. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  110952. /**
  110953. * Create a multi render target texture
  110954. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  110955. * @param size defines the size of the texture
  110956. * @param options defines the creation options
  110957. * @returns the cube texture as an InternalTexture
  110958. */
  110959. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  110960. /**
  110961. * Update the sample count for a given multiple render target texture
  110962. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110963. * @param textures defines the textures to update
  110964. * @param samples defines the sample count to set
  110965. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110966. */
  110967. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  110968. }
  110969. }
  110970. declare module BABYLON {
  110971. /** @hidden */
  110972. export var rgbdEncodePixelShader: {
  110973. name: string;
  110974. shader: string;
  110975. };
  110976. }
  110977. declare module BABYLON {
  110978. /** @hidden */
  110979. export var rgbdDecodePixelShader: {
  110980. name: string;
  110981. shader: string;
  110982. };
  110983. }
  110984. declare module BABYLON {
  110985. /**
  110986. * Raw texture data and descriptor sufficient for WebGL texture upload
  110987. */
  110988. export interface EnvironmentTextureInfo {
  110989. /**
  110990. * Version of the environment map
  110991. */
  110992. version: number;
  110993. /**
  110994. * Width of image
  110995. */
  110996. width: number;
  110997. /**
  110998. * Irradiance information stored in the file.
  110999. */
  111000. irradiance: any;
  111001. /**
  111002. * Specular information stored in the file.
  111003. */
  111004. specular: any;
  111005. }
  111006. /**
  111007. * Defines One Image in the file. It requires only the position in the file
  111008. * as well as the length.
  111009. */
  111010. interface BufferImageData {
  111011. /**
  111012. * Length of the image data.
  111013. */
  111014. length: number;
  111015. /**
  111016. * Position of the data from the null terminator delimiting the end of the JSON.
  111017. */
  111018. position: number;
  111019. }
  111020. /**
  111021. * Defines the specular data enclosed in the file.
  111022. * This corresponds to the version 1 of the data.
  111023. */
  111024. export interface EnvironmentTextureSpecularInfoV1 {
  111025. /**
  111026. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111027. */
  111028. specularDataPosition?: number;
  111029. /**
  111030. * This contains all the images data needed to reconstruct the cubemap.
  111031. */
  111032. mipmaps: Array<BufferImageData>;
  111033. /**
  111034. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111035. */
  111036. lodGenerationScale: number;
  111037. }
  111038. /**
  111039. * Sets of helpers addressing the serialization and deserialization of environment texture
  111040. * stored in a BabylonJS env file.
  111041. * Those files are usually stored as .env files.
  111042. */
  111043. export class EnvironmentTextureTools {
  111044. /**
  111045. * Magic number identifying the env file.
  111046. */
  111047. private static _MagicBytes;
  111048. /**
  111049. * Gets the environment info from an env file.
  111050. * @param data The array buffer containing the .env bytes.
  111051. * @returns the environment file info (the json header) if successfully parsed.
  111052. */
  111053. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111054. /**
  111055. * Creates an environment texture from a loaded cube texture.
  111056. * @param texture defines the cube texture to convert in env file
  111057. * @return a promise containing the environment data if succesfull.
  111058. */
  111059. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111060. /**
  111061. * Creates a JSON representation of the spherical data.
  111062. * @param texture defines the texture containing the polynomials
  111063. * @return the JSON representation of the spherical info
  111064. */
  111065. private static _CreateEnvTextureIrradiance;
  111066. /**
  111067. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111068. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111069. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111070. * @return the views described by info providing access to the underlying buffer
  111071. */
  111072. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111073. /**
  111074. * Uploads the texture info contained in the env file to the GPU.
  111075. * @param texture defines the internal texture to upload to
  111076. * @param arrayBuffer defines the buffer cotaining the data to load
  111077. * @param info defines the texture info retrieved through the GetEnvInfo method
  111078. * @returns a promise
  111079. */
  111080. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111081. /**
  111082. * Uploads the levels of image data to the GPU.
  111083. * @param texture defines the internal texture to upload to
  111084. * @param imageData defines the array buffer views of image data [mipmap][face]
  111085. * @returns a promise
  111086. */
  111087. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111088. /**
  111089. * Uploads spherical polynomials information to the texture.
  111090. * @param texture defines the texture we are trying to upload the information to
  111091. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111092. */
  111093. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111094. /** @hidden */
  111095. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111096. }
  111097. }
  111098. declare module BABYLON {
  111099. /**
  111100. * Contains position and normal vectors for a vertex
  111101. */
  111102. export class PositionNormalVertex {
  111103. /** the position of the vertex (defaut: 0,0,0) */
  111104. position: Vector3;
  111105. /** the normal of the vertex (defaut: 0,1,0) */
  111106. normal: Vector3;
  111107. /**
  111108. * Creates a PositionNormalVertex
  111109. * @param position the position of the vertex (defaut: 0,0,0)
  111110. * @param normal the normal of the vertex (defaut: 0,1,0)
  111111. */
  111112. constructor(
  111113. /** the position of the vertex (defaut: 0,0,0) */
  111114. position?: Vector3,
  111115. /** the normal of the vertex (defaut: 0,1,0) */
  111116. normal?: Vector3);
  111117. /**
  111118. * Clones the PositionNormalVertex
  111119. * @returns the cloned PositionNormalVertex
  111120. */
  111121. clone(): PositionNormalVertex;
  111122. }
  111123. /**
  111124. * Contains position, normal and uv vectors for a vertex
  111125. */
  111126. export class PositionNormalTextureVertex {
  111127. /** the position of the vertex (defaut: 0,0,0) */
  111128. position: Vector3;
  111129. /** the normal of the vertex (defaut: 0,1,0) */
  111130. normal: Vector3;
  111131. /** the uv of the vertex (default: 0,0) */
  111132. uv: Vector2;
  111133. /**
  111134. * Creates a PositionNormalTextureVertex
  111135. * @param position the position of the vertex (defaut: 0,0,0)
  111136. * @param normal the normal of the vertex (defaut: 0,1,0)
  111137. * @param uv the uv of the vertex (default: 0,0)
  111138. */
  111139. constructor(
  111140. /** the position of the vertex (defaut: 0,0,0) */
  111141. position?: Vector3,
  111142. /** the normal of the vertex (defaut: 0,1,0) */
  111143. normal?: Vector3,
  111144. /** the uv of the vertex (default: 0,0) */
  111145. uv?: Vector2);
  111146. /**
  111147. * Clones the PositionNormalTextureVertex
  111148. * @returns the cloned PositionNormalTextureVertex
  111149. */
  111150. clone(): PositionNormalTextureVertex;
  111151. }
  111152. }
  111153. declare module BABYLON {
  111154. /** @hidden */
  111155. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111156. private _genericAttributeLocation;
  111157. private _varyingLocationCount;
  111158. private _varyingLocationMap;
  111159. private _replacements;
  111160. private _textureCount;
  111161. private _uniforms;
  111162. lineProcessor(line: string): string;
  111163. attributeProcessor(attribute: string): string;
  111164. varyingProcessor(varying: string, isFragment: boolean): string;
  111165. uniformProcessor(uniform: string): string;
  111166. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111167. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111168. }
  111169. }
  111170. declare module BABYLON {
  111171. /**
  111172. * Container for accessors for natively-stored mesh data buffers.
  111173. */
  111174. class NativeDataBuffer extends DataBuffer {
  111175. /**
  111176. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111177. */
  111178. nativeIndexBuffer?: any;
  111179. /**
  111180. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111181. */
  111182. nativeVertexBuffer?: any;
  111183. }
  111184. /** @hidden */
  111185. export class NativeEngine extends Engine {
  111186. private readonly _native;
  111187. getHardwareScalingLevel(): number;
  111188. constructor();
  111189. /**
  111190. * Can be used to override the current requestAnimationFrame requester.
  111191. * @hidden
  111192. */
  111193. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111194. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111195. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111196. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111197. recordVertexArrayObject(vertexBuffers: {
  111198. [key: string]: VertexBuffer;
  111199. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111200. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111201. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111202. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111203. /**
  111204. * Draw a list of indexed primitives
  111205. * @param fillMode defines the primitive to use
  111206. * @param indexStart defines the starting index
  111207. * @param indexCount defines the number of index to draw
  111208. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111209. */
  111210. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111211. /**
  111212. * Draw a list of unindexed primitives
  111213. * @param fillMode defines the primitive to use
  111214. * @param verticesStart defines the index of first vertex to draw
  111215. * @param verticesCount defines the count of vertices to draw
  111216. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111217. */
  111218. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111219. createPipelineContext(): IPipelineContext;
  111220. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111221. /** @hidden */
  111222. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111223. /** @hidden */
  111224. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111225. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111226. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111227. protected _setProgram(program: WebGLProgram): void;
  111228. _releaseEffect(effect: Effect): void;
  111229. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111230. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111231. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111232. bindSamplers(effect: Effect): void;
  111233. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111234. getRenderWidth(useScreen?: boolean): number;
  111235. getRenderHeight(useScreen?: boolean): number;
  111236. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111237. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111238. /**
  111239. * Set the z offset to apply to current rendering
  111240. * @param value defines the offset to apply
  111241. */
  111242. setZOffset(value: number): void;
  111243. /**
  111244. * Gets the current value of the zOffset
  111245. * @returns the current zOffset state
  111246. */
  111247. getZOffset(): number;
  111248. /**
  111249. * Enable or disable depth buffering
  111250. * @param enable defines the state to set
  111251. */
  111252. setDepthBuffer(enable: boolean): void;
  111253. /**
  111254. * Gets a boolean indicating if depth writing is enabled
  111255. * @returns the current depth writing state
  111256. */
  111257. getDepthWrite(): boolean;
  111258. /**
  111259. * Enable or disable depth writing
  111260. * @param enable defines the state to set
  111261. */
  111262. setDepthWrite(enable: boolean): void;
  111263. /**
  111264. * Enable or disable color writing
  111265. * @param enable defines the state to set
  111266. */
  111267. setColorWrite(enable: boolean): void;
  111268. /**
  111269. * Gets a boolean indicating if color writing is enabled
  111270. * @returns the current color writing state
  111271. */
  111272. getColorWrite(): boolean;
  111273. /**
  111274. * Sets alpha constants used by some alpha blending modes
  111275. * @param r defines the red component
  111276. * @param g defines the green component
  111277. * @param b defines the blue component
  111278. * @param a defines the alpha component
  111279. */
  111280. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111281. /**
  111282. * Sets the current alpha mode
  111283. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111284. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111285. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111286. */
  111287. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111288. /**
  111289. * Gets the current alpha mode
  111290. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111291. * @returns the current alpha mode
  111292. */
  111293. getAlphaMode(): number;
  111294. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111295. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111296. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111297. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111298. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111299. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111300. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111301. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111302. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111303. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111304. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111305. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111306. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111307. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111308. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111309. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111310. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111311. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111312. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111313. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111314. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111315. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111316. wipeCaches(bruteForce?: boolean): void;
  111317. _createTexture(): WebGLTexture;
  111318. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111319. /**
  111320. * Usually called from BABYLON.Texture.ts.
  111321. * Passed information to create a WebGLTexture
  111322. * @param urlArg defines a value which contains one of the following:
  111323. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111324. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111325. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111326. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111327. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111328. * @param scene needed for loading to the correct scene
  111329. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111330. * @param onLoad optional callback to be called upon successful completion
  111331. * @param onError optional callback to be called upon failure
  111332. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111333. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111334. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111335. * @param forcedExtension defines the extension to use to pick the right loader
  111336. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111337. */
  111338. 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;
  111339. /**
  111340. * Creates a cube texture
  111341. * @param rootUrl defines the url where the files to load is located
  111342. * @param scene defines the current scene
  111343. * @param files defines the list of files to load (1 per face)
  111344. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111345. * @param onLoad defines an optional callback raised when the texture is loaded
  111346. * @param onError defines an optional callback raised if there is an issue to load the texture
  111347. * @param format defines the format of the data
  111348. * @param forcedExtension defines the extension to use to pick the right loader
  111349. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111350. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111351. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111352. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111353. * @returns the cube texture as an InternalTexture
  111354. */
  111355. 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;
  111356. private _getSamplingFilter;
  111357. private static _GetNativeTextureFormat;
  111358. createRenderTargetTexture(size: number | {
  111359. width: number;
  111360. height: number;
  111361. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111362. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111363. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111364. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111365. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111366. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111367. /**
  111368. * Updates a dynamic vertex buffer.
  111369. * @param vertexBuffer the vertex buffer to update
  111370. * @param data the data used to update the vertex buffer
  111371. * @param byteOffset the byte offset of the data (optional)
  111372. * @param byteLength the byte length of the data (optional)
  111373. */
  111374. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111375. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111376. private _updateAnisotropicLevel;
  111377. private _getAddressMode;
  111378. /** @hidden */
  111379. _bindTexture(channel: number, texture: InternalTexture): void;
  111380. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111381. releaseEffects(): void;
  111382. /** @hidden */
  111383. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111384. /** @hidden */
  111385. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111386. /** @hidden */
  111387. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111388. /** @hidden */
  111389. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111390. }
  111391. }
  111392. declare module BABYLON {
  111393. /**
  111394. * Gather the list of clipboard event types as constants.
  111395. */
  111396. export class ClipboardEventTypes {
  111397. /**
  111398. * The clipboard event is fired when a copy command is active (pressed).
  111399. */
  111400. static readonly COPY: number;
  111401. /**
  111402. * The clipboard event is fired when a cut command is active (pressed).
  111403. */
  111404. static readonly CUT: number;
  111405. /**
  111406. * The clipboard event is fired when a paste command is active (pressed).
  111407. */
  111408. static readonly PASTE: number;
  111409. }
  111410. /**
  111411. * This class is used to store clipboard related info for the onClipboardObservable event.
  111412. */
  111413. export class ClipboardInfo {
  111414. /**
  111415. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111416. */
  111417. type: number;
  111418. /**
  111419. * Defines the related dom event
  111420. */
  111421. event: ClipboardEvent;
  111422. /**
  111423. *Creates an instance of ClipboardInfo.
  111424. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111425. * @param event Defines the related dom event
  111426. */
  111427. constructor(
  111428. /**
  111429. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111430. */
  111431. type: number,
  111432. /**
  111433. * Defines the related dom event
  111434. */
  111435. event: ClipboardEvent);
  111436. /**
  111437. * Get the clipboard event's type from the keycode.
  111438. * @param keyCode Defines the keyCode for the current keyboard event.
  111439. * @return {number}
  111440. */
  111441. static GetTypeFromCharacter(keyCode: number): number;
  111442. }
  111443. }
  111444. declare module BABYLON {
  111445. /**
  111446. * Google Daydream controller
  111447. */
  111448. export class DaydreamController extends WebVRController {
  111449. /**
  111450. * Base Url for the controller model.
  111451. */
  111452. static MODEL_BASE_URL: string;
  111453. /**
  111454. * File name for the controller model.
  111455. */
  111456. static MODEL_FILENAME: string;
  111457. /**
  111458. * Gamepad Id prefix used to identify Daydream Controller.
  111459. */
  111460. static readonly GAMEPAD_ID_PREFIX: string;
  111461. /**
  111462. * Creates a new DaydreamController from a gamepad
  111463. * @param vrGamepad the gamepad that the controller should be created from
  111464. */
  111465. constructor(vrGamepad: any);
  111466. /**
  111467. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111468. * @param scene scene in which to add meshes
  111469. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111470. */
  111471. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111472. /**
  111473. * Called once for each button that changed state since the last frame
  111474. * @param buttonIdx Which button index changed
  111475. * @param state New state of the button
  111476. * @param changes Which properties on the state changed since last frame
  111477. */
  111478. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111479. }
  111480. }
  111481. declare module BABYLON {
  111482. /**
  111483. * Gear VR Controller
  111484. */
  111485. export class GearVRController extends WebVRController {
  111486. /**
  111487. * Base Url for the controller model.
  111488. */
  111489. static MODEL_BASE_URL: string;
  111490. /**
  111491. * File name for the controller model.
  111492. */
  111493. static MODEL_FILENAME: string;
  111494. /**
  111495. * Gamepad Id prefix used to identify this controller.
  111496. */
  111497. static readonly GAMEPAD_ID_PREFIX: string;
  111498. private readonly _buttonIndexToObservableNameMap;
  111499. /**
  111500. * Creates a new GearVRController from a gamepad
  111501. * @param vrGamepad the gamepad that the controller should be created from
  111502. */
  111503. constructor(vrGamepad: any);
  111504. /**
  111505. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111506. * @param scene scene in which to add meshes
  111507. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111508. */
  111509. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111510. /**
  111511. * Called once for each button that changed state since the last frame
  111512. * @param buttonIdx Which button index changed
  111513. * @param state New state of the button
  111514. * @param changes Which properties on the state changed since last frame
  111515. */
  111516. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111517. }
  111518. }
  111519. declare module BABYLON {
  111520. /**
  111521. * Class containing static functions to help procedurally build meshes
  111522. */
  111523. export class PolyhedronBuilder {
  111524. /**
  111525. * Creates a polyhedron mesh
  111526. * * 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
  111527. * * The parameter `size` (positive float, default 1) sets the polygon size
  111528. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111529. * * 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`
  111530. * * 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
  111531. * * 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)`)
  111532. * * 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
  111533. * * 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
  111534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111537. * @param name defines the name of the mesh
  111538. * @param options defines the options used to create the mesh
  111539. * @param scene defines the hosting scene
  111540. * @returns the polyhedron mesh
  111541. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111542. */
  111543. static CreatePolyhedron(name: string, options: {
  111544. type?: number;
  111545. size?: number;
  111546. sizeX?: number;
  111547. sizeY?: number;
  111548. sizeZ?: number;
  111549. custom?: any;
  111550. faceUV?: Vector4[];
  111551. faceColors?: Color4[];
  111552. flat?: boolean;
  111553. updatable?: boolean;
  111554. sideOrientation?: number;
  111555. frontUVs?: Vector4;
  111556. backUVs?: Vector4;
  111557. }, scene?: Nullable<Scene>): Mesh;
  111558. }
  111559. }
  111560. declare module BABYLON {
  111561. /**
  111562. * Gizmo that enables scaling a mesh along 3 axis
  111563. */
  111564. export class ScaleGizmo extends Gizmo {
  111565. /**
  111566. * Internal gizmo used for interactions on the x axis
  111567. */
  111568. xGizmo: AxisScaleGizmo;
  111569. /**
  111570. * Internal gizmo used for interactions on the y axis
  111571. */
  111572. yGizmo: AxisScaleGizmo;
  111573. /**
  111574. * Internal gizmo used for interactions on the z axis
  111575. */
  111576. zGizmo: AxisScaleGizmo;
  111577. /**
  111578. * Internal gizmo used to scale all axis equally
  111579. */
  111580. uniformScaleGizmo: AxisScaleGizmo;
  111581. private _meshAttached;
  111582. private _updateGizmoRotationToMatchAttachedMesh;
  111583. private _snapDistance;
  111584. private _scaleRatio;
  111585. private _uniformScalingMesh;
  111586. private _octahedron;
  111587. /** Fires an event when any of it's sub gizmos are dragged */
  111588. onDragStartObservable: Observable<unknown>;
  111589. /** Fires an event when any of it's sub gizmos are released from dragging */
  111590. onDragEndObservable: Observable<unknown>;
  111591. attachedMesh: Nullable<AbstractMesh>;
  111592. /**
  111593. * Creates a ScaleGizmo
  111594. * @param gizmoLayer The utility layer the gizmo will be added to
  111595. */
  111596. constructor(gizmoLayer?: UtilityLayerRenderer);
  111597. updateGizmoRotationToMatchAttachedMesh: boolean;
  111598. /**
  111599. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111600. */
  111601. snapDistance: number;
  111602. /**
  111603. * Ratio for the scale of the gizmo (Default: 1)
  111604. */
  111605. scaleRatio: number;
  111606. /**
  111607. * Disposes of the gizmo
  111608. */
  111609. dispose(): void;
  111610. }
  111611. }
  111612. declare module BABYLON {
  111613. /**
  111614. * Single axis scale gizmo
  111615. */
  111616. export class AxisScaleGizmo extends Gizmo {
  111617. /**
  111618. * Drag behavior responsible for the gizmos dragging interactions
  111619. */
  111620. dragBehavior: PointerDragBehavior;
  111621. private _pointerObserver;
  111622. /**
  111623. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111624. */
  111625. snapDistance: number;
  111626. /**
  111627. * Event that fires each time the gizmo snaps to a new location.
  111628. * * snapDistance is the the change in distance
  111629. */
  111630. onSnapObservable: Observable<{
  111631. snapDistance: number;
  111632. }>;
  111633. /**
  111634. * If the scaling operation should be done on all axis (default: false)
  111635. */
  111636. uniformScaling: boolean;
  111637. private _isEnabled;
  111638. private _parent;
  111639. private _arrow;
  111640. private _coloredMaterial;
  111641. private _hoverMaterial;
  111642. /**
  111643. * Creates an AxisScaleGizmo
  111644. * @param gizmoLayer The utility layer the gizmo will be added to
  111645. * @param dragAxis The axis which the gizmo will be able to scale on
  111646. * @param color The color of the gizmo
  111647. */
  111648. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111649. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111650. /**
  111651. * If the gizmo is enabled
  111652. */
  111653. isEnabled: boolean;
  111654. /**
  111655. * Disposes of the gizmo
  111656. */
  111657. dispose(): void;
  111658. /**
  111659. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111660. * @param mesh The mesh to replace the default mesh of the gizmo
  111661. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111662. */
  111663. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111664. }
  111665. }
  111666. declare module BABYLON {
  111667. /**
  111668. * Bounding box gizmo
  111669. */
  111670. export class BoundingBoxGizmo extends Gizmo {
  111671. private _lineBoundingBox;
  111672. private _rotateSpheresParent;
  111673. private _scaleBoxesParent;
  111674. private _boundingDimensions;
  111675. private _renderObserver;
  111676. private _pointerObserver;
  111677. private _scaleDragSpeed;
  111678. private _tmpQuaternion;
  111679. private _tmpVector;
  111680. private _tmpRotationMatrix;
  111681. /**
  111682. * 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)
  111683. */
  111684. ignoreChildren: boolean;
  111685. /**
  111686. * 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)
  111687. */
  111688. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111689. /**
  111690. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111691. */
  111692. rotationSphereSize: number;
  111693. /**
  111694. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111695. */
  111696. scaleBoxSize: number;
  111697. /**
  111698. * 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)
  111699. */
  111700. fixedDragMeshScreenSize: boolean;
  111701. /**
  111702. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111703. */
  111704. fixedDragMeshScreenSizeDistanceFactor: number;
  111705. /**
  111706. * Fired when a rotation sphere or scale box is dragged
  111707. */
  111708. onDragStartObservable: Observable<{}>;
  111709. /**
  111710. * Fired when a scale box is dragged
  111711. */
  111712. onScaleBoxDragObservable: Observable<{}>;
  111713. /**
  111714. * Fired when a scale box drag is ended
  111715. */
  111716. onScaleBoxDragEndObservable: Observable<{}>;
  111717. /**
  111718. * Fired when a rotation sphere is dragged
  111719. */
  111720. onRotationSphereDragObservable: Observable<{}>;
  111721. /**
  111722. * Fired when a rotation sphere drag is ended
  111723. */
  111724. onRotationSphereDragEndObservable: Observable<{}>;
  111725. /**
  111726. * 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)
  111727. */
  111728. scalePivot: Nullable<Vector3>;
  111729. /**
  111730. * Mesh used as a pivot to rotate the attached mesh
  111731. */
  111732. private _anchorMesh;
  111733. private _existingMeshScale;
  111734. private _dragMesh;
  111735. private pointerDragBehavior;
  111736. private coloredMaterial;
  111737. private hoverColoredMaterial;
  111738. /**
  111739. * Sets the color of the bounding box gizmo
  111740. * @param color the color to set
  111741. */
  111742. setColor(color: Color3): void;
  111743. /**
  111744. * Creates an BoundingBoxGizmo
  111745. * @param gizmoLayer The utility layer the gizmo will be added to
  111746. * @param color The color of the gizmo
  111747. */
  111748. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111749. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111750. private _selectNode;
  111751. /**
  111752. * Updates the bounding box information for the Gizmo
  111753. */
  111754. updateBoundingBox(): void;
  111755. private _updateRotationSpheres;
  111756. private _updateScaleBoxes;
  111757. /**
  111758. * Enables rotation on the specified axis and disables rotation on the others
  111759. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111760. */
  111761. setEnabledRotationAxis(axis: string): void;
  111762. /**
  111763. * Enables/disables scaling
  111764. * @param enable if scaling should be enabled
  111765. */
  111766. setEnabledScaling(enable: boolean): void;
  111767. private _updateDummy;
  111768. /**
  111769. * Enables a pointer drag behavior on the bounding box of the gizmo
  111770. */
  111771. enableDragBehavior(): void;
  111772. /**
  111773. * Disposes of the gizmo
  111774. */
  111775. dispose(): void;
  111776. /**
  111777. * 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)
  111778. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  111779. * @returns the bounding box mesh with the passed in mesh as a child
  111780. */
  111781. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  111782. /**
  111783. * CustomMeshes are not supported by this gizmo
  111784. * @param mesh The mesh to replace the default mesh of the gizmo
  111785. */
  111786. setCustomMesh(mesh: Mesh): void;
  111787. }
  111788. }
  111789. declare module BABYLON {
  111790. /**
  111791. * Single plane rotation gizmo
  111792. */
  111793. export class PlaneRotationGizmo extends Gizmo {
  111794. /**
  111795. * Drag behavior responsible for the gizmos dragging interactions
  111796. */
  111797. dragBehavior: PointerDragBehavior;
  111798. private _pointerObserver;
  111799. /**
  111800. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  111801. */
  111802. snapDistance: number;
  111803. /**
  111804. * Event that fires each time the gizmo snaps to a new location.
  111805. * * snapDistance is the the change in distance
  111806. */
  111807. onSnapObservable: Observable<{
  111808. snapDistance: number;
  111809. }>;
  111810. private _isEnabled;
  111811. private _parent;
  111812. /**
  111813. * Creates a PlaneRotationGizmo
  111814. * @param gizmoLayer The utility layer the gizmo will be added to
  111815. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  111816. * @param color The color of the gizmo
  111817. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111818. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111819. */
  111820. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  111821. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111822. /**
  111823. * If the gizmo is enabled
  111824. */
  111825. isEnabled: boolean;
  111826. /**
  111827. * Disposes of the gizmo
  111828. */
  111829. dispose(): void;
  111830. }
  111831. }
  111832. declare module BABYLON {
  111833. /**
  111834. * Gizmo that enables rotating a mesh along 3 axis
  111835. */
  111836. export class RotationGizmo extends Gizmo {
  111837. /**
  111838. * Internal gizmo used for interactions on the x axis
  111839. */
  111840. xGizmo: PlaneRotationGizmo;
  111841. /**
  111842. * Internal gizmo used for interactions on the y axis
  111843. */
  111844. yGizmo: PlaneRotationGizmo;
  111845. /**
  111846. * Internal gizmo used for interactions on the z axis
  111847. */
  111848. zGizmo: PlaneRotationGizmo;
  111849. /** Fires an event when any of it's sub gizmos are dragged */
  111850. onDragStartObservable: Observable<unknown>;
  111851. /** Fires an event when any of it's sub gizmos are released from dragging */
  111852. onDragEndObservable: Observable<unknown>;
  111853. private _meshAttached;
  111854. attachedMesh: Nullable<AbstractMesh>;
  111855. /**
  111856. * Creates a RotationGizmo
  111857. * @param gizmoLayer The utility layer the gizmo will be added to
  111858. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111859. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111860. */
  111861. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  111862. updateGizmoRotationToMatchAttachedMesh: boolean;
  111863. /**
  111864. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111865. */
  111866. snapDistance: number;
  111867. /**
  111868. * Ratio for the scale of the gizmo (Default: 1)
  111869. */
  111870. scaleRatio: number;
  111871. /**
  111872. * Disposes of the gizmo
  111873. */
  111874. dispose(): void;
  111875. /**
  111876. * CustomMeshes are not supported by this gizmo
  111877. * @param mesh The mesh to replace the default mesh of the gizmo
  111878. */
  111879. setCustomMesh(mesh: Mesh): void;
  111880. }
  111881. }
  111882. declare module BABYLON {
  111883. /**
  111884. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  111885. */
  111886. export class GizmoManager implements IDisposable {
  111887. private scene;
  111888. /**
  111889. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  111890. */
  111891. gizmos: {
  111892. positionGizmo: Nullable<PositionGizmo>;
  111893. rotationGizmo: Nullable<RotationGizmo>;
  111894. scaleGizmo: Nullable<ScaleGizmo>;
  111895. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  111896. };
  111897. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  111898. clearGizmoOnEmptyPointerEvent: boolean;
  111899. /** Fires an event when the manager is attached to a mesh */
  111900. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  111901. private _gizmosEnabled;
  111902. private _pointerObserver;
  111903. private _attachedMesh;
  111904. private _boundingBoxColor;
  111905. private _defaultUtilityLayer;
  111906. private _defaultKeepDepthUtilityLayer;
  111907. /**
  111908. * When bounding box gizmo is enabled, this can be used to track drag/end events
  111909. */
  111910. boundingBoxDragBehavior: SixDofDragBehavior;
  111911. /**
  111912. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  111913. */
  111914. attachableMeshes: Nullable<Array<AbstractMesh>>;
  111915. /**
  111916. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  111917. */
  111918. usePointerToAttachGizmos: boolean;
  111919. /**
  111920. * Utility layer that the bounding box gizmo belongs to
  111921. */
  111922. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  111923. /**
  111924. * Utility layer that all gizmos besides bounding box belong to
  111925. */
  111926. readonly utilityLayer: UtilityLayerRenderer;
  111927. /**
  111928. * Instatiates a gizmo manager
  111929. * @param scene the scene to overlay the gizmos on top of
  111930. */
  111931. constructor(scene: Scene);
  111932. /**
  111933. * Attaches a set of gizmos to the specified mesh
  111934. * @param mesh The mesh the gizmo's should be attached to
  111935. */
  111936. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111937. /**
  111938. * If the position gizmo is enabled
  111939. */
  111940. positionGizmoEnabled: boolean;
  111941. /**
  111942. * If the rotation gizmo is enabled
  111943. */
  111944. rotationGizmoEnabled: boolean;
  111945. /**
  111946. * If the scale gizmo is enabled
  111947. */
  111948. scaleGizmoEnabled: boolean;
  111949. /**
  111950. * If the boundingBox gizmo is enabled
  111951. */
  111952. boundingBoxGizmoEnabled: boolean;
  111953. /**
  111954. * Disposes of the gizmo manager
  111955. */
  111956. dispose(): void;
  111957. }
  111958. }
  111959. declare module BABYLON {
  111960. /**
  111961. * A directional light is defined by a direction (what a surprise!).
  111962. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  111963. * 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.
  111964. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111965. */
  111966. export class DirectionalLight extends ShadowLight {
  111967. private _shadowFrustumSize;
  111968. /**
  111969. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  111970. */
  111971. /**
  111972. * Specifies a fix frustum size for the shadow generation.
  111973. */
  111974. shadowFrustumSize: number;
  111975. private _shadowOrthoScale;
  111976. /**
  111977. * Gets the shadow projection scale against the optimal computed one.
  111978. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111979. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111980. */
  111981. /**
  111982. * Sets the shadow projection scale against the optimal computed one.
  111983. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111984. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111985. */
  111986. shadowOrthoScale: number;
  111987. /**
  111988. * Automatically compute the projection matrix to best fit (including all the casters)
  111989. * on each frame.
  111990. */
  111991. autoUpdateExtends: boolean;
  111992. private _orthoLeft;
  111993. private _orthoRight;
  111994. private _orthoTop;
  111995. private _orthoBottom;
  111996. /**
  111997. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  111998. * The directional light is emitted from everywhere in the given direction.
  111999. * It can cast shadows.
  112000. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112001. * @param name The friendly name of the light
  112002. * @param direction The direction of the light
  112003. * @param scene The scene the light belongs to
  112004. */
  112005. constructor(name: string, direction: Vector3, scene: Scene);
  112006. /**
  112007. * Returns the string "DirectionalLight".
  112008. * @return The class name
  112009. */
  112010. getClassName(): string;
  112011. /**
  112012. * Returns the integer 1.
  112013. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112014. */
  112015. getTypeID(): number;
  112016. /**
  112017. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112018. * Returns the DirectionalLight Shadow projection matrix.
  112019. */
  112020. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112021. /**
  112022. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112023. * Returns the DirectionalLight Shadow projection matrix.
  112024. */
  112025. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112026. /**
  112027. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112028. * Returns the DirectionalLight Shadow projection matrix.
  112029. */
  112030. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112031. protected _buildUniformLayout(): void;
  112032. /**
  112033. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112034. * @param effect The effect to update
  112035. * @param lightIndex The index of the light in the effect to update
  112036. * @returns The directional light
  112037. */
  112038. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112039. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112040. /**
  112041. * Gets the minZ used for shadow according to both the scene and the light.
  112042. *
  112043. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112044. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112045. * @param activeCamera The camera we are returning the min for
  112046. * @returns the depth min z
  112047. */
  112048. getDepthMinZ(activeCamera: Camera): number;
  112049. /**
  112050. * Gets the maxZ used for shadow according to both the scene and the light.
  112051. *
  112052. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112053. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112054. * @param activeCamera The camera we are returning the max for
  112055. * @returns the depth max z
  112056. */
  112057. getDepthMaxZ(activeCamera: Camera): number;
  112058. /**
  112059. * Prepares the list of defines specific to the light type.
  112060. * @param defines the list of defines
  112061. * @param lightIndex defines the index of the light for the effect
  112062. */
  112063. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112064. }
  112065. }
  112066. declare module BABYLON {
  112067. /**
  112068. * Class containing static functions to help procedurally build meshes
  112069. */
  112070. export class HemisphereBuilder {
  112071. /**
  112072. * Creates a hemisphere mesh
  112073. * @param name defines the name of the mesh
  112074. * @param options defines the options used to create the mesh
  112075. * @param scene defines the hosting scene
  112076. * @returns the hemisphere mesh
  112077. */
  112078. static CreateHemisphere(name: string, options: {
  112079. segments?: number;
  112080. diameter?: number;
  112081. sideOrientation?: number;
  112082. }, scene: any): Mesh;
  112083. }
  112084. }
  112085. declare module BABYLON {
  112086. /**
  112087. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112088. * These values define a cone of light starting from the position, emitting toward the direction.
  112089. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112090. * and the exponent defines the speed of the decay of the light with distance (reach).
  112091. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112092. */
  112093. export class SpotLight extends ShadowLight {
  112094. private _angle;
  112095. private _innerAngle;
  112096. private _cosHalfAngle;
  112097. private _lightAngleScale;
  112098. private _lightAngleOffset;
  112099. /**
  112100. * Gets the cone angle of the spot light in Radians.
  112101. */
  112102. /**
  112103. * Sets the cone angle of the spot light in Radians.
  112104. */
  112105. angle: number;
  112106. /**
  112107. * Only used in gltf falloff mode, this defines the angle where
  112108. * the directional falloff will start before cutting at angle which could be seen
  112109. * as outer angle.
  112110. */
  112111. /**
  112112. * Only used in gltf falloff mode, this defines the angle where
  112113. * the directional falloff will start before cutting at angle which could be seen
  112114. * as outer angle.
  112115. */
  112116. innerAngle: number;
  112117. private _shadowAngleScale;
  112118. /**
  112119. * Allows scaling the angle of the light for shadow generation only.
  112120. */
  112121. /**
  112122. * Allows scaling the angle of the light for shadow generation only.
  112123. */
  112124. shadowAngleScale: number;
  112125. /**
  112126. * The light decay speed with the distance from the emission spot.
  112127. */
  112128. exponent: number;
  112129. private _projectionTextureMatrix;
  112130. /**
  112131. * Allows reading the projecton texture
  112132. */
  112133. readonly projectionTextureMatrix: Matrix;
  112134. protected _projectionTextureLightNear: number;
  112135. /**
  112136. * Gets the near clip of the Spotlight for texture projection.
  112137. */
  112138. /**
  112139. * Sets the near clip of the Spotlight for texture projection.
  112140. */
  112141. projectionTextureLightNear: number;
  112142. protected _projectionTextureLightFar: number;
  112143. /**
  112144. * Gets the far clip of the Spotlight for texture projection.
  112145. */
  112146. /**
  112147. * Sets the far clip of the Spotlight for texture projection.
  112148. */
  112149. projectionTextureLightFar: number;
  112150. protected _projectionTextureUpDirection: Vector3;
  112151. /**
  112152. * Gets the Up vector of the Spotlight for texture projection.
  112153. */
  112154. /**
  112155. * Sets the Up vector of the Spotlight for texture projection.
  112156. */
  112157. projectionTextureUpDirection: Vector3;
  112158. private _projectionTexture;
  112159. /**
  112160. * Gets the projection texture of the light.
  112161. */
  112162. /**
  112163. * Sets the projection texture of the light.
  112164. */
  112165. projectionTexture: Nullable<BaseTexture>;
  112166. private _projectionTextureViewLightDirty;
  112167. private _projectionTextureProjectionLightDirty;
  112168. private _projectionTextureDirty;
  112169. private _projectionTextureViewTargetVector;
  112170. private _projectionTextureViewLightMatrix;
  112171. private _projectionTextureProjectionLightMatrix;
  112172. private _projectionTextureScalingMatrix;
  112173. /**
  112174. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112175. * It can cast shadows.
  112176. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112177. * @param name The light friendly name
  112178. * @param position The position of the spot light in the scene
  112179. * @param direction The direction of the light in the scene
  112180. * @param angle The cone angle of the light in Radians
  112181. * @param exponent The light decay speed with the distance from the emission spot
  112182. * @param scene The scene the lights belongs to
  112183. */
  112184. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112185. /**
  112186. * Returns the string "SpotLight".
  112187. * @returns the class name
  112188. */
  112189. getClassName(): string;
  112190. /**
  112191. * Returns the integer 2.
  112192. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112193. */
  112194. getTypeID(): number;
  112195. /**
  112196. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112197. */
  112198. protected _setDirection(value: Vector3): void;
  112199. /**
  112200. * Overrides the position setter to recompute the projection texture view light Matrix.
  112201. */
  112202. protected _setPosition(value: Vector3): void;
  112203. /**
  112204. * 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.
  112205. * Returns the SpotLight.
  112206. */
  112207. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112208. protected _computeProjectionTextureViewLightMatrix(): void;
  112209. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112210. /**
  112211. * Main function for light texture projection matrix computing.
  112212. */
  112213. protected _computeProjectionTextureMatrix(): void;
  112214. protected _buildUniformLayout(): void;
  112215. private _computeAngleValues;
  112216. /**
  112217. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112218. * @param effect The effect to update
  112219. * @param lightIndex The index of the light in the effect to update
  112220. * @returns The spot light
  112221. */
  112222. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112223. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112224. /**
  112225. * Disposes the light and the associated resources.
  112226. */
  112227. dispose(): void;
  112228. /**
  112229. * Prepares the list of defines specific to the light type.
  112230. * @param defines the list of defines
  112231. * @param lightIndex defines the index of the light for the effect
  112232. */
  112233. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112234. }
  112235. }
  112236. declare module BABYLON {
  112237. /**
  112238. * Gizmo that enables viewing a light
  112239. */
  112240. export class LightGizmo extends Gizmo {
  112241. private _lightMesh;
  112242. private _material;
  112243. private cachedPosition;
  112244. private cachedForward;
  112245. /**
  112246. * Creates a LightGizmo
  112247. * @param gizmoLayer The utility layer the gizmo will be added to
  112248. */
  112249. constructor(gizmoLayer?: UtilityLayerRenderer);
  112250. private _light;
  112251. /**
  112252. * The light that the gizmo is attached to
  112253. */
  112254. light: Nullable<Light>;
  112255. /**
  112256. * Gets the material used to render the light gizmo
  112257. */
  112258. readonly material: StandardMaterial;
  112259. /**
  112260. * @hidden
  112261. * Updates the gizmo to match the attached mesh's position/rotation
  112262. */
  112263. protected _update(): void;
  112264. private static _Scale;
  112265. /**
  112266. * Creates the lines for a light mesh
  112267. */
  112268. private static _createLightLines;
  112269. /**
  112270. * Disposes of the light gizmo
  112271. */
  112272. dispose(): void;
  112273. private static _CreateHemisphericLightMesh;
  112274. private static _CreatePointLightMesh;
  112275. private static _CreateSpotLightMesh;
  112276. private static _CreateDirectionalLightMesh;
  112277. }
  112278. }
  112279. declare module BABYLON {
  112280. /** @hidden */
  112281. export var backgroundFragmentDeclaration: {
  112282. name: string;
  112283. shader: string;
  112284. };
  112285. }
  112286. declare module BABYLON {
  112287. /** @hidden */
  112288. export var backgroundUboDeclaration: {
  112289. name: string;
  112290. shader: string;
  112291. };
  112292. }
  112293. declare module BABYLON {
  112294. /** @hidden */
  112295. export var backgroundPixelShader: {
  112296. name: string;
  112297. shader: string;
  112298. };
  112299. }
  112300. declare module BABYLON {
  112301. /** @hidden */
  112302. export var backgroundVertexDeclaration: {
  112303. name: string;
  112304. shader: string;
  112305. };
  112306. }
  112307. declare module BABYLON {
  112308. /** @hidden */
  112309. export var backgroundVertexShader: {
  112310. name: string;
  112311. shader: string;
  112312. };
  112313. }
  112314. declare module BABYLON {
  112315. /**
  112316. * Background material used to create an efficient environement around your scene.
  112317. */
  112318. export class BackgroundMaterial extends PushMaterial {
  112319. /**
  112320. * Standard reflectance value at parallel view angle.
  112321. */
  112322. static StandardReflectance0: number;
  112323. /**
  112324. * Standard reflectance value at grazing angle.
  112325. */
  112326. static StandardReflectance90: number;
  112327. protected _primaryColor: Color3;
  112328. /**
  112329. * Key light Color (multiply against the environement texture)
  112330. */
  112331. primaryColor: Color3;
  112332. protected __perceptualColor: Nullable<Color3>;
  112333. /**
  112334. * Experimental Internal Use Only.
  112335. *
  112336. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112337. * This acts as a helper to set the primary color to a more "human friendly" value.
  112338. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112339. * output color as close as possible from the chosen value.
  112340. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112341. * part of lighting setup.)
  112342. */
  112343. _perceptualColor: Nullable<Color3>;
  112344. protected _primaryColorShadowLevel: float;
  112345. /**
  112346. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112347. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112348. */
  112349. primaryColorShadowLevel: float;
  112350. protected _primaryColorHighlightLevel: float;
  112351. /**
  112352. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112353. * The primary color is used at the level chosen to define what the white area would look.
  112354. */
  112355. primaryColorHighlightLevel: float;
  112356. protected _reflectionTexture: Nullable<BaseTexture>;
  112357. /**
  112358. * Reflection Texture used in the material.
  112359. * Should be author in a specific way for the best result (refer to the documentation).
  112360. */
  112361. reflectionTexture: Nullable<BaseTexture>;
  112362. protected _reflectionBlur: float;
  112363. /**
  112364. * Reflection Texture level of blur.
  112365. *
  112366. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112367. * texture twice.
  112368. */
  112369. reflectionBlur: float;
  112370. protected _diffuseTexture: Nullable<BaseTexture>;
  112371. /**
  112372. * Diffuse Texture used in the material.
  112373. * Should be author in a specific way for the best result (refer to the documentation).
  112374. */
  112375. diffuseTexture: Nullable<BaseTexture>;
  112376. protected _shadowLights: Nullable<IShadowLight[]>;
  112377. /**
  112378. * Specify the list of lights casting shadow on the material.
  112379. * All scene shadow lights will be included if null.
  112380. */
  112381. shadowLights: Nullable<IShadowLight[]>;
  112382. protected _shadowLevel: float;
  112383. /**
  112384. * Helps adjusting the shadow to a softer level if required.
  112385. * 0 means black shadows and 1 means no shadows.
  112386. */
  112387. shadowLevel: float;
  112388. protected _sceneCenter: Vector3;
  112389. /**
  112390. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112391. * It is usually zero but might be interesting to modify according to your setup.
  112392. */
  112393. sceneCenter: Vector3;
  112394. protected _opacityFresnel: boolean;
  112395. /**
  112396. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112397. * This helps ensuring a nice transition when the camera goes under the ground.
  112398. */
  112399. opacityFresnel: boolean;
  112400. protected _reflectionFresnel: boolean;
  112401. /**
  112402. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112403. * This helps adding a mirror texture on the ground.
  112404. */
  112405. reflectionFresnel: boolean;
  112406. protected _reflectionFalloffDistance: number;
  112407. /**
  112408. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112409. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112410. */
  112411. reflectionFalloffDistance: number;
  112412. protected _reflectionAmount: number;
  112413. /**
  112414. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112415. */
  112416. reflectionAmount: number;
  112417. protected _reflectionReflectance0: number;
  112418. /**
  112419. * This specifies the weight of the reflection at grazing angle.
  112420. */
  112421. reflectionReflectance0: number;
  112422. protected _reflectionReflectance90: number;
  112423. /**
  112424. * This specifies the weight of the reflection at a perpendicular point of view.
  112425. */
  112426. reflectionReflectance90: number;
  112427. /**
  112428. * Sets the reflection reflectance fresnel values according to the default standard
  112429. * empirically know to work well :-)
  112430. */
  112431. reflectionStandardFresnelWeight: number;
  112432. protected _useRGBColor: boolean;
  112433. /**
  112434. * Helps to directly use the maps channels instead of their level.
  112435. */
  112436. useRGBColor: boolean;
  112437. protected _enableNoise: boolean;
  112438. /**
  112439. * This helps reducing the banding effect that could occur on the background.
  112440. */
  112441. enableNoise: boolean;
  112442. /**
  112443. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112444. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112445. * Recommended to be keep at 1.0 except for special cases.
  112446. */
  112447. fovMultiplier: number;
  112448. private _fovMultiplier;
  112449. /**
  112450. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112451. */
  112452. useEquirectangularFOV: boolean;
  112453. private _maxSimultaneousLights;
  112454. /**
  112455. * Number of Simultaneous lights allowed on the material.
  112456. */
  112457. maxSimultaneousLights: int;
  112458. /**
  112459. * Default configuration related to image processing available in the Background Material.
  112460. */
  112461. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112462. /**
  112463. * Keep track of the image processing observer to allow dispose and replace.
  112464. */
  112465. private _imageProcessingObserver;
  112466. /**
  112467. * Attaches a new image processing configuration to the PBR Material.
  112468. * @param configuration (if null the scene configuration will be use)
  112469. */
  112470. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112471. /**
  112472. * Gets the image processing configuration used either in this material.
  112473. */
  112474. /**
  112475. * Sets the Default image processing configuration used either in the this material.
  112476. *
  112477. * If sets to null, the scene one is in use.
  112478. */
  112479. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112480. /**
  112481. * Gets wether the color curves effect is enabled.
  112482. */
  112483. /**
  112484. * Sets wether the color curves effect is enabled.
  112485. */
  112486. cameraColorCurvesEnabled: boolean;
  112487. /**
  112488. * Gets wether the color grading effect is enabled.
  112489. */
  112490. /**
  112491. * Gets wether the color grading effect is enabled.
  112492. */
  112493. cameraColorGradingEnabled: boolean;
  112494. /**
  112495. * Gets wether tonemapping is enabled or not.
  112496. */
  112497. /**
  112498. * Sets wether tonemapping is enabled or not
  112499. */
  112500. cameraToneMappingEnabled: boolean;
  112501. /**
  112502. * The camera exposure used on this material.
  112503. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112504. * This corresponds to a photographic exposure.
  112505. */
  112506. /**
  112507. * The camera exposure used on this material.
  112508. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112509. * This corresponds to a photographic exposure.
  112510. */
  112511. cameraExposure: float;
  112512. /**
  112513. * Gets The camera contrast used on this material.
  112514. */
  112515. /**
  112516. * Sets The camera contrast used on this material.
  112517. */
  112518. cameraContrast: float;
  112519. /**
  112520. * Gets the Color Grading 2D Lookup Texture.
  112521. */
  112522. /**
  112523. * Sets the Color Grading 2D Lookup Texture.
  112524. */
  112525. cameraColorGradingTexture: Nullable<BaseTexture>;
  112526. /**
  112527. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112528. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112529. * 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;
  112530. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112531. */
  112532. /**
  112533. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112534. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112535. * 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;
  112536. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112537. */
  112538. cameraColorCurves: Nullable<ColorCurves>;
  112539. /**
  112540. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112541. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112542. */
  112543. switchToBGR: boolean;
  112544. private _renderTargets;
  112545. private _reflectionControls;
  112546. private _white;
  112547. private _primaryShadowColor;
  112548. private _primaryHighlightColor;
  112549. /**
  112550. * Instantiates a Background Material in the given scene
  112551. * @param name The friendly name of the material
  112552. * @param scene The scene to add the material to
  112553. */
  112554. constructor(name: string, scene: Scene);
  112555. /**
  112556. * Gets a boolean indicating that current material needs to register RTT
  112557. */
  112558. readonly hasRenderTargetTextures: boolean;
  112559. /**
  112560. * The entire material has been created in order to prevent overdraw.
  112561. * @returns false
  112562. */
  112563. needAlphaTesting(): boolean;
  112564. /**
  112565. * The entire material has been created in order to prevent overdraw.
  112566. * @returns true if blending is enable
  112567. */
  112568. needAlphaBlending(): boolean;
  112569. /**
  112570. * Checks wether the material is ready to be rendered for a given mesh.
  112571. * @param mesh The mesh to render
  112572. * @param subMesh The submesh to check against
  112573. * @param useInstances Specify wether or not the material is used with instances
  112574. * @returns true if all the dependencies are ready (Textures, Effects...)
  112575. */
  112576. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112577. /**
  112578. * Compute the primary color according to the chosen perceptual color.
  112579. */
  112580. private _computePrimaryColorFromPerceptualColor;
  112581. /**
  112582. * Compute the highlights and shadow colors according to their chosen levels.
  112583. */
  112584. private _computePrimaryColors;
  112585. /**
  112586. * Build the uniform buffer used in the material.
  112587. */
  112588. buildUniformLayout(): void;
  112589. /**
  112590. * Unbind the material.
  112591. */
  112592. unbind(): void;
  112593. /**
  112594. * Bind only the world matrix to the material.
  112595. * @param world The world matrix to bind.
  112596. */
  112597. bindOnlyWorldMatrix(world: Matrix): void;
  112598. /**
  112599. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112600. * @param world The world matrix to bind.
  112601. * @param subMesh The submesh to bind for.
  112602. */
  112603. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112604. /**
  112605. * Checks to see if a texture is used in the material.
  112606. * @param texture - Base texture to use.
  112607. * @returns - Boolean specifying if a texture is used in the material.
  112608. */
  112609. hasTexture(texture: BaseTexture): boolean;
  112610. /**
  112611. * Dispose the material.
  112612. * @param forceDisposeEffect Force disposal of the associated effect.
  112613. * @param forceDisposeTextures Force disposal of the associated textures.
  112614. */
  112615. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112616. /**
  112617. * Clones the material.
  112618. * @param name The cloned name.
  112619. * @returns The cloned material.
  112620. */
  112621. clone(name: string): BackgroundMaterial;
  112622. /**
  112623. * Serializes the current material to its JSON representation.
  112624. * @returns The JSON representation.
  112625. */
  112626. serialize(): any;
  112627. /**
  112628. * Gets the class name of the material
  112629. * @returns "BackgroundMaterial"
  112630. */
  112631. getClassName(): string;
  112632. /**
  112633. * Parse a JSON input to create back a background material.
  112634. * @param source The JSON data to parse
  112635. * @param scene The scene to create the parsed material in
  112636. * @param rootUrl The root url of the assets the material depends upon
  112637. * @returns the instantiated BackgroundMaterial.
  112638. */
  112639. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112640. }
  112641. }
  112642. declare module BABYLON {
  112643. /**
  112644. * Represents the different options available during the creation of
  112645. * a Environment helper.
  112646. *
  112647. * This can control the default ground, skybox and image processing setup of your scene.
  112648. */
  112649. export interface IEnvironmentHelperOptions {
  112650. /**
  112651. * Specifies wether or not to create a ground.
  112652. * True by default.
  112653. */
  112654. createGround: boolean;
  112655. /**
  112656. * Specifies the ground size.
  112657. * 15 by default.
  112658. */
  112659. groundSize: number;
  112660. /**
  112661. * The texture used on the ground for the main color.
  112662. * Comes from the BabylonJS CDN by default.
  112663. *
  112664. * Remarks: Can be either a texture or a url.
  112665. */
  112666. groundTexture: string | BaseTexture;
  112667. /**
  112668. * The color mixed in the ground texture by default.
  112669. * BabylonJS clearColor by default.
  112670. */
  112671. groundColor: Color3;
  112672. /**
  112673. * Specifies the ground opacity.
  112674. * 1 by default.
  112675. */
  112676. groundOpacity: number;
  112677. /**
  112678. * Enables the ground to receive shadows.
  112679. * True by default.
  112680. */
  112681. enableGroundShadow: boolean;
  112682. /**
  112683. * Helps preventing the shadow to be fully black on the ground.
  112684. * 0.5 by default.
  112685. */
  112686. groundShadowLevel: number;
  112687. /**
  112688. * Creates a mirror texture attach to the ground.
  112689. * false by default.
  112690. */
  112691. enableGroundMirror: boolean;
  112692. /**
  112693. * Specifies the ground mirror size ratio.
  112694. * 0.3 by default as the default kernel is 64.
  112695. */
  112696. groundMirrorSizeRatio: number;
  112697. /**
  112698. * Specifies the ground mirror blur kernel size.
  112699. * 64 by default.
  112700. */
  112701. groundMirrorBlurKernel: number;
  112702. /**
  112703. * Specifies the ground mirror visibility amount.
  112704. * 1 by default
  112705. */
  112706. groundMirrorAmount: number;
  112707. /**
  112708. * Specifies the ground mirror reflectance weight.
  112709. * This uses the standard weight of the background material to setup the fresnel effect
  112710. * of the mirror.
  112711. * 1 by default.
  112712. */
  112713. groundMirrorFresnelWeight: number;
  112714. /**
  112715. * Specifies the ground mirror Falloff distance.
  112716. * This can helps reducing the size of the reflection.
  112717. * 0 by Default.
  112718. */
  112719. groundMirrorFallOffDistance: number;
  112720. /**
  112721. * Specifies the ground mirror texture type.
  112722. * Unsigned Int by Default.
  112723. */
  112724. groundMirrorTextureType: number;
  112725. /**
  112726. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112727. * the shown objects.
  112728. */
  112729. groundYBias: number;
  112730. /**
  112731. * Specifies wether or not to create a skybox.
  112732. * True by default.
  112733. */
  112734. createSkybox: boolean;
  112735. /**
  112736. * Specifies the skybox size.
  112737. * 20 by default.
  112738. */
  112739. skyboxSize: number;
  112740. /**
  112741. * The texture used on the skybox for the main color.
  112742. * Comes from the BabylonJS CDN by default.
  112743. *
  112744. * Remarks: Can be either a texture or a url.
  112745. */
  112746. skyboxTexture: string | BaseTexture;
  112747. /**
  112748. * The color mixed in the skybox texture by default.
  112749. * BabylonJS clearColor by default.
  112750. */
  112751. skyboxColor: Color3;
  112752. /**
  112753. * The background rotation around the Y axis of the scene.
  112754. * This helps aligning the key lights of your scene with the background.
  112755. * 0 by default.
  112756. */
  112757. backgroundYRotation: number;
  112758. /**
  112759. * Compute automatically the size of the elements to best fit with the scene.
  112760. */
  112761. sizeAuto: boolean;
  112762. /**
  112763. * Default position of the rootMesh if autoSize is not true.
  112764. */
  112765. rootPosition: Vector3;
  112766. /**
  112767. * Sets up the image processing in the scene.
  112768. * true by default.
  112769. */
  112770. setupImageProcessing: boolean;
  112771. /**
  112772. * The texture used as your environment texture in the scene.
  112773. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  112774. *
  112775. * Remarks: Can be either a texture or a url.
  112776. */
  112777. environmentTexture: string | BaseTexture;
  112778. /**
  112779. * The value of the exposure to apply to the scene.
  112780. * 0.6 by default if setupImageProcessing is true.
  112781. */
  112782. cameraExposure: number;
  112783. /**
  112784. * The value of the contrast to apply to the scene.
  112785. * 1.6 by default if setupImageProcessing is true.
  112786. */
  112787. cameraContrast: number;
  112788. /**
  112789. * Specifies wether or not tonemapping should be enabled in the scene.
  112790. * true by default if setupImageProcessing is true.
  112791. */
  112792. toneMappingEnabled: boolean;
  112793. }
  112794. /**
  112795. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  112796. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  112797. * It also helps with the default setup of your imageProcessing configuration.
  112798. */
  112799. export class EnvironmentHelper {
  112800. /**
  112801. * Default ground texture URL.
  112802. */
  112803. private static _groundTextureCDNUrl;
  112804. /**
  112805. * Default skybox texture URL.
  112806. */
  112807. private static _skyboxTextureCDNUrl;
  112808. /**
  112809. * Default environment texture URL.
  112810. */
  112811. private static _environmentTextureCDNUrl;
  112812. /**
  112813. * Creates the default options for the helper.
  112814. */
  112815. private static _getDefaultOptions;
  112816. private _rootMesh;
  112817. /**
  112818. * Gets the root mesh created by the helper.
  112819. */
  112820. readonly rootMesh: Mesh;
  112821. private _skybox;
  112822. /**
  112823. * Gets the skybox created by the helper.
  112824. */
  112825. readonly skybox: Nullable<Mesh>;
  112826. private _skyboxTexture;
  112827. /**
  112828. * Gets the skybox texture created by the helper.
  112829. */
  112830. readonly skyboxTexture: Nullable<BaseTexture>;
  112831. private _skyboxMaterial;
  112832. /**
  112833. * Gets the skybox material created by the helper.
  112834. */
  112835. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  112836. private _ground;
  112837. /**
  112838. * Gets the ground mesh created by the helper.
  112839. */
  112840. readonly ground: Nullable<Mesh>;
  112841. private _groundTexture;
  112842. /**
  112843. * Gets the ground texture created by the helper.
  112844. */
  112845. readonly groundTexture: Nullable<BaseTexture>;
  112846. private _groundMirror;
  112847. /**
  112848. * Gets the ground mirror created by the helper.
  112849. */
  112850. readonly groundMirror: Nullable<MirrorTexture>;
  112851. /**
  112852. * Gets the ground mirror render list to helps pushing the meshes
  112853. * you wish in the ground reflection.
  112854. */
  112855. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  112856. private _groundMaterial;
  112857. /**
  112858. * Gets the ground material created by the helper.
  112859. */
  112860. readonly groundMaterial: Nullable<BackgroundMaterial>;
  112861. /**
  112862. * Stores the creation options.
  112863. */
  112864. private readonly _scene;
  112865. private _options;
  112866. /**
  112867. * This observable will be notified with any error during the creation of the environment,
  112868. * mainly texture creation errors.
  112869. */
  112870. onErrorObservable: Observable<{
  112871. message?: string;
  112872. exception?: any;
  112873. }>;
  112874. /**
  112875. * constructor
  112876. * @param options Defines the options we want to customize the helper
  112877. * @param scene The scene to add the material to
  112878. */
  112879. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  112880. /**
  112881. * Updates the background according to the new options
  112882. * @param options
  112883. */
  112884. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  112885. /**
  112886. * Sets the primary color of all the available elements.
  112887. * @param color the main color to affect to the ground and the background
  112888. */
  112889. setMainColor(color: Color3): void;
  112890. /**
  112891. * Setup the image processing according to the specified options.
  112892. */
  112893. private _setupImageProcessing;
  112894. /**
  112895. * Setup the environment texture according to the specified options.
  112896. */
  112897. private _setupEnvironmentTexture;
  112898. /**
  112899. * Setup the background according to the specified options.
  112900. */
  112901. private _setupBackground;
  112902. /**
  112903. * Get the scene sizes according to the setup.
  112904. */
  112905. private _getSceneSize;
  112906. /**
  112907. * Setup the ground according to the specified options.
  112908. */
  112909. private _setupGround;
  112910. /**
  112911. * Setup the ground material according to the specified options.
  112912. */
  112913. private _setupGroundMaterial;
  112914. /**
  112915. * Setup the ground diffuse texture according to the specified options.
  112916. */
  112917. private _setupGroundDiffuseTexture;
  112918. /**
  112919. * Setup the ground mirror texture according to the specified options.
  112920. */
  112921. private _setupGroundMirrorTexture;
  112922. /**
  112923. * Setup the ground to receive the mirror texture.
  112924. */
  112925. private _setupMirrorInGroundMaterial;
  112926. /**
  112927. * Setup the skybox according to the specified options.
  112928. */
  112929. private _setupSkybox;
  112930. /**
  112931. * Setup the skybox material according to the specified options.
  112932. */
  112933. private _setupSkyboxMaterial;
  112934. /**
  112935. * Setup the skybox reflection texture according to the specified options.
  112936. */
  112937. private _setupSkyboxReflectionTexture;
  112938. private _errorHandler;
  112939. /**
  112940. * Dispose all the elements created by the Helper.
  112941. */
  112942. dispose(): void;
  112943. }
  112944. }
  112945. declare module BABYLON {
  112946. /**
  112947. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  112948. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  112949. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  112950. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112951. */
  112952. export class PhotoDome extends TransformNode {
  112953. /**
  112954. * Define the image as a Monoscopic panoramic 360 image.
  112955. */
  112956. static readonly MODE_MONOSCOPIC: number;
  112957. /**
  112958. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  112959. */
  112960. static readonly MODE_TOPBOTTOM: number;
  112961. /**
  112962. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  112963. */
  112964. static readonly MODE_SIDEBYSIDE: number;
  112965. private _useDirectMapping;
  112966. /**
  112967. * The texture being displayed on the sphere
  112968. */
  112969. protected _photoTexture: Texture;
  112970. /**
  112971. * Gets or sets the texture being displayed on the sphere
  112972. */
  112973. photoTexture: Texture;
  112974. /**
  112975. * Observable raised when an error occured while loading the 360 image
  112976. */
  112977. onLoadErrorObservable: Observable<string>;
  112978. /**
  112979. * The skybox material
  112980. */
  112981. protected _material: BackgroundMaterial;
  112982. /**
  112983. * The surface used for the skybox
  112984. */
  112985. protected _mesh: Mesh;
  112986. /**
  112987. * Gets the mesh used for the skybox.
  112988. */
  112989. readonly mesh: Mesh;
  112990. /**
  112991. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112992. * Also see the options.resolution property.
  112993. */
  112994. fovMultiplier: number;
  112995. private _imageMode;
  112996. /**
  112997. * Gets or set the current video mode for the video. It can be:
  112998. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  112999. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113000. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113001. */
  113002. imageMode: number;
  113003. /**
  113004. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113005. * @param name Element's name, child elements will append suffixes for their own names.
  113006. * @param urlsOfPhoto defines the url of the photo to display
  113007. * @param options defines an object containing optional or exposed sub element properties
  113008. * @param onError defines a callback called when an error occured while loading the texture
  113009. */
  113010. constructor(name: string, urlOfPhoto: string, options: {
  113011. resolution?: number;
  113012. size?: number;
  113013. useDirectMapping?: boolean;
  113014. faceForward?: boolean;
  113015. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113016. private _onBeforeCameraRenderObserver;
  113017. private _changeImageMode;
  113018. /**
  113019. * Releases resources associated with this node.
  113020. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113021. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113022. */
  113023. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113024. }
  113025. }
  113026. declare module BABYLON {
  113027. /**
  113028. * Class used to host RGBD texture specific utilities
  113029. */
  113030. export class RGBDTextureTools {
  113031. /**
  113032. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113033. * @param texture the texture to expand.
  113034. */
  113035. static ExpandRGBDTexture(texture: Texture): void;
  113036. }
  113037. }
  113038. declare module BABYLON {
  113039. /**
  113040. * Class used to host texture specific utilities
  113041. */
  113042. export class BRDFTextureTools {
  113043. /**
  113044. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113045. * @param scene defines the hosting scene
  113046. * @returns the environment BRDF texture
  113047. */
  113048. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113049. private static _environmentBRDFBase64Texture;
  113050. }
  113051. }
  113052. declare module BABYLON {
  113053. /**
  113054. * @hidden
  113055. */
  113056. export interface IMaterialClearCoatDefines {
  113057. CLEARCOAT: boolean;
  113058. CLEARCOAT_DEFAULTIOR: boolean;
  113059. CLEARCOAT_TEXTURE: boolean;
  113060. CLEARCOAT_TEXTUREDIRECTUV: number;
  113061. CLEARCOAT_BUMP: boolean;
  113062. CLEARCOAT_BUMPDIRECTUV: number;
  113063. CLEARCOAT_TINT: boolean;
  113064. CLEARCOAT_TINT_TEXTURE: boolean;
  113065. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113066. /** @hidden */
  113067. _areTexturesDirty: boolean;
  113068. }
  113069. /**
  113070. * Define the code related to the clear coat parameters of the pbr material.
  113071. */
  113072. export class PBRClearCoatConfiguration {
  113073. /**
  113074. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113075. * The default fits with a polyurethane material.
  113076. */
  113077. private static readonly _DefaultIndexOfRefraction;
  113078. private _isEnabled;
  113079. /**
  113080. * Defines if the clear coat is enabled in the material.
  113081. */
  113082. isEnabled: boolean;
  113083. /**
  113084. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113085. */
  113086. intensity: number;
  113087. /**
  113088. * Defines the clear coat layer roughness.
  113089. */
  113090. roughness: number;
  113091. private _indexOfRefraction;
  113092. /**
  113093. * Defines the index of refraction of the clear coat.
  113094. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113095. * The default fits with a polyurethane material.
  113096. * Changing the default value is more performance intensive.
  113097. */
  113098. indexOfRefraction: number;
  113099. private _texture;
  113100. /**
  113101. * Stores the clear coat values in a texture.
  113102. */
  113103. texture: Nullable<BaseTexture>;
  113104. private _bumpTexture;
  113105. /**
  113106. * Define the clear coat specific bump texture.
  113107. */
  113108. bumpTexture: Nullable<BaseTexture>;
  113109. private _isTintEnabled;
  113110. /**
  113111. * Defines if the clear coat tint is enabled in the material.
  113112. */
  113113. isTintEnabled: boolean;
  113114. /**
  113115. * Defines the clear coat tint of the material.
  113116. * This is only use if tint is enabled
  113117. */
  113118. tintColor: Color3;
  113119. /**
  113120. * Defines the distance at which the tint color should be found in the
  113121. * clear coat media.
  113122. * This is only use if tint is enabled
  113123. */
  113124. tintColorAtDistance: number;
  113125. /**
  113126. * Defines the clear coat layer thickness.
  113127. * This is only use if tint is enabled
  113128. */
  113129. tintThickness: number;
  113130. private _tintTexture;
  113131. /**
  113132. * Stores the clear tint values in a texture.
  113133. * rgb is tint
  113134. * a is a thickness factor
  113135. */
  113136. tintTexture: Nullable<BaseTexture>;
  113137. /** @hidden */
  113138. private _internalMarkAllSubMeshesAsTexturesDirty;
  113139. /** @hidden */
  113140. _markAllSubMeshesAsTexturesDirty(): void;
  113141. /**
  113142. * Instantiate a new istance of clear coat configuration.
  113143. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113144. */
  113145. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113146. /**
  113147. * Gets wehter the submesh is ready to be used or not.
  113148. * @param defines the list of "defines" to update.
  113149. * @param scene defines the scene the material belongs to.
  113150. * @param engine defines the engine the material belongs to.
  113151. * @param disableBumpMap defines wether the material disables bump or not.
  113152. * @returns - boolean indicating that the submesh is ready or not.
  113153. */
  113154. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113155. /**
  113156. * Checks to see if a texture is used in the material.
  113157. * @param defines the list of "defines" to update.
  113158. * @param scene defines the scene to the material belongs to.
  113159. */
  113160. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113161. /**
  113162. * Binds the material data.
  113163. * @param uniformBuffer defines the Uniform buffer to fill in.
  113164. * @param scene defines the scene the material belongs to.
  113165. * @param engine defines the engine the material belongs to.
  113166. * @param disableBumpMap defines wether the material disables bump or not.
  113167. * @param isFrozen defines wether the material is frozen or not.
  113168. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113169. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113170. */
  113171. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113172. /**
  113173. * Checks to see if a texture is used in the material.
  113174. * @param texture - Base texture to use.
  113175. * @returns - Boolean specifying if a texture is used in the material.
  113176. */
  113177. hasTexture(texture: BaseTexture): boolean;
  113178. /**
  113179. * Returns an array of the actively used textures.
  113180. * @param activeTextures Array of BaseTextures
  113181. */
  113182. getActiveTextures(activeTextures: BaseTexture[]): void;
  113183. /**
  113184. * Returns the animatable textures.
  113185. * @param animatables Array of animatable textures.
  113186. */
  113187. getAnimatables(animatables: IAnimatable[]): void;
  113188. /**
  113189. * Disposes the resources of the material.
  113190. * @param forceDisposeTextures - Forces the disposal of all textures.
  113191. */
  113192. dispose(forceDisposeTextures?: boolean): void;
  113193. /**
  113194. * Get the current class name of the texture useful for serialization or dynamic coding.
  113195. * @returns "PBRClearCoatConfiguration"
  113196. */
  113197. getClassName(): string;
  113198. /**
  113199. * Add fallbacks to the effect fallbacks list.
  113200. * @param defines defines the Base texture to use.
  113201. * @param fallbacks defines the current fallback list.
  113202. * @param currentRank defines the current fallback rank.
  113203. * @returns the new fallback rank.
  113204. */
  113205. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113206. /**
  113207. * Add the required uniforms to the current list.
  113208. * @param uniforms defines the current uniform list.
  113209. */
  113210. static AddUniforms(uniforms: string[]): void;
  113211. /**
  113212. * Add the required samplers to the current list.
  113213. * @param samplers defines the current sampler list.
  113214. */
  113215. static AddSamplers(samplers: string[]): void;
  113216. /**
  113217. * Add the required uniforms to the current buffer.
  113218. * @param uniformBuffer defines the current uniform buffer.
  113219. */
  113220. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113221. /**
  113222. * Makes a duplicate of the current configuration into another one.
  113223. * @param clearCoatConfiguration define the config where to copy the info
  113224. */
  113225. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113226. /**
  113227. * Serializes this clear coat configuration.
  113228. * @returns - An object with the serialized config.
  113229. */
  113230. serialize(): any;
  113231. /**
  113232. * Parses a anisotropy Configuration from a serialized object.
  113233. * @param source - Serialized object.
  113234. * @param scene Defines the scene we are parsing for
  113235. * @param rootUrl Defines the rootUrl to load from
  113236. */
  113237. parse(source: any, scene: Scene, rootUrl: string): void;
  113238. }
  113239. }
  113240. declare module BABYLON {
  113241. /**
  113242. * @hidden
  113243. */
  113244. export interface IMaterialAnisotropicDefines {
  113245. ANISOTROPIC: boolean;
  113246. ANISOTROPIC_TEXTURE: boolean;
  113247. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113248. MAINUV1: boolean;
  113249. _areTexturesDirty: boolean;
  113250. _needUVs: boolean;
  113251. }
  113252. /**
  113253. * Define the code related to the anisotropic parameters of the pbr material.
  113254. */
  113255. export class PBRAnisotropicConfiguration {
  113256. private _isEnabled;
  113257. /**
  113258. * Defines if the anisotropy is enabled in the material.
  113259. */
  113260. isEnabled: boolean;
  113261. /**
  113262. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113263. */
  113264. intensity: number;
  113265. /**
  113266. * Defines if the effect is along the tangents, bitangents or in between.
  113267. * By default, the effect is "strectching" the highlights along the tangents.
  113268. */
  113269. direction: Vector2;
  113270. private _texture;
  113271. /**
  113272. * Stores the anisotropy values in a texture.
  113273. * rg is direction (like normal from -1 to 1)
  113274. * b is a intensity
  113275. */
  113276. texture: Nullable<BaseTexture>;
  113277. /** @hidden */
  113278. private _internalMarkAllSubMeshesAsTexturesDirty;
  113279. /** @hidden */
  113280. _markAllSubMeshesAsTexturesDirty(): void;
  113281. /**
  113282. * Instantiate a new istance of anisotropy configuration.
  113283. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113284. */
  113285. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113286. /**
  113287. * Specifies that the submesh is ready to be used.
  113288. * @param defines the list of "defines" to update.
  113289. * @param scene defines the scene the material belongs to.
  113290. * @returns - boolean indicating that the submesh is ready or not.
  113291. */
  113292. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113293. /**
  113294. * Checks to see if a texture is used in the material.
  113295. * @param defines the list of "defines" to update.
  113296. * @param mesh the mesh we are preparing the defines for.
  113297. * @param scene defines the scene the material belongs to.
  113298. */
  113299. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113300. /**
  113301. * Binds the material data.
  113302. * @param uniformBuffer defines the Uniform buffer to fill in.
  113303. * @param scene defines the scene the material belongs to.
  113304. * @param isFrozen defines wether the material is frozen or not.
  113305. */
  113306. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113307. /**
  113308. * Checks to see if a texture is used in the material.
  113309. * @param texture - Base texture to use.
  113310. * @returns - Boolean specifying if a texture is used in the material.
  113311. */
  113312. hasTexture(texture: BaseTexture): boolean;
  113313. /**
  113314. * Returns an array of the actively used textures.
  113315. * @param activeTextures Array of BaseTextures
  113316. */
  113317. getActiveTextures(activeTextures: BaseTexture[]): void;
  113318. /**
  113319. * Returns the animatable textures.
  113320. * @param animatables Array of animatable textures.
  113321. */
  113322. getAnimatables(animatables: IAnimatable[]): void;
  113323. /**
  113324. * Disposes the resources of the material.
  113325. * @param forceDisposeTextures - Forces the disposal of all textures.
  113326. */
  113327. dispose(forceDisposeTextures?: boolean): void;
  113328. /**
  113329. * Get the current class name of the texture useful for serialization or dynamic coding.
  113330. * @returns "PBRAnisotropicConfiguration"
  113331. */
  113332. getClassName(): string;
  113333. /**
  113334. * Add fallbacks to the effect fallbacks list.
  113335. * @param defines defines the Base texture to use.
  113336. * @param fallbacks defines the current fallback list.
  113337. * @param currentRank defines the current fallback rank.
  113338. * @returns the new fallback rank.
  113339. */
  113340. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113341. /**
  113342. * Add the required uniforms to the current list.
  113343. * @param uniforms defines the current uniform list.
  113344. */
  113345. static AddUniforms(uniforms: string[]): void;
  113346. /**
  113347. * Add the required uniforms to the current buffer.
  113348. * @param uniformBuffer defines the current uniform buffer.
  113349. */
  113350. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113351. /**
  113352. * Add the required samplers to the current list.
  113353. * @param samplers defines the current sampler list.
  113354. */
  113355. static AddSamplers(samplers: string[]): void;
  113356. /**
  113357. * Makes a duplicate of the current configuration into another one.
  113358. * @param anisotropicConfiguration define the config where to copy the info
  113359. */
  113360. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113361. /**
  113362. * Serializes this anisotropy configuration.
  113363. * @returns - An object with the serialized config.
  113364. */
  113365. serialize(): any;
  113366. /**
  113367. * Parses a anisotropy Configuration from a serialized object.
  113368. * @param source - Serialized object.
  113369. * @param scene Defines the scene we are parsing for
  113370. * @param rootUrl Defines the rootUrl to load from
  113371. */
  113372. parse(source: any, scene: Scene, rootUrl: string): void;
  113373. }
  113374. }
  113375. declare module BABYLON {
  113376. /**
  113377. * @hidden
  113378. */
  113379. export interface IMaterialBRDFDefines {
  113380. BRDF_V_HEIGHT_CORRELATED: boolean;
  113381. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113382. SPHERICAL_HARMONICS: boolean;
  113383. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113384. /** @hidden */
  113385. _areMiscDirty: boolean;
  113386. }
  113387. /**
  113388. * Define the code related to the BRDF parameters of the pbr material.
  113389. */
  113390. export class PBRBRDFConfiguration {
  113391. /**
  113392. * Default value used for the energy conservation.
  113393. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113394. */
  113395. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113396. /**
  113397. * Default value used for the Smith Visibility Height Correlated mode.
  113398. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113399. */
  113400. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113401. /**
  113402. * Default value used for the IBL diffuse part.
  113403. * This can help switching back to the polynomials mode globally which is a tiny bit
  113404. * less GPU intensive at the drawback of a lower quality.
  113405. */
  113406. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113407. /**
  113408. * Default value used for activating energy conservation for the specular workflow.
  113409. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113410. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113411. */
  113412. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113413. private _useEnergyConservation;
  113414. /**
  113415. * Defines if the material uses energy conservation.
  113416. */
  113417. useEnergyConservation: boolean;
  113418. private _useSmithVisibilityHeightCorrelated;
  113419. /**
  113420. * LEGACY Mode set to false
  113421. * Defines if the material uses height smith correlated visibility term.
  113422. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113423. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113424. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113425. * Not relying on height correlated will also disable energy conservation.
  113426. */
  113427. useSmithVisibilityHeightCorrelated: boolean;
  113428. private _useSphericalHarmonics;
  113429. /**
  113430. * LEGACY Mode set to false
  113431. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113432. * diffuse part of the IBL.
  113433. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113434. * to the ground truth.
  113435. */
  113436. useSphericalHarmonics: boolean;
  113437. private _useSpecularGlossinessInputEnergyConservation;
  113438. /**
  113439. * Defines if the material uses energy conservation, when the specular workflow is active.
  113440. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113441. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113442. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113443. */
  113444. useSpecularGlossinessInputEnergyConservation: boolean;
  113445. /** @hidden */
  113446. private _internalMarkAllSubMeshesAsMiscDirty;
  113447. /** @hidden */
  113448. _markAllSubMeshesAsMiscDirty(): void;
  113449. /**
  113450. * Instantiate a new istance of clear coat configuration.
  113451. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113452. */
  113453. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113454. /**
  113455. * Checks to see if a texture is used in the material.
  113456. * @param defines the list of "defines" to update.
  113457. */
  113458. prepareDefines(defines: IMaterialBRDFDefines): void;
  113459. /**
  113460. * Get the current class name of the texture useful for serialization or dynamic coding.
  113461. * @returns "PBRClearCoatConfiguration"
  113462. */
  113463. getClassName(): string;
  113464. /**
  113465. * Makes a duplicate of the current configuration into another one.
  113466. * @param brdfConfiguration define the config where to copy the info
  113467. */
  113468. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113469. /**
  113470. * Serializes this BRDF configuration.
  113471. * @returns - An object with the serialized config.
  113472. */
  113473. serialize(): any;
  113474. /**
  113475. * Parses a anisotropy Configuration from a serialized object.
  113476. * @param source - Serialized object.
  113477. * @param scene Defines the scene we are parsing for
  113478. * @param rootUrl Defines the rootUrl to load from
  113479. */
  113480. parse(source: any, scene: Scene, rootUrl: string): void;
  113481. }
  113482. }
  113483. declare module BABYLON {
  113484. /**
  113485. * @hidden
  113486. */
  113487. export interface IMaterialSheenDefines {
  113488. SHEEN: boolean;
  113489. SHEEN_TEXTURE: boolean;
  113490. SHEEN_TEXTUREDIRECTUV: number;
  113491. SHEEN_LINKWITHALBEDO: boolean;
  113492. /** @hidden */
  113493. _areTexturesDirty: boolean;
  113494. }
  113495. /**
  113496. * Define the code related to the Sheen parameters of the pbr material.
  113497. */
  113498. export class PBRSheenConfiguration {
  113499. private _isEnabled;
  113500. /**
  113501. * Defines if the material uses sheen.
  113502. */
  113503. isEnabled: boolean;
  113504. private _linkSheenWithAlbedo;
  113505. /**
  113506. * Defines if the sheen is linked to the sheen color.
  113507. */
  113508. linkSheenWithAlbedo: boolean;
  113509. /**
  113510. * Defines the sheen intensity.
  113511. */
  113512. intensity: number;
  113513. /**
  113514. * Defines the sheen color.
  113515. */
  113516. color: Color3;
  113517. private _texture;
  113518. /**
  113519. * Stores the sheen tint values in a texture.
  113520. * rgb is tint
  113521. * a is a intensity
  113522. */
  113523. texture: Nullable<BaseTexture>;
  113524. /** @hidden */
  113525. private _internalMarkAllSubMeshesAsTexturesDirty;
  113526. /** @hidden */
  113527. _markAllSubMeshesAsTexturesDirty(): void;
  113528. /**
  113529. * Instantiate a new istance of clear coat configuration.
  113530. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113531. */
  113532. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113533. /**
  113534. * Specifies that the submesh is ready to be used.
  113535. * @param defines the list of "defines" to update.
  113536. * @param scene defines the scene the material belongs to.
  113537. * @returns - boolean indicating that the submesh is ready or not.
  113538. */
  113539. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113540. /**
  113541. * Checks to see if a texture is used in the material.
  113542. * @param defines the list of "defines" to update.
  113543. * @param scene defines the scene the material belongs to.
  113544. */
  113545. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113546. /**
  113547. * Binds the material data.
  113548. * @param uniformBuffer defines the Uniform buffer to fill in.
  113549. * @param scene defines the scene the material belongs to.
  113550. * @param isFrozen defines wether the material is frozen or not.
  113551. */
  113552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113553. /**
  113554. * Checks to see if a texture is used in the material.
  113555. * @param texture - Base texture to use.
  113556. * @returns - Boolean specifying if a texture is used in the material.
  113557. */
  113558. hasTexture(texture: BaseTexture): boolean;
  113559. /**
  113560. * Returns an array of the actively used textures.
  113561. * @param activeTextures Array of BaseTextures
  113562. */
  113563. getActiveTextures(activeTextures: BaseTexture[]): void;
  113564. /**
  113565. * Returns the animatable textures.
  113566. * @param animatables Array of animatable textures.
  113567. */
  113568. getAnimatables(animatables: IAnimatable[]): void;
  113569. /**
  113570. * Disposes the resources of the material.
  113571. * @param forceDisposeTextures - Forces the disposal of all textures.
  113572. */
  113573. dispose(forceDisposeTextures?: boolean): void;
  113574. /**
  113575. * Get the current class name of the texture useful for serialization or dynamic coding.
  113576. * @returns "PBRSheenConfiguration"
  113577. */
  113578. getClassName(): string;
  113579. /**
  113580. * Add fallbacks to the effect fallbacks list.
  113581. * @param defines defines the Base texture to use.
  113582. * @param fallbacks defines the current fallback list.
  113583. * @param currentRank defines the current fallback rank.
  113584. * @returns the new fallback rank.
  113585. */
  113586. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113587. /**
  113588. * Add the required uniforms to the current list.
  113589. * @param uniforms defines the current uniform list.
  113590. */
  113591. static AddUniforms(uniforms: string[]): void;
  113592. /**
  113593. * Add the required uniforms to the current buffer.
  113594. * @param uniformBuffer defines the current uniform buffer.
  113595. */
  113596. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113597. /**
  113598. * Add the required samplers to the current list.
  113599. * @param samplers defines the current sampler list.
  113600. */
  113601. static AddSamplers(samplers: string[]): void;
  113602. /**
  113603. * Makes a duplicate of the current configuration into another one.
  113604. * @param sheenConfiguration define the config where to copy the info
  113605. */
  113606. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113607. /**
  113608. * Serializes this BRDF configuration.
  113609. * @returns - An object with the serialized config.
  113610. */
  113611. serialize(): any;
  113612. /**
  113613. * Parses a anisotropy Configuration from a serialized object.
  113614. * @param source - Serialized object.
  113615. * @param scene Defines the scene we are parsing for
  113616. * @param rootUrl Defines the rootUrl to load from
  113617. */
  113618. parse(source: any, scene: Scene, rootUrl: string): void;
  113619. }
  113620. }
  113621. declare module BABYLON {
  113622. /**
  113623. * @hidden
  113624. */
  113625. export interface IMaterialSubSurfaceDefines {
  113626. SUBSURFACE: boolean;
  113627. SS_REFRACTION: boolean;
  113628. SS_TRANSLUCENCY: boolean;
  113629. SS_SCATERRING: boolean;
  113630. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113631. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113632. SS_REFRACTIONMAP_3D: boolean;
  113633. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113634. SS_LODINREFRACTIONALPHA: boolean;
  113635. SS_GAMMAREFRACTION: boolean;
  113636. SS_RGBDREFRACTION: boolean;
  113637. SS_LINEARSPECULARREFRACTION: boolean;
  113638. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113639. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113640. /** @hidden */
  113641. _areTexturesDirty: boolean;
  113642. }
  113643. /**
  113644. * Define the code related to the sub surface parameters of the pbr material.
  113645. */
  113646. export class PBRSubSurfaceConfiguration {
  113647. private _isRefractionEnabled;
  113648. /**
  113649. * Defines if the refraction is enabled in the material.
  113650. */
  113651. isRefractionEnabled: boolean;
  113652. private _isTranslucencyEnabled;
  113653. /**
  113654. * Defines if the translucency is enabled in the material.
  113655. */
  113656. isTranslucencyEnabled: boolean;
  113657. private _isScatteringEnabled;
  113658. /**
  113659. * Defines the refraction intensity of the material.
  113660. * The refraction when enabled replaces the Diffuse part of the material.
  113661. * The intensity helps transitionning between diffuse and refraction.
  113662. */
  113663. refractionIntensity: number;
  113664. /**
  113665. * Defines the translucency intensity of the material.
  113666. * When translucency has been enabled, this defines how much of the "translucency"
  113667. * is addded to the diffuse part of the material.
  113668. */
  113669. translucencyIntensity: number;
  113670. /**
  113671. * Defines the scattering intensity of the material.
  113672. * When scattering has been enabled, this defines how much of the "scattered light"
  113673. * is addded to the diffuse part of the material.
  113674. */
  113675. scatteringIntensity: number;
  113676. private _thicknessTexture;
  113677. /**
  113678. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113679. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113680. * 0 would mean minimumThickness
  113681. * 1 would mean maximumThickness
  113682. * The other channels might be use as a mask to vary the different effects intensity.
  113683. */
  113684. thicknessTexture: Nullable<BaseTexture>;
  113685. private _refractionTexture;
  113686. /**
  113687. * Defines the texture to use for refraction.
  113688. */
  113689. refractionTexture: Nullable<BaseTexture>;
  113690. private _indexOfRefraction;
  113691. /**
  113692. * Defines the index of refraction used in the material.
  113693. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113694. */
  113695. indexOfRefraction: number;
  113696. private _invertRefractionY;
  113697. /**
  113698. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113699. */
  113700. invertRefractionY: boolean;
  113701. private _linkRefractionWithTransparency;
  113702. /**
  113703. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113704. * Materials half opaque for instance using refraction could benefit from this control.
  113705. */
  113706. linkRefractionWithTransparency: boolean;
  113707. /**
  113708. * Defines the minimum thickness stored in the thickness map.
  113709. * If no thickness map is defined, this value will be used to simulate thickness.
  113710. */
  113711. minimumThickness: number;
  113712. /**
  113713. * Defines the maximum thickness stored in the thickness map.
  113714. */
  113715. maximumThickness: number;
  113716. /**
  113717. * Defines the volume tint of the material.
  113718. * This is used for both translucency and scattering.
  113719. */
  113720. tintColor: Color3;
  113721. /**
  113722. * Defines the distance at which the tint color should be found in the media.
  113723. * This is used for refraction only.
  113724. */
  113725. tintColorAtDistance: number;
  113726. /**
  113727. * Defines how far each channel transmit through the media.
  113728. * It is defined as a color to simplify it selection.
  113729. */
  113730. diffusionDistance: Color3;
  113731. private _useMaskFromThicknessTexture;
  113732. /**
  113733. * Stores the intensity of the different subsurface effects in the thickness texture.
  113734. * * the green channel is the translucency intensity.
  113735. * * the blue channel is the scattering intensity.
  113736. * * the alpha channel is the refraction intensity.
  113737. */
  113738. useMaskFromThicknessTexture: boolean;
  113739. /** @hidden */
  113740. private _internalMarkAllSubMeshesAsTexturesDirty;
  113741. /** @hidden */
  113742. _markAllSubMeshesAsTexturesDirty(): void;
  113743. /**
  113744. * Instantiate a new istance of sub surface configuration.
  113745. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113746. */
  113747. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113748. /**
  113749. * Gets wehter the submesh is ready to be used or not.
  113750. * @param defines the list of "defines" to update.
  113751. * @param scene defines the scene the material belongs to.
  113752. * @returns - boolean indicating that the submesh is ready or not.
  113753. */
  113754. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113755. /**
  113756. * Checks to see if a texture is used in the material.
  113757. * @param defines the list of "defines" to update.
  113758. * @param scene defines the scene to the material belongs to.
  113759. */
  113760. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113761. /**
  113762. * Binds the material data.
  113763. * @param uniformBuffer defines the Uniform buffer to fill in.
  113764. * @param scene defines the scene the material belongs to.
  113765. * @param engine defines the engine the material belongs to.
  113766. * @param isFrozen defines wether the material is frozen or not.
  113767. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113768. */
  113769. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113770. /**
  113771. * Unbinds the material from the mesh.
  113772. * @param activeEffect defines the effect that should be unbound from.
  113773. * @returns true if unbound, otherwise false
  113774. */
  113775. unbind(activeEffect: Effect): boolean;
  113776. /**
  113777. * Returns the texture used for refraction or null if none is used.
  113778. * @param scene defines the scene the material belongs to.
  113779. * @returns - Refraction texture if present. If no refraction texture and refraction
  113780. * is linked with transparency, returns environment texture. Otherwise, returns null.
  113781. */
  113782. private _getRefractionTexture;
  113783. /**
  113784. * Returns true if alpha blending should be disabled.
  113785. */
  113786. readonly disableAlphaBlending: boolean;
  113787. /**
  113788. * Fills the list of render target textures.
  113789. * @param renderTargets the list of render targets to update
  113790. */
  113791. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  113792. /**
  113793. * Checks to see if a texture is used in the material.
  113794. * @param texture - Base texture to use.
  113795. * @returns - Boolean specifying if a texture is used in the material.
  113796. */
  113797. hasTexture(texture: BaseTexture): boolean;
  113798. /**
  113799. * Gets a boolean indicating that current material needs to register RTT
  113800. * @returns true if this uses a render target otherwise false.
  113801. */
  113802. hasRenderTargetTextures(): boolean;
  113803. /**
  113804. * Returns an array of the actively used textures.
  113805. * @param activeTextures Array of BaseTextures
  113806. */
  113807. getActiveTextures(activeTextures: BaseTexture[]): void;
  113808. /**
  113809. * Returns the animatable textures.
  113810. * @param animatables Array of animatable textures.
  113811. */
  113812. getAnimatables(animatables: IAnimatable[]): void;
  113813. /**
  113814. * Disposes the resources of the material.
  113815. * @param forceDisposeTextures - Forces the disposal of all textures.
  113816. */
  113817. dispose(forceDisposeTextures?: boolean): void;
  113818. /**
  113819. * Get the current class name of the texture useful for serialization or dynamic coding.
  113820. * @returns "PBRSubSurfaceConfiguration"
  113821. */
  113822. getClassName(): string;
  113823. /**
  113824. * Add fallbacks to the effect fallbacks list.
  113825. * @param defines defines the Base texture to use.
  113826. * @param fallbacks defines the current fallback list.
  113827. * @param currentRank defines the current fallback rank.
  113828. * @returns the new fallback rank.
  113829. */
  113830. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113831. /**
  113832. * Add the required uniforms to the current list.
  113833. * @param uniforms defines the current uniform list.
  113834. */
  113835. static AddUniforms(uniforms: string[]): void;
  113836. /**
  113837. * Add the required samplers to the current list.
  113838. * @param samplers defines the current sampler list.
  113839. */
  113840. static AddSamplers(samplers: string[]): void;
  113841. /**
  113842. * Add the required uniforms to the current buffer.
  113843. * @param uniformBuffer defines the current uniform buffer.
  113844. */
  113845. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113846. /**
  113847. * Makes a duplicate of the current configuration into another one.
  113848. * @param configuration define the config where to copy the info
  113849. */
  113850. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  113851. /**
  113852. * Serializes this Sub Surface configuration.
  113853. * @returns - An object with the serialized config.
  113854. */
  113855. serialize(): any;
  113856. /**
  113857. * Parses a anisotropy Configuration from a serialized object.
  113858. * @param source - Serialized object.
  113859. * @param scene Defines the scene we are parsing for
  113860. * @param rootUrl Defines the rootUrl to load from
  113861. */
  113862. parse(source: any, scene: Scene, rootUrl: string): void;
  113863. }
  113864. }
  113865. declare module BABYLON {
  113866. /** @hidden */
  113867. export var pbrFragmentDeclaration: {
  113868. name: string;
  113869. shader: string;
  113870. };
  113871. }
  113872. declare module BABYLON {
  113873. /** @hidden */
  113874. export var pbrUboDeclaration: {
  113875. name: string;
  113876. shader: string;
  113877. };
  113878. }
  113879. declare module BABYLON {
  113880. /** @hidden */
  113881. export var pbrFragmentExtraDeclaration: {
  113882. name: string;
  113883. shader: string;
  113884. };
  113885. }
  113886. declare module BABYLON {
  113887. /** @hidden */
  113888. export var pbrFragmentSamplersDeclaration: {
  113889. name: string;
  113890. shader: string;
  113891. };
  113892. }
  113893. declare module BABYLON {
  113894. /** @hidden */
  113895. export var pbrHelperFunctions: {
  113896. name: string;
  113897. shader: string;
  113898. };
  113899. }
  113900. declare module BABYLON {
  113901. /** @hidden */
  113902. export var harmonicsFunctions: {
  113903. name: string;
  113904. shader: string;
  113905. };
  113906. }
  113907. declare module BABYLON {
  113908. /** @hidden */
  113909. export var pbrDirectLightingSetupFunctions: {
  113910. name: string;
  113911. shader: string;
  113912. };
  113913. }
  113914. declare module BABYLON {
  113915. /** @hidden */
  113916. export var pbrDirectLightingFalloffFunctions: {
  113917. name: string;
  113918. shader: string;
  113919. };
  113920. }
  113921. declare module BABYLON {
  113922. /** @hidden */
  113923. export var pbrBRDFFunctions: {
  113924. name: string;
  113925. shader: string;
  113926. };
  113927. }
  113928. declare module BABYLON {
  113929. /** @hidden */
  113930. export var pbrDirectLightingFunctions: {
  113931. name: string;
  113932. shader: string;
  113933. };
  113934. }
  113935. declare module BABYLON {
  113936. /** @hidden */
  113937. export var pbrIBLFunctions: {
  113938. name: string;
  113939. shader: string;
  113940. };
  113941. }
  113942. declare module BABYLON {
  113943. /** @hidden */
  113944. export var pbrDebug: {
  113945. name: string;
  113946. shader: string;
  113947. };
  113948. }
  113949. declare module BABYLON {
  113950. /** @hidden */
  113951. export var pbrPixelShader: {
  113952. name: string;
  113953. shader: string;
  113954. };
  113955. }
  113956. declare module BABYLON {
  113957. /** @hidden */
  113958. export var pbrVertexDeclaration: {
  113959. name: string;
  113960. shader: string;
  113961. };
  113962. }
  113963. declare module BABYLON {
  113964. /** @hidden */
  113965. export var pbrVertexShader: {
  113966. name: string;
  113967. shader: string;
  113968. };
  113969. }
  113970. declare module BABYLON {
  113971. /**
  113972. * Manages the defines for the PBR Material.
  113973. * @hidden
  113974. */
  113975. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  113976. PBR: boolean;
  113977. MAINUV1: boolean;
  113978. MAINUV2: boolean;
  113979. UV1: boolean;
  113980. UV2: boolean;
  113981. ALBEDO: boolean;
  113982. ALBEDODIRECTUV: number;
  113983. VERTEXCOLOR: boolean;
  113984. AMBIENT: boolean;
  113985. AMBIENTDIRECTUV: number;
  113986. AMBIENTINGRAYSCALE: boolean;
  113987. OPACITY: boolean;
  113988. VERTEXALPHA: boolean;
  113989. OPACITYDIRECTUV: number;
  113990. OPACITYRGB: boolean;
  113991. ALPHATEST: boolean;
  113992. DEPTHPREPASS: boolean;
  113993. ALPHABLEND: boolean;
  113994. ALPHAFROMALBEDO: boolean;
  113995. ALPHATESTVALUE: string;
  113996. SPECULAROVERALPHA: boolean;
  113997. RADIANCEOVERALPHA: boolean;
  113998. ALPHAFRESNEL: boolean;
  113999. LINEARALPHAFRESNEL: boolean;
  114000. PREMULTIPLYALPHA: boolean;
  114001. EMISSIVE: boolean;
  114002. EMISSIVEDIRECTUV: number;
  114003. REFLECTIVITY: boolean;
  114004. REFLECTIVITYDIRECTUV: number;
  114005. SPECULARTERM: boolean;
  114006. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114007. MICROSURFACEAUTOMATIC: boolean;
  114008. LODBASEDMICROSFURACE: boolean;
  114009. MICROSURFACEMAP: boolean;
  114010. MICROSURFACEMAPDIRECTUV: number;
  114011. METALLICWORKFLOW: boolean;
  114012. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114013. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114014. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114015. AOSTOREINMETALMAPRED: boolean;
  114016. ENVIRONMENTBRDF: boolean;
  114017. ENVIRONMENTBRDF_RGBD: boolean;
  114018. NORMAL: boolean;
  114019. TANGENT: boolean;
  114020. BUMP: boolean;
  114021. BUMPDIRECTUV: number;
  114022. OBJECTSPACE_NORMALMAP: boolean;
  114023. PARALLAX: boolean;
  114024. PARALLAXOCCLUSION: boolean;
  114025. NORMALXYSCALE: boolean;
  114026. LIGHTMAP: boolean;
  114027. LIGHTMAPDIRECTUV: number;
  114028. USELIGHTMAPASSHADOWMAP: boolean;
  114029. GAMMALIGHTMAP: boolean;
  114030. RGBDLIGHTMAP: boolean;
  114031. REFLECTION: boolean;
  114032. REFLECTIONMAP_3D: boolean;
  114033. REFLECTIONMAP_SPHERICAL: boolean;
  114034. REFLECTIONMAP_PLANAR: boolean;
  114035. REFLECTIONMAP_CUBIC: boolean;
  114036. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114037. REFLECTIONMAP_PROJECTION: boolean;
  114038. REFLECTIONMAP_SKYBOX: boolean;
  114039. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114040. REFLECTIONMAP_EXPLICIT: boolean;
  114041. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114042. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114043. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114044. INVERTCUBICMAP: boolean;
  114045. USESPHERICALFROMREFLECTIONMAP: boolean;
  114046. USEIRRADIANCEMAP: boolean;
  114047. SPHERICAL_HARMONICS: boolean;
  114048. USESPHERICALINVERTEX: boolean;
  114049. REFLECTIONMAP_OPPOSITEZ: boolean;
  114050. LODINREFLECTIONALPHA: boolean;
  114051. GAMMAREFLECTION: boolean;
  114052. RGBDREFLECTION: boolean;
  114053. LINEARSPECULARREFLECTION: boolean;
  114054. RADIANCEOCCLUSION: boolean;
  114055. HORIZONOCCLUSION: boolean;
  114056. INSTANCES: boolean;
  114057. NUM_BONE_INFLUENCERS: number;
  114058. BonesPerMesh: number;
  114059. BONETEXTURE: boolean;
  114060. NONUNIFORMSCALING: boolean;
  114061. MORPHTARGETS: boolean;
  114062. MORPHTARGETS_NORMAL: boolean;
  114063. MORPHTARGETS_TANGENT: boolean;
  114064. MORPHTARGETS_UV: boolean;
  114065. NUM_MORPH_INFLUENCERS: number;
  114066. IMAGEPROCESSING: boolean;
  114067. VIGNETTE: boolean;
  114068. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114069. VIGNETTEBLENDMODEOPAQUE: boolean;
  114070. TONEMAPPING: boolean;
  114071. TONEMAPPING_ACES: boolean;
  114072. CONTRAST: boolean;
  114073. COLORCURVES: boolean;
  114074. COLORGRADING: boolean;
  114075. COLORGRADING3D: boolean;
  114076. SAMPLER3DGREENDEPTH: boolean;
  114077. SAMPLER3DBGRMAP: boolean;
  114078. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114079. EXPOSURE: boolean;
  114080. MULTIVIEW: boolean;
  114081. USEPHYSICALLIGHTFALLOFF: boolean;
  114082. USEGLTFLIGHTFALLOFF: boolean;
  114083. TWOSIDEDLIGHTING: boolean;
  114084. SHADOWFLOAT: boolean;
  114085. CLIPPLANE: boolean;
  114086. CLIPPLANE2: boolean;
  114087. CLIPPLANE3: boolean;
  114088. CLIPPLANE4: boolean;
  114089. POINTSIZE: boolean;
  114090. FOG: boolean;
  114091. LOGARITHMICDEPTH: boolean;
  114092. FORCENORMALFORWARD: boolean;
  114093. SPECULARAA: boolean;
  114094. CLEARCOAT: boolean;
  114095. CLEARCOAT_DEFAULTIOR: boolean;
  114096. CLEARCOAT_TEXTURE: boolean;
  114097. CLEARCOAT_TEXTUREDIRECTUV: number;
  114098. CLEARCOAT_BUMP: boolean;
  114099. CLEARCOAT_BUMPDIRECTUV: number;
  114100. CLEARCOAT_TINT: boolean;
  114101. CLEARCOAT_TINT_TEXTURE: boolean;
  114102. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114103. ANISOTROPIC: boolean;
  114104. ANISOTROPIC_TEXTURE: boolean;
  114105. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114106. BRDF_V_HEIGHT_CORRELATED: boolean;
  114107. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114108. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114109. SHEEN: boolean;
  114110. SHEEN_TEXTURE: boolean;
  114111. SHEEN_TEXTUREDIRECTUV: number;
  114112. SHEEN_LINKWITHALBEDO: boolean;
  114113. SUBSURFACE: boolean;
  114114. SS_REFRACTION: boolean;
  114115. SS_TRANSLUCENCY: boolean;
  114116. SS_SCATERRING: boolean;
  114117. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114118. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114119. SS_REFRACTIONMAP_3D: boolean;
  114120. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114121. SS_LODINREFRACTIONALPHA: boolean;
  114122. SS_GAMMAREFRACTION: boolean;
  114123. SS_RGBDREFRACTION: boolean;
  114124. SS_LINEARSPECULARREFRACTION: boolean;
  114125. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114126. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114127. UNLIT: boolean;
  114128. DEBUGMODE: number;
  114129. /**
  114130. * Initializes the PBR Material defines.
  114131. */
  114132. constructor();
  114133. /**
  114134. * Resets the PBR Material defines.
  114135. */
  114136. reset(): void;
  114137. }
  114138. /**
  114139. * The Physically based material base class of BJS.
  114140. *
  114141. * This offers the main features of a standard PBR material.
  114142. * For more information, please refer to the documentation :
  114143. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114144. */
  114145. export abstract class PBRBaseMaterial extends PushMaterial {
  114146. /**
  114147. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114148. */
  114149. static readonly PBRMATERIAL_OPAQUE: number;
  114150. /**
  114151. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114152. */
  114153. static readonly PBRMATERIAL_ALPHATEST: number;
  114154. /**
  114155. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114156. */
  114157. static readonly PBRMATERIAL_ALPHABLEND: number;
  114158. /**
  114159. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114160. * They are also discarded below the alpha cutoff threshold to improve performances.
  114161. */
  114162. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114163. /**
  114164. * Defines the default value of how much AO map is occluding the analytical lights
  114165. * (point spot...).
  114166. */
  114167. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114168. /**
  114169. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114170. */
  114171. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114172. /**
  114173. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114174. * to enhance interoperability with other engines.
  114175. */
  114176. static readonly LIGHTFALLOFF_GLTF: number;
  114177. /**
  114178. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114179. * to enhance interoperability with other materials.
  114180. */
  114181. static readonly LIGHTFALLOFF_STANDARD: number;
  114182. /**
  114183. * Intensity of the direct lights e.g. the four lights available in your scene.
  114184. * This impacts both the direct diffuse and specular highlights.
  114185. */
  114186. protected _directIntensity: number;
  114187. /**
  114188. * Intensity of the emissive part of the material.
  114189. * This helps controlling the emissive effect without modifying the emissive color.
  114190. */
  114191. protected _emissiveIntensity: number;
  114192. /**
  114193. * Intensity of the environment e.g. how much the environment will light the object
  114194. * either through harmonics for rough material or through the refelction for shiny ones.
  114195. */
  114196. protected _environmentIntensity: number;
  114197. /**
  114198. * This is a special control allowing the reduction of the specular highlights coming from the
  114199. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114200. */
  114201. protected _specularIntensity: number;
  114202. /**
  114203. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114204. */
  114205. private _lightingInfos;
  114206. /**
  114207. * Debug Control allowing disabling the bump map on this material.
  114208. */
  114209. protected _disableBumpMap: boolean;
  114210. /**
  114211. * AKA Diffuse Texture in standard nomenclature.
  114212. */
  114213. protected _albedoTexture: Nullable<BaseTexture>;
  114214. /**
  114215. * AKA Occlusion Texture in other nomenclature.
  114216. */
  114217. protected _ambientTexture: Nullable<BaseTexture>;
  114218. /**
  114219. * AKA Occlusion Texture Intensity in other nomenclature.
  114220. */
  114221. protected _ambientTextureStrength: number;
  114222. /**
  114223. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114224. * 1 means it completely occludes it
  114225. * 0 mean it has no impact
  114226. */
  114227. protected _ambientTextureImpactOnAnalyticalLights: number;
  114228. /**
  114229. * Stores the alpha values in a texture.
  114230. */
  114231. protected _opacityTexture: Nullable<BaseTexture>;
  114232. /**
  114233. * Stores the reflection values in a texture.
  114234. */
  114235. protected _reflectionTexture: Nullable<BaseTexture>;
  114236. /**
  114237. * Stores the emissive values in a texture.
  114238. */
  114239. protected _emissiveTexture: Nullable<BaseTexture>;
  114240. /**
  114241. * AKA Specular texture in other nomenclature.
  114242. */
  114243. protected _reflectivityTexture: Nullable<BaseTexture>;
  114244. /**
  114245. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114246. */
  114247. protected _metallicTexture: Nullable<BaseTexture>;
  114248. /**
  114249. * Specifies the metallic scalar of the metallic/roughness workflow.
  114250. * Can also be used to scale the metalness values of the metallic texture.
  114251. */
  114252. protected _metallic: Nullable<number>;
  114253. /**
  114254. * Specifies the roughness scalar of the metallic/roughness workflow.
  114255. * Can also be used to scale the roughness values of the metallic texture.
  114256. */
  114257. protected _roughness: Nullable<number>;
  114258. /**
  114259. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114260. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114261. */
  114262. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114263. /**
  114264. * Stores surface normal data used to displace a mesh in a texture.
  114265. */
  114266. protected _bumpTexture: Nullable<BaseTexture>;
  114267. /**
  114268. * Stores the pre-calculated light information of a mesh in a texture.
  114269. */
  114270. protected _lightmapTexture: Nullable<BaseTexture>;
  114271. /**
  114272. * The color of a material in ambient lighting.
  114273. */
  114274. protected _ambientColor: Color3;
  114275. /**
  114276. * AKA Diffuse Color in other nomenclature.
  114277. */
  114278. protected _albedoColor: Color3;
  114279. /**
  114280. * AKA Specular Color in other nomenclature.
  114281. */
  114282. protected _reflectivityColor: Color3;
  114283. /**
  114284. * The color applied when light is reflected from a material.
  114285. */
  114286. protected _reflectionColor: Color3;
  114287. /**
  114288. * The color applied when light is emitted from a material.
  114289. */
  114290. protected _emissiveColor: Color3;
  114291. /**
  114292. * AKA Glossiness in other nomenclature.
  114293. */
  114294. protected _microSurface: number;
  114295. /**
  114296. * Specifies that the material will use the light map as a show map.
  114297. */
  114298. protected _useLightmapAsShadowmap: boolean;
  114299. /**
  114300. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114301. * makes the reflect vector face the model (under horizon).
  114302. */
  114303. protected _useHorizonOcclusion: boolean;
  114304. /**
  114305. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114306. * too much the area relying on ambient texture to define their ambient occlusion.
  114307. */
  114308. protected _useRadianceOcclusion: boolean;
  114309. /**
  114310. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114311. */
  114312. protected _useAlphaFromAlbedoTexture: boolean;
  114313. /**
  114314. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114315. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114316. */
  114317. protected _useSpecularOverAlpha: boolean;
  114318. /**
  114319. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114320. */
  114321. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114322. /**
  114323. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114324. */
  114325. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114326. /**
  114327. * Specifies if the metallic texture contains the roughness information in its green channel.
  114328. */
  114329. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114330. /**
  114331. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114332. */
  114333. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114334. /**
  114335. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114336. */
  114337. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114338. /**
  114339. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114340. */
  114341. protected _useAmbientInGrayScale: boolean;
  114342. /**
  114343. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114344. * The material will try to infer what glossiness each pixel should be.
  114345. */
  114346. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114347. /**
  114348. * Defines the falloff type used in this material.
  114349. * It by default is Physical.
  114350. */
  114351. protected _lightFalloff: number;
  114352. /**
  114353. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114354. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114355. */
  114356. protected _useRadianceOverAlpha: boolean;
  114357. /**
  114358. * Allows using an object space normal map (instead of tangent space).
  114359. */
  114360. protected _useObjectSpaceNormalMap: boolean;
  114361. /**
  114362. * Allows using the bump map in parallax mode.
  114363. */
  114364. protected _useParallax: boolean;
  114365. /**
  114366. * Allows using the bump map in parallax occlusion mode.
  114367. */
  114368. protected _useParallaxOcclusion: boolean;
  114369. /**
  114370. * Controls the scale bias of the parallax mode.
  114371. */
  114372. protected _parallaxScaleBias: number;
  114373. /**
  114374. * If sets to true, disables all the lights affecting the material.
  114375. */
  114376. protected _disableLighting: boolean;
  114377. /**
  114378. * Number of Simultaneous lights allowed on the material.
  114379. */
  114380. protected _maxSimultaneousLights: number;
  114381. /**
  114382. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114383. */
  114384. protected _invertNormalMapX: boolean;
  114385. /**
  114386. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114387. */
  114388. protected _invertNormalMapY: boolean;
  114389. /**
  114390. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114391. */
  114392. protected _twoSidedLighting: boolean;
  114393. /**
  114394. * Defines the alpha limits in alpha test mode.
  114395. */
  114396. protected _alphaCutOff: number;
  114397. /**
  114398. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114399. */
  114400. protected _forceAlphaTest: boolean;
  114401. /**
  114402. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114403. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114404. */
  114405. protected _useAlphaFresnel: boolean;
  114406. /**
  114407. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114408. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114409. */
  114410. protected _useLinearAlphaFresnel: boolean;
  114411. /**
  114412. * The transparency mode of the material.
  114413. */
  114414. protected _transparencyMode: Nullable<number>;
  114415. /**
  114416. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114417. * from cos thetav and roughness:
  114418. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114419. */
  114420. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114421. /**
  114422. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114423. */
  114424. protected _forceIrradianceInFragment: boolean;
  114425. /**
  114426. * Force normal to face away from face.
  114427. */
  114428. protected _forceNormalForward: boolean;
  114429. /**
  114430. * Enables specular anti aliasing in the PBR shader.
  114431. * It will both interacts on the Geometry for analytical and IBL lighting.
  114432. * It also prefilter the roughness map based on the bump values.
  114433. */
  114434. protected _enableSpecularAntiAliasing: boolean;
  114435. /**
  114436. * Default configuration related to image processing available in the PBR Material.
  114437. */
  114438. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114439. /**
  114440. * Keep track of the image processing observer to allow dispose and replace.
  114441. */
  114442. private _imageProcessingObserver;
  114443. /**
  114444. * Attaches a new image processing configuration to the PBR Material.
  114445. * @param configuration
  114446. */
  114447. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114448. /**
  114449. * Stores the available render targets.
  114450. */
  114451. private _renderTargets;
  114452. /**
  114453. * Sets the global ambient color for the material used in lighting calculations.
  114454. */
  114455. private _globalAmbientColor;
  114456. /**
  114457. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114458. */
  114459. private _useLogarithmicDepth;
  114460. /**
  114461. * If set to true, no lighting calculations will be applied.
  114462. */
  114463. private _unlit;
  114464. private _debugMode;
  114465. /**
  114466. * @hidden
  114467. * This is reserved for the inspector.
  114468. * Defines the material debug mode.
  114469. * It helps seeing only some components of the material while troubleshooting.
  114470. */
  114471. debugMode: number;
  114472. /**
  114473. * @hidden
  114474. * This is reserved for the inspector.
  114475. * Specify from where on screen the debug mode should start.
  114476. * The value goes from -1 (full screen) to 1 (not visible)
  114477. * It helps with side by side comparison against the final render
  114478. * This defaults to -1
  114479. */
  114480. private debugLimit;
  114481. /**
  114482. * @hidden
  114483. * This is reserved for the inspector.
  114484. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114485. * You can use the factor to better multiply the final value.
  114486. */
  114487. private debugFactor;
  114488. /**
  114489. * Defines the clear coat layer parameters for the material.
  114490. */
  114491. readonly clearCoat: PBRClearCoatConfiguration;
  114492. /**
  114493. * Defines the anisotropic parameters for the material.
  114494. */
  114495. readonly anisotropy: PBRAnisotropicConfiguration;
  114496. /**
  114497. * Defines the BRDF parameters for the material.
  114498. */
  114499. readonly brdf: PBRBRDFConfiguration;
  114500. /**
  114501. * Defines the Sheen parameters for the material.
  114502. */
  114503. readonly sheen: PBRSheenConfiguration;
  114504. /**
  114505. * Defines the SubSurface parameters for the material.
  114506. */
  114507. readonly subSurface: PBRSubSurfaceConfiguration;
  114508. /**
  114509. * Custom callback helping to override the default shader used in the material.
  114510. */
  114511. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114512. protected _rebuildInParallel: boolean;
  114513. /**
  114514. * Instantiates a new PBRMaterial instance.
  114515. *
  114516. * @param name The material name
  114517. * @param scene The scene the material will be use in.
  114518. */
  114519. constructor(name: string, scene: Scene);
  114520. /**
  114521. * Gets a boolean indicating that current material needs to register RTT
  114522. */
  114523. readonly hasRenderTargetTextures: boolean;
  114524. /**
  114525. * Gets the name of the material class.
  114526. */
  114527. getClassName(): string;
  114528. /**
  114529. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114530. */
  114531. /**
  114532. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114533. */
  114534. useLogarithmicDepth: boolean;
  114535. /**
  114536. * Gets the current transparency mode.
  114537. */
  114538. /**
  114539. * Sets the transparency mode of the material.
  114540. *
  114541. * | Value | Type | Description |
  114542. * | ----- | ----------------------------------- | ----------- |
  114543. * | 0 | OPAQUE | |
  114544. * | 1 | ALPHATEST | |
  114545. * | 2 | ALPHABLEND | |
  114546. * | 3 | ALPHATESTANDBLEND | |
  114547. *
  114548. */
  114549. transparencyMode: Nullable<number>;
  114550. /**
  114551. * Returns true if alpha blending should be disabled.
  114552. */
  114553. private readonly _disableAlphaBlending;
  114554. /**
  114555. * Specifies whether or not this material should be rendered in alpha blend mode.
  114556. */
  114557. needAlphaBlending(): boolean;
  114558. /**
  114559. * Specifies if the mesh will require alpha blending.
  114560. * @param mesh - BJS mesh.
  114561. */
  114562. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114563. /**
  114564. * Specifies whether or not this material should be rendered in alpha test mode.
  114565. */
  114566. needAlphaTesting(): boolean;
  114567. /**
  114568. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114569. */
  114570. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114571. /**
  114572. * Gets the texture used for the alpha test.
  114573. */
  114574. getAlphaTestTexture(): Nullable<BaseTexture>;
  114575. /**
  114576. * Specifies that the submesh is ready to be used.
  114577. * @param mesh - BJS mesh.
  114578. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114579. * @param useInstances - Specifies that instances should be used.
  114580. * @returns - boolean indicating that the submesh is ready or not.
  114581. */
  114582. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114583. /**
  114584. * Specifies if the material uses metallic roughness workflow.
  114585. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114586. */
  114587. isMetallicWorkflow(): boolean;
  114588. private _prepareEffect;
  114589. private _prepareDefines;
  114590. /**
  114591. * Force shader compilation
  114592. */
  114593. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114594. clipPlane: boolean;
  114595. }>): void;
  114596. /**
  114597. * Initializes the uniform buffer layout for the shader.
  114598. */
  114599. buildUniformLayout(): void;
  114600. /**
  114601. * Unbinds the material from the mesh
  114602. */
  114603. unbind(): void;
  114604. /**
  114605. * Binds the submesh data.
  114606. * @param world - The world matrix.
  114607. * @param mesh - The BJS mesh.
  114608. * @param subMesh - A submesh of the BJS mesh.
  114609. */
  114610. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114611. /**
  114612. * Returns the animatable textures.
  114613. * @returns - Array of animatable textures.
  114614. */
  114615. getAnimatables(): IAnimatable[];
  114616. /**
  114617. * Returns the texture used for reflections.
  114618. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114619. */
  114620. private _getReflectionTexture;
  114621. /**
  114622. * Returns an array of the actively used textures.
  114623. * @returns - Array of BaseTextures
  114624. */
  114625. getActiveTextures(): BaseTexture[];
  114626. /**
  114627. * Checks to see if a texture is used in the material.
  114628. * @param texture - Base texture to use.
  114629. * @returns - Boolean specifying if a texture is used in the material.
  114630. */
  114631. hasTexture(texture: BaseTexture): boolean;
  114632. /**
  114633. * Disposes the resources of the material.
  114634. * @param forceDisposeEffect - Forces the disposal of effects.
  114635. * @param forceDisposeTextures - Forces the disposal of all textures.
  114636. */
  114637. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114638. }
  114639. }
  114640. declare module BABYLON {
  114641. /**
  114642. * The Physically based material of BJS.
  114643. *
  114644. * This offers the main features of a standard PBR material.
  114645. * For more information, please refer to the documentation :
  114646. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114647. */
  114648. export class PBRMaterial extends PBRBaseMaterial {
  114649. /**
  114650. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114651. */
  114652. static readonly PBRMATERIAL_OPAQUE: number;
  114653. /**
  114654. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114655. */
  114656. static readonly PBRMATERIAL_ALPHATEST: number;
  114657. /**
  114658. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114659. */
  114660. static readonly PBRMATERIAL_ALPHABLEND: number;
  114661. /**
  114662. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114663. * They are also discarded below the alpha cutoff threshold to improve performances.
  114664. */
  114665. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114666. /**
  114667. * Defines the default value of how much AO map is occluding the analytical lights
  114668. * (point spot...).
  114669. */
  114670. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114671. /**
  114672. * Intensity of the direct lights e.g. the four lights available in your scene.
  114673. * This impacts both the direct diffuse and specular highlights.
  114674. */
  114675. directIntensity: number;
  114676. /**
  114677. * Intensity of the emissive part of the material.
  114678. * This helps controlling the emissive effect without modifying the emissive color.
  114679. */
  114680. emissiveIntensity: number;
  114681. /**
  114682. * Intensity of the environment e.g. how much the environment will light the object
  114683. * either through harmonics for rough material or through the refelction for shiny ones.
  114684. */
  114685. environmentIntensity: number;
  114686. /**
  114687. * This is a special control allowing the reduction of the specular highlights coming from the
  114688. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114689. */
  114690. specularIntensity: number;
  114691. /**
  114692. * Debug Control allowing disabling the bump map on this material.
  114693. */
  114694. disableBumpMap: boolean;
  114695. /**
  114696. * AKA Diffuse Texture in standard nomenclature.
  114697. */
  114698. albedoTexture: BaseTexture;
  114699. /**
  114700. * AKA Occlusion Texture in other nomenclature.
  114701. */
  114702. ambientTexture: BaseTexture;
  114703. /**
  114704. * AKA Occlusion Texture Intensity in other nomenclature.
  114705. */
  114706. ambientTextureStrength: number;
  114707. /**
  114708. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114709. * 1 means it completely occludes it
  114710. * 0 mean it has no impact
  114711. */
  114712. ambientTextureImpactOnAnalyticalLights: number;
  114713. /**
  114714. * Stores the alpha values in a texture.
  114715. */
  114716. opacityTexture: BaseTexture;
  114717. /**
  114718. * Stores the reflection values in a texture.
  114719. */
  114720. reflectionTexture: Nullable<BaseTexture>;
  114721. /**
  114722. * Stores the emissive values in a texture.
  114723. */
  114724. emissiveTexture: BaseTexture;
  114725. /**
  114726. * AKA Specular texture in other nomenclature.
  114727. */
  114728. reflectivityTexture: BaseTexture;
  114729. /**
  114730. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114731. */
  114732. metallicTexture: BaseTexture;
  114733. /**
  114734. * Specifies the metallic scalar of the metallic/roughness workflow.
  114735. * Can also be used to scale the metalness values of the metallic texture.
  114736. */
  114737. metallic: Nullable<number>;
  114738. /**
  114739. * Specifies the roughness scalar of the metallic/roughness workflow.
  114740. * Can also be used to scale the roughness values of the metallic texture.
  114741. */
  114742. roughness: Nullable<number>;
  114743. /**
  114744. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114745. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114746. */
  114747. microSurfaceTexture: BaseTexture;
  114748. /**
  114749. * Stores surface normal data used to displace a mesh in a texture.
  114750. */
  114751. bumpTexture: BaseTexture;
  114752. /**
  114753. * Stores the pre-calculated light information of a mesh in a texture.
  114754. */
  114755. lightmapTexture: BaseTexture;
  114756. /**
  114757. * Stores the refracted light information in a texture.
  114758. */
  114759. refractionTexture: Nullable<BaseTexture>;
  114760. /**
  114761. * The color of a material in ambient lighting.
  114762. */
  114763. ambientColor: Color3;
  114764. /**
  114765. * AKA Diffuse Color in other nomenclature.
  114766. */
  114767. albedoColor: Color3;
  114768. /**
  114769. * AKA Specular Color in other nomenclature.
  114770. */
  114771. reflectivityColor: Color3;
  114772. /**
  114773. * The color reflected from the material.
  114774. */
  114775. reflectionColor: Color3;
  114776. /**
  114777. * The color emitted from the material.
  114778. */
  114779. emissiveColor: Color3;
  114780. /**
  114781. * AKA Glossiness in other nomenclature.
  114782. */
  114783. microSurface: number;
  114784. /**
  114785. * source material index of refraction (IOR)' / 'destination material IOR.
  114786. */
  114787. indexOfRefraction: number;
  114788. /**
  114789. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114790. */
  114791. invertRefractionY: boolean;
  114792. /**
  114793. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114794. * Materials half opaque for instance using refraction could benefit from this control.
  114795. */
  114796. linkRefractionWithTransparency: boolean;
  114797. /**
  114798. * If true, the light map contains occlusion information instead of lighting info.
  114799. */
  114800. useLightmapAsShadowmap: boolean;
  114801. /**
  114802. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114803. */
  114804. useAlphaFromAlbedoTexture: boolean;
  114805. /**
  114806. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114807. */
  114808. forceAlphaTest: boolean;
  114809. /**
  114810. * Defines the alpha limits in alpha test mode.
  114811. */
  114812. alphaCutOff: number;
  114813. /**
  114814. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  114815. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114816. */
  114817. useSpecularOverAlpha: boolean;
  114818. /**
  114819. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114820. */
  114821. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114822. /**
  114823. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114824. */
  114825. useRoughnessFromMetallicTextureAlpha: boolean;
  114826. /**
  114827. * Specifies if the metallic texture contains the roughness information in its green channel.
  114828. */
  114829. useRoughnessFromMetallicTextureGreen: boolean;
  114830. /**
  114831. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114832. */
  114833. useMetallnessFromMetallicTextureBlue: boolean;
  114834. /**
  114835. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114836. */
  114837. useAmbientOcclusionFromMetallicTextureRed: boolean;
  114838. /**
  114839. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114840. */
  114841. useAmbientInGrayScale: boolean;
  114842. /**
  114843. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114844. * The material will try to infer what glossiness each pixel should be.
  114845. */
  114846. useAutoMicroSurfaceFromReflectivityMap: boolean;
  114847. /**
  114848. * BJS is using an harcoded light falloff based on a manually sets up range.
  114849. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114850. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114851. */
  114852. /**
  114853. * BJS is using an harcoded light falloff based on a manually sets up range.
  114854. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114855. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114856. */
  114857. usePhysicalLightFalloff: boolean;
  114858. /**
  114859. * In order to support the falloff compatibility with gltf, a special mode has been added
  114860. * to reproduce the gltf light falloff.
  114861. */
  114862. /**
  114863. * In order to support the falloff compatibility with gltf, a special mode has been added
  114864. * to reproduce the gltf light falloff.
  114865. */
  114866. useGLTFLightFalloff: boolean;
  114867. /**
  114868. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114869. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114870. */
  114871. useRadianceOverAlpha: boolean;
  114872. /**
  114873. * Allows using an object space normal map (instead of tangent space).
  114874. */
  114875. useObjectSpaceNormalMap: boolean;
  114876. /**
  114877. * Allows using the bump map in parallax mode.
  114878. */
  114879. useParallax: boolean;
  114880. /**
  114881. * Allows using the bump map in parallax occlusion mode.
  114882. */
  114883. useParallaxOcclusion: boolean;
  114884. /**
  114885. * Controls the scale bias of the parallax mode.
  114886. */
  114887. parallaxScaleBias: number;
  114888. /**
  114889. * If sets to true, disables all the lights affecting the material.
  114890. */
  114891. disableLighting: boolean;
  114892. /**
  114893. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114894. */
  114895. forceIrradianceInFragment: boolean;
  114896. /**
  114897. * Number of Simultaneous lights allowed on the material.
  114898. */
  114899. maxSimultaneousLights: number;
  114900. /**
  114901. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114902. */
  114903. invertNormalMapX: boolean;
  114904. /**
  114905. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114906. */
  114907. invertNormalMapY: boolean;
  114908. /**
  114909. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114910. */
  114911. twoSidedLighting: boolean;
  114912. /**
  114913. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114914. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114915. */
  114916. useAlphaFresnel: boolean;
  114917. /**
  114918. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114919. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114920. */
  114921. useLinearAlphaFresnel: boolean;
  114922. /**
  114923. * Let user defines the brdf lookup texture used for IBL.
  114924. * A default 8bit version is embedded but you could point at :
  114925. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  114926. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  114927. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  114928. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  114929. */
  114930. environmentBRDFTexture: Nullable<BaseTexture>;
  114931. /**
  114932. * Force normal to face away from face.
  114933. */
  114934. forceNormalForward: boolean;
  114935. /**
  114936. * Enables specular anti aliasing in the PBR shader.
  114937. * It will both interacts on the Geometry for analytical and IBL lighting.
  114938. * It also prefilter the roughness map based on the bump values.
  114939. */
  114940. enableSpecularAntiAliasing: boolean;
  114941. /**
  114942. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114943. * makes the reflect vector face the model (under horizon).
  114944. */
  114945. useHorizonOcclusion: boolean;
  114946. /**
  114947. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114948. * too much the area relying on ambient texture to define their ambient occlusion.
  114949. */
  114950. useRadianceOcclusion: boolean;
  114951. /**
  114952. * If set to true, no lighting calculations will be applied.
  114953. */
  114954. unlit: boolean;
  114955. /**
  114956. * Gets the image processing configuration used either in this material.
  114957. */
  114958. /**
  114959. * Sets the Default image processing configuration used either in the this material.
  114960. *
  114961. * If sets to null, the scene one is in use.
  114962. */
  114963. imageProcessingConfiguration: ImageProcessingConfiguration;
  114964. /**
  114965. * Gets wether the color curves effect is enabled.
  114966. */
  114967. /**
  114968. * Sets wether the color curves effect is enabled.
  114969. */
  114970. cameraColorCurvesEnabled: boolean;
  114971. /**
  114972. * Gets wether the color grading effect is enabled.
  114973. */
  114974. /**
  114975. * Gets wether the color grading effect is enabled.
  114976. */
  114977. cameraColorGradingEnabled: boolean;
  114978. /**
  114979. * Gets wether tonemapping is enabled or not.
  114980. */
  114981. /**
  114982. * Sets wether tonemapping is enabled or not
  114983. */
  114984. cameraToneMappingEnabled: boolean;
  114985. /**
  114986. * The camera exposure used on this material.
  114987. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114988. * This corresponds to a photographic exposure.
  114989. */
  114990. /**
  114991. * The camera exposure used on this material.
  114992. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114993. * This corresponds to a photographic exposure.
  114994. */
  114995. cameraExposure: number;
  114996. /**
  114997. * Gets The camera contrast used on this material.
  114998. */
  114999. /**
  115000. * Sets The camera contrast used on this material.
  115001. */
  115002. cameraContrast: number;
  115003. /**
  115004. * Gets the Color Grading 2D Lookup Texture.
  115005. */
  115006. /**
  115007. * Sets the Color Grading 2D Lookup Texture.
  115008. */
  115009. cameraColorGradingTexture: Nullable<BaseTexture>;
  115010. /**
  115011. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115012. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115013. * 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;
  115014. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115015. */
  115016. /**
  115017. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115018. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115019. * 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;
  115020. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115021. */
  115022. cameraColorCurves: Nullable<ColorCurves>;
  115023. /**
  115024. * Instantiates a new PBRMaterial instance.
  115025. *
  115026. * @param name The material name
  115027. * @param scene The scene the material will be use in.
  115028. */
  115029. constructor(name: string, scene: Scene);
  115030. /**
  115031. * Returns the name of this material class.
  115032. */
  115033. getClassName(): string;
  115034. /**
  115035. * Makes a duplicate of the current material.
  115036. * @param name - name to use for the new material.
  115037. */
  115038. clone(name: string): PBRMaterial;
  115039. /**
  115040. * Serializes this PBR Material.
  115041. * @returns - An object with the serialized material.
  115042. */
  115043. serialize(): any;
  115044. /**
  115045. * Parses a PBR Material from a serialized object.
  115046. * @param source - Serialized object.
  115047. * @param scene - BJS scene instance.
  115048. * @param rootUrl - url for the scene object
  115049. * @returns - PBRMaterial
  115050. */
  115051. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115052. }
  115053. }
  115054. declare module BABYLON {
  115055. /**
  115056. * Direct draw surface info
  115057. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115058. */
  115059. export interface DDSInfo {
  115060. /**
  115061. * Width of the texture
  115062. */
  115063. width: number;
  115064. /**
  115065. * Width of the texture
  115066. */
  115067. height: number;
  115068. /**
  115069. * Number of Mipmaps for the texture
  115070. * @see https://en.wikipedia.org/wiki/Mipmap
  115071. */
  115072. mipmapCount: number;
  115073. /**
  115074. * If the textures format is a known fourCC format
  115075. * @see https://www.fourcc.org/
  115076. */
  115077. isFourCC: boolean;
  115078. /**
  115079. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115080. */
  115081. isRGB: boolean;
  115082. /**
  115083. * If the texture is a lumincance format
  115084. */
  115085. isLuminance: boolean;
  115086. /**
  115087. * If this is a cube texture
  115088. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115089. */
  115090. isCube: boolean;
  115091. /**
  115092. * If the texture is a compressed format eg. FOURCC_DXT1
  115093. */
  115094. isCompressed: boolean;
  115095. /**
  115096. * The dxgiFormat of the texture
  115097. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115098. */
  115099. dxgiFormat: number;
  115100. /**
  115101. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115102. */
  115103. textureType: number;
  115104. /**
  115105. * Sphericle polynomial created for the dds texture
  115106. */
  115107. sphericalPolynomial?: SphericalPolynomial;
  115108. }
  115109. /**
  115110. * Class used to provide DDS decompression tools
  115111. */
  115112. export class DDSTools {
  115113. /**
  115114. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115115. */
  115116. static StoreLODInAlphaChannel: boolean;
  115117. /**
  115118. * Gets DDS information from an array buffer
  115119. * @param arrayBuffer defines the array buffer to read data from
  115120. * @returns the DDS information
  115121. */
  115122. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115123. private static _FloatView;
  115124. private static _Int32View;
  115125. private static _ToHalfFloat;
  115126. private static _FromHalfFloat;
  115127. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115128. private static _GetHalfFloatRGBAArrayBuffer;
  115129. private static _GetFloatRGBAArrayBuffer;
  115130. private static _GetFloatAsUIntRGBAArrayBuffer;
  115131. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115132. private static _GetRGBAArrayBuffer;
  115133. private static _ExtractLongWordOrder;
  115134. private static _GetRGBArrayBuffer;
  115135. private static _GetLuminanceArrayBuffer;
  115136. /**
  115137. * Uploads DDS Levels to a Babylon Texture
  115138. * @hidden
  115139. */
  115140. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115141. }
  115142. interface ThinEngine {
  115143. /**
  115144. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115145. * @param rootUrl defines the url where the file to load is located
  115146. * @param scene defines the current scene
  115147. * @param lodScale defines scale to apply to the mip map selection
  115148. * @param lodOffset defines offset to apply to the mip map selection
  115149. * @param onLoad defines an optional callback raised when the texture is loaded
  115150. * @param onError defines an optional callback raised if there is an issue to load the texture
  115151. * @param format defines the format of the data
  115152. * @param forcedExtension defines the extension to use to pick the right loader
  115153. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115154. * @returns the cube texture as an InternalTexture
  115155. */
  115156. 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;
  115157. }
  115158. }
  115159. declare module BABYLON {
  115160. /**
  115161. * Implementation of the DDS Texture Loader.
  115162. * @hidden
  115163. */
  115164. export class _DDSTextureLoader implements IInternalTextureLoader {
  115165. /**
  115166. * Defines wether the loader supports cascade loading the different faces.
  115167. */
  115168. readonly supportCascades: boolean;
  115169. /**
  115170. * This returns if the loader support the current file information.
  115171. * @param extension defines the file extension of the file being loaded
  115172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115173. * @param fallback defines the fallback internal texture if any
  115174. * @param isBase64 defines whether the texture is encoded as a base64
  115175. * @param isBuffer defines whether the texture data are stored as a buffer
  115176. * @returns true if the loader can load the specified file
  115177. */
  115178. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115179. /**
  115180. * Transform the url before loading if required.
  115181. * @param rootUrl the url of the texture
  115182. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115183. * @returns the transformed texture
  115184. */
  115185. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115186. /**
  115187. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115188. * @param rootUrl the url of the texture
  115189. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115190. * @returns the fallback texture
  115191. */
  115192. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115193. /**
  115194. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115195. * @param data contains the texture data
  115196. * @param texture defines the BabylonJS internal texture
  115197. * @param createPolynomials will be true if polynomials have been requested
  115198. * @param onLoad defines the callback to trigger once the texture is ready
  115199. * @param onError defines the callback to trigger in case of error
  115200. */
  115201. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115202. /**
  115203. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115204. * @param data contains the texture data
  115205. * @param texture defines the BabylonJS internal texture
  115206. * @param callback defines the method to call once ready to upload
  115207. */
  115208. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115209. }
  115210. }
  115211. declare module BABYLON {
  115212. /**
  115213. * Implementation of the ENV Texture Loader.
  115214. * @hidden
  115215. */
  115216. export class _ENVTextureLoader implements IInternalTextureLoader {
  115217. /**
  115218. * Defines wether the loader supports cascade loading the different faces.
  115219. */
  115220. readonly supportCascades: boolean;
  115221. /**
  115222. * This returns if the loader support the current file information.
  115223. * @param extension defines the file extension of the file being loaded
  115224. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115225. * @param fallback defines the fallback internal texture if any
  115226. * @param isBase64 defines whether the texture is encoded as a base64
  115227. * @param isBuffer defines whether the texture data are stored as a buffer
  115228. * @returns true if the loader can load the specified file
  115229. */
  115230. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115231. /**
  115232. * Transform the url before loading if required.
  115233. * @param rootUrl the url of the texture
  115234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115235. * @returns the transformed texture
  115236. */
  115237. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115238. /**
  115239. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115240. * @param rootUrl the url of the texture
  115241. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115242. * @returns the fallback texture
  115243. */
  115244. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115245. /**
  115246. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115247. * @param data contains the texture data
  115248. * @param texture defines the BabylonJS internal texture
  115249. * @param createPolynomials will be true if polynomials have been requested
  115250. * @param onLoad defines the callback to trigger once the texture is ready
  115251. * @param onError defines the callback to trigger in case of error
  115252. */
  115253. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115254. /**
  115255. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115256. * @param data contains the texture data
  115257. * @param texture defines the BabylonJS internal texture
  115258. * @param callback defines the method to call once ready to upload
  115259. */
  115260. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115261. }
  115262. }
  115263. declare module BABYLON {
  115264. /**
  115265. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115266. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115267. */
  115268. export class KhronosTextureContainer {
  115269. /** contents of the KTX container file */
  115270. arrayBuffer: any;
  115271. private static HEADER_LEN;
  115272. private static COMPRESSED_2D;
  115273. private static COMPRESSED_3D;
  115274. private static TEX_2D;
  115275. private static TEX_3D;
  115276. /**
  115277. * Gets the openGL type
  115278. */
  115279. glType: number;
  115280. /**
  115281. * Gets the openGL type size
  115282. */
  115283. glTypeSize: number;
  115284. /**
  115285. * Gets the openGL format
  115286. */
  115287. glFormat: number;
  115288. /**
  115289. * Gets the openGL internal format
  115290. */
  115291. glInternalFormat: number;
  115292. /**
  115293. * Gets the base internal format
  115294. */
  115295. glBaseInternalFormat: number;
  115296. /**
  115297. * Gets image width in pixel
  115298. */
  115299. pixelWidth: number;
  115300. /**
  115301. * Gets image height in pixel
  115302. */
  115303. pixelHeight: number;
  115304. /**
  115305. * Gets image depth in pixels
  115306. */
  115307. pixelDepth: number;
  115308. /**
  115309. * Gets the number of array elements
  115310. */
  115311. numberOfArrayElements: number;
  115312. /**
  115313. * Gets the number of faces
  115314. */
  115315. numberOfFaces: number;
  115316. /**
  115317. * Gets the number of mipmap levels
  115318. */
  115319. numberOfMipmapLevels: number;
  115320. /**
  115321. * Gets the bytes of key value data
  115322. */
  115323. bytesOfKeyValueData: number;
  115324. /**
  115325. * Gets the load type
  115326. */
  115327. loadType: number;
  115328. /**
  115329. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115330. */
  115331. isInvalid: boolean;
  115332. /**
  115333. * Creates a new KhronosTextureContainer
  115334. * @param arrayBuffer contents of the KTX container file
  115335. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115336. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115337. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115338. */
  115339. constructor(
  115340. /** contents of the KTX container file */
  115341. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115342. /**
  115343. * Uploads KTX content to a Babylon Texture.
  115344. * It is assumed that the texture has already been created & is currently bound
  115345. * @hidden
  115346. */
  115347. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115348. private _upload2DCompressedLevels;
  115349. }
  115350. }
  115351. declare module BABYLON {
  115352. /**
  115353. * Implementation of the KTX Texture Loader.
  115354. * @hidden
  115355. */
  115356. export class _KTXTextureLoader implements IInternalTextureLoader {
  115357. /**
  115358. * Defines wether the loader supports cascade loading the different faces.
  115359. */
  115360. readonly supportCascades: boolean;
  115361. /**
  115362. * This returns if the loader support the current file information.
  115363. * @param extension defines the file extension of the file being loaded
  115364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115365. * @param fallback defines the fallback internal texture if any
  115366. * @param isBase64 defines whether the texture is encoded as a base64
  115367. * @param isBuffer defines whether the texture data are stored as a buffer
  115368. * @returns true if the loader can load the specified file
  115369. */
  115370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115371. /**
  115372. * Transform the url before loading if required.
  115373. * @param rootUrl the url of the texture
  115374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115375. * @returns the transformed texture
  115376. */
  115377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115378. /**
  115379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115380. * @param rootUrl the url of the texture
  115381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115382. * @returns the fallback texture
  115383. */
  115384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115385. /**
  115386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115387. * @param data contains the texture data
  115388. * @param texture defines the BabylonJS internal texture
  115389. * @param createPolynomials will be true if polynomials have been requested
  115390. * @param onLoad defines the callback to trigger once the texture is ready
  115391. * @param onError defines the callback to trigger in case of error
  115392. */
  115393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115394. /**
  115395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115396. * @param data contains the texture data
  115397. * @param texture defines the BabylonJS internal texture
  115398. * @param callback defines the method to call once ready to upload
  115399. */
  115400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115401. }
  115402. }
  115403. declare module BABYLON {
  115404. /**
  115405. * Options for the default xr helper
  115406. */
  115407. export class WebXRDefaultExperienceOptions {
  115408. /**
  115409. * Floor meshes that should be used for teleporting
  115410. */
  115411. floorMeshes: Array<AbstractMesh>;
  115412. }
  115413. /**
  115414. * Default experience which provides a similar setup to the previous webVRExperience
  115415. */
  115416. export class WebXRDefaultExperience {
  115417. /**
  115418. * Base experience
  115419. */
  115420. baseExperience: WebXRExperienceHelper;
  115421. /**
  115422. * Input experience extension
  115423. */
  115424. input: WebXRInput;
  115425. /**
  115426. * Loads the controller models
  115427. */
  115428. controllerModelLoader: WebXRControllerModelLoader;
  115429. /**
  115430. * Enables laser pointer and selection
  115431. */
  115432. pointerSelection: WebXRControllerPointerSelection;
  115433. /**
  115434. * Enables teleportation
  115435. */
  115436. teleportation: WebXRControllerTeleportation;
  115437. /**
  115438. * Enables ui for enetering/exiting xr
  115439. */
  115440. enterExitUI: WebXREnterExitUI;
  115441. /**
  115442. * Default output canvas xr should render to
  115443. */
  115444. outputCanvas: WebXRManagedOutputCanvas;
  115445. /**
  115446. * Creates the default xr experience
  115447. * @param scene scene
  115448. * @param options options for basic configuration
  115449. * @returns resulting WebXRDefaultExperience
  115450. */
  115451. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115452. private constructor();
  115453. /**
  115454. * DIsposes of the experience helper
  115455. */
  115456. dispose(): void;
  115457. }
  115458. }
  115459. declare module BABYLON {
  115460. /** @hidden */
  115461. export var _forceSceneHelpersToBundle: boolean;
  115462. interface Scene {
  115463. /**
  115464. * Creates a default light for the scene.
  115465. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115466. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115467. */
  115468. createDefaultLight(replace?: boolean): void;
  115469. /**
  115470. * Creates a default camera for the scene.
  115471. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115472. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115473. * @param replace has default false, when true replaces the active camera in the scene
  115474. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115475. */
  115476. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115477. /**
  115478. * Creates a default camera and a default light.
  115479. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115480. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115481. * @param replace has the default false, when true replaces the active camera/light in the scene
  115482. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115483. */
  115484. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115485. /**
  115486. * Creates a new sky box
  115487. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115488. * @param environmentTexture defines the texture to use as environment texture
  115489. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115490. * @param scale defines the overall scale of the skybox
  115491. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115492. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115493. * @returns a new mesh holding the sky box
  115494. */
  115495. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115496. /**
  115497. * Creates a new environment
  115498. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115499. * @param options defines the options you can use to configure the environment
  115500. * @returns the new EnvironmentHelper
  115501. */
  115502. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115503. /**
  115504. * Creates a new VREXperienceHelper
  115505. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115506. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115507. * @returns a new VREXperienceHelper
  115508. */
  115509. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115510. /**
  115511. * Creates a new WebXRDefaultExperience
  115512. * @see http://doc.babylonjs.com/how_to/webxr
  115513. * @param options experience options
  115514. * @returns a promise for a new WebXRDefaultExperience
  115515. */
  115516. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115517. }
  115518. }
  115519. declare module BABYLON {
  115520. /**
  115521. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115522. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115523. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115524. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115525. */
  115526. export class VideoDome extends TransformNode {
  115527. /**
  115528. * Define the video source as a Monoscopic panoramic 360 video.
  115529. */
  115530. static readonly MODE_MONOSCOPIC: number;
  115531. /**
  115532. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115533. */
  115534. static readonly MODE_TOPBOTTOM: number;
  115535. /**
  115536. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115537. */
  115538. static readonly MODE_SIDEBYSIDE: number;
  115539. private _halfDome;
  115540. private _useDirectMapping;
  115541. /**
  115542. * The video texture being displayed on the sphere
  115543. */
  115544. protected _videoTexture: VideoTexture;
  115545. /**
  115546. * Gets the video texture being displayed on the sphere
  115547. */
  115548. readonly videoTexture: VideoTexture;
  115549. /**
  115550. * The skybox material
  115551. */
  115552. protected _material: BackgroundMaterial;
  115553. /**
  115554. * The surface used for the skybox
  115555. */
  115556. protected _mesh: Mesh;
  115557. /**
  115558. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115559. */
  115560. private _halfDomeMask;
  115561. /**
  115562. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115563. * Also see the options.resolution property.
  115564. */
  115565. fovMultiplier: number;
  115566. private _videoMode;
  115567. /**
  115568. * Gets or set the current video mode for the video. It can be:
  115569. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115570. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115571. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115572. */
  115573. videoMode: number;
  115574. /**
  115575. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115576. *
  115577. */
  115578. /**
  115579. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115580. */
  115581. halfDome: boolean;
  115582. /**
  115583. * Oberserver used in Stereoscopic VR Mode.
  115584. */
  115585. private _onBeforeCameraRenderObserver;
  115586. /**
  115587. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115588. * @param name Element's name, child elements will append suffixes for their own names.
  115589. * @param urlsOrVideo defines the url(s) or the video element to use
  115590. * @param options An object containing optional or exposed sub element properties
  115591. */
  115592. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115593. resolution?: number;
  115594. clickToPlay?: boolean;
  115595. autoPlay?: boolean;
  115596. loop?: boolean;
  115597. size?: number;
  115598. poster?: string;
  115599. faceForward?: boolean;
  115600. useDirectMapping?: boolean;
  115601. halfDomeMode?: boolean;
  115602. }, scene: Scene);
  115603. private _changeVideoMode;
  115604. /**
  115605. * Releases resources associated with this node.
  115606. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115607. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115608. */
  115609. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115610. }
  115611. }
  115612. declare module BABYLON {
  115613. /**
  115614. * This class can be used to get instrumentation data from a Babylon engine
  115615. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115616. */
  115617. export class EngineInstrumentation implements IDisposable {
  115618. /**
  115619. * Define the instrumented engine.
  115620. */
  115621. engine: Engine;
  115622. private _captureGPUFrameTime;
  115623. private _gpuFrameTimeToken;
  115624. private _gpuFrameTime;
  115625. private _captureShaderCompilationTime;
  115626. private _shaderCompilationTime;
  115627. private _onBeginFrameObserver;
  115628. private _onEndFrameObserver;
  115629. private _onBeforeShaderCompilationObserver;
  115630. private _onAfterShaderCompilationObserver;
  115631. /**
  115632. * Gets the perf counter used for GPU frame time
  115633. */
  115634. readonly gpuFrameTimeCounter: PerfCounter;
  115635. /**
  115636. * Gets the GPU frame time capture status
  115637. */
  115638. /**
  115639. * Enable or disable the GPU frame time capture
  115640. */
  115641. captureGPUFrameTime: boolean;
  115642. /**
  115643. * Gets the perf counter used for shader compilation time
  115644. */
  115645. readonly shaderCompilationTimeCounter: PerfCounter;
  115646. /**
  115647. * Gets the shader compilation time capture status
  115648. */
  115649. /**
  115650. * Enable or disable the shader compilation time capture
  115651. */
  115652. captureShaderCompilationTime: boolean;
  115653. /**
  115654. * Instantiates a new engine instrumentation.
  115655. * This class can be used to get instrumentation data from a Babylon engine
  115656. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115657. * @param engine Defines the engine to instrument
  115658. */
  115659. constructor(
  115660. /**
  115661. * Define the instrumented engine.
  115662. */
  115663. engine: Engine);
  115664. /**
  115665. * Dispose and release associated resources.
  115666. */
  115667. dispose(): void;
  115668. }
  115669. }
  115670. declare module BABYLON {
  115671. /**
  115672. * This class can be used to get instrumentation data from a Babylon engine
  115673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115674. */
  115675. export class SceneInstrumentation implements IDisposable {
  115676. /**
  115677. * Defines the scene to instrument
  115678. */
  115679. scene: Scene;
  115680. private _captureActiveMeshesEvaluationTime;
  115681. private _activeMeshesEvaluationTime;
  115682. private _captureRenderTargetsRenderTime;
  115683. private _renderTargetsRenderTime;
  115684. private _captureFrameTime;
  115685. private _frameTime;
  115686. private _captureRenderTime;
  115687. private _renderTime;
  115688. private _captureInterFrameTime;
  115689. private _interFrameTime;
  115690. private _captureParticlesRenderTime;
  115691. private _particlesRenderTime;
  115692. private _captureSpritesRenderTime;
  115693. private _spritesRenderTime;
  115694. private _capturePhysicsTime;
  115695. private _physicsTime;
  115696. private _captureAnimationsTime;
  115697. private _animationsTime;
  115698. private _captureCameraRenderTime;
  115699. private _cameraRenderTime;
  115700. private _onBeforeActiveMeshesEvaluationObserver;
  115701. private _onAfterActiveMeshesEvaluationObserver;
  115702. private _onBeforeRenderTargetsRenderObserver;
  115703. private _onAfterRenderTargetsRenderObserver;
  115704. private _onAfterRenderObserver;
  115705. private _onBeforeDrawPhaseObserver;
  115706. private _onAfterDrawPhaseObserver;
  115707. private _onBeforeAnimationsObserver;
  115708. private _onBeforeParticlesRenderingObserver;
  115709. private _onAfterParticlesRenderingObserver;
  115710. private _onBeforeSpritesRenderingObserver;
  115711. private _onAfterSpritesRenderingObserver;
  115712. private _onBeforePhysicsObserver;
  115713. private _onAfterPhysicsObserver;
  115714. private _onAfterAnimationsObserver;
  115715. private _onBeforeCameraRenderObserver;
  115716. private _onAfterCameraRenderObserver;
  115717. /**
  115718. * Gets the perf counter used for active meshes evaluation time
  115719. */
  115720. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115721. /**
  115722. * Gets the active meshes evaluation time capture status
  115723. */
  115724. /**
  115725. * Enable or disable the active meshes evaluation time capture
  115726. */
  115727. captureActiveMeshesEvaluationTime: boolean;
  115728. /**
  115729. * Gets the perf counter used for render targets render time
  115730. */
  115731. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115732. /**
  115733. * Gets the render targets render time capture status
  115734. */
  115735. /**
  115736. * Enable or disable the render targets render time capture
  115737. */
  115738. captureRenderTargetsRenderTime: boolean;
  115739. /**
  115740. * Gets the perf counter used for particles render time
  115741. */
  115742. readonly particlesRenderTimeCounter: PerfCounter;
  115743. /**
  115744. * Gets the particles render time capture status
  115745. */
  115746. /**
  115747. * Enable or disable the particles render time capture
  115748. */
  115749. captureParticlesRenderTime: boolean;
  115750. /**
  115751. * Gets the perf counter used for sprites render time
  115752. */
  115753. readonly spritesRenderTimeCounter: PerfCounter;
  115754. /**
  115755. * Gets the sprites render time capture status
  115756. */
  115757. /**
  115758. * Enable or disable the sprites render time capture
  115759. */
  115760. captureSpritesRenderTime: boolean;
  115761. /**
  115762. * Gets the perf counter used for physics time
  115763. */
  115764. readonly physicsTimeCounter: PerfCounter;
  115765. /**
  115766. * Gets the physics time capture status
  115767. */
  115768. /**
  115769. * Enable or disable the physics time capture
  115770. */
  115771. capturePhysicsTime: boolean;
  115772. /**
  115773. * Gets the perf counter used for animations time
  115774. */
  115775. readonly animationsTimeCounter: PerfCounter;
  115776. /**
  115777. * Gets the animations time capture status
  115778. */
  115779. /**
  115780. * Enable or disable the animations time capture
  115781. */
  115782. captureAnimationsTime: boolean;
  115783. /**
  115784. * Gets the perf counter used for frame time capture
  115785. */
  115786. readonly frameTimeCounter: PerfCounter;
  115787. /**
  115788. * Gets the frame time capture status
  115789. */
  115790. /**
  115791. * Enable or disable the frame time capture
  115792. */
  115793. captureFrameTime: boolean;
  115794. /**
  115795. * Gets the perf counter used for inter-frames time capture
  115796. */
  115797. readonly interFrameTimeCounter: PerfCounter;
  115798. /**
  115799. * Gets the inter-frames time capture status
  115800. */
  115801. /**
  115802. * Enable or disable the inter-frames time capture
  115803. */
  115804. captureInterFrameTime: boolean;
  115805. /**
  115806. * Gets the perf counter used for render time capture
  115807. */
  115808. readonly renderTimeCounter: PerfCounter;
  115809. /**
  115810. * Gets the render time capture status
  115811. */
  115812. /**
  115813. * Enable or disable the render time capture
  115814. */
  115815. captureRenderTime: boolean;
  115816. /**
  115817. * Gets the perf counter used for camera render time capture
  115818. */
  115819. readonly cameraRenderTimeCounter: PerfCounter;
  115820. /**
  115821. * Gets the camera render time capture status
  115822. */
  115823. /**
  115824. * Enable or disable the camera render time capture
  115825. */
  115826. captureCameraRenderTime: boolean;
  115827. /**
  115828. * Gets the perf counter used for draw calls
  115829. */
  115830. readonly drawCallsCounter: PerfCounter;
  115831. /**
  115832. * Instantiates a new scene instrumentation.
  115833. * This class can be used to get instrumentation data from a Babylon engine
  115834. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115835. * @param scene Defines the scene to instrument
  115836. */
  115837. constructor(
  115838. /**
  115839. * Defines the scene to instrument
  115840. */
  115841. scene: Scene);
  115842. /**
  115843. * Dispose and release associated resources.
  115844. */
  115845. dispose(): void;
  115846. }
  115847. }
  115848. declare module BABYLON {
  115849. /** @hidden */
  115850. export var glowMapGenerationPixelShader: {
  115851. name: string;
  115852. shader: string;
  115853. };
  115854. }
  115855. declare module BABYLON {
  115856. /** @hidden */
  115857. export var glowMapGenerationVertexShader: {
  115858. name: string;
  115859. shader: string;
  115860. };
  115861. }
  115862. declare module BABYLON {
  115863. /**
  115864. * Effect layer options. This helps customizing the behaviour
  115865. * of the effect layer.
  115866. */
  115867. export interface IEffectLayerOptions {
  115868. /**
  115869. * Multiplication factor apply to the canvas size to compute the render target size
  115870. * used to generated the objects (the smaller the faster).
  115871. */
  115872. mainTextureRatio: number;
  115873. /**
  115874. * Enforces a fixed size texture to ensure effect stability across devices.
  115875. */
  115876. mainTextureFixedSize?: number;
  115877. /**
  115878. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  115879. */
  115880. alphaBlendingMode: number;
  115881. /**
  115882. * The camera attached to the layer.
  115883. */
  115884. camera: Nullable<Camera>;
  115885. /**
  115886. * The rendering group to draw the layer in.
  115887. */
  115888. renderingGroupId: number;
  115889. }
  115890. /**
  115891. * The effect layer Helps adding post process effect blended with the main pass.
  115892. *
  115893. * This can be for instance use to generate glow or higlight effects on the scene.
  115894. *
  115895. * The effect layer class can not be used directly and is intented to inherited from to be
  115896. * customized per effects.
  115897. */
  115898. export abstract class EffectLayer {
  115899. private _vertexBuffers;
  115900. private _indexBuffer;
  115901. private _cachedDefines;
  115902. private _effectLayerMapGenerationEffect;
  115903. private _effectLayerOptions;
  115904. private _mergeEffect;
  115905. protected _scene: Scene;
  115906. protected _engine: Engine;
  115907. protected _maxSize: number;
  115908. protected _mainTextureDesiredSize: ISize;
  115909. protected _mainTexture: RenderTargetTexture;
  115910. protected _shouldRender: boolean;
  115911. protected _postProcesses: PostProcess[];
  115912. protected _textures: BaseTexture[];
  115913. protected _emissiveTextureAndColor: {
  115914. texture: Nullable<BaseTexture>;
  115915. color: Color4;
  115916. };
  115917. /**
  115918. * The name of the layer
  115919. */
  115920. name: string;
  115921. /**
  115922. * The clear color of the texture used to generate the glow map.
  115923. */
  115924. neutralColor: Color4;
  115925. /**
  115926. * Specifies wether the highlight layer is enabled or not.
  115927. */
  115928. isEnabled: boolean;
  115929. /**
  115930. * Gets the camera attached to the layer.
  115931. */
  115932. readonly camera: Nullable<Camera>;
  115933. /**
  115934. * Gets the rendering group id the layer should render in.
  115935. */
  115936. renderingGroupId: number;
  115937. /**
  115938. * An event triggered when the effect layer has been disposed.
  115939. */
  115940. onDisposeObservable: Observable<EffectLayer>;
  115941. /**
  115942. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  115943. */
  115944. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  115945. /**
  115946. * An event triggered when the generated texture is being merged in the scene.
  115947. */
  115948. onBeforeComposeObservable: Observable<EffectLayer>;
  115949. /**
  115950. * An event triggered when the generated texture has been merged in the scene.
  115951. */
  115952. onAfterComposeObservable: Observable<EffectLayer>;
  115953. /**
  115954. * An event triggered when the efffect layer changes its size.
  115955. */
  115956. onSizeChangedObservable: Observable<EffectLayer>;
  115957. /** @hidden */
  115958. static _SceneComponentInitialization: (scene: Scene) => void;
  115959. /**
  115960. * Instantiates a new effect Layer and references it in the scene.
  115961. * @param name The name of the layer
  115962. * @param scene The scene to use the layer in
  115963. */
  115964. constructor(
  115965. /** The Friendly of the effect in the scene */
  115966. name: string, scene: Scene);
  115967. /**
  115968. * Get the effect name of the layer.
  115969. * @return The effect name
  115970. */
  115971. abstract getEffectName(): string;
  115972. /**
  115973. * Checks for the readiness of the element composing the layer.
  115974. * @param subMesh the mesh to check for
  115975. * @param useInstances specify wether or not to use instances to render the mesh
  115976. * @return true if ready otherwise, false
  115977. */
  115978. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115979. /**
  115980. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115981. * @returns true if the effect requires stencil during the main canvas render pass.
  115982. */
  115983. abstract needStencil(): boolean;
  115984. /**
  115985. * Create the merge effect. This is the shader use to blit the information back
  115986. * to the main canvas at the end of the scene rendering.
  115987. * @returns The effect containing the shader used to merge the effect on the main canvas
  115988. */
  115989. protected abstract _createMergeEffect(): Effect;
  115990. /**
  115991. * Creates the render target textures and post processes used in the effect layer.
  115992. */
  115993. protected abstract _createTextureAndPostProcesses(): void;
  115994. /**
  115995. * Implementation specific of rendering the generating effect on the main canvas.
  115996. * @param effect The effect used to render through
  115997. */
  115998. protected abstract _internalRender(effect: Effect): void;
  115999. /**
  116000. * Sets the required values for both the emissive texture and and the main color.
  116001. */
  116002. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116003. /**
  116004. * Free any resources and references associated to a mesh.
  116005. * Internal use
  116006. * @param mesh The mesh to free.
  116007. */
  116008. abstract _disposeMesh(mesh: Mesh): void;
  116009. /**
  116010. * Serializes this layer (Glow or Highlight for example)
  116011. * @returns a serialized layer object
  116012. */
  116013. abstract serialize?(): any;
  116014. /**
  116015. * Initializes the effect layer with the required options.
  116016. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116017. */
  116018. protected _init(options: Partial<IEffectLayerOptions>): void;
  116019. /**
  116020. * Generates the index buffer of the full screen quad blending to the main canvas.
  116021. */
  116022. private _generateIndexBuffer;
  116023. /**
  116024. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116025. */
  116026. private _generateVertexBuffer;
  116027. /**
  116028. * Sets the main texture desired size which is the closest power of two
  116029. * of the engine canvas size.
  116030. */
  116031. private _setMainTextureSize;
  116032. /**
  116033. * Creates the main texture for the effect layer.
  116034. */
  116035. protected _createMainTexture(): void;
  116036. /**
  116037. * Adds specific effects defines.
  116038. * @param defines The defines to add specifics to.
  116039. */
  116040. protected _addCustomEffectDefines(defines: string[]): void;
  116041. /**
  116042. * Checks for the readiness of the element composing the layer.
  116043. * @param subMesh the mesh to check for
  116044. * @param useInstances specify wether or not to use instances to render the mesh
  116045. * @param emissiveTexture the associated emissive texture used to generate the glow
  116046. * @return true if ready otherwise, false
  116047. */
  116048. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116049. /**
  116050. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116051. */
  116052. render(): void;
  116053. /**
  116054. * Determine if a given mesh will be used in the current effect.
  116055. * @param mesh mesh to test
  116056. * @returns true if the mesh will be used
  116057. */
  116058. hasMesh(mesh: AbstractMesh): boolean;
  116059. /**
  116060. * Returns true if the layer contains information to display, otherwise false.
  116061. * @returns true if the glow layer should be rendered
  116062. */
  116063. shouldRender(): boolean;
  116064. /**
  116065. * Returns true if the mesh should render, otherwise false.
  116066. * @param mesh The mesh to render
  116067. * @returns true if it should render otherwise false
  116068. */
  116069. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116070. /**
  116071. * Returns true if the mesh can be rendered, otherwise false.
  116072. * @param mesh The mesh to render
  116073. * @param material The material used on the mesh
  116074. * @returns true if it can be rendered otherwise false
  116075. */
  116076. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116077. /**
  116078. * Returns true if the mesh should render, otherwise false.
  116079. * @param mesh The mesh to render
  116080. * @returns true if it should render otherwise false
  116081. */
  116082. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116083. /**
  116084. * Renders the submesh passed in parameter to the generation map.
  116085. */
  116086. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116087. /**
  116088. * Rebuild the required buffers.
  116089. * @hidden Internal use only.
  116090. */
  116091. _rebuild(): void;
  116092. /**
  116093. * Dispose only the render target textures and post process.
  116094. */
  116095. private _disposeTextureAndPostProcesses;
  116096. /**
  116097. * Dispose the highlight layer and free resources.
  116098. */
  116099. dispose(): void;
  116100. /**
  116101. * Gets the class name of the effect layer
  116102. * @returns the string with the class name of the effect layer
  116103. */
  116104. getClassName(): string;
  116105. /**
  116106. * Creates an effect layer from parsed effect layer data
  116107. * @param parsedEffectLayer defines effect layer data
  116108. * @param scene defines the current scene
  116109. * @param rootUrl defines the root URL containing the effect layer information
  116110. * @returns a parsed effect Layer
  116111. */
  116112. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116113. }
  116114. }
  116115. declare module BABYLON {
  116116. interface AbstractScene {
  116117. /**
  116118. * The list of effect layers (highlights/glow) added to the scene
  116119. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116120. * @see http://doc.babylonjs.com/how_to/glow_layer
  116121. */
  116122. effectLayers: Array<EffectLayer>;
  116123. /**
  116124. * Removes the given effect layer from this scene.
  116125. * @param toRemove defines the effect layer to remove
  116126. * @returns the index of the removed effect layer
  116127. */
  116128. removeEffectLayer(toRemove: EffectLayer): number;
  116129. /**
  116130. * Adds the given effect layer to this scene
  116131. * @param newEffectLayer defines the effect layer to add
  116132. */
  116133. addEffectLayer(newEffectLayer: EffectLayer): void;
  116134. }
  116135. /**
  116136. * Defines the layer scene component responsible to manage any effect layers
  116137. * in a given scene.
  116138. */
  116139. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116140. /**
  116141. * The component name helpfull to identify the component in the list of scene components.
  116142. */
  116143. readonly name: string;
  116144. /**
  116145. * The scene the component belongs to.
  116146. */
  116147. scene: Scene;
  116148. private _engine;
  116149. private _renderEffects;
  116150. private _needStencil;
  116151. private _previousStencilState;
  116152. /**
  116153. * Creates a new instance of the component for the given scene
  116154. * @param scene Defines the scene to register the component in
  116155. */
  116156. constructor(scene: Scene);
  116157. /**
  116158. * Registers the component in a given scene
  116159. */
  116160. register(): void;
  116161. /**
  116162. * Rebuilds the elements related to this component in case of
  116163. * context lost for instance.
  116164. */
  116165. rebuild(): void;
  116166. /**
  116167. * Serializes the component data to the specified json object
  116168. * @param serializationObject The object to serialize to
  116169. */
  116170. serialize(serializationObject: any): void;
  116171. /**
  116172. * Adds all the elements from the container to the scene
  116173. * @param container the container holding the elements
  116174. */
  116175. addFromContainer(container: AbstractScene): void;
  116176. /**
  116177. * Removes all the elements in the container from the scene
  116178. * @param container contains the elements to remove
  116179. * @param dispose if the removed element should be disposed (default: false)
  116180. */
  116181. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116182. /**
  116183. * Disposes the component and the associated ressources.
  116184. */
  116185. dispose(): void;
  116186. private _isReadyForMesh;
  116187. private _renderMainTexture;
  116188. private _setStencil;
  116189. private _setStencilBack;
  116190. private _draw;
  116191. private _drawCamera;
  116192. private _drawRenderingGroup;
  116193. }
  116194. }
  116195. declare module BABYLON {
  116196. /** @hidden */
  116197. export var glowMapMergePixelShader: {
  116198. name: string;
  116199. shader: string;
  116200. };
  116201. }
  116202. declare module BABYLON {
  116203. /** @hidden */
  116204. export var glowMapMergeVertexShader: {
  116205. name: string;
  116206. shader: string;
  116207. };
  116208. }
  116209. declare module BABYLON {
  116210. interface AbstractScene {
  116211. /**
  116212. * Return a the first highlight layer of the scene with a given name.
  116213. * @param name The name of the highlight layer to look for.
  116214. * @return The highlight layer if found otherwise null.
  116215. */
  116216. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116217. }
  116218. /**
  116219. * Glow layer options. This helps customizing the behaviour
  116220. * of the glow layer.
  116221. */
  116222. export interface IGlowLayerOptions {
  116223. /**
  116224. * Multiplication factor apply to the canvas size to compute the render target size
  116225. * used to generated the glowing objects (the smaller the faster).
  116226. */
  116227. mainTextureRatio: number;
  116228. /**
  116229. * Enforces a fixed size texture to ensure resize independant blur.
  116230. */
  116231. mainTextureFixedSize?: number;
  116232. /**
  116233. * How big is the kernel of the blur texture.
  116234. */
  116235. blurKernelSize: number;
  116236. /**
  116237. * The camera attached to the layer.
  116238. */
  116239. camera: Nullable<Camera>;
  116240. /**
  116241. * Enable MSAA by chosing the number of samples.
  116242. */
  116243. mainTextureSamples?: number;
  116244. /**
  116245. * The rendering group to draw the layer in.
  116246. */
  116247. renderingGroupId: number;
  116248. }
  116249. /**
  116250. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116251. *
  116252. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116253. * glowy meshes to your scene.
  116254. *
  116255. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116256. */
  116257. export class GlowLayer extends EffectLayer {
  116258. /**
  116259. * Effect Name of the layer.
  116260. */
  116261. static readonly EffectName: string;
  116262. /**
  116263. * The default blur kernel size used for the glow.
  116264. */
  116265. static DefaultBlurKernelSize: number;
  116266. /**
  116267. * The default texture size ratio used for the glow.
  116268. */
  116269. static DefaultTextureRatio: number;
  116270. /**
  116271. * Sets the kernel size of the blur.
  116272. */
  116273. /**
  116274. * Gets the kernel size of the blur.
  116275. */
  116276. blurKernelSize: number;
  116277. /**
  116278. * Sets the glow intensity.
  116279. */
  116280. /**
  116281. * Gets the glow intensity.
  116282. */
  116283. intensity: number;
  116284. private _options;
  116285. private _intensity;
  116286. private _horizontalBlurPostprocess1;
  116287. private _verticalBlurPostprocess1;
  116288. private _horizontalBlurPostprocess2;
  116289. private _verticalBlurPostprocess2;
  116290. private _blurTexture1;
  116291. private _blurTexture2;
  116292. private _postProcesses1;
  116293. private _postProcesses2;
  116294. private _includedOnlyMeshes;
  116295. private _excludedMeshes;
  116296. /**
  116297. * Callback used to let the user override the color selection on a per mesh basis
  116298. */
  116299. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116300. /**
  116301. * Callback used to let the user override the texture selection on a per mesh basis
  116302. */
  116303. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116304. /**
  116305. * Instantiates a new glow Layer and references it to the scene.
  116306. * @param name The name of the layer
  116307. * @param scene The scene to use the layer in
  116308. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116309. */
  116310. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116311. /**
  116312. * Get the effect name of the layer.
  116313. * @return The effect name
  116314. */
  116315. getEffectName(): string;
  116316. /**
  116317. * Create the merge effect. This is the shader use to blit the information back
  116318. * to the main canvas at the end of the scene rendering.
  116319. */
  116320. protected _createMergeEffect(): Effect;
  116321. /**
  116322. * Creates the render target textures and post processes used in the glow layer.
  116323. */
  116324. protected _createTextureAndPostProcesses(): void;
  116325. /**
  116326. * Checks for the readiness of the element composing the layer.
  116327. * @param subMesh the mesh to check for
  116328. * @param useInstances specify wether or not to use instances to render the mesh
  116329. * @param emissiveTexture the associated emissive texture used to generate the glow
  116330. * @return true if ready otherwise, false
  116331. */
  116332. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116333. /**
  116334. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116335. */
  116336. needStencil(): boolean;
  116337. /**
  116338. * Returns true if the mesh can be rendered, otherwise false.
  116339. * @param mesh The mesh to render
  116340. * @param material The material used on the mesh
  116341. * @returns true if it can be rendered otherwise false
  116342. */
  116343. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116344. /**
  116345. * Implementation specific of rendering the generating effect on the main canvas.
  116346. * @param effect The effect used to render through
  116347. */
  116348. protected _internalRender(effect: Effect): void;
  116349. /**
  116350. * Sets the required values for both the emissive texture and and the main color.
  116351. */
  116352. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116353. /**
  116354. * Returns true if the mesh should render, otherwise false.
  116355. * @param mesh The mesh to render
  116356. * @returns true if it should render otherwise false
  116357. */
  116358. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116359. /**
  116360. * Adds specific effects defines.
  116361. * @param defines The defines to add specifics to.
  116362. */
  116363. protected _addCustomEffectDefines(defines: string[]): void;
  116364. /**
  116365. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116366. * @param mesh The mesh to exclude from the glow layer
  116367. */
  116368. addExcludedMesh(mesh: Mesh): void;
  116369. /**
  116370. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116371. * @param mesh The mesh to remove
  116372. */
  116373. removeExcludedMesh(mesh: Mesh): void;
  116374. /**
  116375. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116376. * @param mesh The mesh to include in the glow layer
  116377. */
  116378. addIncludedOnlyMesh(mesh: Mesh): void;
  116379. /**
  116380. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116381. * @param mesh The mesh to remove
  116382. */
  116383. removeIncludedOnlyMesh(mesh: Mesh): void;
  116384. /**
  116385. * Determine if a given mesh will be used in the glow layer
  116386. * @param mesh The mesh to test
  116387. * @returns true if the mesh will be highlighted by the current glow layer
  116388. */
  116389. hasMesh(mesh: AbstractMesh): boolean;
  116390. /**
  116391. * Free any resources and references associated to a mesh.
  116392. * Internal use
  116393. * @param mesh The mesh to free.
  116394. * @hidden
  116395. */
  116396. _disposeMesh(mesh: Mesh): void;
  116397. /**
  116398. * Gets the class name of the effect layer
  116399. * @returns the string with the class name of the effect layer
  116400. */
  116401. getClassName(): string;
  116402. /**
  116403. * Serializes this glow layer
  116404. * @returns a serialized glow layer object
  116405. */
  116406. serialize(): any;
  116407. /**
  116408. * Creates a Glow Layer from parsed glow layer data
  116409. * @param parsedGlowLayer defines glow layer data
  116410. * @param scene defines the current scene
  116411. * @param rootUrl defines the root URL containing the glow layer information
  116412. * @returns a parsed Glow Layer
  116413. */
  116414. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116415. }
  116416. }
  116417. declare module BABYLON {
  116418. /** @hidden */
  116419. export var glowBlurPostProcessPixelShader: {
  116420. name: string;
  116421. shader: string;
  116422. };
  116423. }
  116424. declare module BABYLON {
  116425. interface AbstractScene {
  116426. /**
  116427. * Return a the first highlight layer of the scene with a given name.
  116428. * @param name The name of the highlight layer to look for.
  116429. * @return The highlight layer if found otherwise null.
  116430. */
  116431. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116432. }
  116433. /**
  116434. * Highlight layer options. This helps customizing the behaviour
  116435. * of the highlight layer.
  116436. */
  116437. export interface IHighlightLayerOptions {
  116438. /**
  116439. * Multiplication factor apply to the canvas size to compute the render target size
  116440. * used to generated the glowing objects (the smaller the faster).
  116441. */
  116442. mainTextureRatio: number;
  116443. /**
  116444. * Enforces a fixed size texture to ensure resize independant blur.
  116445. */
  116446. mainTextureFixedSize?: number;
  116447. /**
  116448. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116449. * of the picture to blur (the smaller the faster).
  116450. */
  116451. blurTextureSizeRatio: number;
  116452. /**
  116453. * How big in texel of the blur texture is the vertical blur.
  116454. */
  116455. blurVerticalSize: number;
  116456. /**
  116457. * How big in texel of the blur texture is the horizontal blur.
  116458. */
  116459. blurHorizontalSize: number;
  116460. /**
  116461. * Alpha blending mode used to apply the blur. Default is combine.
  116462. */
  116463. alphaBlendingMode: number;
  116464. /**
  116465. * The camera attached to the layer.
  116466. */
  116467. camera: Nullable<Camera>;
  116468. /**
  116469. * Should we display highlight as a solid stroke?
  116470. */
  116471. isStroke?: boolean;
  116472. /**
  116473. * The rendering group to draw the layer in.
  116474. */
  116475. renderingGroupId: number;
  116476. }
  116477. /**
  116478. * The highlight layer Helps adding a glow effect around a mesh.
  116479. *
  116480. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116481. * glowy meshes to your scene.
  116482. *
  116483. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116484. */
  116485. export class HighlightLayer extends EffectLayer {
  116486. name: string;
  116487. /**
  116488. * Effect Name of the highlight layer.
  116489. */
  116490. static readonly EffectName: string;
  116491. /**
  116492. * The neutral color used during the preparation of the glow effect.
  116493. * This is black by default as the blend operation is a blend operation.
  116494. */
  116495. static NeutralColor: Color4;
  116496. /**
  116497. * Stencil value used for glowing meshes.
  116498. */
  116499. static GlowingMeshStencilReference: number;
  116500. /**
  116501. * Stencil value used for the other meshes in the scene.
  116502. */
  116503. static NormalMeshStencilReference: number;
  116504. /**
  116505. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116506. */
  116507. innerGlow: boolean;
  116508. /**
  116509. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116510. */
  116511. outerGlow: boolean;
  116512. /**
  116513. * Specifies the horizontal size of the blur.
  116514. */
  116515. /**
  116516. * Gets the horizontal size of the blur.
  116517. */
  116518. blurHorizontalSize: number;
  116519. /**
  116520. * Specifies the vertical size of the blur.
  116521. */
  116522. /**
  116523. * Gets the vertical size of the blur.
  116524. */
  116525. blurVerticalSize: number;
  116526. /**
  116527. * An event triggered when the highlight layer is being blurred.
  116528. */
  116529. onBeforeBlurObservable: Observable<HighlightLayer>;
  116530. /**
  116531. * An event triggered when the highlight layer has been blurred.
  116532. */
  116533. onAfterBlurObservable: Observable<HighlightLayer>;
  116534. private _instanceGlowingMeshStencilReference;
  116535. private _options;
  116536. private _downSamplePostprocess;
  116537. private _horizontalBlurPostprocess;
  116538. private _verticalBlurPostprocess;
  116539. private _blurTexture;
  116540. private _meshes;
  116541. private _excludedMeshes;
  116542. /**
  116543. * Instantiates a new highlight Layer and references it to the scene..
  116544. * @param name The name of the layer
  116545. * @param scene The scene to use the layer in
  116546. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116547. */
  116548. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116549. /**
  116550. * Get the effect name of the layer.
  116551. * @return The effect name
  116552. */
  116553. getEffectName(): string;
  116554. /**
  116555. * Create the merge effect. This is the shader use to blit the information back
  116556. * to the main canvas at the end of the scene rendering.
  116557. */
  116558. protected _createMergeEffect(): Effect;
  116559. /**
  116560. * Creates the render target textures and post processes used in the highlight layer.
  116561. */
  116562. protected _createTextureAndPostProcesses(): void;
  116563. /**
  116564. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116565. */
  116566. needStencil(): boolean;
  116567. /**
  116568. * Checks for the readiness of the element composing the layer.
  116569. * @param subMesh the mesh to check for
  116570. * @param useInstances specify wether or not to use instances to render the mesh
  116571. * @param emissiveTexture the associated emissive texture used to generate the glow
  116572. * @return true if ready otherwise, false
  116573. */
  116574. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116575. /**
  116576. * Implementation specific of rendering the generating effect on the main canvas.
  116577. * @param effect The effect used to render through
  116578. */
  116579. protected _internalRender(effect: Effect): void;
  116580. /**
  116581. * Returns true if the layer contains information to display, otherwise false.
  116582. */
  116583. shouldRender(): boolean;
  116584. /**
  116585. * Returns true if the mesh should render, otherwise false.
  116586. * @param mesh The mesh to render
  116587. * @returns true if it should render otherwise false
  116588. */
  116589. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116590. /**
  116591. * Sets the required values for both the emissive texture and and the main color.
  116592. */
  116593. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116594. /**
  116595. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116596. * @param mesh The mesh to exclude from the highlight layer
  116597. */
  116598. addExcludedMesh(mesh: Mesh): void;
  116599. /**
  116600. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116601. * @param mesh The mesh to highlight
  116602. */
  116603. removeExcludedMesh(mesh: Mesh): void;
  116604. /**
  116605. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116606. * @param mesh mesh to test
  116607. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116608. */
  116609. hasMesh(mesh: AbstractMesh): boolean;
  116610. /**
  116611. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116612. * @param mesh The mesh to highlight
  116613. * @param color The color of the highlight
  116614. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116615. */
  116616. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116617. /**
  116618. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116619. * @param mesh The mesh to highlight
  116620. */
  116621. removeMesh(mesh: Mesh): void;
  116622. /**
  116623. * Force the stencil to the normal expected value for none glowing parts
  116624. */
  116625. private _defaultStencilReference;
  116626. /**
  116627. * Free any resources and references associated to a mesh.
  116628. * Internal use
  116629. * @param mesh The mesh to free.
  116630. * @hidden
  116631. */
  116632. _disposeMesh(mesh: Mesh): void;
  116633. /**
  116634. * Dispose the highlight layer and free resources.
  116635. */
  116636. dispose(): void;
  116637. /**
  116638. * Gets the class name of the effect layer
  116639. * @returns the string with the class name of the effect layer
  116640. */
  116641. getClassName(): string;
  116642. /**
  116643. * Serializes this Highlight layer
  116644. * @returns a serialized Highlight layer object
  116645. */
  116646. serialize(): any;
  116647. /**
  116648. * Creates a Highlight layer from parsed Highlight layer data
  116649. * @param parsedHightlightLayer defines the Highlight layer data
  116650. * @param scene defines the current scene
  116651. * @param rootUrl defines the root URL containing the Highlight layer information
  116652. * @returns a parsed Highlight layer
  116653. */
  116654. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116655. }
  116656. }
  116657. declare module BABYLON {
  116658. interface AbstractScene {
  116659. /**
  116660. * The list of layers (background and foreground) of the scene
  116661. */
  116662. layers: Array<Layer>;
  116663. }
  116664. /**
  116665. * Defines the layer scene component responsible to manage any layers
  116666. * in a given scene.
  116667. */
  116668. export class LayerSceneComponent implements ISceneComponent {
  116669. /**
  116670. * The component name helpfull to identify the component in the list of scene components.
  116671. */
  116672. readonly name: string;
  116673. /**
  116674. * The scene the component belongs to.
  116675. */
  116676. scene: Scene;
  116677. private _engine;
  116678. /**
  116679. * Creates a new instance of the component for the given scene
  116680. * @param scene Defines the scene to register the component in
  116681. */
  116682. constructor(scene: Scene);
  116683. /**
  116684. * Registers the component in a given scene
  116685. */
  116686. register(): void;
  116687. /**
  116688. * Rebuilds the elements related to this component in case of
  116689. * context lost for instance.
  116690. */
  116691. rebuild(): void;
  116692. /**
  116693. * Disposes the component and the associated ressources.
  116694. */
  116695. dispose(): void;
  116696. private _draw;
  116697. private _drawCameraPredicate;
  116698. private _drawCameraBackground;
  116699. private _drawCameraForeground;
  116700. private _drawRenderTargetPredicate;
  116701. private _drawRenderTargetBackground;
  116702. private _drawRenderTargetForeground;
  116703. /**
  116704. * Adds all the elements from the container to the scene
  116705. * @param container the container holding the elements
  116706. */
  116707. addFromContainer(container: AbstractScene): void;
  116708. /**
  116709. * Removes all the elements in the container from the scene
  116710. * @param container contains the elements to remove
  116711. * @param dispose if the removed element should be disposed (default: false)
  116712. */
  116713. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116714. }
  116715. }
  116716. declare module BABYLON {
  116717. /** @hidden */
  116718. export var layerPixelShader: {
  116719. name: string;
  116720. shader: string;
  116721. };
  116722. }
  116723. declare module BABYLON {
  116724. /** @hidden */
  116725. export var layerVertexShader: {
  116726. name: string;
  116727. shader: string;
  116728. };
  116729. }
  116730. declare module BABYLON {
  116731. /**
  116732. * This represents a full screen 2d layer.
  116733. * This can be useful to display a picture in the background of your scene for instance.
  116734. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116735. */
  116736. export class Layer {
  116737. /**
  116738. * Define the name of the layer.
  116739. */
  116740. name: string;
  116741. /**
  116742. * Define the texture the layer should display.
  116743. */
  116744. texture: Nullable<Texture>;
  116745. /**
  116746. * Is the layer in background or foreground.
  116747. */
  116748. isBackground: boolean;
  116749. /**
  116750. * Define the color of the layer (instead of texture).
  116751. */
  116752. color: Color4;
  116753. /**
  116754. * Define the scale of the layer in order to zoom in out of the texture.
  116755. */
  116756. scale: Vector2;
  116757. /**
  116758. * Define an offset for the layer in order to shift the texture.
  116759. */
  116760. offset: Vector2;
  116761. /**
  116762. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116763. */
  116764. alphaBlendingMode: number;
  116765. /**
  116766. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116767. * Alpha test will not mix with the background color in case of transparency.
  116768. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116769. */
  116770. alphaTest: boolean;
  116771. /**
  116772. * Define a mask to restrict the layer to only some of the scene cameras.
  116773. */
  116774. layerMask: number;
  116775. /**
  116776. * Define the list of render target the layer is visible into.
  116777. */
  116778. renderTargetTextures: RenderTargetTexture[];
  116779. /**
  116780. * Define if the layer is only used in renderTarget or if it also
  116781. * renders in the main frame buffer of the canvas.
  116782. */
  116783. renderOnlyInRenderTargetTextures: boolean;
  116784. private _scene;
  116785. private _vertexBuffers;
  116786. private _indexBuffer;
  116787. private _effect;
  116788. private _alphaTestEffect;
  116789. /**
  116790. * An event triggered when the layer is disposed.
  116791. */
  116792. onDisposeObservable: Observable<Layer>;
  116793. private _onDisposeObserver;
  116794. /**
  116795. * Back compatibility with callback before the onDisposeObservable existed.
  116796. * The set callback will be triggered when the layer has been disposed.
  116797. */
  116798. onDispose: () => void;
  116799. /**
  116800. * An event triggered before rendering the scene
  116801. */
  116802. onBeforeRenderObservable: Observable<Layer>;
  116803. private _onBeforeRenderObserver;
  116804. /**
  116805. * Back compatibility with callback before the onBeforeRenderObservable existed.
  116806. * The set callback will be triggered just before rendering the layer.
  116807. */
  116808. onBeforeRender: () => void;
  116809. /**
  116810. * An event triggered after rendering the scene
  116811. */
  116812. onAfterRenderObservable: Observable<Layer>;
  116813. private _onAfterRenderObserver;
  116814. /**
  116815. * Back compatibility with callback before the onAfterRenderObservable existed.
  116816. * The set callback will be triggered just after rendering the layer.
  116817. */
  116818. onAfterRender: () => void;
  116819. /**
  116820. * Instantiates a new layer.
  116821. * This represents a full screen 2d layer.
  116822. * This can be useful to display a picture in the background of your scene for instance.
  116823. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116824. * @param name Define the name of the layer in the scene
  116825. * @param imgUrl Define the url of the texture to display in the layer
  116826. * @param scene Define the scene the layer belongs to
  116827. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  116828. * @param color Defines a color for the layer
  116829. */
  116830. constructor(
  116831. /**
  116832. * Define the name of the layer.
  116833. */
  116834. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  116835. private _createIndexBuffer;
  116836. /** @hidden */
  116837. _rebuild(): void;
  116838. /**
  116839. * Renders the layer in the scene.
  116840. */
  116841. render(): void;
  116842. /**
  116843. * Disposes and releases the associated ressources.
  116844. */
  116845. dispose(): void;
  116846. }
  116847. }
  116848. declare module BABYLON {
  116849. /** @hidden */
  116850. export var lensFlarePixelShader: {
  116851. name: string;
  116852. shader: string;
  116853. };
  116854. }
  116855. declare module BABYLON {
  116856. /** @hidden */
  116857. export var lensFlareVertexShader: {
  116858. name: string;
  116859. shader: string;
  116860. };
  116861. }
  116862. declare module BABYLON {
  116863. /**
  116864. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116865. * It is usually composed of several `lensFlare`.
  116866. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116867. */
  116868. export class LensFlareSystem {
  116869. /**
  116870. * Define the name of the lens flare system
  116871. */
  116872. name: string;
  116873. /**
  116874. * List of lens flares used in this system.
  116875. */
  116876. lensFlares: LensFlare[];
  116877. /**
  116878. * Define a limit from the border the lens flare can be visible.
  116879. */
  116880. borderLimit: number;
  116881. /**
  116882. * Define a viewport border we do not want to see the lens flare in.
  116883. */
  116884. viewportBorder: number;
  116885. /**
  116886. * Define a predicate which could limit the list of meshes able to occlude the effect.
  116887. */
  116888. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  116889. /**
  116890. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  116891. */
  116892. layerMask: number;
  116893. /**
  116894. * Define the id of the lens flare system in the scene.
  116895. * (equal to name by default)
  116896. */
  116897. id: string;
  116898. private _scene;
  116899. private _emitter;
  116900. private _vertexBuffers;
  116901. private _indexBuffer;
  116902. private _effect;
  116903. private _positionX;
  116904. private _positionY;
  116905. private _isEnabled;
  116906. /** @hidden */
  116907. static _SceneComponentInitialization: (scene: Scene) => void;
  116908. /**
  116909. * Instantiates a lens flare system.
  116910. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116911. * It is usually composed of several `lensFlare`.
  116912. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116913. * @param name Define the name of the lens flare system in the scene
  116914. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  116915. * @param scene Define the scene the lens flare system belongs to
  116916. */
  116917. constructor(
  116918. /**
  116919. * Define the name of the lens flare system
  116920. */
  116921. name: string, emitter: any, scene: Scene);
  116922. /**
  116923. * Define if the lens flare system is enabled.
  116924. */
  116925. isEnabled: boolean;
  116926. /**
  116927. * Get the scene the effects belongs to.
  116928. * @returns the scene holding the lens flare system
  116929. */
  116930. getScene(): Scene;
  116931. /**
  116932. * Get the emitter of the lens flare system.
  116933. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116934. * @returns the emitter of the lens flare system
  116935. */
  116936. getEmitter(): any;
  116937. /**
  116938. * Set the emitter of the lens flare system.
  116939. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116940. * @param newEmitter Define the new emitter of the system
  116941. */
  116942. setEmitter(newEmitter: any): void;
  116943. /**
  116944. * Get the lens flare system emitter position.
  116945. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  116946. * @returns the position
  116947. */
  116948. getEmitterPosition(): Vector3;
  116949. /**
  116950. * @hidden
  116951. */
  116952. computeEffectivePosition(globalViewport: Viewport): boolean;
  116953. /** @hidden */
  116954. _isVisible(): boolean;
  116955. /**
  116956. * @hidden
  116957. */
  116958. render(): boolean;
  116959. /**
  116960. * Dispose and release the lens flare with its associated resources.
  116961. */
  116962. dispose(): void;
  116963. /**
  116964. * Parse a lens flare system from a JSON repressentation
  116965. * @param parsedLensFlareSystem Define the JSON to parse
  116966. * @param scene Define the scene the parsed system should be instantiated in
  116967. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  116968. * @returns the parsed system
  116969. */
  116970. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  116971. /**
  116972. * Serialize the current Lens Flare System into a JSON representation.
  116973. * @returns the serialized JSON
  116974. */
  116975. serialize(): any;
  116976. }
  116977. }
  116978. declare module BABYLON {
  116979. /**
  116980. * This represents one of the lens effect in a `lensFlareSystem`.
  116981. * It controls one of the indiviual texture used in the effect.
  116982. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116983. */
  116984. export class LensFlare {
  116985. /**
  116986. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  116987. */
  116988. size: number;
  116989. /**
  116990. * 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.
  116991. */
  116992. position: number;
  116993. /**
  116994. * Define the lens color.
  116995. */
  116996. color: Color3;
  116997. /**
  116998. * Define the lens texture.
  116999. */
  117000. texture: Nullable<Texture>;
  117001. /**
  117002. * Define the alpha mode to render this particular lens.
  117003. */
  117004. alphaMode: number;
  117005. private _system;
  117006. /**
  117007. * Creates a new Lens Flare.
  117008. * This represents one of the lens effect in a `lensFlareSystem`.
  117009. * It controls one of the indiviual texture used in the effect.
  117010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117011. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117012. * @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.
  117013. * @param color Define the lens color
  117014. * @param imgUrl Define the lens texture url
  117015. * @param system Define the `lensFlareSystem` this flare is part of
  117016. * @returns The newly created Lens Flare
  117017. */
  117018. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117019. /**
  117020. * Instantiates a new Lens Flare.
  117021. * This represents one of the lens effect in a `lensFlareSystem`.
  117022. * It controls one of the indiviual texture used in the effect.
  117023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117024. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117025. * @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.
  117026. * @param color Define the lens color
  117027. * @param imgUrl Define the lens texture url
  117028. * @param system Define the `lensFlareSystem` this flare is part of
  117029. */
  117030. constructor(
  117031. /**
  117032. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117033. */
  117034. size: number,
  117035. /**
  117036. * 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.
  117037. */
  117038. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117039. /**
  117040. * Dispose and release the lens flare with its associated resources.
  117041. */
  117042. dispose(): void;
  117043. }
  117044. }
  117045. declare module BABYLON {
  117046. interface AbstractScene {
  117047. /**
  117048. * The list of lens flare system added to the scene
  117049. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117050. */
  117051. lensFlareSystems: Array<LensFlareSystem>;
  117052. /**
  117053. * Removes the given lens flare system from this scene.
  117054. * @param toRemove The lens flare system to remove
  117055. * @returns The index of the removed lens flare system
  117056. */
  117057. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117058. /**
  117059. * Adds the given lens flare system to this scene
  117060. * @param newLensFlareSystem The lens flare system to add
  117061. */
  117062. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117063. /**
  117064. * Gets a lens flare system using its name
  117065. * @param name defines the name to look for
  117066. * @returns the lens flare system or null if not found
  117067. */
  117068. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117069. /**
  117070. * Gets a lens flare system using its id
  117071. * @param id defines the id to look for
  117072. * @returns the lens flare system or null if not found
  117073. */
  117074. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117075. }
  117076. /**
  117077. * Defines the lens flare scene component responsible to manage any lens flares
  117078. * in a given scene.
  117079. */
  117080. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117081. /**
  117082. * The component name helpfull to identify the component in the list of scene components.
  117083. */
  117084. readonly name: string;
  117085. /**
  117086. * The scene the component belongs to.
  117087. */
  117088. scene: Scene;
  117089. /**
  117090. * Creates a new instance of the component for the given scene
  117091. * @param scene Defines the scene to register the component in
  117092. */
  117093. constructor(scene: Scene);
  117094. /**
  117095. * Registers the component in a given scene
  117096. */
  117097. register(): void;
  117098. /**
  117099. * Rebuilds the elements related to this component in case of
  117100. * context lost for instance.
  117101. */
  117102. rebuild(): void;
  117103. /**
  117104. * Adds all the elements from the container to the scene
  117105. * @param container the container holding the elements
  117106. */
  117107. addFromContainer(container: AbstractScene): void;
  117108. /**
  117109. * Removes all the elements in the container from the scene
  117110. * @param container contains the elements to remove
  117111. * @param dispose if the removed element should be disposed (default: false)
  117112. */
  117113. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117114. /**
  117115. * Serializes the component data to the specified json object
  117116. * @param serializationObject The object to serialize to
  117117. */
  117118. serialize(serializationObject: any): void;
  117119. /**
  117120. * Disposes the component and the associated ressources.
  117121. */
  117122. dispose(): void;
  117123. private _draw;
  117124. }
  117125. }
  117126. declare module BABYLON {
  117127. /**
  117128. * Defines the shadow generator component responsible to manage any shadow generators
  117129. * in a given scene.
  117130. */
  117131. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117132. /**
  117133. * The component name helpfull to identify the component in the list of scene components.
  117134. */
  117135. readonly name: string;
  117136. /**
  117137. * The scene the component belongs to.
  117138. */
  117139. scene: Scene;
  117140. /**
  117141. * Creates a new instance of the component for the given scene
  117142. * @param scene Defines the scene to register the component in
  117143. */
  117144. constructor(scene: Scene);
  117145. /**
  117146. * Registers the component in a given scene
  117147. */
  117148. register(): void;
  117149. /**
  117150. * Rebuilds the elements related to this component in case of
  117151. * context lost for instance.
  117152. */
  117153. rebuild(): void;
  117154. /**
  117155. * Serializes the component data to the specified json object
  117156. * @param serializationObject The object to serialize to
  117157. */
  117158. serialize(serializationObject: any): void;
  117159. /**
  117160. * Adds all the elements from the container to the scene
  117161. * @param container the container holding the elements
  117162. */
  117163. addFromContainer(container: AbstractScene): void;
  117164. /**
  117165. * Removes all the elements in the container from the scene
  117166. * @param container contains the elements to remove
  117167. * @param dispose if the removed element should be disposed (default: false)
  117168. */
  117169. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117170. /**
  117171. * Rebuilds the elements related to this component in case of
  117172. * context lost for instance.
  117173. */
  117174. dispose(): void;
  117175. private _gatherRenderTargets;
  117176. }
  117177. }
  117178. declare module BABYLON {
  117179. /**
  117180. * A point light is a light defined by an unique point in world space.
  117181. * The light is emitted in every direction from this point.
  117182. * A good example of a point light is a standard light bulb.
  117183. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117184. */
  117185. export class PointLight extends ShadowLight {
  117186. private _shadowAngle;
  117187. /**
  117188. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117189. * This specifies what angle the shadow will use to be created.
  117190. *
  117191. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117192. */
  117193. /**
  117194. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117195. * This specifies what angle the shadow will use to be created.
  117196. *
  117197. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117198. */
  117199. shadowAngle: number;
  117200. /**
  117201. * Gets the direction if it has been set.
  117202. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117203. */
  117204. /**
  117205. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117206. */
  117207. direction: Vector3;
  117208. /**
  117209. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117210. * A PointLight emits the light in every direction.
  117211. * It can cast shadows.
  117212. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117213. * ```javascript
  117214. * var pointLight = new PointLight("pl", camera.position, scene);
  117215. * ```
  117216. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117217. * @param name The light friendly name
  117218. * @param position The position of the point light in the scene
  117219. * @param scene The scene the lights belongs to
  117220. */
  117221. constructor(name: string, position: Vector3, scene: Scene);
  117222. /**
  117223. * Returns the string "PointLight"
  117224. * @returns the class name
  117225. */
  117226. getClassName(): string;
  117227. /**
  117228. * Returns the integer 0.
  117229. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117230. */
  117231. getTypeID(): number;
  117232. /**
  117233. * Specifies wether or not the shadowmap should be a cube texture.
  117234. * @returns true if the shadowmap needs to be a cube texture.
  117235. */
  117236. needCube(): boolean;
  117237. /**
  117238. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117239. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117240. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117241. */
  117242. getShadowDirection(faceIndex?: number): Vector3;
  117243. /**
  117244. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117245. * - fov = PI / 2
  117246. * - aspect ratio : 1.0
  117247. * - z-near and far equal to the active camera minZ and maxZ.
  117248. * Returns the PointLight.
  117249. */
  117250. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117251. protected _buildUniformLayout(): void;
  117252. /**
  117253. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117254. * @param effect The effect to update
  117255. * @param lightIndex The index of the light in the effect to update
  117256. * @returns The point light
  117257. */
  117258. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117259. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117260. /**
  117261. * Prepares the list of defines specific to the light type.
  117262. * @param defines the list of defines
  117263. * @param lightIndex defines the index of the light for the effect
  117264. */
  117265. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117266. }
  117267. }
  117268. declare module BABYLON {
  117269. /**
  117270. * Header information of HDR texture files.
  117271. */
  117272. export interface HDRInfo {
  117273. /**
  117274. * The height of the texture in pixels.
  117275. */
  117276. height: number;
  117277. /**
  117278. * The width of the texture in pixels.
  117279. */
  117280. width: number;
  117281. /**
  117282. * The index of the beginning of the data in the binary file.
  117283. */
  117284. dataPosition: number;
  117285. }
  117286. /**
  117287. * This groups tools to convert HDR texture to native colors array.
  117288. */
  117289. export class HDRTools {
  117290. private static Ldexp;
  117291. private static Rgbe2float;
  117292. private static readStringLine;
  117293. /**
  117294. * Reads header information from an RGBE texture stored in a native array.
  117295. * More information on this format are available here:
  117296. * https://en.wikipedia.org/wiki/RGBE_image_format
  117297. *
  117298. * @param uint8array The binary file stored in native array.
  117299. * @return The header information.
  117300. */
  117301. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117302. /**
  117303. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117304. * This RGBE texture needs to store the information as a panorama.
  117305. *
  117306. * More information on this format are available here:
  117307. * https://en.wikipedia.org/wiki/RGBE_image_format
  117308. *
  117309. * @param buffer The binary file stored in an array buffer.
  117310. * @param size The expected size of the extracted cubemap.
  117311. * @return The Cube Map information.
  117312. */
  117313. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117314. /**
  117315. * Returns the pixels data extracted from an RGBE texture.
  117316. * This pixels will be stored left to right up to down in the R G B order in one array.
  117317. *
  117318. * More information on this format are available here:
  117319. * https://en.wikipedia.org/wiki/RGBE_image_format
  117320. *
  117321. * @param uint8array The binary file stored in an array buffer.
  117322. * @param hdrInfo The header information of the file.
  117323. * @return The pixels data in RGB right to left up to down order.
  117324. */
  117325. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117326. private static RGBE_ReadPixels_RLE;
  117327. }
  117328. }
  117329. declare module BABYLON {
  117330. /**
  117331. * This represents a texture coming from an HDR input.
  117332. *
  117333. * The only supported format is currently panorama picture stored in RGBE format.
  117334. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117335. */
  117336. export class HDRCubeTexture extends BaseTexture {
  117337. private static _facesMapping;
  117338. private _generateHarmonics;
  117339. private _noMipmap;
  117340. private _textureMatrix;
  117341. private _size;
  117342. private _onLoad;
  117343. private _onError;
  117344. /**
  117345. * The texture URL.
  117346. */
  117347. url: string;
  117348. /**
  117349. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117350. */
  117351. coordinatesMode: number;
  117352. protected _isBlocking: boolean;
  117353. /**
  117354. * Sets wether or not the texture is blocking during loading.
  117355. */
  117356. /**
  117357. * Gets wether or not the texture is blocking during loading.
  117358. */
  117359. isBlocking: boolean;
  117360. protected _rotationY: number;
  117361. /**
  117362. * Sets texture matrix rotation angle around Y axis in radians.
  117363. */
  117364. /**
  117365. * Gets texture matrix rotation angle around Y axis radians.
  117366. */
  117367. rotationY: number;
  117368. /**
  117369. * Gets or sets the center of the bounding box associated with the cube texture
  117370. * It must define where the camera used to render the texture was set
  117371. */
  117372. boundingBoxPosition: Vector3;
  117373. private _boundingBoxSize;
  117374. /**
  117375. * Gets or sets the size of the bounding box associated with the cube texture
  117376. * When defined, the cubemap will switch to local mode
  117377. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117378. * @example https://www.babylonjs-playground.com/#RNASML
  117379. */
  117380. boundingBoxSize: Vector3;
  117381. /**
  117382. * Instantiates an HDRTexture from the following parameters.
  117383. *
  117384. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117385. * @param scene The scene the texture will be used in
  117386. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117387. * @param noMipmap Forces to not generate the mipmap if true
  117388. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117389. * @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)
  117390. * @param reserved Reserved flag for internal use.
  117391. */
  117392. 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>);
  117393. /**
  117394. * Get the current class name of the texture useful for serialization or dynamic coding.
  117395. * @returns "HDRCubeTexture"
  117396. */
  117397. getClassName(): string;
  117398. /**
  117399. * Occurs when the file is raw .hdr file.
  117400. */
  117401. private loadTexture;
  117402. clone(): HDRCubeTexture;
  117403. delayLoad(): void;
  117404. /**
  117405. * Get the texture reflection matrix used to rotate/transform the reflection.
  117406. * @returns the reflection matrix
  117407. */
  117408. getReflectionTextureMatrix(): Matrix;
  117409. /**
  117410. * Set the texture reflection matrix used to rotate/transform the reflection.
  117411. * @param value Define the reflection matrix to set
  117412. */
  117413. setReflectionTextureMatrix(value: Matrix): void;
  117414. /**
  117415. * Parses a JSON representation of an HDR Texture in order to create the texture
  117416. * @param parsedTexture Define the JSON representation
  117417. * @param scene Define the scene the texture should be created in
  117418. * @param rootUrl Define the root url in case we need to load relative dependencies
  117419. * @returns the newly created texture after parsing
  117420. */
  117421. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117422. serialize(): any;
  117423. }
  117424. }
  117425. declare module BABYLON {
  117426. /**
  117427. * Class used to control physics engine
  117428. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117429. */
  117430. export class PhysicsEngine implements IPhysicsEngine {
  117431. private _physicsPlugin;
  117432. /**
  117433. * Global value used to control the smallest number supported by the simulation
  117434. */
  117435. static Epsilon: number;
  117436. private _impostors;
  117437. private _joints;
  117438. /**
  117439. * Gets the gravity vector used by the simulation
  117440. */
  117441. gravity: Vector3;
  117442. /**
  117443. * Factory used to create the default physics plugin.
  117444. * @returns The default physics plugin
  117445. */
  117446. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117447. /**
  117448. * Creates a new Physics Engine
  117449. * @param gravity defines the gravity vector used by the simulation
  117450. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117451. */
  117452. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117453. /**
  117454. * Sets the gravity vector used by the simulation
  117455. * @param gravity defines the gravity vector to use
  117456. */
  117457. setGravity(gravity: Vector3): void;
  117458. /**
  117459. * Set the time step of the physics engine.
  117460. * Default is 1/60.
  117461. * To slow it down, enter 1/600 for example.
  117462. * To speed it up, 1/30
  117463. * @param newTimeStep defines the new timestep to apply to this world.
  117464. */
  117465. setTimeStep(newTimeStep?: number): void;
  117466. /**
  117467. * Get the time step of the physics engine.
  117468. * @returns the current time step
  117469. */
  117470. getTimeStep(): number;
  117471. /**
  117472. * Release all resources
  117473. */
  117474. dispose(): void;
  117475. /**
  117476. * Gets the name of the current physics plugin
  117477. * @returns the name of the plugin
  117478. */
  117479. getPhysicsPluginName(): string;
  117480. /**
  117481. * Adding a new impostor for the impostor tracking.
  117482. * This will be done by the impostor itself.
  117483. * @param impostor the impostor to add
  117484. */
  117485. addImpostor(impostor: PhysicsImpostor): void;
  117486. /**
  117487. * Remove an impostor from the engine.
  117488. * This impostor and its mesh will not longer be updated by the physics engine.
  117489. * @param impostor the impostor to remove
  117490. */
  117491. removeImpostor(impostor: PhysicsImpostor): void;
  117492. /**
  117493. * Add a joint to the physics engine
  117494. * @param mainImpostor defines the main impostor to which the joint is added.
  117495. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117496. * @param joint defines the joint that will connect both impostors.
  117497. */
  117498. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117499. /**
  117500. * Removes a joint from the simulation
  117501. * @param mainImpostor defines the impostor used with the joint
  117502. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117503. * @param joint defines the joint to remove
  117504. */
  117505. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117506. /**
  117507. * Called by the scene. No need to call it.
  117508. * @param delta defines the timespam between frames
  117509. */
  117510. _step(delta: number): void;
  117511. /**
  117512. * Gets the current plugin used to run the simulation
  117513. * @returns current plugin
  117514. */
  117515. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117516. /**
  117517. * Gets the list of physic impostors
  117518. * @returns an array of PhysicsImpostor
  117519. */
  117520. getImpostors(): Array<PhysicsImpostor>;
  117521. /**
  117522. * Gets the impostor for a physics enabled object
  117523. * @param object defines the object impersonated by the impostor
  117524. * @returns the PhysicsImpostor or null if not found
  117525. */
  117526. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117527. /**
  117528. * Gets the impostor for a physics body object
  117529. * @param body defines physics body used by the impostor
  117530. * @returns the PhysicsImpostor or null if not found
  117531. */
  117532. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117533. /**
  117534. * Does a raycast in the physics world
  117535. * @param from when should the ray start?
  117536. * @param to when should the ray end?
  117537. * @returns PhysicsRaycastResult
  117538. */
  117539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117540. }
  117541. }
  117542. declare module BABYLON {
  117543. /** @hidden */
  117544. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117545. private _useDeltaForWorldStep;
  117546. world: any;
  117547. name: string;
  117548. private _physicsMaterials;
  117549. private _fixedTimeStep;
  117550. private _cannonRaycastResult;
  117551. private _raycastResult;
  117552. private _physicsBodysToRemoveAfterStep;
  117553. BJSCANNON: any;
  117554. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117555. setGravity(gravity: Vector3): void;
  117556. setTimeStep(timeStep: number): void;
  117557. getTimeStep(): number;
  117558. executeStep(delta: number): void;
  117559. private _removeMarkedPhysicsBodiesFromWorld;
  117560. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117561. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117562. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117563. private _processChildMeshes;
  117564. removePhysicsBody(impostor: PhysicsImpostor): void;
  117565. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117566. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117567. private _addMaterial;
  117568. private _checkWithEpsilon;
  117569. private _createShape;
  117570. private _createHeightmap;
  117571. private _minus90X;
  117572. private _plus90X;
  117573. private _tmpPosition;
  117574. private _tmpDeltaPosition;
  117575. private _tmpUnityRotation;
  117576. private _updatePhysicsBodyTransformation;
  117577. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117578. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117579. isSupported(): boolean;
  117580. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117581. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117582. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117583. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117584. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117585. getBodyMass(impostor: PhysicsImpostor): number;
  117586. getBodyFriction(impostor: PhysicsImpostor): number;
  117587. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117588. getBodyRestitution(impostor: PhysicsImpostor): number;
  117589. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117590. sleepBody(impostor: PhysicsImpostor): void;
  117591. wakeUpBody(impostor: PhysicsImpostor): void;
  117592. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117593. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117594. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117595. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117596. getRadius(impostor: PhysicsImpostor): number;
  117597. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117598. dispose(): void;
  117599. private _extendNamespace;
  117600. /**
  117601. * Does a raycast in the physics world
  117602. * @param from when should the ray start?
  117603. * @param to when should the ray end?
  117604. * @returns PhysicsRaycastResult
  117605. */
  117606. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117607. }
  117608. }
  117609. declare module BABYLON {
  117610. /** @hidden */
  117611. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117612. world: any;
  117613. name: string;
  117614. BJSOIMO: any;
  117615. private _raycastResult;
  117616. constructor(iterations?: number, oimoInjection?: any);
  117617. setGravity(gravity: Vector3): void;
  117618. setTimeStep(timeStep: number): void;
  117619. getTimeStep(): number;
  117620. private _tmpImpostorsArray;
  117621. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117622. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117623. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117624. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117625. private _tmpPositionVector;
  117626. removePhysicsBody(impostor: PhysicsImpostor): void;
  117627. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117628. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117629. isSupported(): boolean;
  117630. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117631. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117632. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117633. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117634. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117635. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117636. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117637. getBodyMass(impostor: PhysicsImpostor): number;
  117638. getBodyFriction(impostor: PhysicsImpostor): number;
  117639. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117640. getBodyRestitution(impostor: PhysicsImpostor): number;
  117641. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117642. sleepBody(impostor: PhysicsImpostor): void;
  117643. wakeUpBody(impostor: PhysicsImpostor): void;
  117644. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117645. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117646. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117647. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117648. getRadius(impostor: PhysicsImpostor): number;
  117649. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117650. dispose(): void;
  117651. /**
  117652. * Does a raycast in the physics world
  117653. * @param from when should the ray start?
  117654. * @param to when should the ray end?
  117655. * @returns PhysicsRaycastResult
  117656. */
  117657. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117658. }
  117659. }
  117660. declare module BABYLON {
  117661. /**
  117662. * Class containing static functions to help procedurally build meshes
  117663. */
  117664. export class RibbonBuilder {
  117665. /**
  117666. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117667. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117668. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117669. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117670. * * 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
  117671. * * 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
  117672. * * 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
  117673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117675. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117676. * * 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
  117677. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117678. * * 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
  117679. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117681. * @param name defines the name of the mesh
  117682. * @param options defines the options used to create the mesh
  117683. * @param scene defines the hosting scene
  117684. * @returns the ribbon mesh
  117685. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117686. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117687. */
  117688. static CreateRibbon(name: string, options: {
  117689. pathArray: Vector3[][];
  117690. closeArray?: boolean;
  117691. closePath?: boolean;
  117692. offset?: number;
  117693. updatable?: boolean;
  117694. sideOrientation?: number;
  117695. frontUVs?: Vector4;
  117696. backUVs?: Vector4;
  117697. instance?: Mesh;
  117698. invertUV?: boolean;
  117699. uvs?: Vector2[];
  117700. colors?: Color4[];
  117701. }, scene?: Nullable<Scene>): Mesh;
  117702. }
  117703. }
  117704. declare module BABYLON {
  117705. /**
  117706. * Class containing static functions to help procedurally build meshes
  117707. */
  117708. export class ShapeBuilder {
  117709. /**
  117710. * 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.
  117711. * * 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.
  117712. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117713. * * 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.
  117714. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117715. * * 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
  117716. * * 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
  117717. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117720. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117722. * @param name defines the name of the mesh
  117723. * @param options defines the options used to create the mesh
  117724. * @param scene defines the hosting scene
  117725. * @returns the extruded shape mesh
  117726. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117727. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117728. */
  117729. static ExtrudeShape(name: string, options: {
  117730. shape: Vector3[];
  117731. path: Vector3[];
  117732. scale?: number;
  117733. rotation?: number;
  117734. cap?: number;
  117735. updatable?: boolean;
  117736. sideOrientation?: number;
  117737. frontUVs?: Vector4;
  117738. backUVs?: Vector4;
  117739. instance?: Mesh;
  117740. invertUV?: boolean;
  117741. }, scene?: Nullable<Scene>): Mesh;
  117742. /**
  117743. * Creates an custom extruded shape mesh.
  117744. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117745. * * 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.
  117746. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117747. * * 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
  117748. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117749. * * 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
  117750. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117751. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117752. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117753. * * 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
  117754. * * 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
  117755. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117760. * @param name defines the name of the mesh
  117761. * @param options defines the options used to create the mesh
  117762. * @param scene defines the hosting scene
  117763. * @returns the custom extruded shape mesh
  117764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117765. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117767. */
  117768. static ExtrudeShapeCustom(name: string, options: {
  117769. shape: Vector3[];
  117770. path: Vector3[];
  117771. scaleFunction?: any;
  117772. rotationFunction?: any;
  117773. ribbonCloseArray?: boolean;
  117774. ribbonClosePath?: boolean;
  117775. cap?: number;
  117776. updatable?: boolean;
  117777. sideOrientation?: number;
  117778. frontUVs?: Vector4;
  117779. backUVs?: Vector4;
  117780. instance?: Mesh;
  117781. invertUV?: boolean;
  117782. }, scene?: Nullable<Scene>): Mesh;
  117783. private static _ExtrudeShapeGeneric;
  117784. }
  117785. }
  117786. declare module BABYLON {
  117787. /**
  117788. * AmmoJS Physics plugin
  117789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117790. * @see https://github.com/kripken/ammo.js/
  117791. */
  117792. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  117793. private _useDeltaForWorldStep;
  117794. /**
  117795. * Reference to the Ammo library
  117796. */
  117797. bjsAMMO: any;
  117798. /**
  117799. * Created ammoJS world which physics bodies are added to
  117800. */
  117801. world: any;
  117802. /**
  117803. * Name of the plugin
  117804. */
  117805. name: string;
  117806. private _timeStep;
  117807. private _fixedTimeStep;
  117808. private _maxSteps;
  117809. private _tmpQuaternion;
  117810. private _tmpAmmoTransform;
  117811. private _tmpAmmoQuaternion;
  117812. private _tmpAmmoConcreteContactResultCallback;
  117813. private _collisionConfiguration;
  117814. private _dispatcher;
  117815. private _overlappingPairCache;
  117816. private _solver;
  117817. private _softBodySolver;
  117818. private _tmpAmmoVectorA;
  117819. private _tmpAmmoVectorB;
  117820. private _tmpAmmoVectorC;
  117821. private _tmpAmmoVectorD;
  117822. private _tmpContactCallbackResult;
  117823. private _tmpAmmoVectorRCA;
  117824. private _tmpAmmoVectorRCB;
  117825. private _raycastResult;
  117826. private static readonly DISABLE_COLLISION_FLAG;
  117827. private static readonly KINEMATIC_FLAG;
  117828. private static readonly DISABLE_DEACTIVATION_FLAG;
  117829. /**
  117830. * Initializes the ammoJS plugin
  117831. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  117832. * @param ammoInjection can be used to inject your own ammo reference
  117833. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  117834. */
  117835. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  117836. /**
  117837. * Sets the gravity of the physics world (m/(s^2))
  117838. * @param gravity Gravity to set
  117839. */
  117840. setGravity(gravity: Vector3): void;
  117841. /**
  117842. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  117843. * @param timeStep timestep to use in seconds
  117844. */
  117845. setTimeStep(timeStep: number): void;
  117846. /**
  117847. * 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)
  117848. * @param fixedTimeStep fixedTimeStep to use in seconds
  117849. */
  117850. setFixedTimeStep(fixedTimeStep: number): void;
  117851. /**
  117852. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  117853. * @param maxSteps the maximum number of steps by the physics engine per frame
  117854. */
  117855. setMaxSteps(maxSteps: number): void;
  117856. /**
  117857. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  117858. * @returns the current timestep in seconds
  117859. */
  117860. getTimeStep(): number;
  117861. private _isImpostorInContact;
  117862. private _isImpostorPairInContact;
  117863. private _stepSimulation;
  117864. /**
  117865. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  117866. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  117867. * After the step the babylon meshes are set to the position of the physics imposters
  117868. * @param delta amount of time to step forward
  117869. * @param impostors array of imposters to update before/after the step
  117870. */
  117871. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117872. /**
  117873. * Update babylon mesh to match physics world object
  117874. * @param impostor imposter to match
  117875. */
  117876. private _afterSoftStep;
  117877. /**
  117878. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117879. * @param impostor imposter to match
  117880. */
  117881. private _ropeStep;
  117882. /**
  117883. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117884. * @param impostor imposter to match
  117885. */
  117886. private _softbodyOrClothStep;
  117887. private _tmpVector;
  117888. private _tmpMatrix;
  117889. /**
  117890. * Applies an impulse on the imposter
  117891. * @param impostor imposter to apply impulse to
  117892. * @param force amount of force to be applied to the imposter
  117893. * @param contactPoint the location to apply the impulse on the imposter
  117894. */
  117895. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117896. /**
  117897. * Applies a force on the imposter
  117898. * @param impostor imposter to apply force
  117899. * @param force amount of force to be applied to the imposter
  117900. * @param contactPoint the location to apply the force on the imposter
  117901. */
  117902. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117903. /**
  117904. * Creates a physics body using the plugin
  117905. * @param impostor the imposter to create the physics body on
  117906. */
  117907. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117908. /**
  117909. * Removes the physics body from the imposter and disposes of the body's memory
  117910. * @param impostor imposter to remove the physics body from
  117911. */
  117912. removePhysicsBody(impostor: PhysicsImpostor): void;
  117913. /**
  117914. * Generates a joint
  117915. * @param impostorJoint the imposter joint to create the joint with
  117916. */
  117917. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117918. /**
  117919. * Removes a joint
  117920. * @param impostorJoint the imposter joint to remove the joint from
  117921. */
  117922. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117923. private _addMeshVerts;
  117924. /**
  117925. * Initialise the soft body vertices to match its object's (mesh) vertices
  117926. * Softbody vertices (nodes) are in world space and to match this
  117927. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  117928. * @param impostor to create the softbody for
  117929. */
  117930. private _softVertexData;
  117931. /**
  117932. * Create an impostor's soft body
  117933. * @param impostor to create the softbody for
  117934. */
  117935. private _createSoftbody;
  117936. /**
  117937. * Create cloth for an impostor
  117938. * @param impostor to create the softbody for
  117939. */
  117940. private _createCloth;
  117941. /**
  117942. * Create rope for an impostor
  117943. * @param impostor to create the softbody for
  117944. */
  117945. private _createRope;
  117946. private _addHullVerts;
  117947. private _createShape;
  117948. /**
  117949. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  117950. * @param impostor imposter containing the physics body and babylon object
  117951. */
  117952. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117953. /**
  117954. * Sets the babylon object's position/rotation from the physics body's position/rotation
  117955. * @param impostor imposter containing the physics body and babylon object
  117956. * @param newPosition new position
  117957. * @param newRotation new rotation
  117958. */
  117959. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117960. /**
  117961. * If this plugin is supported
  117962. * @returns true if its supported
  117963. */
  117964. isSupported(): boolean;
  117965. /**
  117966. * Sets the linear velocity of the physics body
  117967. * @param impostor imposter to set the velocity on
  117968. * @param velocity velocity to set
  117969. */
  117970. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117971. /**
  117972. * Sets the angular velocity of the physics body
  117973. * @param impostor imposter to set the velocity on
  117974. * @param velocity velocity to set
  117975. */
  117976. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117977. /**
  117978. * gets the linear velocity
  117979. * @param impostor imposter to get linear velocity from
  117980. * @returns linear velocity
  117981. */
  117982. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117983. /**
  117984. * gets the angular velocity
  117985. * @param impostor imposter to get angular velocity from
  117986. * @returns angular velocity
  117987. */
  117988. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117989. /**
  117990. * Sets the mass of physics body
  117991. * @param impostor imposter to set the mass on
  117992. * @param mass mass to set
  117993. */
  117994. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117995. /**
  117996. * Gets the mass of the physics body
  117997. * @param impostor imposter to get the mass from
  117998. * @returns mass
  117999. */
  118000. getBodyMass(impostor: PhysicsImpostor): number;
  118001. /**
  118002. * Gets friction of the impostor
  118003. * @param impostor impostor to get friction from
  118004. * @returns friction value
  118005. */
  118006. getBodyFriction(impostor: PhysicsImpostor): number;
  118007. /**
  118008. * Sets friction of the impostor
  118009. * @param impostor impostor to set friction on
  118010. * @param friction friction value
  118011. */
  118012. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118013. /**
  118014. * Gets restitution of the impostor
  118015. * @param impostor impostor to get restitution from
  118016. * @returns restitution value
  118017. */
  118018. getBodyRestitution(impostor: PhysicsImpostor): number;
  118019. /**
  118020. * Sets resitution of the impostor
  118021. * @param impostor impostor to set resitution on
  118022. * @param restitution resitution value
  118023. */
  118024. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118025. /**
  118026. * Gets pressure inside the impostor
  118027. * @param impostor impostor to get pressure from
  118028. * @returns pressure value
  118029. */
  118030. getBodyPressure(impostor: PhysicsImpostor): number;
  118031. /**
  118032. * Sets pressure inside a soft body impostor
  118033. * Cloth and rope must remain 0 pressure
  118034. * @param impostor impostor to set pressure on
  118035. * @param pressure pressure value
  118036. */
  118037. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118038. /**
  118039. * Gets stiffness of the impostor
  118040. * @param impostor impostor to get stiffness from
  118041. * @returns pressure value
  118042. */
  118043. getBodyStiffness(impostor: PhysicsImpostor): number;
  118044. /**
  118045. * Sets stiffness of the impostor
  118046. * @param impostor impostor to set stiffness on
  118047. * @param stiffness stiffness value from 0 to 1
  118048. */
  118049. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118050. /**
  118051. * Gets velocityIterations of the impostor
  118052. * @param impostor impostor to get velocity iterations from
  118053. * @returns velocityIterations value
  118054. */
  118055. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118056. /**
  118057. * Sets velocityIterations of the impostor
  118058. * @param impostor impostor to set velocity iterations on
  118059. * @param velocityIterations velocityIterations value
  118060. */
  118061. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118062. /**
  118063. * Gets positionIterations of the impostor
  118064. * @param impostor impostor to get position iterations from
  118065. * @returns positionIterations value
  118066. */
  118067. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118068. /**
  118069. * Sets positionIterations of the impostor
  118070. * @param impostor impostor to set position on
  118071. * @param positionIterations positionIterations value
  118072. */
  118073. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118074. /**
  118075. * Append an anchor to a cloth object
  118076. * @param impostor is the cloth impostor to add anchor to
  118077. * @param otherImpostor is the rigid impostor to anchor to
  118078. * @param width ratio across width from 0 to 1
  118079. * @param height ratio up height from 0 to 1
  118080. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118081. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118082. */
  118083. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118084. /**
  118085. * Append an hook to a rope object
  118086. * @param impostor is the rope impostor to add hook to
  118087. * @param otherImpostor is the rigid impostor to hook to
  118088. * @param length ratio along the rope from 0 to 1
  118089. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118090. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118091. */
  118092. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118093. /**
  118094. * Sleeps the physics body and stops it from being active
  118095. * @param impostor impostor to sleep
  118096. */
  118097. sleepBody(impostor: PhysicsImpostor): void;
  118098. /**
  118099. * Activates the physics body
  118100. * @param impostor impostor to activate
  118101. */
  118102. wakeUpBody(impostor: PhysicsImpostor): void;
  118103. /**
  118104. * Updates the distance parameters of the joint
  118105. * @param joint joint to update
  118106. * @param maxDistance maximum distance of the joint
  118107. * @param minDistance minimum distance of the joint
  118108. */
  118109. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118110. /**
  118111. * Sets a motor on the joint
  118112. * @param joint joint to set motor on
  118113. * @param speed speed of the motor
  118114. * @param maxForce maximum force of the motor
  118115. * @param motorIndex index of the motor
  118116. */
  118117. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118118. /**
  118119. * Sets the motors limit
  118120. * @param joint joint to set limit on
  118121. * @param upperLimit upper limit
  118122. * @param lowerLimit lower limit
  118123. */
  118124. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118125. /**
  118126. * Syncs the position and rotation of a mesh with the impostor
  118127. * @param mesh mesh to sync
  118128. * @param impostor impostor to update the mesh with
  118129. */
  118130. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118131. /**
  118132. * Gets the radius of the impostor
  118133. * @param impostor impostor to get radius from
  118134. * @returns the radius
  118135. */
  118136. getRadius(impostor: PhysicsImpostor): number;
  118137. /**
  118138. * Gets the box size of the impostor
  118139. * @param impostor impostor to get box size from
  118140. * @param result the resulting box size
  118141. */
  118142. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118143. /**
  118144. * Disposes of the impostor
  118145. */
  118146. dispose(): void;
  118147. /**
  118148. * Does a raycast in the physics world
  118149. * @param from when should the ray start?
  118150. * @param to when should the ray end?
  118151. * @returns PhysicsRaycastResult
  118152. */
  118153. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118154. }
  118155. }
  118156. declare module BABYLON {
  118157. interface AbstractScene {
  118158. /**
  118159. * The list of reflection probes added to the scene
  118160. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118161. */
  118162. reflectionProbes: Array<ReflectionProbe>;
  118163. /**
  118164. * Removes the given reflection probe from this scene.
  118165. * @param toRemove The reflection probe to remove
  118166. * @returns The index of the removed reflection probe
  118167. */
  118168. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118169. /**
  118170. * Adds the given reflection probe to this scene.
  118171. * @param newReflectionProbe The reflection probe to add
  118172. */
  118173. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118174. }
  118175. /**
  118176. * Class used to generate realtime reflection / refraction cube textures
  118177. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118178. */
  118179. export class ReflectionProbe {
  118180. /** defines the name of the probe */
  118181. name: string;
  118182. private _scene;
  118183. private _renderTargetTexture;
  118184. private _projectionMatrix;
  118185. private _viewMatrix;
  118186. private _target;
  118187. private _add;
  118188. private _attachedMesh;
  118189. private _invertYAxis;
  118190. /** Gets or sets probe position (center of the cube map) */
  118191. position: Vector3;
  118192. /**
  118193. * Creates a new reflection probe
  118194. * @param name defines the name of the probe
  118195. * @param size defines the texture resolution (for each face)
  118196. * @param scene defines the hosting scene
  118197. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118198. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118199. */
  118200. constructor(
  118201. /** defines the name of the probe */
  118202. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118203. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118204. samples: number;
  118205. /** Gets or sets the refresh rate to use (on every frame by default) */
  118206. refreshRate: number;
  118207. /**
  118208. * Gets the hosting scene
  118209. * @returns a Scene
  118210. */
  118211. getScene(): Scene;
  118212. /** Gets the internal CubeTexture used to render to */
  118213. readonly cubeTexture: RenderTargetTexture;
  118214. /** Gets the list of meshes to render */
  118215. readonly renderList: Nullable<AbstractMesh[]>;
  118216. /**
  118217. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118218. * @param mesh defines the mesh to attach to
  118219. */
  118220. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118221. /**
  118222. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118223. * @param renderingGroupId The rendering group id corresponding to its index
  118224. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118225. */
  118226. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118227. /**
  118228. * Clean all associated resources
  118229. */
  118230. dispose(): void;
  118231. /**
  118232. * Converts the reflection probe information to a readable string for debug purpose.
  118233. * @param fullDetails Supports for multiple levels of logging within scene loading
  118234. * @returns the human readable reflection probe info
  118235. */
  118236. toString(fullDetails?: boolean): string;
  118237. /**
  118238. * Get the class name of the relfection probe.
  118239. * @returns "ReflectionProbe"
  118240. */
  118241. getClassName(): string;
  118242. /**
  118243. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118244. * @returns The JSON representation of the texture
  118245. */
  118246. serialize(): any;
  118247. /**
  118248. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118249. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118250. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118251. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118252. * @returns The parsed reflection probe if successful
  118253. */
  118254. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118255. }
  118256. }
  118257. declare module BABYLON {
  118258. /** @hidden */
  118259. export var _BabylonLoaderRegistered: boolean;
  118260. }
  118261. declare module BABYLON {
  118262. /**
  118263. * The Physically based simple base material of BJS.
  118264. *
  118265. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118266. * It is used as the base class for both the specGloss and metalRough conventions.
  118267. */
  118268. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118269. /**
  118270. * Number of Simultaneous lights allowed on the material.
  118271. */
  118272. maxSimultaneousLights: number;
  118273. /**
  118274. * If sets to true, disables all the lights affecting the material.
  118275. */
  118276. disableLighting: boolean;
  118277. /**
  118278. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118279. */
  118280. environmentTexture: BaseTexture;
  118281. /**
  118282. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118283. */
  118284. invertNormalMapX: boolean;
  118285. /**
  118286. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118287. */
  118288. invertNormalMapY: boolean;
  118289. /**
  118290. * Normal map used in the model.
  118291. */
  118292. normalTexture: BaseTexture;
  118293. /**
  118294. * Emissivie color used to self-illuminate the model.
  118295. */
  118296. emissiveColor: Color3;
  118297. /**
  118298. * Emissivie texture used to self-illuminate the model.
  118299. */
  118300. emissiveTexture: BaseTexture;
  118301. /**
  118302. * Occlusion Channel Strenght.
  118303. */
  118304. occlusionStrength: number;
  118305. /**
  118306. * Occlusion Texture of the material (adding extra occlusion effects).
  118307. */
  118308. occlusionTexture: BaseTexture;
  118309. /**
  118310. * Defines the alpha limits in alpha test mode.
  118311. */
  118312. alphaCutOff: number;
  118313. /**
  118314. * Gets the current double sided mode.
  118315. */
  118316. /**
  118317. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118318. */
  118319. doubleSided: boolean;
  118320. /**
  118321. * Stores the pre-calculated light information of a mesh in a texture.
  118322. */
  118323. lightmapTexture: BaseTexture;
  118324. /**
  118325. * If true, the light map contains occlusion information instead of lighting info.
  118326. */
  118327. useLightmapAsShadowmap: boolean;
  118328. /**
  118329. * Instantiates a new PBRMaterial instance.
  118330. *
  118331. * @param name The material name
  118332. * @param scene The scene the material will be use in.
  118333. */
  118334. constructor(name: string, scene: Scene);
  118335. getClassName(): string;
  118336. }
  118337. }
  118338. declare module BABYLON {
  118339. /**
  118340. * The PBR material of BJS following the metal roughness convention.
  118341. *
  118342. * This fits to the PBR convention in the GLTF definition:
  118343. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118344. */
  118345. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118346. /**
  118347. * The base color has two different interpretations depending on the value of metalness.
  118348. * When the material is a metal, the base color is the specific measured reflectance value
  118349. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118350. * of the material.
  118351. */
  118352. baseColor: Color3;
  118353. /**
  118354. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118355. * well as opacity information in the alpha channel.
  118356. */
  118357. baseTexture: BaseTexture;
  118358. /**
  118359. * Specifies the metallic scalar value of the material.
  118360. * Can also be used to scale the metalness values of the metallic texture.
  118361. */
  118362. metallic: number;
  118363. /**
  118364. * Specifies the roughness scalar value of the material.
  118365. * Can also be used to scale the roughness values of the metallic texture.
  118366. */
  118367. roughness: number;
  118368. /**
  118369. * Texture containing both the metallic value in the B channel and the
  118370. * roughness value in the G channel to keep better precision.
  118371. */
  118372. metallicRoughnessTexture: BaseTexture;
  118373. /**
  118374. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118375. *
  118376. * @param name The material name
  118377. * @param scene The scene the material will be use in.
  118378. */
  118379. constructor(name: string, scene: Scene);
  118380. /**
  118381. * Return the currrent class name of the material.
  118382. */
  118383. getClassName(): string;
  118384. /**
  118385. * Makes a duplicate of the current material.
  118386. * @param name - name to use for the new material.
  118387. */
  118388. clone(name: string): PBRMetallicRoughnessMaterial;
  118389. /**
  118390. * Serialize the material to a parsable JSON object.
  118391. */
  118392. serialize(): any;
  118393. /**
  118394. * Parses a JSON object correponding to the serialize function.
  118395. */
  118396. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118397. }
  118398. }
  118399. declare module BABYLON {
  118400. /**
  118401. * The PBR material of BJS following the specular glossiness convention.
  118402. *
  118403. * This fits to the PBR convention in the GLTF definition:
  118404. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118405. */
  118406. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118407. /**
  118408. * Specifies the diffuse color of the material.
  118409. */
  118410. diffuseColor: Color3;
  118411. /**
  118412. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118413. * channel.
  118414. */
  118415. diffuseTexture: BaseTexture;
  118416. /**
  118417. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118418. */
  118419. specularColor: Color3;
  118420. /**
  118421. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118422. */
  118423. glossiness: number;
  118424. /**
  118425. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118426. */
  118427. specularGlossinessTexture: BaseTexture;
  118428. /**
  118429. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118430. *
  118431. * @param name The material name
  118432. * @param scene The scene the material will be use in.
  118433. */
  118434. constructor(name: string, scene: Scene);
  118435. /**
  118436. * Return the currrent class name of the material.
  118437. */
  118438. getClassName(): string;
  118439. /**
  118440. * Makes a duplicate of the current material.
  118441. * @param name - name to use for the new material.
  118442. */
  118443. clone(name: string): PBRSpecularGlossinessMaterial;
  118444. /**
  118445. * Serialize the material to a parsable JSON object.
  118446. */
  118447. serialize(): any;
  118448. /**
  118449. * Parses a JSON object correponding to the serialize function.
  118450. */
  118451. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118452. }
  118453. }
  118454. declare module BABYLON {
  118455. /**
  118456. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118457. * It can help converting any input color in a desired output one. This can then be used to create effects
  118458. * from sepia, black and white to sixties or futuristic rendering...
  118459. *
  118460. * The only supported format is currently 3dl.
  118461. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118462. */
  118463. export class ColorGradingTexture extends BaseTexture {
  118464. /**
  118465. * The current texture matrix. (will always be identity in color grading texture)
  118466. */
  118467. private _textureMatrix;
  118468. /**
  118469. * The texture URL.
  118470. */
  118471. url: string;
  118472. /**
  118473. * Empty line regex stored for GC.
  118474. */
  118475. private static _noneEmptyLineRegex;
  118476. private _engine;
  118477. /**
  118478. * Instantiates a ColorGradingTexture from the following parameters.
  118479. *
  118480. * @param url The location of the color gradind data (currently only supporting 3dl)
  118481. * @param scene The scene the texture will be used in
  118482. */
  118483. constructor(url: string, scene: Scene);
  118484. /**
  118485. * Returns the texture matrix used in most of the material.
  118486. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118487. */
  118488. getTextureMatrix(): Matrix;
  118489. /**
  118490. * Occurs when the file being loaded is a .3dl LUT file.
  118491. */
  118492. private load3dlTexture;
  118493. /**
  118494. * Starts the loading process of the texture.
  118495. */
  118496. private loadTexture;
  118497. /**
  118498. * Clones the color gradind texture.
  118499. */
  118500. clone(): ColorGradingTexture;
  118501. /**
  118502. * Called during delayed load for textures.
  118503. */
  118504. delayLoad(): void;
  118505. /**
  118506. * Parses a color grading texture serialized by Babylon.
  118507. * @param parsedTexture The texture information being parsedTexture
  118508. * @param scene The scene to load the texture in
  118509. * @param rootUrl The root url of the data assets to load
  118510. * @return A color gradind texture
  118511. */
  118512. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118513. /**
  118514. * Serializes the LUT texture to json format.
  118515. */
  118516. serialize(): any;
  118517. }
  118518. }
  118519. declare module BABYLON {
  118520. /**
  118521. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118522. */
  118523. export class EquiRectangularCubeTexture extends BaseTexture {
  118524. /** The six faces of the cube. */
  118525. private static _FacesMapping;
  118526. private _noMipmap;
  118527. private _onLoad;
  118528. private _onError;
  118529. /** The size of the cubemap. */
  118530. private _size;
  118531. /** The buffer of the image. */
  118532. private _buffer;
  118533. /** The width of the input image. */
  118534. private _width;
  118535. /** The height of the input image. */
  118536. private _height;
  118537. /** The URL to the image. */
  118538. url: string;
  118539. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118540. coordinatesMode: number;
  118541. /**
  118542. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118543. * @param url The location of the image
  118544. * @param scene The scene the texture will be used in
  118545. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118546. * @param noMipmap Forces to not generate the mipmap if true
  118547. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118548. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118549. * @param onLoad — defines a callback called when texture is loaded
  118550. * @param onError — defines a callback called if there is an error
  118551. */
  118552. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118553. /**
  118554. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118555. */
  118556. private loadImage;
  118557. /**
  118558. * Convert the image buffer into a cubemap and create a CubeTexture.
  118559. */
  118560. private loadTexture;
  118561. /**
  118562. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118563. * @param buffer The ArrayBuffer that should be converted.
  118564. * @returns The buffer as Float32Array.
  118565. */
  118566. private getFloat32ArrayFromArrayBuffer;
  118567. /**
  118568. * Get the current class name of the texture useful for serialization or dynamic coding.
  118569. * @returns "EquiRectangularCubeTexture"
  118570. */
  118571. getClassName(): string;
  118572. /**
  118573. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118574. * @returns A clone of the current EquiRectangularCubeTexture.
  118575. */
  118576. clone(): EquiRectangularCubeTexture;
  118577. }
  118578. }
  118579. declare module BABYLON {
  118580. /**
  118581. * Based on jsTGALoader - Javascript loader for TGA file
  118582. * By Vincent Thibault
  118583. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118584. */
  118585. export class TGATools {
  118586. private static _TYPE_INDEXED;
  118587. private static _TYPE_RGB;
  118588. private static _TYPE_GREY;
  118589. private static _TYPE_RLE_INDEXED;
  118590. private static _TYPE_RLE_RGB;
  118591. private static _TYPE_RLE_GREY;
  118592. private static _ORIGIN_MASK;
  118593. private static _ORIGIN_SHIFT;
  118594. private static _ORIGIN_BL;
  118595. private static _ORIGIN_BR;
  118596. private static _ORIGIN_UL;
  118597. private static _ORIGIN_UR;
  118598. /**
  118599. * Gets the header of a TGA file
  118600. * @param data defines the TGA data
  118601. * @returns the header
  118602. */
  118603. static GetTGAHeader(data: Uint8Array): any;
  118604. /**
  118605. * Uploads TGA content to a Babylon Texture
  118606. * @hidden
  118607. */
  118608. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118609. /** @hidden */
  118610. 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;
  118611. /** @hidden */
  118612. 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;
  118613. /** @hidden */
  118614. 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;
  118615. /** @hidden */
  118616. 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;
  118617. /** @hidden */
  118618. 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;
  118619. /** @hidden */
  118620. 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;
  118621. }
  118622. }
  118623. declare module BABYLON {
  118624. /**
  118625. * Implementation of the TGA Texture Loader.
  118626. * @hidden
  118627. */
  118628. export class _TGATextureLoader implements IInternalTextureLoader {
  118629. /**
  118630. * Defines wether the loader supports cascade loading the different faces.
  118631. */
  118632. readonly supportCascades: boolean;
  118633. /**
  118634. * This returns if the loader support the current file information.
  118635. * @param extension defines the file extension of the file being loaded
  118636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118637. * @param fallback defines the fallback internal texture if any
  118638. * @param isBase64 defines whether the texture is encoded as a base64
  118639. * @param isBuffer defines whether the texture data are stored as a buffer
  118640. * @returns true if the loader can load the specified file
  118641. */
  118642. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118643. /**
  118644. * Transform the url before loading if required.
  118645. * @param rootUrl the url of the texture
  118646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118647. * @returns the transformed texture
  118648. */
  118649. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118650. /**
  118651. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118652. * @param rootUrl the url of the texture
  118653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118654. * @returns the fallback texture
  118655. */
  118656. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118657. /**
  118658. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118659. * @param data contains the texture data
  118660. * @param texture defines the BabylonJS internal texture
  118661. * @param createPolynomials will be true if polynomials have been requested
  118662. * @param onLoad defines the callback to trigger once the texture is ready
  118663. * @param onError defines the callback to trigger in case of error
  118664. */
  118665. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118666. /**
  118667. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118668. * @param data contains the texture data
  118669. * @param texture defines the BabylonJS internal texture
  118670. * @param callback defines the method to call once ready to upload
  118671. */
  118672. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118673. }
  118674. }
  118675. declare module BABYLON {
  118676. /**
  118677. * Info about the .basis files
  118678. */
  118679. class BasisFileInfo {
  118680. /**
  118681. * If the file has alpha
  118682. */
  118683. hasAlpha: boolean;
  118684. /**
  118685. * Info about each image of the basis file
  118686. */
  118687. images: Array<{
  118688. levels: Array<{
  118689. width: number;
  118690. height: number;
  118691. transcodedPixels: ArrayBufferView;
  118692. }>;
  118693. }>;
  118694. }
  118695. /**
  118696. * Result of transcoding a basis file
  118697. */
  118698. class TranscodeResult {
  118699. /**
  118700. * Info about the .basis file
  118701. */
  118702. fileInfo: BasisFileInfo;
  118703. /**
  118704. * Format to use when loading the file
  118705. */
  118706. format: number;
  118707. }
  118708. /**
  118709. * Configuration options for the Basis transcoder
  118710. */
  118711. export class BasisTranscodeConfiguration {
  118712. /**
  118713. * Supported compression formats used to determine the supported output format of the transcoder
  118714. */
  118715. supportedCompressionFormats?: {
  118716. /**
  118717. * etc1 compression format
  118718. */
  118719. etc1?: boolean;
  118720. /**
  118721. * s3tc compression format
  118722. */
  118723. s3tc?: boolean;
  118724. /**
  118725. * pvrtc compression format
  118726. */
  118727. pvrtc?: boolean;
  118728. /**
  118729. * etc2 compression format
  118730. */
  118731. etc2?: boolean;
  118732. };
  118733. /**
  118734. * If mipmap levels should be loaded for transcoded images (Default: true)
  118735. */
  118736. loadMipmapLevels?: boolean;
  118737. /**
  118738. * Index of a single image to load (Default: all images)
  118739. */
  118740. loadSingleImage?: number;
  118741. }
  118742. /**
  118743. * Used to load .Basis files
  118744. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118745. */
  118746. export class BasisTools {
  118747. private static _IgnoreSupportedFormats;
  118748. /**
  118749. * URL to use when loading the basis transcoder
  118750. */
  118751. static JSModuleURL: string;
  118752. /**
  118753. * URL to use when loading the wasm module for the transcoder
  118754. */
  118755. static WasmModuleURL: string;
  118756. /**
  118757. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118758. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118759. * @returns internal format corresponding to the Basis format
  118760. */
  118761. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118762. private static _WorkerPromise;
  118763. private static _Worker;
  118764. private static _actionId;
  118765. private static _CreateWorkerAsync;
  118766. /**
  118767. * Transcodes a loaded image file to compressed pixel data
  118768. * @param imageData image data to transcode
  118769. * @param config configuration options for the transcoding
  118770. * @returns a promise resulting in the transcoded image
  118771. */
  118772. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118773. /**
  118774. * Loads a texture from the transcode result
  118775. * @param texture texture load to
  118776. * @param transcodeResult the result of transcoding the basis file to load from
  118777. */
  118778. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  118779. }
  118780. }
  118781. declare module BABYLON {
  118782. /**
  118783. * Loader for .basis file format
  118784. */
  118785. export class _BasisTextureLoader implements IInternalTextureLoader {
  118786. /**
  118787. * Defines whether the loader supports cascade loading the different faces.
  118788. */
  118789. readonly supportCascades: boolean;
  118790. /**
  118791. * This returns if the loader support the current file information.
  118792. * @param extension defines the file extension of the file being loaded
  118793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118794. * @param fallback defines the fallback internal texture if any
  118795. * @param isBase64 defines whether the texture is encoded as a base64
  118796. * @param isBuffer defines whether the texture data are stored as a buffer
  118797. * @returns true if the loader can load the specified file
  118798. */
  118799. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118800. /**
  118801. * Transform the url before loading if required.
  118802. * @param rootUrl the url of the texture
  118803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118804. * @returns the transformed texture
  118805. */
  118806. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118807. /**
  118808. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118809. * @param rootUrl the url of the texture
  118810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118811. * @returns the fallback texture
  118812. */
  118813. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118814. /**
  118815. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  118816. * @param data contains the texture data
  118817. * @param texture defines the BabylonJS internal texture
  118818. * @param createPolynomials will be true if polynomials have been requested
  118819. * @param onLoad defines the callback to trigger once the texture is ready
  118820. * @param onError defines the callback to trigger in case of error
  118821. */
  118822. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118823. /**
  118824. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118825. * @param data contains the texture data
  118826. * @param texture defines the BabylonJS internal texture
  118827. * @param callback defines the method to call once ready to upload
  118828. */
  118829. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118830. }
  118831. }
  118832. declare module BABYLON {
  118833. /**
  118834. * 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.
  118835. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118837. */
  118838. export class CustomProceduralTexture extends ProceduralTexture {
  118839. private _animate;
  118840. private _time;
  118841. private _config;
  118842. private _texturePath;
  118843. /**
  118844. * Instantiates a new Custom Procedural Texture.
  118845. * 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.
  118846. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118847. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118848. * @param name Define the name of the texture
  118849. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  118850. * @param size Define the size of the texture to create
  118851. * @param scene Define the scene the texture belongs to
  118852. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  118853. * @param generateMipMaps Define if the texture should creates mip maps or not
  118854. */
  118855. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118856. private _loadJson;
  118857. /**
  118858. * Is the texture ready to be used ? (rendered at least once)
  118859. * @returns true if ready, otherwise, false.
  118860. */
  118861. isReady(): boolean;
  118862. /**
  118863. * Render the texture to its associated render target.
  118864. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  118865. */
  118866. render(useCameraPostProcess?: boolean): void;
  118867. /**
  118868. * Update the list of dependant textures samplers in the shader.
  118869. */
  118870. updateTextures(): void;
  118871. /**
  118872. * Update the uniform values of the procedural texture in the shader.
  118873. */
  118874. updateShaderUniforms(): void;
  118875. /**
  118876. * Define if the texture animates or not.
  118877. */
  118878. animate: boolean;
  118879. }
  118880. }
  118881. declare module BABYLON {
  118882. /** @hidden */
  118883. export var noisePixelShader: {
  118884. name: string;
  118885. shader: string;
  118886. };
  118887. }
  118888. declare module BABYLON {
  118889. /**
  118890. * Class used to generate noise procedural textures
  118891. */
  118892. export class NoiseProceduralTexture extends ProceduralTexture {
  118893. private _time;
  118894. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  118895. brightness: number;
  118896. /** Defines the number of octaves to process */
  118897. octaves: number;
  118898. /** Defines the level of persistence (0.8 by default) */
  118899. persistence: number;
  118900. /** Gets or sets animation speed factor (default is 1) */
  118901. animationSpeedFactor: number;
  118902. /**
  118903. * Creates a new NoiseProceduralTexture
  118904. * @param name defines the name fo the texture
  118905. * @param size defines the size of the texture (default is 256)
  118906. * @param scene defines the hosting scene
  118907. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  118908. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  118909. */
  118910. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118911. private _updateShaderUniforms;
  118912. protected _getDefines(): string;
  118913. /** Generate the current state of the procedural texture */
  118914. render(useCameraPostProcess?: boolean): void;
  118915. /**
  118916. * Serializes this noise procedural texture
  118917. * @returns a serialized noise procedural texture object
  118918. */
  118919. serialize(): any;
  118920. /**
  118921. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  118922. * @param parsedTexture defines parsed texture data
  118923. * @param scene defines the current scene
  118924. * @param rootUrl defines the root URL containing noise procedural texture information
  118925. * @returns a parsed NoiseProceduralTexture
  118926. */
  118927. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  118928. }
  118929. }
  118930. declare module BABYLON {
  118931. /**
  118932. * Raw cube texture where the raw buffers are passed in
  118933. */
  118934. export class RawCubeTexture extends CubeTexture {
  118935. /**
  118936. * Creates a cube texture where the raw buffers are passed in.
  118937. * @param scene defines the scene the texture is attached to
  118938. * @param data defines the array of data to use to create each face
  118939. * @param size defines the size of the textures
  118940. * @param format defines the format of the data
  118941. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  118942. * @param generateMipMaps defines if the engine should generate the mip levels
  118943. * @param invertY defines if data must be stored with Y axis inverted
  118944. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  118945. * @param compression defines the compression used (null by default)
  118946. */
  118947. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  118948. /**
  118949. * Updates the raw cube texture.
  118950. * @param data defines the data to store
  118951. * @param format defines the data format
  118952. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118953. * @param invertY defines if data must be stored with Y axis inverted
  118954. * @param compression defines the compression used (null by default)
  118955. * @param level defines which level of the texture to update
  118956. */
  118957. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  118958. /**
  118959. * Updates a raw cube texture with RGBD encoded data.
  118960. * @param data defines the array of data [mipmap][face] to use to create each face
  118961. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  118962. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  118963. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  118964. * @returns a promsie that resolves when the operation is complete
  118965. */
  118966. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  118967. /**
  118968. * Clones the raw cube texture.
  118969. * @return a new cube texture
  118970. */
  118971. clone(): CubeTexture;
  118972. /** @hidden */
  118973. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  118974. }
  118975. }
  118976. declare module BABYLON {
  118977. /**
  118978. * Class used to store 3D textures containing user data
  118979. */
  118980. export class RawTexture3D extends Texture {
  118981. /** Gets or sets the texture format to use */
  118982. format: number;
  118983. private _engine;
  118984. /**
  118985. * Create a new RawTexture3D
  118986. * @param data defines the data of the texture
  118987. * @param width defines the width of the texture
  118988. * @param height defines the height of the texture
  118989. * @param depth defines the depth of the texture
  118990. * @param format defines the texture format to use
  118991. * @param scene defines the hosting scene
  118992. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  118993. * @param invertY defines if texture must be stored with Y axis inverted
  118994. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  118995. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  118996. */
  118997. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  118998. /** Gets or sets the texture format to use */
  118999. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119000. /**
  119001. * Update the texture with new data
  119002. * @param data defines the data to store in the texture
  119003. */
  119004. update(data: ArrayBufferView): void;
  119005. }
  119006. }
  119007. declare module BABYLON {
  119008. /**
  119009. * Creates a refraction texture used by refraction channel of the standard material.
  119010. * It is like a mirror but to see through a material.
  119011. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119012. */
  119013. export class RefractionTexture extends RenderTargetTexture {
  119014. /**
  119015. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119016. * 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.
  119017. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119018. */
  119019. refractionPlane: Plane;
  119020. /**
  119021. * Define how deep under the surface we should see.
  119022. */
  119023. depth: number;
  119024. /**
  119025. * Creates a refraction texture used by refraction channel of the standard material.
  119026. * It is like a mirror but to see through a material.
  119027. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119028. * @param name Define the texture name
  119029. * @param size Define the size of the underlying texture
  119030. * @param scene Define the scene the refraction belongs to
  119031. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119032. */
  119033. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119034. /**
  119035. * Clone the refraction texture.
  119036. * @returns the cloned texture
  119037. */
  119038. clone(): RefractionTexture;
  119039. /**
  119040. * Serialize the texture to a JSON representation you could use in Parse later on
  119041. * @returns the serialized JSON representation
  119042. */
  119043. serialize(): any;
  119044. }
  119045. }
  119046. declare module BABYLON {
  119047. /**
  119048. * Defines the options related to the creation of an HtmlElementTexture
  119049. */
  119050. export interface IHtmlElementTextureOptions {
  119051. /**
  119052. * Defines wether mip maps should be created or not.
  119053. */
  119054. generateMipMaps?: boolean;
  119055. /**
  119056. * Defines the sampling mode of the texture.
  119057. */
  119058. samplingMode?: number;
  119059. /**
  119060. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119061. */
  119062. engine: Nullable<Engine>;
  119063. /**
  119064. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119065. */
  119066. scene: Nullable<Scene>;
  119067. }
  119068. /**
  119069. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119070. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119071. * is automatically managed.
  119072. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119073. * in your application.
  119074. *
  119075. * As the update is not automatic, you need to call them manually.
  119076. */
  119077. export class HtmlElementTexture extends BaseTexture {
  119078. /**
  119079. * The texture URL.
  119080. */
  119081. element: HTMLVideoElement | HTMLCanvasElement;
  119082. private static readonly DefaultOptions;
  119083. private _textureMatrix;
  119084. private _engine;
  119085. private _isVideo;
  119086. private _generateMipMaps;
  119087. private _samplingMode;
  119088. /**
  119089. * Instantiates a HtmlElementTexture from the following parameters.
  119090. *
  119091. * @param name Defines the name of the texture
  119092. * @param element Defines the video or canvas the texture is filled with
  119093. * @param options Defines the other none mandatory texture creation options
  119094. */
  119095. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119096. private _createInternalTexture;
  119097. /**
  119098. * Returns the texture matrix used in most of the material.
  119099. */
  119100. getTextureMatrix(): Matrix;
  119101. /**
  119102. * Updates the content of the texture.
  119103. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119104. */
  119105. update(invertY?: Nullable<boolean>): void;
  119106. }
  119107. }
  119108. declare module BABYLON {
  119109. /**
  119110. * Enum used to define the target of a block
  119111. */
  119112. export enum NodeMaterialBlockTargets {
  119113. /** Vertex shader */
  119114. Vertex = 1,
  119115. /** Fragment shader */
  119116. Fragment = 2,
  119117. /** Neutral */
  119118. Neutral = 4,
  119119. /** Vertex and Fragment */
  119120. VertexAndFragment = 3
  119121. }
  119122. }
  119123. declare module BABYLON {
  119124. /**
  119125. * Defines the kind of connection point for node based material
  119126. */
  119127. export enum NodeMaterialBlockConnectionPointTypes {
  119128. /** Float */
  119129. Float = 1,
  119130. /** Int */
  119131. Int = 2,
  119132. /** Vector2 */
  119133. Vector2 = 4,
  119134. /** Vector3 */
  119135. Vector3 = 8,
  119136. /** Vector4 */
  119137. Vector4 = 16,
  119138. /** Color3 */
  119139. Color3 = 32,
  119140. /** Color4 */
  119141. Color4 = 64,
  119142. /** Matrix */
  119143. Matrix = 128,
  119144. /** Detect type based on connection */
  119145. AutoDetect = 1024,
  119146. /** Output type that will be defined by input type */
  119147. BasedOnInput = 2048
  119148. }
  119149. }
  119150. declare module BABYLON {
  119151. /**
  119152. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119153. */
  119154. export enum NodeMaterialBlockConnectionPointMode {
  119155. /** Value is an uniform */
  119156. Uniform = 0,
  119157. /** Value is a mesh attribute */
  119158. Attribute = 1,
  119159. /** Value is a varying between vertex and fragment shaders */
  119160. Varying = 2,
  119161. /** Mode is undefined */
  119162. Undefined = 3
  119163. }
  119164. }
  119165. declare module BABYLON {
  119166. /**
  119167. * Enum used to define system values e.g. values automatically provided by the system
  119168. */
  119169. export enum NodeMaterialSystemValues {
  119170. /** World */
  119171. World = 1,
  119172. /** View */
  119173. View = 2,
  119174. /** Projection */
  119175. Projection = 3,
  119176. /** ViewProjection */
  119177. ViewProjection = 4,
  119178. /** WorldView */
  119179. WorldView = 5,
  119180. /** WorldViewProjection */
  119181. WorldViewProjection = 6,
  119182. /** CameraPosition */
  119183. CameraPosition = 7,
  119184. /** Fog Color */
  119185. FogColor = 8,
  119186. /** Delta time */
  119187. DeltaTime = 9
  119188. }
  119189. }
  119190. declare module BABYLON {
  119191. /**
  119192. * Root class for all node material optimizers
  119193. */
  119194. export class NodeMaterialOptimizer {
  119195. /**
  119196. * Function used to optimize a NodeMaterial graph
  119197. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119198. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119199. */
  119200. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119201. }
  119202. }
  119203. declare module BABYLON {
  119204. /**
  119205. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119206. */
  119207. export class TransformBlock extends NodeMaterialBlock {
  119208. /**
  119209. * Defines the value to use to complement W value to transform it to a Vector4
  119210. */
  119211. complementW: number;
  119212. /**
  119213. * Defines the value to use to complement z value to transform it to a Vector4
  119214. */
  119215. complementZ: number;
  119216. /**
  119217. * Creates a new TransformBlock
  119218. * @param name defines the block name
  119219. */
  119220. constructor(name: string);
  119221. /**
  119222. * Gets the current class name
  119223. * @returns the class name
  119224. */
  119225. getClassName(): string;
  119226. /**
  119227. * Gets the vector input
  119228. */
  119229. readonly vector: NodeMaterialConnectionPoint;
  119230. /**
  119231. * Gets the output component
  119232. */
  119233. readonly output: NodeMaterialConnectionPoint;
  119234. /**
  119235. * Gets the matrix transform input
  119236. */
  119237. readonly transform: NodeMaterialConnectionPoint;
  119238. protected _buildBlock(state: NodeMaterialBuildState): this;
  119239. serialize(): any;
  119240. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119241. protected _dumpPropertiesCode(): string;
  119242. }
  119243. }
  119244. declare module BABYLON {
  119245. /**
  119246. * Block used to output the vertex position
  119247. */
  119248. export class VertexOutputBlock extends NodeMaterialBlock {
  119249. /**
  119250. * Creates a new VertexOutputBlock
  119251. * @param name defines the block name
  119252. */
  119253. constructor(name: string);
  119254. /**
  119255. * Gets the current class name
  119256. * @returns the class name
  119257. */
  119258. getClassName(): string;
  119259. /**
  119260. * Gets the vector input component
  119261. */
  119262. readonly vector: NodeMaterialConnectionPoint;
  119263. protected _buildBlock(state: NodeMaterialBuildState): this;
  119264. }
  119265. }
  119266. declare module BABYLON {
  119267. /**
  119268. * Block used to output the final color
  119269. */
  119270. export class FragmentOutputBlock extends NodeMaterialBlock {
  119271. /**
  119272. * Create a new FragmentOutputBlock
  119273. * @param name defines the block name
  119274. */
  119275. constructor(name: string);
  119276. /**
  119277. * Gets the current class name
  119278. * @returns the class name
  119279. */
  119280. getClassName(): string;
  119281. /**
  119282. * Gets the rgba input component
  119283. */
  119284. readonly rgba: NodeMaterialConnectionPoint;
  119285. /**
  119286. * Gets the rgb input component
  119287. */
  119288. readonly rgb: NodeMaterialConnectionPoint;
  119289. /**
  119290. * Gets the a input component
  119291. */
  119292. readonly a: NodeMaterialConnectionPoint;
  119293. protected _buildBlock(state: NodeMaterialBuildState): this;
  119294. }
  119295. }
  119296. declare module BABYLON {
  119297. /**
  119298. * Block used to read a reflection texture from a sampler
  119299. */
  119300. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119301. private _define3DName;
  119302. private _defineCubicName;
  119303. private _defineExplicitName;
  119304. private _defineProjectionName;
  119305. private _defineLocalCubicName;
  119306. private _defineSphericalName;
  119307. private _definePlanarName;
  119308. private _defineEquirectangularName;
  119309. private _defineMirroredEquirectangularFixedName;
  119310. private _defineEquirectangularFixedName;
  119311. private _defineSkyboxName;
  119312. private _cubeSamplerName;
  119313. private _2DSamplerName;
  119314. private _positionUVWName;
  119315. private _directionWName;
  119316. private _reflectionCoordsName;
  119317. private _reflection2DCoordsName;
  119318. private _reflectionColorName;
  119319. private _reflectionMatrixName;
  119320. /**
  119321. * Gets or sets the texture associated with the node
  119322. */
  119323. texture: Nullable<BaseTexture>;
  119324. /**
  119325. * Create a new TextureBlock
  119326. * @param name defines the block name
  119327. */
  119328. constructor(name: string);
  119329. /**
  119330. * Gets the current class name
  119331. * @returns the class name
  119332. */
  119333. getClassName(): string;
  119334. /**
  119335. * Gets the world position input component
  119336. */
  119337. readonly position: NodeMaterialConnectionPoint;
  119338. /**
  119339. * Gets the world position input component
  119340. */
  119341. readonly worldPosition: NodeMaterialConnectionPoint;
  119342. /**
  119343. * Gets the world normal input component
  119344. */
  119345. readonly worldNormal: NodeMaterialConnectionPoint;
  119346. /**
  119347. * Gets the world input component
  119348. */
  119349. readonly world: NodeMaterialConnectionPoint;
  119350. /**
  119351. * Gets the camera (or eye) position component
  119352. */
  119353. readonly cameraPosition: NodeMaterialConnectionPoint;
  119354. /**
  119355. * Gets the view input component
  119356. */
  119357. readonly view: NodeMaterialConnectionPoint;
  119358. /**
  119359. * Gets the rgb output component
  119360. */
  119361. readonly rgb: NodeMaterialConnectionPoint;
  119362. /**
  119363. * Gets the r output component
  119364. */
  119365. readonly r: NodeMaterialConnectionPoint;
  119366. /**
  119367. * Gets the g output component
  119368. */
  119369. readonly g: NodeMaterialConnectionPoint;
  119370. /**
  119371. * Gets the b output component
  119372. */
  119373. readonly b: NodeMaterialConnectionPoint;
  119374. autoConfigure(material: NodeMaterial): void;
  119375. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119376. isReady(): boolean;
  119377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119378. private _injectVertexCode;
  119379. private _writeOutput;
  119380. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119381. serialize(): any;
  119382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119383. }
  119384. }
  119385. declare module BABYLON {
  119386. /**
  119387. * Interface used to configure the node material editor
  119388. */
  119389. export interface INodeMaterialEditorOptions {
  119390. /** Define the URl to load node editor script */
  119391. editorURL?: string;
  119392. }
  119393. /** @hidden */
  119394. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119395. /** BONES */
  119396. NUM_BONE_INFLUENCERS: number;
  119397. BonesPerMesh: number;
  119398. BONETEXTURE: boolean;
  119399. /** MORPH TARGETS */
  119400. MORPHTARGETS: boolean;
  119401. MORPHTARGETS_NORMAL: boolean;
  119402. MORPHTARGETS_TANGENT: boolean;
  119403. MORPHTARGETS_UV: boolean;
  119404. NUM_MORPH_INFLUENCERS: number;
  119405. /** IMAGE PROCESSING */
  119406. IMAGEPROCESSING: boolean;
  119407. VIGNETTE: boolean;
  119408. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119409. VIGNETTEBLENDMODEOPAQUE: boolean;
  119410. TONEMAPPING: boolean;
  119411. TONEMAPPING_ACES: boolean;
  119412. CONTRAST: boolean;
  119413. EXPOSURE: boolean;
  119414. COLORCURVES: boolean;
  119415. COLORGRADING: boolean;
  119416. COLORGRADING3D: boolean;
  119417. SAMPLER3DGREENDEPTH: boolean;
  119418. SAMPLER3DBGRMAP: boolean;
  119419. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119420. /** MISC. */
  119421. BUMPDIRECTUV: number;
  119422. constructor();
  119423. setValue(name: string, value: boolean): void;
  119424. }
  119425. /**
  119426. * Class used to configure NodeMaterial
  119427. */
  119428. export interface INodeMaterialOptions {
  119429. /**
  119430. * Defines if blocks should emit comments
  119431. */
  119432. emitComments: boolean;
  119433. }
  119434. /**
  119435. * Class used to create a node based material built by assembling shader blocks
  119436. */
  119437. export class NodeMaterial extends PushMaterial {
  119438. private static _BuildIdGenerator;
  119439. private _options;
  119440. private _vertexCompilationState;
  119441. private _fragmentCompilationState;
  119442. private _sharedData;
  119443. private _buildId;
  119444. private _buildWasSuccessful;
  119445. private _cachedWorldViewMatrix;
  119446. private _cachedWorldViewProjectionMatrix;
  119447. private _optimizers;
  119448. private _animationFrame;
  119449. /** Define the URl to load node editor script */
  119450. static EditorURL: string;
  119451. private BJSNODEMATERIALEDITOR;
  119452. /** Get the inspector from bundle or global */
  119453. private _getGlobalNodeMaterialEditor;
  119454. /**
  119455. * 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)
  119456. */
  119457. ignoreAlpha: boolean;
  119458. /**
  119459. * Defines the maximum number of lights that can be used in the material
  119460. */
  119461. maxSimultaneousLights: number;
  119462. /**
  119463. * Observable raised when the material is built
  119464. */
  119465. onBuildObservable: Observable<NodeMaterial>;
  119466. /**
  119467. * Gets or sets the root nodes of the material vertex shader
  119468. */
  119469. _vertexOutputNodes: NodeMaterialBlock[];
  119470. /**
  119471. * Gets or sets the root nodes of the material fragment (pixel) shader
  119472. */
  119473. _fragmentOutputNodes: NodeMaterialBlock[];
  119474. /** Gets or sets options to control the node material overall behavior */
  119475. options: INodeMaterialOptions;
  119476. /**
  119477. * Default configuration related to image processing available in the standard Material.
  119478. */
  119479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119480. /**
  119481. * Gets the image processing configuration used either in this material.
  119482. */
  119483. /**
  119484. * Sets the Default image processing configuration used either in the this material.
  119485. *
  119486. * If sets to null, the scene one is in use.
  119487. */
  119488. imageProcessingConfiguration: ImageProcessingConfiguration;
  119489. /**
  119490. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119491. */
  119492. attachedBlocks: NodeMaterialBlock[];
  119493. /**
  119494. * Create a new node based material
  119495. * @param name defines the material name
  119496. * @param scene defines the hosting scene
  119497. * @param options defines creation option
  119498. */
  119499. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119500. /**
  119501. * Gets the current class name of the material e.g. "NodeMaterial"
  119502. * @returns the class name
  119503. */
  119504. getClassName(): string;
  119505. /**
  119506. * Keep track of the image processing observer to allow dispose and replace.
  119507. */
  119508. private _imageProcessingObserver;
  119509. /**
  119510. * Attaches a new image processing configuration to the Standard Material.
  119511. * @param configuration
  119512. */
  119513. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119514. /**
  119515. * Get a block by its name
  119516. * @param name defines the name of the block to retrieve
  119517. * @returns the required block or null if not found
  119518. */
  119519. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119520. /**
  119521. * Get a block by its name
  119522. * @param predicate defines the predicate used to find the good candidate
  119523. * @returns the required block or null if not found
  119524. */
  119525. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119526. /**
  119527. * Get an input block by its name
  119528. * @param predicate defines the predicate used to find the good candidate
  119529. * @returns the required input block or null if not found
  119530. */
  119531. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119532. /**
  119533. * Gets the list of input blocks attached to this material
  119534. * @returns an array of InputBlocks
  119535. */
  119536. getInputBlocks(): InputBlock[];
  119537. /**
  119538. * Adds a new optimizer to the list of optimizers
  119539. * @param optimizer defines the optimizers to add
  119540. * @returns the current material
  119541. */
  119542. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119543. /**
  119544. * Remove an optimizer from the list of optimizers
  119545. * @param optimizer defines the optimizers to remove
  119546. * @returns the current material
  119547. */
  119548. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119549. /**
  119550. * Add a new block to the list of output nodes
  119551. * @param node defines the node to add
  119552. * @returns the current material
  119553. */
  119554. addOutputNode(node: NodeMaterialBlock): this;
  119555. /**
  119556. * Remove a block from the list of root nodes
  119557. * @param node defines the node to remove
  119558. * @returns the current material
  119559. */
  119560. removeOutputNode(node: NodeMaterialBlock): this;
  119561. private _addVertexOutputNode;
  119562. private _removeVertexOutputNode;
  119563. private _addFragmentOutputNode;
  119564. private _removeFragmentOutputNode;
  119565. /**
  119566. * Specifies if the material will require alpha blending
  119567. * @returns a boolean specifying if alpha blending is needed
  119568. */
  119569. needAlphaBlending(): boolean;
  119570. /**
  119571. * Specifies if this material should be rendered in alpha test mode
  119572. * @returns a boolean specifying if an alpha test is needed.
  119573. */
  119574. needAlphaTesting(): boolean;
  119575. private _initializeBlock;
  119576. private _resetDualBlocks;
  119577. /**
  119578. * Build the material and generates the inner effect
  119579. * @param verbose defines if the build should log activity
  119580. */
  119581. build(verbose?: boolean): void;
  119582. /**
  119583. * Runs an otpimization phase to try to improve the shader code
  119584. */
  119585. optimize(): void;
  119586. private _prepareDefinesForAttributes;
  119587. /**
  119588. * Get if the submesh is ready to be used and all its information available.
  119589. * Child classes can use it to update shaders
  119590. * @param mesh defines the mesh to check
  119591. * @param subMesh defines which submesh to check
  119592. * @param useInstances specifies that instances should be used
  119593. * @returns a boolean indicating that the submesh is ready or not
  119594. */
  119595. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119596. /**
  119597. * Get a string representing the shaders built by the current node graph
  119598. */
  119599. readonly compiledShaders: string;
  119600. /**
  119601. * Binds the world matrix to the material
  119602. * @param world defines the world transformation matrix
  119603. */
  119604. bindOnlyWorldMatrix(world: Matrix): void;
  119605. /**
  119606. * Binds the submesh to this material by preparing the effect and shader to draw
  119607. * @param world defines the world transformation matrix
  119608. * @param mesh defines the mesh containing the submesh
  119609. * @param subMesh defines the submesh to bind the material to
  119610. */
  119611. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119612. /**
  119613. * Gets the active textures from the material
  119614. * @returns an array of textures
  119615. */
  119616. getActiveTextures(): BaseTexture[];
  119617. /**
  119618. * Gets the list of texture blocks
  119619. * @returns an array of texture blocks
  119620. */
  119621. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119622. /**
  119623. * Specifies if the material uses a texture
  119624. * @param texture defines the texture to check against the material
  119625. * @returns a boolean specifying if the material uses the texture
  119626. */
  119627. hasTexture(texture: BaseTexture): boolean;
  119628. /**
  119629. * Disposes the material
  119630. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119631. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119632. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119633. */
  119634. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119635. /** Creates the node editor window. */
  119636. private _createNodeEditor;
  119637. /**
  119638. * Launch the node material editor
  119639. * @param config Define the configuration of the editor
  119640. * @return a promise fulfilled when the node editor is visible
  119641. */
  119642. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119643. /**
  119644. * Clear the current material
  119645. */
  119646. clear(): void;
  119647. /**
  119648. * Clear the current material and set it to a default state
  119649. */
  119650. setToDefault(): void;
  119651. /**
  119652. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119653. * @param url defines the url to load from
  119654. * @returns a promise that will fullfil when the material is fully loaded
  119655. */
  119656. loadAsync(url: string): Promise<unknown>;
  119657. private _gatherBlocks;
  119658. /**
  119659. * Generate a string containing the code declaration required to create an equivalent of this material
  119660. * @returns a string
  119661. */
  119662. generateCode(): string;
  119663. /**
  119664. * Serializes this material in a JSON representation
  119665. * @returns the serialized material object
  119666. */
  119667. serialize(): any;
  119668. private _restoreConnections;
  119669. /**
  119670. * Clear the current graph and load a new one from a serialization object
  119671. * @param source defines the JSON representation of the material
  119672. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119673. */
  119674. loadFromSerialization(source: any, rootUrl?: string): void;
  119675. /**
  119676. * Creates a node material from parsed material data
  119677. * @param source defines the JSON representation of the material
  119678. * @param scene defines the hosting scene
  119679. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119680. * @returns a new node material
  119681. */
  119682. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119683. /**
  119684. * Creates a new node material set to default basic configuration
  119685. * @param name defines the name of the material
  119686. * @param scene defines the hosting scene
  119687. * @returns a new NodeMaterial
  119688. */
  119689. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119690. }
  119691. }
  119692. declare module BABYLON {
  119693. /**
  119694. * Block used to read a texture from a sampler
  119695. */
  119696. export class TextureBlock extends NodeMaterialBlock {
  119697. private _defineName;
  119698. private _linearDefineName;
  119699. private _samplerName;
  119700. private _transformedUVName;
  119701. private _textureTransformName;
  119702. private _textureInfoName;
  119703. private _mainUVName;
  119704. private _mainUVDefineName;
  119705. /**
  119706. * Gets or sets the texture associated with the node
  119707. */
  119708. texture: Nullable<Texture>;
  119709. /**
  119710. * Create a new TextureBlock
  119711. * @param name defines the block name
  119712. */
  119713. constructor(name: string);
  119714. /**
  119715. * Gets the current class name
  119716. * @returns the class name
  119717. */
  119718. getClassName(): string;
  119719. /**
  119720. * Gets the uv input component
  119721. */
  119722. readonly uv: NodeMaterialConnectionPoint;
  119723. /**
  119724. * Gets the rgba output component
  119725. */
  119726. readonly rgba: NodeMaterialConnectionPoint;
  119727. /**
  119728. * Gets the rgb output component
  119729. */
  119730. readonly rgb: NodeMaterialConnectionPoint;
  119731. /**
  119732. * Gets the r output component
  119733. */
  119734. readonly r: NodeMaterialConnectionPoint;
  119735. /**
  119736. * Gets the g output component
  119737. */
  119738. readonly g: NodeMaterialConnectionPoint;
  119739. /**
  119740. * Gets the b output component
  119741. */
  119742. readonly b: NodeMaterialConnectionPoint;
  119743. /**
  119744. * Gets the a output component
  119745. */
  119746. readonly a: NodeMaterialConnectionPoint;
  119747. readonly target: NodeMaterialBlockTargets;
  119748. autoConfigure(material: NodeMaterial): void;
  119749. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119750. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119751. isReady(): boolean;
  119752. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119753. private readonly _isMixed;
  119754. private _injectVertexCode;
  119755. private _writeOutput;
  119756. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119757. protected _dumpPropertiesCode(): string;
  119758. serialize(): any;
  119759. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119760. }
  119761. }
  119762. declare module BABYLON {
  119763. /**
  119764. * Class used to store shared data between 2 NodeMaterialBuildState
  119765. */
  119766. export class NodeMaterialBuildStateSharedData {
  119767. /**
  119768. * Gets the list of emitted varyings
  119769. */
  119770. temps: string[];
  119771. /**
  119772. * Gets the list of emitted varyings
  119773. */
  119774. varyings: string[];
  119775. /**
  119776. * Gets the varying declaration string
  119777. */
  119778. varyingDeclaration: string;
  119779. /**
  119780. * Input blocks
  119781. */
  119782. inputBlocks: InputBlock[];
  119783. /**
  119784. * Input blocks
  119785. */
  119786. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  119787. /**
  119788. * Bindable blocks (Blocks that need to set data to the effect)
  119789. */
  119790. bindableBlocks: NodeMaterialBlock[];
  119791. /**
  119792. * List of blocks that can provide a compilation fallback
  119793. */
  119794. blocksWithFallbacks: NodeMaterialBlock[];
  119795. /**
  119796. * List of blocks that can provide a define update
  119797. */
  119798. blocksWithDefines: NodeMaterialBlock[];
  119799. /**
  119800. * List of blocks that can provide a repeatable content
  119801. */
  119802. repeatableContentBlocks: NodeMaterialBlock[];
  119803. /**
  119804. * List of blocks that can provide a dynamic list of uniforms
  119805. */
  119806. dynamicUniformBlocks: NodeMaterialBlock[];
  119807. /**
  119808. * List of blocks that can block the isReady function for the material
  119809. */
  119810. blockingBlocks: NodeMaterialBlock[];
  119811. /**
  119812. * Gets the list of animated inputs
  119813. */
  119814. animatedInputs: InputBlock[];
  119815. /**
  119816. * Build Id used to avoid multiple recompilations
  119817. */
  119818. buildId: number;
  119819. /** List of emitted variables */
  119820. variableNames: {
  119821. [key: string]: number;
  119822. };
  119823. /** List of emitted defines */
  119824. defineNames: {
  119825. [key: string]: number;
  119826. };
  119827. /** Should emit comments? */
  119828. emitComments: boolean;
  119829. /** Emit build activity */
  119830. verbose: boolean;
  119831. /** Gets or sets the hosting scene */
  119832. scene: Scene;
  119833. /**
  119834. * Gets the compilation hints emitted at compilation time
  119835. */
  119836. hints: {
  119837. needWorldViewMatrix: boolean;
  119838. needWorldViewProjectionMatrix: boolean;
  119839. needAlphaBlending: boolean;
  119840. needAlphaTesting: boolean;
  119841. };
  119842. /**
  119843. * List of compilation checks
  119844. */
  119845. checks: {
  119846. emitVertex: boolean;
  119847. emitFragment: boolean;
  119848. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  119849. };
  119850. /** Creates a new shared data */
  119851. constructor();
  119852. /**
  119853. * Emits console errors and exceptions if there is a failing check
  119854. */
  119855. emitErrors(): void;
  119856. }
  119857. }
  119858. declare module BABYLON {
  119859. /**
  119860. * Class used to store node based material build state
  119861. */
  119862. export class NodeMaterialBuildState {
  119863. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  119864. supportUniformBuffers: boolean;
  119865. /**
  119866. * Gets the list of emitted attributes
  119867. */
  119868. attributes: string[];
  119869. /**
  119870. * Gets the list of emitted uniforms
  119871. */
  119872. uniforms: string[];
  119873. /**
  119874. * Gets the list of emitted constants
  119875. */
  119876. constants: string[];
  119877. /**
  119878. * Gets the list of emitted uniform buffers
  119879. */
  119880. uniformBuffers: string[];
  119881. /**
  119882. * Gets the list of emitted samplers
  119883. */
  119884. samplers: string[];
  119885. /**
  119886. * Gets the list of emitted functions
  119887. */
  119888. functions: {
  119889. [key: string]: string;
  119890. };
  119891. /**
  119892. * Gets the list of emitted extensions
  119893. */
  119894. extensions: {
  119895. [key: string]: string;
  119896. };
  119897. /**
  119898. * Gets the target of the compilation state
  119899. */
  119900. target: NodeMaterialBlockTargets;
  119901. /**
  119902. * Gets the list of emitted counters
  119903. */
  119904. counters: {
  119905. [key: string]: number;
  119906. };
  119907. /**
  119908. * Shared data between multiple NodeMaterialBuildState instances
  119909. */
  119910. sharedData: NodeMaterialBuildStateSharedData;
  119911. /** @hidden */
  119912. _vertexState: NodeMaterialBuildState;
  119913. /** @hidden */
  119914. _attributeDeclaration: string;
  119915. /** @hidden */
  119916. _uniformDeclaration: string;
  119917. /** @hidden */
  119918. _constantDeclaration: string;
  119919. /** @hidden */
  119920. _samplerDeclaration: string;
  119921. /** @hidden */
  119922. _varyingTransfer: string;
  119923. private _repeatableContentAnchorIndex;
  119924. /** @hidden */
  119925. _builtCompilationString: string;
  119926. /**
  119927. * Gets the emitted compilation strings
  119928. */
  119929. compilationString: string;
  119930. /**
  119931. * Finalize the compilation strings
  119932. * @param state defines the current compilation state
  119933. */
  119934. finalize(state: NodeMaterialBuildState): void;
  119935. /** @hidden */
  119936. readonly _repeatableContentAnchor: string;
  119937. /** @hidden */
  119938. _getFreeVariableName(prefix: string): string;
  119939. /** @hidden */
  119940. _getFreeDefineName(prefix: string): string;
  119941. /** @hidden */
  119942. _excludeVariableName(name: string): void;
  119943. /** @hidden */
  119944. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  119945. /** @hidden */
  119946. _emitExtension(name: string, extension: string): void;
  119947. /** @hidden */
  119948. _emitFunction(name: string, code: string, comments: string): void;
  119949. /** @hidden */
  119950. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  119951. replaceStrings?: {
  119952. search: RegExp;
  119953. replace: string;
  119954. }[];
  119955. repeatKey?: string;
  119956. }): string;
  119957. /** @hidden */
  119958. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  119959. repeatKey?: string;
  119960. removeAttributes?: boolean;
  119961. removeUniforms?: boolean;
  119962. removeVaryings?: boolean;
  119963. removeIfDef?: boolean;
  119964. replaceStrings?: {
  119965. search: RegExp;
  119966. replace: string;
  119967. }[];
  119968. }, storeKey?: string): void;
  119969. /** @hidden */
  119970. _registerTempVariable(name: string): boolean;
  119971. /** @hidden */
  119972. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  119973. /** @hidden */
  119974. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  119975. }
  119976. }
  119977. declare module BABYLON {
  119978. /**
  119979. * Defines a block that can be used inside a node based material
  119980. */
  119981. export class NodeMaterialBlock {
  119982. private _buildId;
  119983. private _buildTarget;
  119984. private _target;
  119985. private _isFinalMerger;
  119986. private _isInput;
  119987. /** @hidden */
  119988. _codeVariableName: string;
  119989. /** @hidden */
  119990. _inputs: NodeMaterialConnectionPoint[];
  119991. /** @hidden */
  119992. _outputs: NodeMaterialConnectionPoint[];
  119993. /** @hidden */
  119994. _preparationId: number;
  119995. /**
  119996. * Gets or sets the name of the block
  119997. */
  119998. name: string;
  119999. /**
  120000. * Gets or sets the unique id of the node
  120001. */
  120002. uniqueId: number;
  120003. /**
  120004. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120005. */
  120006. readonly isFinalMerger: boolean;
  120007. /**
  120008. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120009. */
  120010. readonly isInput: boolean;
  120011. /**
  120012. * Gets or sets the build Id
  120013. */
  120014. buildId: number;
  120015. /**
  120016. * Gets or sets the target of the block
  120017. */
  120018. target: NodeMaterialBlockTargets;
  120019. /**
  120020. * Gets the list of input points
  120021. */
  120022. readonly inputs: NodeMaterialConnectionPoint[];
  120023. /** Gets the list of output points */
  120024. readonly outputs: NodeMaterialConnectionPoint[];
  120025. /**
  120026. * Find an input by its name
  120027. * @param name defines the name of the input to look for
  120028. * @returns the input or null if not found
  120029. */
  120030. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120031. /**
  120032. * Find an output by its name
  120033. * @param name defines the name of the outputto look for
  120034. * @returns the output or null if not found
  120035. */
  120036. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120037. /**
  120038. * Creates a new NodeMaterialBlock
  120039. * @param name defines the block name
  120040. * @param target defines the target of that block (Vertex by default)
  120041. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120042. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120043. */
  120044. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120045. /**
  120046. * Initialize the block and prepare the context for build
  120047. * @param state defines the state that will be used for the build
  120048. */
  120049. initialize(state: NodeMaterialBuildState): void;
  120050. /**
  120051. * Bind data to effect. Will only be called for blocks with isBindable === true
  120052. * @param effect defines the effect to bind data to
  120053. * @param nodeMaterial defines the hosting NodeMaterial
  120054. * @param mesh defines the mesh that will be rendered
  120055. */
  120056. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120057. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120058. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120059. protected _writeFloat(value: number): string;
  120060. /**
  120061. * Gets the current class name e.g. "NodeMaterialBlock"
  120062. * @returns the class name
  120063. */
  120064. getClassName(): string;
  120065. /**
  120066. * Register a new input. Must be called inside a block constructor
  120067. * @param name defines the connection point name
  120068. * @param type defines the connection point type
  120069. * @param isOptional defines a boolean indicating that this input can be omitted
  120070. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120071. * @returns the current block
  120072. */
  120073. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120074. /**
  120075. * Register a new output. Must be called inside a block constructor
  120076. * @param name defines the connection point name
  120077. * @param type defines the connection point type
  120078. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120079. * @returns the current block
  120080. */
  120081. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120082. /**
  120083. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120084. * @param forOutput defines an optional connection point to check compatibility with
  120085. * @returns the first available input or null
  120086. */
  120087. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120088. /**
  120089. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120090. * @param forBlock defines an optional block to check compatibility with
  120091. * @returns the first available input or null
  120092. */
  120093. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120094. /**
  120095. * Gets the sibling of the given output
  120096. * @param current defines the current output
  120097. * @returns the next output in the list or null
  120098. */
  120099. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120100. /**
  120101. * Connect current block with another block
  120102. * @param other defines the block to connect with
  120103. * @param options define the various options to help pick the right connections
  120104. * @returns the current block
  120105. */
  120106. connectTo(other: NodeMaterialBlock, options?: {
  120107. input?: string;
  120108. output?: string;
  120109. outputSwizzle?: string;
  120110. }): this | undefined;
  120111. protected _buildBlock(state: NodeMaterialBuildState): void;
  120112. /**
  120113. * Add uniforms, samplers and uniform buffers at compilation time
  120114. * @param state defines the state to update
  120115. * @param nodeMaterial defines the node material requesting the update
  120116. * @param defines defines the material defines to update
  120117. */
  120118. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120119. /**
  120120. * Add potential fallbacks if shader compilation fails
  120121. * @param mesh defines the mesh to be rendered
  120122. * @param fallbacks defines the current prioritized list of fallbacks
  120123. */
  120124. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120125. /**
  120126. * Initialize defines for shader compilation
  120127. * @param mesh defines the mesh to be rendered
  120128. * @param nodeMaterial defines the node material requesting the update
  120129. * @param defines defines the material defines to update
  120130. * @param useInstances specifies that instances should be used
  120131. */
  120132. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120133. /**
  120134. * Update defines for shader compilation
  120135. * @param mesh defines the mesh to be rendered
  120136. * @param nodeMaterial defines the node material requesting the update
  120137. * @param defines defines the material defines to update
  120138. * @param useInstances specifies that instances should be used
  120139. */
  120140. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120141. /**
  120142. * Lets the block try to connect some inputs automatically
  120143. * @param material defines the hosting NodeMaterial
  120144. */
  120145. autoConfigure(material: NodeMaterial): void;
  120146. /**
  120147. * Function called when a block is declared as repeatable content generator
  120148. * @param vertexShaderState defines the current compilation state for the vertex shader
  120149. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120150. * @param mesh defines the mesh to be rendered
  120151. * @param defines defines the material defines to update
  120152. */
  120153. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120154. /**
  120155. * Checks if the block is ready
  120156. * @param mesh defines the mesh to be rendered
  120157. * @param nodeMaterial defines the node material requesting the update
  120158. * @param defines defines the material defines to update
  120159. * @param useInstances specifies that instances should be used
  120160. * @returns true if the block is ready
  120161. */
  120162. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120163. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120164. private _processBuild;
  120165. /**
  120166. * Compile the current node and generate the shader code
  120167. * @param state defines the current compilation state (uniforms, samplers, current string)
  120168. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120169. * @returns true if already built
  120170. */
  120171. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120172. protected _inputRename(name: string): string;
  120173. protected _outputRename(name: string): string;
  120174. protected _dumpPropertiesCode(): string;
  120175. /** @hidden */
  120176. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120177. /**
  120178. * Clone the current block to a new identical block
  120179. * @param scene defines the hosting scene
  120180. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120181. * @returns a copy of the current block
  120182. */
  120183. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120184. /**
  120185. * Serializes this block in a JSON representation
  120186. * @returns the serialized block object
  120187. */
  120188. serialize(): any;
  120189. /** @hidden */
  120190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120191. }
  120192. }
  120193. declare module BABYLON {
  120194. /**
  120195. * Enum defining the type of animations supported by InputBlock
  120196. */
  120197. export enum AnimatedInputBlockTypes {
  120198. /** No animation */
  120199. None = 0,
  120200. /** Time based animation. Will only work for floats */
  120201. Time = 1
  120202. }
  120203. }
  120204. declare module BABYLON {
  120205. /**
  120206. * Block used to expose an input value
  120207. */
  120208. export class InputBlock extends NodeMaterialBlock {
  120209. private _mode;
  120210. private _associatedVariableName;
  120211. private _storedValue;
  120212. private _valueCallback;
  120213. private _type;
  120214. private _animationType;
  120215. /** Gets or set a value used to limit the range of float values */
  120216. min: number;
  120217. /** Gets or set a value used to limit the range of float values */
  120218. max: number;
  120219. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120220. matrixMode: number;
  120221. /** @hidden */
  120222. _systemValue: Nullable<NodeMaterialSystemValues>;
  120223. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120224. visibleInInspector: boolean;
  120225. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120226. isConstant: boolean;
  120227. /**
  120228. * Gets or sets the connection point type (default is float)
  120229. */
  120230. readonly type: NodeMaterialBlockConnectionPointTypes;
  120231. /**
  120232. * Creates a new InputBlock
  120233. * @param name defines the block name
  120234. * @param target defines the target of that block (Vertex by default)
  120235. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120236. */
  120237. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120238. /**
  120239. * Gets the output component
  120240. */
  120241. readonly output: NodeMaterialConnectionPoint;
  120242. /**
  120243. * Set the source of this connection point to a vertex attribute
  120244. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120245. * @returns the current connection point
  120246. */
  120247. setAsAttribute(attributeName?: string): InputBlock;
  120248. /**
  120249. * Set the source of this connection point to a system value
  120250. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120251. * @returns the current connection point
  120252. */
  120253. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120254. /**
  120255. * Gets or sets the value of that point.
  120256. * Please note that this value will be ignored if valueCallback is defined
  120257. */
  120258. value: any;
  120259. /**
  120260. * Gets or sets a callback used to get the value of that point.
  120261. * Please note that setting this value will force the connection point to ignore the value property
  120262. */
  120263. valueCallback: () => any;
  120264. /**
  120265. * Gets or sets the associated variable name in the shader
  120266. */
  120267. associatedVariableName: string;
  120268. /** Gets or sets the type of animation applied to the input */
  120269. animationType: AnimatedInputBlockTypes;
  120270. /**
  120271. * Gets a boolean indicating that this connection point not defined yet
  120272. */
  120273. readonly isUndefined: boolean;
  120274. /**
  120275. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120276. * In this case the connection point name must be the name of the uniform to use.
  120277. * Can only be set on inputs
  120278. */
  120279. isUniform: boolean;
  120280. /**
  120281. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120282. * In this case the connection point name must be the name of the attribute to use
  120283. * Can only be set on inputs
  120284. */
  120285. isAttribute: boolean;
  120286. /**
  120287. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120288. * Can only be set on exit points
  120289. */
  120290. isVarying: boolean;
  120291. /**
  120292. * Gets a boolean indicating that the current connection point is a system value
  120293. */
  120294. readonly isSystemValue: boolean;
  120295. /**
  120296. * Gets or sets the current well known value or null if not defined as a system value
  120297. */
  120298. systemValue: Nullable<NodeMaterialSystemValues>;
  120299. /**
  120300. * Gets the current class name
  120301. * @returns the class name
  120302. */
  120303. getClassName(): string;
  120304. /**
  120305. * Animate the input if animationType !== None
  120306. * @param scene defines the rendering scene
  120307. */
  120308. animate(scene: Scene): void;
  120309. private _emitDefine;
  120310. initialize(state: NodeMaterialBuildState): void;
  120311. /**
  120312. * Set the input block to its default value (based on its type)
  120313. */
  120314. setDefaultValue(): void;
  120315. private _emitConstant;
  120316. private _emit;
  120317. /** @hidden */
  120318. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120319. /** @hidden */
  120320. _transmit(effect: Effect, scene: Scene): void;
  120321. protected _buildBlock(state: NodeMaterialBuildState): void;
  120322. protected _dumpPropertiesCode(): string;
  120323. serialize(): any;
  120324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120325. }
  120326. }
  120327. declare module BABYLON {
  120328. /**
  120329. * Defines a connection point for a block
  120330. */
  120331. export class NodeMaterialConnectionPoint {
  120332. /** @hidden */
  120333. _ownerBlock: NodeMaterialBlock;
  120334. /** @hidden */
  120335. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120336. private _endpoints;
  120337. private _associatedVariableName;
  120338. /** @hidden */
  120339. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120340. /** @hidden */
  120341. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120342. private _type;
  120343. /** @hidden */
  120344. _enforceAssociatedVariableName: boolean;
  120345. /**
  120346. * Gets or sets the additional types supported by this connection point
  120347. */
  120348. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120349. /**
  120350. * Gets or sets the additional types excluded by this connection point
  120351. */
  120352. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120353. /**
  120354. * Gets or sets the associated variable name in the shader
  120355. */
  120356. associatedVariableName: string;
  120357. /**
  120358. * Gets or sets the connection point type (default is float)
  120359. */
  120360. type: NodeMaterialBlockConnectionPointTypes;
  120361. /**
  120362. * Gets or sets the connection point name
  120363. */
  120364. name: string;
  120365. /**
  120366. * Gets or sets a boolean indicating that this connection point can be omitted
  120367. */
  120368. isOptional: boolean;
  120369. /**
  120370. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120371. */
  120372. define: string;
  120373. /** Gets or sets the target of that connection point */
  120374. target: NodeMaterialBlockTargets;
  120375. /**
  120376. * Gets a boolean indicating that the current point is connected
  120377. */
  120378. readonly isConnected: boolean;
  120379. /**
  120380. * Gets a boolean indicating that the current point is connected to an input block
  120381. */
  120382. readonly isConnectedToInputBlock: boolean;
  120383. /**
  120384. * Gets a the connected input block (if any)
  120385. */
  120386. readonly connectInputBlock: Nullable<InputBlock>;
  120387. /** Get the other side of the connection (if any) */
  120388. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120389. /** Get the block that owns this connection point */
  120390. readonly ownerBlock: NodeMaterialBlock;
  120391. /** Get the block connected on the other side of this connection (if any) */
  120392. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120393. /** Get the block connected on the endpoints of this connection (if any) */
  120394. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120395. /** Gets the list of connected endpoints */
  120396. readonly endpoints: NodeMaterialConnectionPoint[];
  120397. /** Gets a boolean indicating if that output point is connected to at least one input */
  120398. readonly hasEndpoints: boolean;
  120399. /**
  120400. * Creates a new connection point
  120401. * @param name defines the connection point name
  120402. * @param ownerBlock defines the block hosting this connection point
  120403. */
  120404. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120405. /**
  120406. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120407. * @returns the class name
  120408. */
  120409. getClassName(): string;
  120410. /**
  120411. * Gets an boolean indicating if the current point can be connected to another point
  120412. * @param connectionPoint defines the other connection point
  120413. * @returns true if the connection is possible
  120414. */
  120415. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120416. /**
  120417. * Connect this point to another connection point
  120418. * @param connectionPoint defines the other connection point
  120419. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120420. * @returns the current connection point
  120421. */
  120422. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120423. /**
  120424. * Disconnect this point from one of his endpoint
  120425. * @param endpoint defines the other connection point
  120426. * @returns the current connection point
  120427. */
  120428. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120429. /**
  120430. * Serializes this point in a JSON representation
  120431. * @returns the serialized point object
  120432. */
  120433. serialize(): any;
  120434. }
  120435. }
  120436. declare module BABYLON {
  120437. /**
  120438. * Block used to add support for vertex skinning (bones)
  120439. */
  120440. export class BonesBlock extends NodeMaterialBlock {
  120441. /**
  120442. * Creates a new BonesBlock
  120443. * @param name defines the block name
  120444. */
  120445. constructor(name: string);
  120446. /**
  120447. * Initialize the block and prepare the context for build
  120448. * @param state defines the state that will be used for the build
  120449. */
  120450. initialize(state: NodeMaterialBuildState): void;
  120451. /**
  120452. * Gets the current class name
  120453. * @returns the class name
  120454. */
  120455. getClassName(): string;
  120456. /**
  120457. * Gets the matrix indices input component
  120458. */
  120459. readonly matricesIndices: NodeMaterialConnectionPoint;
  120460. /**
  120461. * Gets the matrix weights input component
  120462. */
  120463. readonly matricesWeights: NodeMaterialConnectionPoint;
  120464. /**
  120465. * Gets the extra matrix indices input component
  120466. */
  120467. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120468. /**
  120469. * Gets the extra matrix weights input component
  120470. */
  120471. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120472. /**
  120473. * Gets the world input component
  120474. */
  120475. readonly world: NodeMaterialConnectionPoint;
  120476. /**
  120477. * Gets the output component
  120478. */
  120479. readonly output: NodeMaterialConnectionPoint;
  120480. autoConfigure(material: NodeMaterial): void;
  120481. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120482. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120484. protected _buildBlock(state: NodeMaterialBuildState): this;
  120485. }
  120486. }
  120487. declare module BABYLON {
  120488. /**
  120489. * Block used to add support for instances
  120490. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120491. */
  120492. export class InstancesBlock extends NodeMaterialBlock {
  120493. /**
  120494. * Creates a new InstancesBlock
  120495. * @param name defines the block name
  120496. */
  120497. constructor(name: string);
  120498. /**
  120499. * Gets the current class name
  120500. * @returns the class name
  120501. */
  120502. getClassName(): string;
  120503. /**
  120504. * Gets the first world row input component
  120505. */
  120506. readonly world0: NodeMaterialConnectionPoint;
  120507. /**
  120508. * Gets the second world row input component
  120509. */
  120510. readonly world1: NodeMaterialConnectionPoint;
  120511. /**
  120512. * Gets the third world row input component
  120513. */
  120514. readonly world2: NodeMaterialConnectionPoint;
  120515. /**
  120516. * Gets the forth world row input component
  120517. */
  120518. readonly world3: NodeMaterialConnectionPoint;
  120519. /**
  120520. * Gets the world input component
  120521. */
  120522. readonly world: NodeMaterialConnectionPoint;
  120523. /**
  120524. * Gets the output component
  120525. */
  120526. readonly output: NodeMaterialConnectionPoint;
  120527. autoConfigure(material: NodeMaterial): void;
  120528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120529. protected _buildBlock(state: NodeMaterialBuildState): this;
  120530. }
  120531. }
  120532. declare module BABYLON {
  120533. /**
  120534. * Block used to add morph targets support to vertex shader
  120535. */
  120536. export class MorphTargetsBlock extends NodeMaterialBlock {
  120537. private _repeatableContentAnchor;
  120538. private _repeatebleContentGenerated;
  120539. /**
  120540. * Create a new MorphTargetsBlock
  120541. * @param name defines the block name
  120542. */
  120543. constructor(name: string);
  120544. /**
  120545. * Gets the current class name
  120546. * @returns the class name
  120547. */
  120548. getClassName(): string;
  120549. /**
  120550. * Gets the position input component
  120551. */
  120552. readonly position: NodeMaterialConnectionPoint;
  120553. /**
  120554. * Gets the normal input component
  120555. */
  120556. readonly normal: NodeMaterialConnectionPoint;
  120557. /**
  120558. * Gets the tangent input component
  120559. */
  120560. readonly tangent: NodeMaterialConnectionPoint;
  120561. /**
  120562. * Gets the tangent input component
  120563. */
  120564. readonly uv: NodeMaterialConnectionPoint;
  120565. /**
  120566. * Gets the position output component
  120567. */
  120568. readonly positionOutput: NodeMaterialConnectionPoint;
  120569. /**
  120570. * Gets the normal output component
  120571. */
  120572. readonly normalOutput: NodeMaterialConnectionPoint;
  120573. /**
  120574. * Gets the tangent output component
  120575. */
  120576. readonly tangentOutput: NodeMaterialConnectionPoint;
  120577. /**
  120578. * Gets the tangent output component
  120579. */
  120580. readonly uvOutput: NodeMaterialConnectionPoint;
  120581. initialize(state: NodeMaterialBuildState): void;
  120582. autoConfigure(material: NodeMaterial): void;
  120583. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120584. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120585. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120586. protected _buildBlock(state: NodeMaterialBuildState): this;
  120587. }
  120588. }
  120589. declare module BABYLON {
  120590. /**
  120591. * Block used to get data information from a light
  120592. */
  120593. export class LightInformationBlock extends NodeMaterialBlock {
  120594. private _lightDataUniformName;
  120595. private _lightColorUniformName;
  120596. private _lightTypeDefineName;
  120597. /**
  120598. * Gets or sets the light associated with this block
  120599. */
  120600. light: Nullable<Light>;
  120601. /**
  120602. * Creates a new LightInformationBlock
  120603. * @param name defines the block name
  120604. */
  120605. constructor(name: string);
  120606. /**
  120607. * Gets the current class name
  120608. * @returns the class name
  120609. */
  120610. getClassName(): string;
  120611. /**
  120612. * Gets the world position input component
  120613. */
  120614. readonly worldPosition: NodeMaterialConnectionPoint;
  120615. /**
  120616. * Gets the direction output component
  120617. */
  120618. readonly direction: NodeMaterialConnectionPoint;
  120619. /**
  120620. * Gets the direction output component
  120621. */
  120622. readonly color: NodeMaterialConnectionPoint;
  120623. /**
  120624. * Gets the direction output component
  120625. */
  120626. readonly intensity: NodeMaterialConnectionPoint;
  120627. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120629. protected _buildBlock(state: NodeMaterialBuildState): this;
  120630. serialize(): any;
  120631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120632. }
  120633. }
  120634. declare module BABYLON {
  120635. /**
  120636. * Block used to add image processing support to fragment shader
  120637. */
  120638. export class ImageProcessingBlock extends NodeMaterialBlock {
  120639. /**
  120640. * Create a new ImageProcessingBlock
  120641. * @param name defines the block name
  120642. */
  120643. constructor(name: string);
  120644. /**
  120645. * Gets the current class name
  120646. * @returns the class name
  120647. */
  120648. getClassName(): string;
  120649. /**
  120650. * Gets the color input component
  120651. */
  120652. readonly color: NodeMaterialConnectionPoint;
  120653. /**
  120654. * Gets the output component
  120655. */
  120656. readonly output: NodeMaterialConnectionPoint;
  120657. /**
  120658. * Initialize the block and prepare the context for build
  120659. * @param state defines the state that will be used for the build
  120660. */
  120661. initialize(state: NodeMaterialBuildState): void;
  120662. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120665. protected _buildBlock(state: NodeMaterialBuildState): this;
  120666. }
  120667. }
  120668. declare module BABYLON {
  120669. /**
  120670. * Block used to pertub normals based on a normal map
  120671. */
  120672. export class PerturbNormalBlock extends NodeMaterialBlock {
  120673. private _tangentSpaceParameterName;
  120674. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120675. invertX: boolean;
  120676. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120677. invertY: boolean;
  120678. /**
  120679. * Create a new PerturbNormalBlock
  120680. * @param name defines the block name
  120681. */
  120682. constructor(name: string);
  120683. /**
  120684. * Gets the current class name
  120685. * @returns the class name
  120686. */
  120687. getClassName(): string;
  120688. /**
  120689. * Gets the world position input component
  120690. */
  120691. readonly worldPosition: NodeMaterialConnectionPoint;
  120692. /**
  120693. * Gets the world normal input component
  120694. */
  120695. readonly worldNormal: NodeMaterialConnectionPoint;
  120696. /**
  120697. * Gets the uv input component
  120698. */
  120699. readonly uv: NodeMaterialConnectionPoint;
  120700. /**
  120701. * Gets the normal map color input component
  120702. */
  120703. readonly normalMapColor: NodeMaterialConnectionPoint;
  120704. /**
  120705. * Gets the strength input component
  120706. */
  120707. readonly strength: NodeMaterialConnectionPoint;
  120708. /**
  120709. * Gets the output component
  120710. */
  120711. readonly output: NodeMaterialConnectionPoint;
  120712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120713. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120714. autoConfigure(material: NodeMaterial): void;
  120715. protected _buildBlock(state: NodeMaterialBuildState): this;
  120716. protected _dumpPropertiesCode(): string;
  120717. serialize(): any;
  120718. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120719. }
  120720. }
  120721. declare module BABYLON {
  120722. /**
  120723. * Block used to discard a pixel if a value is smaller than a cutoff
  120724. */
  120725. export class DiscardBlock extends NodeMaterialBlock {
  120726. /**
  120727. * Create a new DiscardBlock
  120728. * @param name defines the block name
  120729. */
  120730. constructor(name: string);
  120731. /**
  120732. * Gets the current class name
  120733. * @returns the class name
  120734. */
  120735. getClassName(): string;
  120736. /**
  120737. * Gets the color input component
  120738. */
  120739. readonly value: NodeMaterialConnectionPoint;
  120740. /**
  120741. * Gets the cutoff input component
  120742. */
  120743. readonly cutoff: NodeMaterialConnectionPoint;
  120744. protected _buildBlock(state: NodeMaterialBuildState): this;
  120745. }
  120746. }
  120747. declare module BABYLON {
  120748. /**
  120749. * Block used to add support for scene fog
  120750. */
  120751. export class FogBlock extends NodeMaterialBlock {
  120752. private _fogDistanceName;
  120753. private _fogParameters;
  120754. /**
  120755. * Create a new FogBlock
  120756. * @param name defines the block name
  120757. */
  120758. constructor(name: string);
  120759. /**
  120760. * Gets the current class name
  120761. * @returns the class name
  120762. */
  120763. getClassName(): string;
  120764. /**
  120765. * Gets the world position input component
  120766. */
  120767. readonly worldPosition: NodeMaterialConnectionPoint;
  120768. /**
  120769. * Gets the view input component
  120770. */
  120771. readonly view: NodeMaterialConnectionPoint;
  120772. /**
  120773. * Gets the color input component
  120774. */
  120775. readonly input: NodeMaterialConnectionPoint;
  120776. /**
  120777. * Gets the fog color input component
  120778. */
  120779. readonly fogColor: NodeMaterialConnectionPoint;
  120780. /**
  120781. * Gets the output component
  120782. */
  120783. readonly output: NodeMaterialConnectionPoint;
  120784. autoConfigure(material: NodeMaterial): void;
  120785. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120786. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120787. protected _buildBlock(state: NodeMaterialBuildState): this;
  120788. }
  120789. }
  120790. declare module BABYLON {
  120791. /**
  120792. * Block used to add light in the fragment shader
  120793. */
  120794. export class LightBlock extends NodeMaterialBlock {
  120795. private _lightId;
  120796. /**
  120797. * Gets or sets the light associated with this block
  120798. */
  120799. light: Nullable<Light>;
  120800. /**
  120801. * Create a new LightBlock
  120802. * @param name defines the block name
  120803. */
  120804. constructor(name: string);
  120805. /**
  120806. * Gets the current class name
  120807. * @returns the class name
  120808. */
  120809. getClassName(): string;
  120810. /**
  120811. * Gets the world position input component
  120812. */
  120813. readonly worldPosition: NodeMaterialConnectionPoint;
  120814. /**
  120815. * Gets the world normal input component
  120816. */
  120817. readonly worldNormal: NodeMaterialConnectionPoint;
  120818. /**
  120819. * Gets the camera (or eye) position component
  120820. */
  120821. readonly cameraPosition: NodeMaterialConnectionPoint;
  120822. /**
  120823. * Gets the glossiness component
  120824. */
  120825. readonly glossiness: NodeMaterialConnectionPoint;
  120826. /**
  120827. * Gets the glossinness power component
  120828. */
  120829. readonly glossPower: NodeMaterialConnectionPoint;
  120830. /**
  120831. * Gets the diffuse color component
  120832. */
  120833. readonly diffuseColor: NodeMaterialConnectionPoint;
  120834. /**
  120835. * Gets the specular color component
  120836. */
  120837. readonly specularColor: NodeMaterialConnectionPoint;
  120838. /**
  120839. * Gets the diffuse output component
  120840. */
  120841. readonly diffuseOutput: NodeMaterialConnectionPoint;
  120842. /**
  120843. * Gets the specular output component
  120844. */
  120845. readonly specularOutput: NodeMaterialConnectionPoint;
  120846. autoConfigure(material: NodeMaterial): void;
  120847. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120848. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120850. private _injectVertexCode;
  120851. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120852. serialize(): any;
  120853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120854. }
  120855. }
  120856. declare module BABYLON {
  120857. /**
  120858. * Block used to multiply 2 values
  120859. */
  120860. export class MultiplyBlock extends NodeMaterialBlock {
  120861. /**
  120862. * Creates a new MultiplyBlock
  120863. * @param name defines the block name
  120864. */
  120865. constructor(name: string);
  120866. /**
  120867. * Gets the current class name
  120868. * @returns the class name
  120869. */
  120870. getClassName(): string;
  120871. /**
  120872. * Gets the left operand input component
  120873. */
  120874. readonly left: NodeMaterialConnectionPoint;
  120875. /**
  120876. * Gets the right operand input component
  120877. */
  120878. readonly right: NodeMaterialConnectionPoint;
  120879. /**
  120880. * Gets the output component
  120881. */
  120882. readonly output: NodeMaterialConnectionPoint;
  120883. protected _buildBlock(state: NodeMaterialBuildState): this;
  120884. }
  120885. }
  120886. declare module BABYLON {
  120887. /**
  120888. * Block used to add 2 vectors
  120889. */
  120890. export class AddBlock extends NodeMaterialBlock {
  120891. /**
  120892. * Creates a new AddBlock
  120893. * @param name defines the block name
  120894. */
  120895. constructor(name: string);
  120896. /**
  120897. * Gets the current class name
  120898. * @returns the class name
  120899. */
  120900. getClassName(): string;
  120901. /**
  120902. * Gets the left operand input component
  120903. */
  120904. readonly left: NodeMaterialConnectionPoint;
  120905. /**
  120906. * Gets the right operand input component
  120907. */
  120908. readonly right: NodeMaterialConnectionPoint;
  120909. /**
  120910. * Gets the output component
  120911. */
  120912. readonly output: NodeMaterialConnectionPoint;
  120913. protected _buildBlock(state: NodeMaterialBuildState): this;
  120914. }
  120915. }
  120916. declare module BABYLON {
  120917. /**
  120918. * Block used to scale a vector by a float
  120919. */
  120920. export class ScaleBlock extends NodeMaterialBlock {
  120921. /**
  120922. * Creates a new ScaleBlock
  120923. * @param name defines the block name
  120924. */
  120925. constructor(name: string);
  120926. /**
  120927. * Gets the current class name
  120928. * @returns the class name
  120929. */
  120930. getClassName(): string;
  120931. /**
  120932. * Gets the input component
  120933. */
  120934. readonly input: NodeMaterialConnectionPoint;
  120935. /**
  120936. * Gets the factor input component
  120937. */
  120938. readonly factor: NodeMaterialConnectionPoint;
  120939. /**
  120940. * Gets the output component
  120941. */
  120942. readonly output: NodeMaterialConnectionPoint;
  120943. protected _buildBlock(state: NodeMaterialBuildState): this;
  120944. }
  120945. }
  120946. declare module BABYLON {
  120947. /**
  120948. * Block used to clamp a float
  120949. */
  120950. export class ClampBlock extends NodeMaterialBlock {
  120951. /** Gets or sets the minimum range */
  120952. minimum: number;
  120953. /** Gets or sets the maximum range */
  120954. maximum: number;
  120955. /**
  120956. * Creates a new ClampBlock
  120957. * @param name defines the block name
  120958. */
  120959. constructor(name: string);
  120960. /**
  120961. * Gets the current class name
  120962. * @returns the class name
  120963. */
  120964. getClassName(): string;
  120965. /**
  120966. * Gets the value input component
  120967. */
  120968. readonly value: NodeMaterialConnectionPoint;
  120969. /**
  120970. * Gets the output component
  120971. */
  120972. readonly output: NodeMaterialConnectionPoint;
  120973. protected _buildBlock(state: NodeMaterialBuildState): this;
  120974. protected _dumpPropertiesCode(): string;
  120975. serialize(): any;
  120976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120977. }
  120978. }
  120979. declare module BABYLON {
  120980. /**
  120981. * Block used to apply a cross product between 2 vectors
  120982. */
  120983. export class CrossBlock extends NodeMaterialBlock {
  120984. /**
  120985. * Creates a new CrossBlock
  120986. * @param name defines the block name
  120987. */
  120988. constructor(name: string);
  120989. /**
  120990. * Gets the current class name
  120991. * @returns the class name
  120992. */
  120993. getClassName(): string;
  120994. /**
  120995. * Gets the left operand input component
  120996. */
  120997. readonly left: NodeMaterialConnectionPoint;
  120998. /**
  120999. * Gets the right operand input component
  121000. */
  121001. readonly right: NodeMaterialConnectionPoint;
  121002. /**
  121003. * Gets the output component
  121004. */
  121005. readonly output: NodeMaterialConnectionPoint;
  121006. protected _buildBlock(state: NodeMaterialBuildState): this;
  121007. }
  121008. }
  121009. declare module BABYLON {
  121010. /**
  121011. * Block used to apply a dot product between 2 vectors
  121012. */
  121013. export class DotBlock extends NodeMaterialBlock {
  121014. /**
  121015. * Creates a new DotBlock
  121016. * @param name defines the block name
  121017. */
  121018. constructor(name: string);
  121019. /**
  121020. * Gets the current class name
  121021. * @returns the class name
  121022. */
  121023. getClassName(): string;
  121024. /**
  121025. * Gets the left operand input component
  121026. */
  121027. readonly left: NodeMaterialConnectionPoint;
  121028. /**
  121029. * Gets the right operand input component
  121030. */
  121031. readonly right: NodeMaterialConnectionPoint;
  121032. /**
  121033. * Gets the output component
  121034. */
  121035. readonly output: NodeMaterialConnectionPoint;
  121036. protected _buildBlock(state: NodeMaterialBuildState): this;
  121037. }
  121038. }
  121039. declare module BABYLON {
  121040. /**
  121041. * Block used to remap a float from a range to a new one
  121042. */
  121043. export class RemapBlock extends NodeMaterialBlock {
  121044. /**
  121045. * Gets or sets the source range
  121046. */
  121047. sourceRange: Vector2;
  121048. /**
  121049. * Gets or sets the target range
  121050. */
  121051. targetRange: Vector2;
  121052. /**
  121053. * Creates a new RemapBlock
  121054. * @param name defines the block name
  121055. */
  121056. constructor(name: string);
  121057. /**
  121058. * Gets the current class name
  121059. * @returns the class name
  121060. */
  121061. getClassName(): string;
  121062. /**
  121063. * Gets the input component
  121064. */
  121065. readonly input: NodeMaterialConnectionPoint;
  121066. /**
  121067. * Gets the source min input component
  121068. */
  121069. readonly sourceMin: NodeMaterialConnectionPoint;
  121070. /**
  121071. * Gets the source max input component
  121072. */
  121073. readonly sourceMax: NodeMaterialConnectionPoint;
  121074. /**
  121075. * Gets the target min input component
  121076. */
  121077. readonly targetMin: NodeMaterialConnectionPoint;
  121078. /**
  121079. * Gets the target max input component
  121080. */
  121081. readonly targetMax: NodeMaterialConnectionPoint;
  121082. /**
  121083. * Gets the output component
  121084. */
  121085. readonly output: NodeMaterialConnectionPoint;
  121086. protected _buildBlock(state: NodeMaterialBuildState): this;
  121087. protected _dumpPropertiesCode(): string;
  121088. serialize(): any;
  121089. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121090. }
  121091. }
  121092. declare module BABYLON {
  121093. /**
  121094. * Block used to normalize a vector
  121095. */
  121096. export class NormalizeBlock extends NodeMaterialBlock {
  121097. /**
  121098. * Creates a new NormalizeBlock
  121099. * @param name defines the block name
  121100. */
  121101. constructor(name: string);
  121102. /**
  121103. * Gets the current class name
  121104. * @returns the class name
  121105. */
  121106. getClassName(): string;
  121107. /**
  121108. * Gets the input component
  121109. */
  121110. readonly input: NodeMaterialConnectionPoint;
  121111. /**
  121112. * Gets the output component
  121113. */
  121114. readonly output: NodeMaterialConnectionPoint;
  121115. protected _buildBlock(state: NodeMaterialBuildState): this;
  121116. }
  121117. }
  121118. declare module BABYLON {
  121119. /**
  121120. * Operations supported by the Trigonometry block
  121121. */
  121122. export enum TrigonometryBlockOperations {
  121123. /** Cos */
  121124. Cos = 0,
  121125. /** Sin */
  121126. Sin = 1,
  121127. /** Abs */
  121128. Abs = 2,
  121129. /** Exp */
  121130. Exp = 3,
  121131. /** Exp2 */
  121132. Exp2 = 4,
  121133. /** Round */
  121134. Round = 5,
  121135. /** Floor */
  121136. Floor = 6,
  121137. /** Ceiling */
  121138. Ceiling = 7,
  121139. /** Square root */
  121140. Sqrt = 8,
  121141. /** Log */
  121142. Log = 9,
  121143. /** Tangent */
  121144. Tan = 10,
  121145. /** Arc tangent */
  121146. ArcTan = 11,
  121147. /** Arc cosinus */
  121148. ArcCos = 12,
  121149. /** Arc sinus */
  121150. ArcSin = 13,
  121151. /** Fraction */
  121152. Fract = 14,
  121153. /** Sign */
  121154. Sign = 15,
  121155. /** To radians (from degrees) */
  121156. Radians = 16,
  121157. /** To degrees (from radians) */
  121158. Degrees = 17
  121159. }
  121160. /**
  121161. * Block used to apply trigonometry operation to floats
  121162. */
  121163. export class TrigonometryBlock extends NodeMaterialBlock {
  121164. /**
  121165. * Gets or sets the operation applied by the block
  121166. */
  121167. operation: TrigonometryBlockOperations;
  121168. /**
  121169. * Creates a new TrigonometryBlock
  121170. * @param name defines the block name
  121171. */
  121172. constructor(name: string);
  121173. /**
  121174. * Gets the current class name
  121175. * @returns the class name
  121176. */
  121177. getClassName(): string;
  121178. /**
  121179. * Gets the input component
  121180. */
  121181. readonly input: NodeMaterialConnectionPoint;
  121182. /**
  121183. * Gets the output component
  121184. */
  121185. readonly output: NodeMaterialConnectionPoint;
  121186. protected _buildBlock(state: NodeMaterialBuildState): this;
  121187. serialize(): any;
  121188. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121189. }
  121190. }
  121191. declare module BABYLON {
  121192. /**
  121193. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121194. */
  121195. export class ColorMergerBlock extends NodeMaterialBlock {
  121196. /**
  121197. * Create a new ColorMergerBlock
  121198. * @param name defines the block name
  121199. */
  121200. constructor(name: string);
  121201. /**
  121202. * Gets the current class name
  121203. * @returns the class name
  121204. */
  121205. getClassName(): string;
  121206. /**
  121207. * Gets the r component (input)
  121208. */
  121209. readonly r: NodeMaterialConnectionPoint;
  121210. /**
  121211. * Gets the g component (input)
  121212. */
  121213. readonly g: NodeMaterialConnectionPoint;
  121214. /**
  121215. * Gets the b component (input)
  121216. */
  121217. readonly b: NodeMaterialConnectionPoint;
  121218. /**
  121219. * Gets the a component (input)
  121220. */
  121221. readonly a: NodeMaterialConnectionPoint;
  121222. /**
  121223. * Gets the rgba component (output)
  121224. */
  121225. readonly rgba: NodeMaterialConnectionPoint;
  121226. /**
  121227. * Gets the rgb component (output)
  121228. */
  121229. readonly rgb: NodeMaterialConnectionPoint;
  121230. protected _buildBlock(state: NodeMaterialBuildState): this;
  121231. }
  121232. }
  121233. declare module BABYLON {
  121234. /**
  121235. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121236. */
  121237. export class VectorMergerBlock extends NodeMaterialBlock {
  121238. /**
  121239. * Create a new VectorMergerBlock
  121240. * @param name defines the block name
  121241. */
  121242. constructor(name: string);
  121243. /**
  121244. * Gets the current class name
  121245. * @returns the class name
  121246. */
  121247. getClassName(): string;
  121248. /**
  121249. * Gets the x component (input)
  121250. */
  121251. readonly x: NodeMaterialConnectionPoint;
  121252. /**
  121253. * Gets the y component (input)
  121254. */
  121255. readonly y: NodeMaterialConnectionPoint;
  121256. /**
  121257. * Gets the z component (input)
  121258. */
  121259. readonly z: NodeMaterialConnectionPoint;
  121260. /**
  121261. * Gets the w component (input)
  121262. */
  121263. readonly w: NodeMaterialConnectionPoint;
  121264. /**
  121265. * Gets the xyzw component (output)
  121266. */
  121267. readonly xyzw: NodeMaterialConnectionPoint;
  121268. /**
  121269. * Gets the xyz component (output)
  121270. */
  121271. readonly xyz: NodeMaterialConnectionPoint;
  121272. /**
  121273. * Gets the xy component (output)
  121274. */
  121275. readonly xy: NodeMaterialConnectionPoint;
  121276. protected _buildBlock(state: NodeMaterialBuildState): this;
  121277. }
  121278. }
  121279. declare module BABYLON {
  121280. /**
  121281. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121282. */
  121283. export class ColorSplitterBlock extends NodeMaterialBlock {
  121284. /**
  121285. * Create a new ColorSplitterBlock
  121286. * @param name defines the block name
  121287. */
  121288. constructor(name: string);
  121289. /**
  121290. * Gets the current class name
  121291. * @returns the class name
  121292. */
  121293. getClassName(): string;
  121294. /**
  121295. * Gets the rgba component (input)
  121296. */
  121297. readonly rgba: NodeMaterialConnectionPoint;
  121298. /**
  121299. * Gets the rgb component (input)
  121300. */
  121301. readonly rgbIn: NodeMaterialConnectionPoint;
  121302. /**
  121303. * Gets the rgb component (output)
  121304. */
  121305. readonly rgbOut: NodeMaterialConnectionPoint;
  121306. /**
  121307. * Gets the r component (output)
  121308. */
  121309. readonly r: NodeMaterialConnectionPoint;
  121310. /**
  121311. * Gets the g component (output)
  121312. */
  121313. readonly g: NodeMaterialConnectionPoint;
  121314. /**
  121315. * Gets the b component (output)
  121316. */
  121317. readonly b: NodeMaterialConnectionPoint;
  121318. /**
  121319. * Gets the a component (output)
  121320. */
  121321. readonly a: NodeMaterialConnectionPoint;
  121322. protected _inputRename(name: string): string;
  121323. protected _outputRename(name: string): string;
  121324. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121325. }
  121326. }
  121327. declare module BABYLON {
  121328. /**
  121329. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121330. */
  121331. export class VectorSplitterBlock extends NodeMaterialBlock {
  121332. /**
  121333. * Create a new VectorSplitterBlock
  121334. * @param name defines the block name
  121335. */
  121336. constructor(name: string);
  121337. /**
  121338. * Gets the current class name
  121339. * @returns the class name
  121340. */
  121341. getClassName(): string;
  121342. /**
  121343. * Gets the xyzw component (input)
  121344. */
  121345. readonly xyzw: NodeMaterialConnectionPoint;
  121346. /**
  121347. * Gets the xyz component (input)
  121348. */
  121349. readonly xyzIn: NodeMaterialConnectionPoint;
  121350. /**
  121351. * Gets the xy component (input)
  121352. */
  121353. readonly xyIn: NodeMaterialConnectionPoint;
  121354. /**
  121355. * Gets the xyz component (output)
  121356. */
  121357. readonly xyzOut: NodeMaterialConnectionPoint;
  121358. /**
  121359. * Gets the xy component (output)
  121360. */
  121361. readonly xyOut: NodeMaterialConnectionPoint;
  121362. /**
  121363. * Gets the x component (output)
  121364. */
  121365. readonly x: NodeMaterialConnectionPoint;
  121366. /**
  121367. * Gets the y component (output)
  121368. */
  121369. readonly y: NodeMaterialConnectionPoint;
  121370. /**
  121371. * Gets the z component (output)
  121372. */
  121373. readonly z: NodeMaterialConnectionPoint;
  121374. /**
  121375. * Gets the w component (output)
  121376. */
  121377. readonly w: NodeMaterialConnectionPoint;
  121378. protected _inputRename(name: string): string;
  121379. protected _outputRename(name: string): string;
  121380. protected _buildBlock(state: NodeMaterialBuildState): this;
  121381. }
  121382. }
  121383. declare module BABYLON {
  121384. /**
  121385. * Block used to lerp 2 values
  121386. */
  121387. export class LerpBlock extends NodeMaterialBlock {
  121388. /**
  121389. * Creates a new LerpBlock
  121390. * @param name defines the block name
  121391. */
  121392. constructor(name: string);
  121393. /**
  121394. * Gets the current class name
  121395. * @returns the class name
  121396. */
  121397. getClassName(): string;
  121398. /**
  121399. * Gets the left operand input component
  121400. */
  121401. readonly left: NodeMaterialConnectionPoint;
  121402. /**
  121403. * Gets the right operand input component
  121404. */
  121405. readonly right: NodeMaterialConnectionPoint;
  121406. /**
  121407. * Gets the gradient operand input component
  121408. */
  121409. readonly gradient: NodeMaterialConnectionPoint;
  121410. /**
  121411. * Gets the output component
  121412. */
  121413. readonly output: NodeMaterialConnectionPoint;
  121414. protected _buildBlock(state: NodeMaterialBuildState): this;
  121415. }
  121416. }
  121417. declare module BABYLON {
  121418. /**
  121419. * Block used to divide 2 vectors
  121420. */
  121421. export class DivideBlock extends NodeMaterialBlock {
  121422. /**
  121423. * Creates a new DivideBlock
  121424. * @param name defines the block name
  121425. */
  121426. constructor(name: string);
  121427. /**
  121428. * Gets the current class name
  121429. * @returns the class name
  121430. */
  121431. getClassName(): string;
  121432. /**
  121433. * Gets the left operand input component
  121434. */
  121435. readonly left: NodeMaterialConnectionPoint;
  121436. /**
  121437. * Gets the right operand input component
  121438. */
  121439. readonly right: NodeMaterialConnectionPoint;
  121440. /**
  121441. * Gets the output component
  121442. */
  121443. readonly output: NodeMaterialConnectionPoint;
  121444. protected _buildBlock(state: NodeMaterialBuildState): this;
  121445. }
  121446. }
  121447. declare module BABYLON {
  121448. /**
  121449. * Block used to subtract 2 vectors
  121450. */
  121451. export class SubtractBlock extends NodeMaterialBlock {
  121452. /**
  121453. * Creates a new SubtractBlock
  121454. * @param name defines the block name
  121455. */
  121456. constructor(name: string);
  121457. /**
  121458. * Gets the current class name
  121459. * @returns the class name
  121460. */
  121461. getClassName(): string;
  121462. /**
  121463. * Gets the left operand input component
  121464. */
  121465. readonly left: NodeMaterialConnectionPoint;
  121466. /**
  121467. * Gets the right operand input component
  121468. */
  121469. readonly right: NodeMaterialConnectionPoint;
  121470. /**
  121471. * Gets the output component
  121472. */
  121473. readonly output: NodeMaterialConnectionPoint;
  121474. protected _buildBlock(state: NodeMaterialBuildState): this;
  121475. }
  121476. }
  121477. declare module BABYLON {
  121478. /**
  121479. * Block used to step a value
  121480. */
  121481. export class StepBlock extends NodeMaterialBlock {
  121482. /**
  121483. * Creates a new StepBlock
  121484. * @param name defines the block name
  121485. */
  121486. constructor(name: string);
  121487. /**
  121488. * Gets the current class name
  121489. * @returns the class name
  121490. */
  121491. getClassName(): string;
  121492. /**
  121493. * Gets the value operand input component
  121494. */
  121495. readonly value: NodeMaterialConnectionPoint;
  121496. /**
  121497. * Gets the edge operand input component
  121498. */
  121499. readonly edge: NodeMaterialConnectionPoint;
  121500. /**
  121501. * Gets the output component
  121502. */
  121503. readonly output: NodeMaterialConnectionPoint;
  121504. protected _buildBlock(state: NodeMaterialBuildState): this;
  121505. }
  121506. }
  121507. declare module BABYLON {
  121508. /**
  121509. * Block used to get the opposite (1 - x) of a value
  121510. */
  121511. export class OneMinusBlock extends NodeMaterialBlock {
  121512. /**
  121513. * Creates a new OneMinusBlock
  121514. * @param name defines the block name
  121515. */
  121516. constructor(name: string);
  121517. /**
  121518. * Gets the current class name
  121519. * @returns the class name
  121520. */
  121521. getClassName(): string;
  121522. /**
  121523. * Gets the input component
  121524. */
  121525. readonly input: NodeMaterialConnectionPoint;
  121526. /**
  121527. * Gets the output component
  121528. */
  121529. readonly output: NodeMaterialConnectionPoint;
  121530. protected _buildBlock(state: NodeMaterialBuildState): this;
  121531. }
  121532. }
  121533. declare module BABYLON {
  121534. /**
  121535. * Block used to get the view direction
  121536. */
  121537. export class ViewDirectionBlock extends NodeMaterialBlock {
  121538. /**
  121539. * Creates a new ViewDirectionBlock
  121540. * @param name defines the block name
  121541. */
  121542. constructor(name: string);
  121543. /**
  121544. * Gets the current class name
  121545. * @returns the class name
  121546. */
  121547. getClassName(): string;
  121548. /**
  121549. * Gets the world position component
  121550. */
  121551. readonly worldPosition: NodeMaterialConnectionPoint;
  121552. /**
  121553. * Gets the camera position component
  121554. */
  121555. readonly cameraPosition: NodeMaterialConnectionPoint;
  121556. /**
  121557. * Gets the output component
  121558. */
  121559. readonly output: NodeMaterialConnectionPoint;
  121560. autoConfigure(material: NodeMaterial): void;
  121561. protected _buildBlock(state: NodeMaterialBuildState): this;
  121562. }
  121563. }
  121564. declare module BABYLON {
  121565. /**
  121566. * Block used to compute fresnel value
  121567. */
  121568. export class FresnelBlock extends NodeMaterialBlock {
  121569. /**
  121570. * Create a new FresnelBlock
  121571. * @param name defines the block name
  121572. */
  121573. constructor(name: string);
  121574. /**
  121575. * Gets the current class name
  121576. * @returns the class name
  121577. */
  121578. getClassName(): string;
  121579. /**
  121580. * Gets the world normal input component
  121581. */
  121582. readonly worldNormal: NodeMaterialConnectionPoint;
  121583. /**
  121584. * Gets the view direction input component
  121585. */
  121586. readonly viewDirection: NodeMaterialConnectionPoint;
  121587. /**
  121588. * Gets the bias input component
  121589. */
  121590. readonly bias: NodeMaterialConnectionPoint;
  121591. /**
  121592. * Gets the camera (or eye) position component
  121593. */
  121594. readonly power: NodeMaterialConnectionPoint;
  121595. /**
  121596. * Gets the fresnel output component
  121597. */
  121598. readonly fresnel: NodeMaterialConnectionPoint;
  121599. autoConfigure(material: NodeMaterial): void;
  121600. protected _buildBlock(state: NodeMaterialBuildState): this;
  121601. }
  121602. }
  121603. declare module BABYLON {
  121604. /**
  121605. * Block used to get the max of 2 values
  121606. */
  121607. export class MaxBlock extends NodeMaterialBlock {
  121608. /**
  121609. * Creates a new MaxBlock
  121610. * @param name defines the block name
  121611. */
  121612. constructor(name: string);
  121613. /**
  121614. * Gets the current class name
  121615. * @returns the class name
  121616. */
  121617. getClassName(): string;
  121618. /**
  121619. * Gets the left operand input component
  121620. */
  121621. readonly left: NodeMaterialConnectionPoint;
  121622. /**
  121623. * Gets the right operand input component
  121624. */
  121625. readonly right: NodeMaterialConnectionPoint;
  121626. /**
  121627. * Gets the output component
  121628. */
  121629. readonly output: NodeMaterialConnectionPoint;
  121630. protected _buildBlock(state: NodeMaterialBuildState): this;
  121631. }
  121632. }
  121633. declare module BABYLON {
  121634. /**
  121635. * Block used to get the min of 2 values
  121636. */
  121637. export class MinBlock extends NodeMaterialBlock {
  121638. /**
  121639. * Creates a new MinBlock
  121640. * @param name defines the block name
  121641. */
  121642. constructor(name: string);
  121643. /**
  121644. * Gets the current class name
  121645. * @returns the class name
  121646. */
  121647. getClassName(): string;
  121648. /**
  121649. * Gets the left operand input component
  121650. */
  121651. readonly left: NodeMaterialConnectionPoint;
  121652. /**
  121653. * Gets the right operand input component
  121654. */
  121655. readonly right: NodeMaterialConnectionPoint;
  121656. /**
  121657. * Gets the output component
  121658. */
  121659. readonly output: NodeMaterialConnectionPoint;
  121660. protected _buildBlock(state: NodeMaterialBuildState): this;
  121661. }
  121662. }
  121663. declare module BABYLON {
  121664. /**
  121665. * Block used to get the distance between 2 values
  121666. */
  121667. export class DistanceBlock extends NodeMaterialBlock {
  121668. /**
  121669. * Creates a new DistanceBlock
  121670. * @param name defines the block name
  121671. */
  121672. constructor(name: string);
  121673. /**
  121674. * Gets the current class name
  121675. * @returns the class name
  121676. */
  121677. getClassName(): string;
  121678. /**
  121679. * Gets the left operand input component
  121680. */
  121681. readonly left: NodeMaterialConnectionPoint;
  121682. /**
  121683. * Gets the right operand input component
  121684. */
  121685. readonly right: NodeMaterialConnectionPoint;
  121686. /**
  121687. * Gets the output component
  121688. */
  121689. readonly output: NodeMaterialConnectionPoint;
  121690. protected _buildBlock(state: NodeMaterialBuildState): this;
  121691. }
  121692. }
  121693. declare module BABYLON {
  121694. /**
  121695. * Block used to get the length of a vector
  121696. */
  121697. export class LengthBlock extends NodeMaterialBlock {
  121698. /**
  121699. * Creates a new LengthBlock
  121700. * @param name defines the block name
  121701. */
  121702. constructor(name: string);
  121703. /**
  121704. * Gets the current class name
  121705. * @returns the class name
  121706. */
  121707. getClassName(): string;
  121708. /**
  121709. * Gets the value input component
  121710. */
  121711. readonly value: NodeMaterialConnectionPoint;
  121712. /**
  121713. * Gets the output component
  121714. */
  121715. readonly output: NodeMaterialConnectionPoint;
  121716. protected _buildBlock(state: NodeMaterialBuildState): this;
  121717. }
  121718. }
  121719. declare module BABYLON {
  121720. /**
  121721. * Block used to get negative version of a value (i.e. x * -1)
  121722. */
  121723. export class NegateBlock extends NodeMaterialBlock {
  121724. /**
  121725. * Creates a new NegateBlock
  121726. * @param name defines the block name
  121727. */
  121728. constructor(name: string);
  121729. /**
  121730. * Gets the current class name
  121731. * @returns the class name
  121732. */
  121733. getClassName(): string;
  121734. /**
  121735. * Gets the value input component
  121736. */
  121737. readonly value: NodeMaterialConnectionPoint;
  121738. /**
  121739. * Gets the output component
  121740. */
  121741. readonly output: NodeMaterialConnectionPoint;
  121742. protected _buildBlock(state: NodeMaterialBuildState): this;
  121743. }
  121744. }
  121745. declare module BABYLON {
  121746. /**
  121747. * Block used to get the value of the first parameter raised to the power of the second
  121748. */
  121749. export class PowBlock extends NodeMaterialBlock {
  121750. /**
  121751. * Creates a new PowBlock
  121752. * @param name defines the block name
  121753. */
  121754. constructor(name: string);
  121755. /**
  121756. * Gets the current class name
  121757. * @returns the class name
  121758. */
  121759. getClassName(): string;
  121760. /**
  121761. * Gets the value operand input component
  121762. */
  121763. readonly value: NodeMaterialConnectionPoint;
  121764. /**
  121765. * Gets the power operand input component
  121766. */
  121767. readonly power: NodeMaterialConnectionPoint;
  121768. /**
  121769. * Gets the output component
  121770. */
  121771. readonly output: NodeMaterialConnectionPoint;
  121772. protected _buildBlock(state: NodeMaterialBuildState): this;
  121773. }
  121774. }
  121775. declare module BABYLON {
  121776. /**
  121777. * Block used to get a random number
  121778. */
  121779. export class RandomNumberBlock extends NodeMaterialBlock {
  121780. /**
  121781. * Creates a new RandomNumberBlock
  121782. * @param name defines the block name
  121783. */
  121784. constructor(name: string);
  121785. /**
  121786. * Gets the current class name
  121787. * @returns the class name
  121788. */
  121789. getClassName(): string;
  121790. /**
  121791. * Gets the seed input component
  121792. */
  121793. readonly seed: NodeMaterialConnectionPoint;
  121794. /**
  121795. * Gets the output component
  121796. */
  121797. readonly output: NodeMaterialConnectionPoint;
  121798. protected _buildBlock(state: NodeMaterialBuildState): this;
  121799. }
  121800. }
  121801. declare module BABYLON {
  121802. /**
  121803. * Block used to compute arc tangent of 2 values
  121804. */
  121805. export class ArcTan2Block extends NodeMaterialBlock {
  121806. /**
  121807. * Creates a new ArcTan2Block
  121808. * @param name defines the block name
  121809. */
  121810. constructor(name: string);
  121811. /**
  121812. * Gets the current class name
  121813. * @returns the class name
  121814. */
  121815. getClassName(): string;
  121816. /**
  121817. * Gets the x operand input component
  121818. */
  121819. readonly x: NodeMaterialConnectionPoint;
  121820. /**
  121821. * Gets the y operand input component
  121822. */
  121823. readonly y: NodeMaterialConnectionPoint;
  121824. /**
  121825. * Gets the output component
  121826. */
  121827. readonly output: NodeMaterialConnectionPoint;
  121828. protected _buildBlock(state: NodeMaterialBuildState): this;
  121829. }
  121830. }
  121831. declare module BABYLON {
  121832. /**
  121833. * Block used to smooth step a value
  121834. */
  121835. export class SmoothStepBlock extends NodeMaterialBlock {
  121836. /**
  121837. * Creates a new SmoothStepBlock
  121838. * @param name defines the block name
  121839. */
  121840. constructor(name: string);
  121841. /**
  121842. * Gets the current class name
  121843. * @returns the class name
  121844. */
  121845. getClassName(): string;
  121846. /**
  121847. * Gets the value operand input component
  121848. */
  121849. readonly value: NodeMaterialConnectionPoint;
  121850. /**
  121851. * Gets the first edge operand input component
  121852. */
  121853. readonly edge0: NodeMaterialConnectionPoint;
  121854. /**
  121855. * Gets the second edge operand input component
  121856. */
  121857. readonly edge1: NodeMaterialConnectionPoint;
  121858. /**
  121859. * Gets the output component
  121860. */
  121861. readonly output: NodeMaterialConnectionPoint;
  121862. protected _buildBlock(state: NodeMaterialBuildState): this;
  121863. }
  121864. }
  121865. declare module BABYLON {
  121866. /**
  121867. * Block used to get the reciprocal (1 / x) of a value
  121868. */
  121869. export class ReciprocalBlock extends NodeMaterialBlock {
  121870. /**
  121871. * Creates a new ReciprocalBlock
  121872. * @param name defines the block name
  121873. */
  121874. constructor(name: string);
  121875. /**
  121876. * Gets the current class name
  121877. * @returns the class name
  121878. */
  121879. getClassName(): string;
  121880. /**
  121881. * Gets the input component
  121882. */
  121883. readonly input: NodeMaterialConnectionPoint;
  121884. /**
  121885. * Gets the output component
  121886. */
  121887. readonly output: NodeMaterialConnectionPoint;
  121888. protected _buildBlock(state: NodeMaterialBuildState): this;
  121889. }
  121890. }
  121891. declare module BABYLON {
  121892. /**
  121893. * Block used to replace a color by another one
  121894. */
  121895. export class ReplaceColorBlock extends NodeMaterialBlock {
  121896. /**
  121897. * Creates a new ReplaceColorBlock
  121898. * @param name defines the block name
  121899. */
  121900. constructor(name: string);
  121901. /**
  121902. * Gets the current class name
  121903. * @returns the class name
  121904. */
  121905. getClassName(): string;
  121906. /**
  121907. * Gets the value input component
  121908. */
  121909. readonly value: NodeMaterialConnectionPoint;
  121910. /**
  121911. * Gets the reference input component
  121912. */
  121913. readonly reference: NodeMaterialConnectionPoint;
  121914. /**
  121915. * Gets the distance input component
  121916. */
  121917. readonly distance: NodeMaterialConnectionPoint;
  121918. /**
  121919. * Gets the replacement input component
  121920. */
  121921. readonly replacement: NodeMaterialConnectionPoint;
  121922. /**
  121923. * Gets the output component
  121924. */
  121925. readonly output: NodeMaterialConnectionPoint;
  121926. protected _buildBlock(state: NodeMaterialBuildState): this;
  121927. }
  121928. }
  121929. declare module BABYLON {
  121930. /**
  121931. * Block used to posterize a value
  121932. * @see https://en.wikipedia.org/wiki/Posterization
  121933. */
  121934. export class PosterizeBlock extends NodeMaterialBlock {
  121935. /**
  121936. * Creates a new PosterizeBlock
  121937. * @param name defines the block name
  121938. */
  121939. constructor(name: string);
  121940. /**
  121941. * Gets the current class name
  121942. * @returns the class name
  121943. */
  121944. getClassName(): string;
  121945. /**
  121946. * Gets the value input component
  121947. */
  121948. readonly value: NodeMaterialConnectionPoint;
  121949. /**
  121950. * Gets the steps input component
  121951. */
  121952. readonly steps: NodeMaterialConnectionPoint;
  121953. /**
  121954. * Gets the output component
  121955. */
  121956. readonly output: NodeMaterialConnectionPoint;
  121957. protected _buildBlock(state: NodeMaterialBuildState): this;
  121958. }
  121959. }
  121960. declare module BABYLON {
  121961. /**
  121962. * Operations supported by the Wave block
  121963. */
  121964. export enum WaveBlockKind {
  121965. /** SawTooth */
  121966. SawTooth = 0,
  121967. /** Square */
  121968. Square = 1,
  121969. /** Triangle */
  121970. Triangle = 2
  121971. }
  121972. /**
  121973. * Block used to apply wave operation to floats
  121974. */
  121975. export class WaveBlock extends NodeMaterialBlock {
  121976. /**
  121977. * Gets or sets the kibnd of wave to be applied by the block
  121978. */
  121979. kind: WaveBlockKind;
  121980. /**
  121981. * Creates a new WaveBlock
  121982. * @param name defines the block name
  121983. */
  121984. constructor(name: string);
  121985. /**
  121986. * Gets the current class name
  121987. * @returns the class name
  121988. */
  121989. getClassName(): string;
  121990. /**
  121991. * Gets the input component
  121992. */
  121993. readonly input: NodeMaterialConnectionPoint;
  121994. /**
  121995. * Gets the output component
  121996. */
  121997. readonly output: NodeMaterialConnectionPoint;
  121998. protected _buildBlock(state: NodeMaterialBuildState): this;
  121999. serialize(): any;
  122000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122001. }
  122002. }
  122003. declare module BABYLON {
  122004. /**
  122005. * Effect Render Options
  122006. */
  122007. export interface IEffectRendererOptions {
  122008. /**
  122009. * Defines the vertices positions.
  122010. */
  122011. positions?: number[];
  122012. /**
  122013. * Defines the indices.
  122014. */
  122015. indices?: number[];
  122016. }
  122017. /**
  122018. * Helper class to render one or more effects
  122019. */
  122020. export class EffectRenderer {
  122021. private engine;
  122022. private static _DefaultOptions;
  122023. private _vertexBuffers;
  122024. private _indexBuffer;
  122025. private _ringBufferIndex;
  122026. private _ringScreenBuffer;
  122027. private _fullscreenViewport;
  122028. private _getNextFrameBuffer;
  122029. /**
  122030. * Creates an effect renderer
  122031. * @param engine the engine to use for rendering
  122032. * @param options defines the options of the effect renderer
  122033. */
  122034. constructor(engine: Engine, options?: IEffectRendererOptions);
  122035. /**
  122036. * Sets the current viewport in normalized coordinates 0-1
  122037. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122038. */
  122039. setViewport(viewport?: Viewport): void;
  122040. /**
  122041. * Binds the embedded attributes buffer to the effect.
  122042. * @param effect Defines the effect to bind the attributes for
  122043. */
  122044. bindBuffers(effect: Effect): void;
  122045. /**
  122046. * Sets the current effect wrapper to use during draw.
  122047. * The effect needs to be ready before calling this api.
  122048. * This also sets the default full screen position attribute.
  122049. * @param effectWrapper Defines the effect to draw with
  122050. */
  122051. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122052. /**
  122053. * Draws a full screen quad.
  122054. */
  122055. draw(): void;
  122056. /**
  122057. * renders one or more effects to a specified texture
  122058. * @param effectWrappers list of effects to renderer
  122059. * @param outputTexture texture to draw to, if null it will render to the screen
  122060. */
  122061. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122062. /**
  122063. * Disposes of the effect renderer
  122064. */
  122065. dispose(): void;
  122066. }
  122067. /**
  122068. * Options to create an EffectWrapper
  122069. */
  122070. interface EffectWrapperCreationOptions {
  122071. /**
  122072. * Engine to use to create the effect
  122073. */
  122074. engine: Engine;
  122075. /**
  122076. * Fragment shader for the effect
  122077. */
  122078. fragmentShader: string;
  122079. /**
  122080. * Vertex shader for the effect
  122081. */
  122082. vertexShader?: string;
  122083. /**
  122084. * Attributes to use in the shader
  122085. */
  122086. attributeNames?: Array<string>;
  122087. /**
  122088. * Uniforms to use in the shader
  122089. */
  122090. uniformNames?: Array<string>;
  122091. /**
  122092. * Texture sampler names to use in the shader
  122093. */
  122094. samplerNames?: Array<string>;
  122095. /**
  122096. * The friendly name of the effect displayed in Spector.
  122097. */
  122098. name?: string;
  122099. }
  122100. /**
  122101. * Wraps an effect to be used for rendering
  122102. */
  122103. export class EffectWrapper {
  122104. /**
  122105. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122106. */
  122107. onApplyObservable: Observable<{}>;
  122108. /**
  122109. * The underlying effect
  122110. */
  122111. effect: Effect;
  122112. /**
  122113. * Creates an effect to be renderer
  122114. * @param creationOptions options to create the effect
  122115. */
  122116. constructor(creationOptions: EffectWrapperCreationOptions);
  122117. /**
  122118. * Disposes of the effect wrapper
  122119. */
  122120. dispose(): void;
  122121. }
  122122. }
  122123. declare module BABYLON {
  122124. /**
  122125. * Helper class to push actions to a pool of workers.
  122126. */
  122127. export class WorkerPool implements IDisposable {
  122128. private _workerInfos;
  122129. private _pendingActions;
  122130. /**
  122131. * Constructor
  122132. * @param workers Array of workers to use for actions
  122133. */
  122134. constructor(workers: Array<Worker>);
  122135. /**
  122136. * Terminates all workers and clears any pending actions.
  122137. */
  122138. dispose(): void;
  122139. /**
  122140. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122141. * pended until a worker has completed its action.
  122142. * @param action The action to perform. Call onComplete when the action is complete.
  122143. */
  122144. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122145. private _execute;
  122146. }
  122147. }
  122148. declare module BABYLON {
  122149. /**
  122150. * Configuration for Draco compression
  122151. */
  122152. export interface IDracoCompressionConfiguration {
  122153. /**
  122154. * Configuration for the decoder.
  122155. */
  122156. decoder: {
  122157. /**
  122158. * The url to the WebAssembly module.
  122159. */
  122160. wasmUrl?: string;
  122161. /**
  122162. * The url to the WebAssembly binary.
  122163. */
  122164. wasmBinaryUrl?: string;
  122165. /**
  122166. * The url to the fallback JavaScript module.
  122167. */
  122168. fallbackUrl?: string;
  122169. };
  122170. }
  122171. /**
  122172. * Draco compression (https://google.github.io/draco/)
  122173. *
  122174. * This class wraps the Draco module.
  122175. *
  122176. * **Encoder**
  122177. *
  122178. * The encoder is not currently implemented.
  122179. *
  122180. * **Decoder**
  122181. *
  122182. * 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.
  122183. *
  122184. * To update the configuration, use the following code:
  122185. * ```javascript
  122186. * DracoCompression.Configuration = {
  122187. * decoder: {
  122188. * wasmUrl: "<url to the WebAssembly library>",
  122189. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122190. * fallbackUrl: "<url to the fallback JavaScript library>",
  122191. * }
  122192. * };
  122193. * ```
  122194. *
  122195. * 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.
  122196. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122197. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122198. *
  122199. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122200. * ```javascript
  122201. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122202. * ```
  122203. *
  122204. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122205. */
  122206. export class DracoCompression implements IDisposable {
  122207. private _workerPoolPromise?;
  122208. private _decoderModulePromise?;
  122209. /**
  122210. * The configuration. Defaults to the following urls:
  122211. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122212. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122213. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122214. */
  122215. static Configuration: IDracoCompressionConfiguration;
  122216. /**
  122217. * Returns true if the decoder configuration is available.
  122218. */
  122219. static readonly DecoderAvailable: boolean;
  122220. /**
  122221. * Default number of workers to create when creating the draco compression object.
  122222. */
  122223. static DefaultNumWorkers: number;
  122224. private static GetDefaultNumWorkers;
  122225. private static _Default;
  122226. /**
  122227. * Default instance for the draco compression object.
  122228. */
  122229. static readonly Default: DracoCompression;
  122230. /**
  122231. * Constructor
  122232. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122233. */
  122234. constructor(numWorkers?: number);
  122235. /**
  122236. * Stop all async operations and release resources.
  122237. */
  122238. dispose(): void;
  122239. /**
  122240. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122241. * @returns a promise that resolves when ready
  122242. */
  122243. whenReadyAsync(): Promise<void>;
  122244. /**
  122245. * Decode Draco compressed mesh data to vertex data.
  122246. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122247. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122248. * @returns A promise that resolves with the decoded vertex data
  122249. */
  122250. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122251. [kind: string]: number;
  122252. }): Promise<VertexData>;
  122253. }
  122254. }
  122255. declare module BABYLON {
  122256. /**
  122257. * Class for building Constructive Solid Geometry
  122258. */
  122259. export class CSG {
  122260. private polygons;
  122261. /**
  122262. * The world matrix
  122263. */
  122264. matrix: Matrix;
  122265. /**
  122266. * Stores the position
  122267. */
  122268. position: Vector3;
  122269. /**
  122270. * Stores the rotation
  122271. */
  122272. rotation: Vector3;
  122273. /**
  122274. * Stores the rotation quaternion
  122275. */
  122276. rotationQuaternion: Nullable<Quaternion>;
  122277. /**
  122278. * Stores the scaling vector
  122279. */
  122280. scaling: Vector3;
  122281. /**
  122282. * Convert the Mesh to CSG
  122283. * @param mesh The Mesh to convert to CSG
  122284. * @returns A new CSG from the Mesh
  122285. */
  122286. static FromMesh(mesh: Mesh): CSG;
  122287. /**
  122288. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122289. * @param polygons Polygons used to construct a CSG solid
  122290. */
  122291. private static FromPolygons;
  122292. /**
  122293. * Clones, or makes a deep copy, of the CSG
  122294. * @returns A new CSG
  122295. */
  122296. clone(): CSG;
  122297. /**
  122298. * Unions this CSG with another CSG
  122299. * @param csg The CSG to union against this CSG
  122300. * @returns The unioned CSG
  122301. */
  122302. union(csg: CSG): CSG;
  122303. /**
  122304. * Unions this CSG with another CSG in place
  122305. * @param csg The CSG to union against this CSG
  122306. */
  122307. unionInPlace(csg: CSG): void;
  122308. /**
  122309. * Subtracts this CSG with another CSG
  122310. * @param csg The CSG to subtract against this CSG
  122311. * @returns A new CSG
  122312. */
  122313. subtract(csg: CSG): CSG;
  122314. /**
  122315. * Subtracts this CSG with another CSG in place
  122316. * @param csg The CSG to subtact against this CSG
  122317. */
  122318. subtractInPlace(csg: CSG): void;
  122319. /**
  122320. * Intersect this CSG with another CSG
  122321. * @param csg The CSG to intersect against this CSG
  122322. * @returns A new CSG
  122323. */
  122324. intersect(csg: CSG): CSG;
  122325. /**
  122326. * Intersects this CSG with another CSG in place
  122327. * @param csg The CSG to intersect against this CSG
  122328. */
  122329. intersectInPlace(csg: CSG): void;
  122330. /**
  122331. * Return a new CSG solid with solid and empty space switched. This solid is
  122332. * not modified.
  122333. * @returns A new CSG solid with solid and empty space switched
  122334. */
  122335. inverse(): CSG;
  122336. /**
  122337. * Inverses the CSG in place
  122338. */
  122339. inverseInPlace(): void;
  122340. /**
  122341. * This is used to keep meshes transformations so they can be restored
  122342. * when we build back a Babylon Mesh
  122343. * NB : All CSG operations are performed in world coordinates
  122344. * @param csg The CSG to copy the transform attributes from
  122345. * @returns This CSG
  122346. */
  122347. copyTransformAttributes(csg: CSG): CSG;
  122348. /**
  122349. * Build Raw mesh from CSG
  122350. * Coordinates here are in world space
  122351. * @param name The name of the mesh geometry
  122352. * @param scene The Scene
  122353. * @param keepSubMeshes Specifies if the submeshes should be kept
  122354. * @returns A new Mesh
  122355. */
  122356. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122357. /**
  122358. * Build Mesh from CSG taking material and transforms into account
  122359. * @param name The name of the Mesh
  122360. * @param material The material of the Mesh
  122361. * @param scene The Scene
  122362. * @param keepSubMeshes Specifies if submeshes should be kept
  122363. * @returns The new Mesh
  122364. */
  122365. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122366. }
  122367. }
  122368. declare module BABYLON {
  122369. /**
  122370. * Class used to create a trail following a mesh
  122371. */
  122372. export class TrailMesh extends Mesh {
  122373. private _generator;
  122374. private _autoStart;
  122375. private _running;
  122376. private _diameter;
  122377. private _length;
  122378. private _sectionPolygonPointsCount;
  122379. private _sectionVectors;
  122380. private _sectionNormalVectors;
  122381. private _beforeRenderObserver;
  122382. /**
  122383. * @constructor
  122384. * @param name The value used by scene.getMeshByName() to do a lookup.
  122385. * @param generator The mesh to generate a trail.
  122386. * @param scene The scene to add this mesh to.
  122387. * @param diameter Diameter of trailing mesh. Default is 1.
  122388. * @param length Length of trailing mesh. Default is 60.
  122389. * @param autoStart Automatically start trailing mesh. Default true.
  122390. */
  122391. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122392. /**
  122393. * "TrailMesh"
  122394. * @returns "TrailMesh"
  122395. */
  122396. getClassName(): string;
  122397. private _createMesh;
  122398. /**
  122399. * Start trailing mesh.
  122400. */
  122401. start(): void;
  122402. /**
  122403. * Stop trailing mesh.
  122404. */
  122405. stop(): void;
  122406. /**
  122407. * Update trailing mesh geometry.
  122408. */
  122409. update(): void;
  122410. /**
  122411. * Returns a new TrailMesh object.
  122412. * @param name is a string, the name given to the new mesh
  122413. * @param newGenerator use new generator object for cloned trail mesh
  122414. * @returns a new mesh
  122415. */
  122416. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122417. /**
  122418. * Serializes this trail mesh
  122419. * @param serializationObject object to write serialization to
  122420. */
  122421. serialize(serializationObject: any): void;
  122422. /**
  122423. * Parses a serialized trail mesh
  122424. * @param parsedMesh the serialized mesh
  122425. * @param scene the scene to create the trail mesh in
  122426. * @returns the created trail mesh
  122427. */
  122428. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122429. }
  122430. }
  122431. declare module BABYLON {
  122432. /**
  122433. * Class containing static functions to help procedurally build meshes
  122434. */
  122435. export class TiledBoxBuilder {
  122436. /**
  122437. * Creates a box mesh
  122438. * 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)
  122439. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122443. * @param name defines the name of the mesh
  122444. * @param options defines the options used to create the mesh
  122445. * @param scene defines the hosting scene
  122446. * @returns the box mesh
  122447. */
  122448. static CreateTiledBox(name: string, options: {
  122449. pattern?: number;
  122450. width?: number;
  122451. height?: number;
  122452. depth?: number;
  122453. tileSize?: number;
  122454. tileWidth?: number;
  122455. tileHeight?: number;
  122456. alignHorizontal?: number;
  122457. alignVertical?: number;
  122458. faceUV?: Vector4[];
  122459. faceColors?: Color4[];
  122460. sideOrientation?: number;
  122461. updatable?: boolean;
  122462. }, scene?: Nullable<Scene>): Mesh;
  122463. }
  122464. }
  122465. declare module BABYLON {
  122466. /**
  122467. * Class containing static functions to help procedurally build meshes
  122468. */
  122469. export class TorusKnotBuilder {
  122470. /**
  122471. * Creates a torus knot mesh
  122472. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122473. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122474. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122475. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122479. * @param name defines the name of the mesh
  122480. * @param options defines the options used to create the mesh
  122481. * @param scene defines the hosting scene
  122482. * @returns the torus knot mesh
  122483. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122484. */
  122485. static CreateTorusKnot(name: string, options: {
  122486. radius?: number;
  122487. tube?: number;
  122488. radialSegments?: number;
  122489. tubularSegments?: number;
  122490. p?: number;
  122491. q?: number;
  122492. updatable?: boolean;
  122493. sideOrientation?: number;
  122494. frontUVs?: Vector4;
  122495. backUVs?: Vector4;
  122496. }, scene: any): Mesh;
  122497. }
  122498. }
  122499. declare module BABYLON {
  122500. /**
  122501. * Polygon
  122502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122503. */
  122504. export class Polygon {
  122505. /**
  122506. * Creates a rectangle
  122507. * @param xmin bottom X coord
  122508. * @param ymin bottom Y coord
  122509. * @param xmax top X coord
  122510. * @param ymax top Y coord
  122511. * @returns points that make the resulting rectation
  122512. */
  122513. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122514. /**
  122515. * Creates a circle
  122516. * @param radius radius of circle
  122517. * @param cx scale in x
  122518. * @param cy scale in y
  122519. * @param numberOfSides number of sides that make up the circle
  122520. * @returns points that make the resulting circle
  122521. */
  122522. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122523. /**
  122524. * Creates a polygon from input string
  122525. * @param input Input polygon data
  122526. * @returns the parsed points
  122527. */
  122528. static Parse(input: string): Vector2[];
  122529. /**
  122530. * Starts building a polygon from x and y coordinates
  122531. * @param x x coordinate
  122532. * @param y y coordinate
  122533. * @returns the started path2
  122534. */
  122535. static StartingAt(x: number, y: number): Path2;
  122536. }
  122537. /**
  122538. * Builds a polygon
  122539. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122540. */
  122541. export class PolygonMeshBuilder {
  122542. private _points;
  122543. private _outlinepoints;
  122544. private _holes;
  122545. private _name;
  122546. private _scene;
  122547. private _epoints;
  122548. private _eholes;
  122549. private _addToepoint;
  122550. /**
  122551. * Babylon reference to the earcut plugin.
  122552. */
  122553. bjsEarcut: any;
  122554. /**
  122555. * Creates a PolygonMeshBuilder
  122556. * @param name name of the builder
  122557. * @param contours Path of the polygon
  122558. * @param scene scene to add to when creating the mesh
  122559. * @param earcutInjection can be used to inject your own earcut reference
  122560. */
  122561. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122562. /**
  122563. * Adds a whole within the polygon
  122564. * @param hole Array of points defining the hole
  122565. * @returns this
  122566. */
  122567. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122568. /**
  122569. * Creates the polygon
  122570. * @param updatable If the mesh should be updatable
  122571. * @param depth The depth of the mesh created
  122572. * @returns the created mesh
  122573. */
  122574. build(updatable?: boolean, depth?: number): Mesh;
  122575. /**
  122576. * Creates the polygon
  122577. * @param depth The depth of the mesh created
  122578. * @returns the created VertexData
  122579. */
  122580. buildVertexData(depth?: number): VertexData;
  122581. /**
  122582. * Adds a side to the polygon
  122583. * @param positions points that make the polygon
  122584. * @param normals normals of the polygon
  122585. * @param uvs uvs of the polygon
  122586. * @param indices indices of the polygon
  122587. * @param bounds bounds of the polygon
  122588. * @param points points of the polygon
  122589. * @param depth depth of the polygon
  122590. * @param flip flip of the polygon
  122591. */
  122592. private addSide;
  122593. }
  122594. }
  122595. declare module BABYLON {
  122596. /**
  122597. * Class containing static functions to help procedurally build meshes
  122598. */
  122599. export class PolygonBuilder {
  122600. /**
  122601. * Creates a polygon mesh
  122602. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122603. * * 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
  122604. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122607. * * Remember you can only change the shape positions, not their number when updating a polygon
  122608. * @param name defines the name of the mesh
  122609. * @param options defines the options used to create the mesh
  122610. * @param scene defines the hosting scene
  122611. * @param earcutInjection can be used to inject your own earcut reference
  122612. * @returns the polygon mesh
  122613. */
  122614. static CreatePolygon(name: string, options: {
  122615. shape: Vector3[];
  122616. holes?: Vector3[][];
  122617. depth?: number;
  122618. faceUV?: Vector4[];
  122619. faceColors?: Color4[];
  122620. updatable?: boolean;
  122621. sideOrientation?: number;
  122622. frontUVs?: Vector4;
  122623. backUVs?: Vector4;
  122624. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122625. /**
  122626. * Creates an extruded polygon mesh, with depth in the Y direction.
  122627. * * 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)
  122628. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122629. * @param name defines the name of the mesh
  122630. * @param options defines the options used to create the mesh
  122631. * @param scene defines the hosting scene
  122632. * @param earcutInjection can be used to inject your own earcut reference
  122633. * @returns the polygon mesh
  122634. */
  122635. static ExtrudePolygon(name: string, options: {
  122636. shape: Vector3[];
  122637. holes?: Vector3[][];
  122638. depth?: number;
  122639. faceUV?: Vector4[];
  122640. faceColors?: Color4[];
  122641. updatable?: boolean;
  122642. sideOrientation?: number;
  122643. frontUVs?: Vector4;
  122644. backUVs?: Vector4;
  122645. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122646. }
  122647. }
  122648. declare module BABYLON {
  122649. /**
  122650. * Class containing static functions to help procedurally build meshes
  122651. */
  122652. export class LatheBuilder {
  122653. /**
  122654. * Creates lathe mesh.
  122655. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122656. * * 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
  122657. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122658. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122659. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122660. * * 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
  122661. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122662. * * 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
  122663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122665. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122667. * @param name defines the name of the mesh
  122668. * @param options defines the options used to create the mesh
  122669. * @param scene defines the hosting scene
  122670. * @returns the lathe mesh
  122671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122672. */
  122673. static CreateLathe(name: string, options: {
  122674. shape: Vector3[];
  122675. radius?: number;
  122676. tessellation?: number;
  122677. clip?: number;
  122678. arc?: number;
  122679. closed?: boolean;
  122680. updatable?: boolean;
  122681. sideOrientation?: number;
  122682. frontUVs?: Vector4;
  122683. backUVs?: Vector4;
  122684. cap?: number;
  122685. invertUV?: boolean;
  122686. }, scene?: Nullable<Scene>): Mesh;
  122687. }
  122688. }
  122689. declare module BABYLON {
  122690. /**
  122691. * Class containing static functions to help procedurally build meshes
  122692. */
  122693. export class TiledPlaneBuilder {
  122694. /**
  122695. * Creates a tiled plane mesh
  122696. * * The parameter `pattern` will, depending on value, do nothing or
  122697. * * * flip (reflect about central vertical) alternate tiles across and up
  122698. * * * flip every tile on alternate rows
  122699. * * * rotate (180 degs) alternate tiles across and up
  122700. * * * rotate every tile on alternate rows
  122701. * * * flip and rotate alternate tiles across and up
  122702. * * * flip and rotate every tile on alternate rows
  122703. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  122704. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  122705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122706. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122707. * * 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)
  122708. * * 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)
  122709. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122710. * @param name defines the name of the mesh
  122711. * @param options defines the options used to create the mesh
  122712. * @param scene defines the hosting scene
  122713. * @returns the box mesh
  122714. */
  122715. static CreateTiledPlane(name: string, options: {
  122716. pattern?: number;
  122717. tileSize?: number;
  122718. tileWidth?: number;
  122719. tileHeight?: number;
  122720. size?: number;
  122721. width?: number;
  122722. height?: number;
  122723. alignHorizontal?: number;
  122724. alignVertical?: number;
  122725. sideOrientation?: number;
  122726. frontUVs?: Vector4;
  122727. backUVs?: Vector4;
  122728. updatable?: boolean;
  122729. }, scene?: Nullable<Scene>): Mesh;
  122730. }
  122731. }
  122732. declare module BABYLON {
  122733. /**
  122734. * Class containing static functions to help procedurally build meshes
  122735. */
  122736. export class TubeBuilder {
  122737. /**
  122738. * Creates a tube mesh.
  122739. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122740. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122741. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122742. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122743. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122744. * * 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)
  122745. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122746. * * 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
  122747. * * 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
  122748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122752. * @param name defines the name of the mesh
  122753. * @param options defines the options used to create the mesh
  122754. * @param scene defines the hosting scene
  122755. * @returns the tube mesh
  122756. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122757. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122758. */
  122759. static CreateTube(name: string, options: {
  122760. path: Vector3[];
  122761. radius?: number;
  122762. tessellation?: number;
  122763. radiusFunction?: {
  122764. (i: number, distance: number): number;
  122765. };
  122766. cap?: number;
  122767. arc?: number;
  122768. updatable?: boolean;
  122769. sideOrientation?: number;
  122770. frontUVs?: Vector4;
  122771. backUVs?: Vector4;
  122772. instance?: Mesh;
  122773. invertUV?: boolean;
  122774. }, scene?: Nullable<Scene>): Mesh;
  122775. }
  122776. }
  122777. declare module BABYLON {
  122778. /**
  122779. * Class containing static functions to help procedurally build meshes
  122780. */
  122781. export class IcoSphereBuilder {
  122782. /**
  122783. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122784. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122785. * * 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`)
  122786. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122787. * * 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
  122788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122791. * @param name defines the name of the mesh
  122792. * @param options defines the options used to create the mesh
  122793. * @param scene defines the hosting scene
  122794. * @returns the icosahedron mesh
  122795. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122796. */
  122797. static CreateIcoSphere(name: string, options: {
  122798. radius?: number;
  122799. radiusX?: number;
  122800. radiusY?: number;
  122801. radiusZ?: number;
  122802. flat?: boolean;
  122803. subdivisions?: number;
  122804. sideOrientation?: number;
  122805. frontUVs?: Vector4;
  122806. backUVs?: Vector4;
  122807. updatable?: boolean;
  122808. }, scene?: Nullable<Scene>): Mesh;
  122809. }
  122810. }
  122811. declare module BABYLON {
  122812. /**
  122813. * Class containing static functions to help procedurally build meshes
  122814. */
  122815. export class DecalBuilder {
  122816. /**
  122817. * Creates a decal mesh.
  122818. * 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
  122819. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122820. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122821. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122822. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122823. * @param name defines the name of the mesh
  122824. * @param sourceMesh defines the mesh where the decal must be applied
  122825. * @param options defines the options used to create the mesh
  122826. * @param scene defines the hosting scene
  122827. * @returns the decal mesh
  122828. * @see https://doc.babylonjs.com/how_to/decals
  122829. */
  122830. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122831. position?: Vector3;
  122832. normal?: Vector3;
  122833. size?: Vector3;
  122834. angle?: number;
  122835. }): Mesh;
  122836. }
  122837. }
  122838. declare module BABYLON {
  122839. /**
  122840. * Class containing static functions to help procedurally build meshes
  122841. */
  122842. export class MeshBuilder {
  122843. /**
  122844. * Creates a box mesh
  122845. * * The parameter `size` sets the size (float) of each box side (default 1)
  122846. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122847. * * 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)
  122848. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122852. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122853. * @param name defines the name of the mesh
  122854. * @param options defines the options used to create the mesh
  122855. * @param scene defines the hosting scene
  122856. * @returns the box mesh
  122857. */
  122858. static CreateBox(name: string, options: {
  122859. size?: number;
  122860. width?: number;
  122861. height?: number;
  122862. depth?: number;
  122863. faceUV?: Vector4[];
  122864. faceColors?: Color4[];
  122865. sideOrientation?: number;
  122866. frontUVs?: Vector4;
  122867. backUVs?: Vector4;
  122868. updatable?: boolean;
  122869. }, scene?: Nullable<Scene>): Mesh;
  122870. /**
  122871. * Creates a tiled box mesh
  122872. * * faceTiles sets the pattern, tile size and number of tiles for a face
  122873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122874. * @param name defines the name of the mesh
  122875. * @param options defines the options used to create the mesh
  122876. * @param scene defines the hosting scene
  122877. * @returns the tiled box mesh
  122878. */
  122879. static CreateTiledBox(name: string, options: {
  122880. pattern?: number;
  122881. size?: number;
  122882. width?: number;
  122883. height?: number;
  122884. depth: number;
  122885. tileSize?: number;
  122886. tileWidth?: number;
  122887. tileHeight?: number;
  122888. faceUV?: Vector4[];
  122889. faceColors?: Color4[];
  122890. alignHorizontal?: number;
  122891. alignVertical?: number;
  122892. sideOrientation?: number;
  122893. updatable?: boolean;
  122894. }, scene?: Nullable<Scene>): Mesh;
  122895. /**
  122896. * Creates a sphere mesh
  122897. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  122898. * * 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`)
  122899. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  122900. * * 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
  122901. * * 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)
  122902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122905. * @param name defines the name of the mesh
  122906. * @param options defines the options used to create the mesh
  122907. * @param scene defines the hosting scene
  122908. * @returns the sphere mesh
  122909. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  122910. */
  122911. static CreateSphere(name: string, options: {
  122912. segments?: number;
  122913. diameter?: number;
  122914. diameterX?: number;
  122915. diameterY?: number;
  122916. diameterZ?: number;
  122917. arc?: number;
  122918. slice?: number;
  122919. sideOrientation?: number;
  122920. frontUVs?: Vector4;
  122921. backUVs?: Vector4;
  122922. updatable?: boolean;
  122923. }, scene?: Nullable<Scene>): Mesh;
  122924. /**
  122925. * Creates a plane polygonal mesh. By default, this is a disc
  122926. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  122927. * * 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
  122928. * * 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
  122929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122932. * @param name defines the name of the mesh
  122933. * @param options defines the options used to create the mesh
  122934. * @param scene defines the hosting scene
  122935. * @returns the plane polygonal mesh
  122936. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  122937. */
  122938. static CreateDisc(name: string, options: {
  122939. radius?: number;
  122940. tessellation?: number;
  122941. arc?: number;
  122942. updatable?: boolean;
  122943. sideOrientation?: number;
  122944. frontUVs?: Vector4;
  122945. backUVs?: Vector4;
  122946. }, scene?: Nullable<Scene>): Mesh;
  122947. /**
  122948. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122949. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122950. * * 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`)
  122951. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122952. * * 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
  122953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122956. * @param name defines the name of the mesh
  122957. * @param options defines the options used to create the mesh
  122958. * @param scene defines the hosting scene
  122959. * @returns the icosahedron mesh
  122960. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122961. */
  122962. static CreateIcoSphere(name: string, options: {
  122963. radius?: number;
  122964. radiusX?: number;
  122965. radiusY?: number;
  122966. radiusZ?: number;
  122967. flat?: boolean;
  122968. subdivisions?: number;
  122969. sideOrientation?: number;
  122970. frontUVs?: Vector4;
  122971. backUVs?: Vector4;
  122972. updatable?: boolean;
  122973. }, scene?: Nullable<Scene>): Mesh;
  122974. /**
  122975. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122976. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  122977. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  122978. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  122979. * * 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
  122980. * * 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
  122981. * * 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
  122982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122984. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122985. * * 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
  122986. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  122987. * * 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
  122988. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  122989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122990. * @param name defines the name of the mesh
  122991. * @param options defines the options used to create the mesh
  122992. * @param scene defines the hosting scene
  122993. * @returns the ribbon mesh
  122994. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  122995. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122996. */
  122997. static CreateRibbon(name: string, options: {
  122998. pathArray: Vector3[][];
  122999. closeArray?: boolean;
  123000. closePath?: boolean;
  123001. offset?: number;
  123002. updatable?: boolean;
  123003. sideOrientation?: number;
  123004. frontUVs?: Vector4;
  123005. backUVs?: Vector4;
  123006. instance?: Mesh;
  123007. invertUV?: boolean;
  123008. uvs?: Vector2[];
  123009. colors?: Color4[];
  123010. }, scene?: Nullable<Scene>): Mesh;
  123011. /**
  123012. * Creates a cylinder or a cone mesh
  123013. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123014. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123015. * * 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.
  123016. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123017. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123018. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123019. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123020. * * 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).
  123021. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123022. * * 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).
  123023. * * 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
  123024. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123025. * * 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
  123026. * * 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.
  123027. * * If `enclose` is false, a ring surface is one element.
  123028. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123029. * * 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
  123030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123033. * @param name defines the name of the mesh
  123034. * @param options defines the options used to create the mesh
  123035. * @param scene defines the hosting scene
  123036. * @returns the cylinder mesh
  123037. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123038. */
  123039. static CreateCylinder(name: string, options: {
  123040. height?: number;
  123041. diameterTop?: number;
  123042. diameterBottom?: number;
  123043. diameter?: number;
  123044. tessellation?: number;
  123045. subdivisions?: number;
  123046. arc?: number;
  123047. faceColors?: Color4[];
  123048. faceUV?: Vector4[];
  123049. updatable?: boolean;
  123050. hasRings?: boolean;
  123051. enclose?: boolean;
  123052. cap?: number;
  123053. sideOrientation?: number;
  123054. frontUVs?: Vector4;
  123055. backUVs?: Vector4;
  123056. }, scene?: Nullable<Scene>): Mesh;
  123057. /**
  123058. * Creates a torus mesh
  123059. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123060. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123061. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123065. * @param name defines the name of the mesh
  123066. * @param options defines the options used to create the mesh
  123067. * @param scene defines the hosting scene
  123068. * @returns the torus mesh
  123069. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123070. */
  123071. static CreateTorus(name: string, options: {
  123072. diameter?: number;
  123073. thickness?: number;
  123074. tessellation?: number;
  123075. updatable?: boolean;
  123076. sideOrientation?: number;
  123077. frontUVs?: Vector4;
  123078. backUVs?: Vector4;
  123079. }, scene?: Nullable<Scene>): Mesh;
  123080. /**
  123081. * Creates a torus knot mesh
  123082. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123083. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123084. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123085. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123089. * @param name defines the name of the mesh
  123090. * @param options defines the options used to create the mesh
  123091. * @param scene defines the hosting scene
  123092. * @returns the torus knot mesh
  123093. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123094. */
  123095. static CreateTorusKnot(name: string, options: {
  123096. radius?: number;
  123097. tube?: number;
  123098. radialSegments?: number;
  123099. tubularSegments?: number;
  123100. p?: number;
  123101. q?: number;
  123102. updatable?: boolean;
  123103. sideOrientation?: number;
  123104. frontUVs?: Vector4;
  123105. backUVs?: Vector4;
  123106. }, scene?: Nullable<Scene>): Mesh;
  123107. /**
  123108. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123109. * * 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
  123110. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123111. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123112. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123113. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123114. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123115. * * 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
  123116. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123119. * @param name defines the name of the new line system
  123120. * @param options defines the options used to create the line system
  123121. * @param scene defines the hosting scene
  123122. * @returns a new line system mesh
  123123. */
  123124. static CreateLineSystem(name: string, options: {
  123125. lines: Vector3[][];
  123126. updatable?: boolean;
  123127. instance?: Nullable<LinesMesh>;
  123128. colors?: Nullable<Color4[][]>;
  123129. useVertexAlpha?: boolean;
  123130. }, scene: Nullable<Scene>): LinesMesh;
  123131. /**
  123132. * Creates a line mesh
  123133. * 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
  123134. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123135. * * The parameter `points` is an array successive Vector3
  123136. * * 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
  123137. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123138. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123139. * * When updating an instance, remember that only point positions can change, not the number of points
  123140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123142. * @param name defines the name of the new line system
  123143. * @param options defines the options used to create the line system
  123144. * @param scene defines the hosting scene
  123145. * @returns a new line mesh
  123146. */
  123147. static CreateLines(name: string, options: {
  123148. points: Vector3[];
  123149. updatable?: boolean;
  123150. instance?: Nullable<LinesMesh>;
  123151. colors?: Color4[];
  123152. useVertexAlpha?: boolean;
  123153. }, scene?: Nullable<Scene>): LinesMesh;
  123154. /**
  123155. * Creates a dashed line mesh
  123156. * * 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
  123157. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123158. * * The parameter `points` is an array successive Vector3
  123159. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123160. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123161. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123162. * * 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
  123163. * * When updating an instance, remember that only point positions can change, not the number of points
  123164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123165. * @param name defines the name of the mesh
  123166. * @param options defines the options used to create the mesh
  123167. * @param scene defines the hosting scene
  123168. * @returns the dashed line mesh
  123169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123170. */
  123171. static CreateDashedLines(name: string, options: {
  123172. points: Vector3[];
  123173. dashSize?: number;
  123174. gapSize?: number;
  123175. dashNb?: number;
  123176. updatable?: boolean;
  123177. instance?: LinesMesh;
  123178. }, scene?: Nullable<Scene>): LinesMesh;
  123179. /**
  123180. * 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.
  123181. * * 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.
  123182. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123183. * * 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.
  123184. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123185. * * 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
  123186. * * 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
  123187. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123190. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123192. * @param name defines the name of the mesh
  123193. * @param options defines the options used to create the mesh
  123194. * @param scene defines the hosting scene
  123195. * @returns the extruded shape mesh
  123196. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123198. */
  123199. static ExtrudeShape(name: string, options: {
  123200. shape: Vector3[];
  123201. path: Vector3[];
  123202. scale?: number;
  123203. rotation?: number;
  123204. cap?: number;
  123205. updatable?: boolean;
  123206. sideOrientation?: number;
  123207. frontUVs?: Vector4;
  123208. backUVs?: Vector4;
  123209. instance?: Mesh;
  123210. invertUV?: boolean;
  123211. }, scene?: Nullable<Scene>): Mesh;
  123212. /**
  123213. * Creates an custom extruded shape mesh.
  123214. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123215. * * 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.
  123216. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123217. * * 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
  123218. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123219. * * 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
  123220. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123221. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123222. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123223. * * 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
  123224. * * 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
  123225. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123228. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123230. * @param name defines the name of the mesh
  123231. * @param options defines the options used to create the mesh
  123232. * @param scene defines the hosting scene
  123233. * @returns the custom extruded shape mesh
  123234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123235. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123236. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123237. */
  123238. static ExtrudeShapeCustom(name: string, options: {
  123239. shape: Vector3[];
  123240. path: Vector3[];
  123241. scaleFunction?: any;
  123242. rotationFunction?: any;
  123243. ribbonCloseArray?: boolean;
  123244. ribbonClosePath?: boolean;
  123245. cap?: number;
  123246. updatable?: boolean;
  123247. sideOrientation?: number;
  123248. frontUVs?: Vector4;
  123249. backUVs?: Vector4;
  123250. instance?: Mesh;
  123251. invertUV?: boolean;
  123252. }, scene?: Nullable<Scene>): Mesh;
  123253. /**
  123254. * Creates lathe mesh.
  123255. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123256. * * 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
  123257. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123258. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123259. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123260. * * 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
  123261. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123262. * * 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
  123263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123265. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123267. * @param name defines the name of the mesh
  123268. * @param options defines the options used to create the mesh
  123269. * @param scene defines the hosting scene
  123270. * @returns the lathe mesh
  123271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123272. */
  123273. static CreateLathe(name: string, options: {
  123274. shape: Vector3[];
  123275. radius?: number;
  123276. tessellation?: number;
  123277. clip?: number;
  123278. arc?: number;
  123279. closed?: boolean;
  123280. updatable?: boolean;
  123281. sideOrientation?: number;
  123282. frontUVs?: Vector4;
  123283. backUVs?: Vector4;
  123284. cap?: number;
  123285. invertUV?: boolean;
  123286. }, scene?: Nullable<Scene>): Mesh;
  123287. /**
  123288. * Creates a tiled plane mesh
  123289. * * You can set a limited pattern arrangement with the tiles
  123290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123293. * @param name defines the name of the mesh
  123294. * @param options defines the options used to create the mesh
  123295. * @param scene defines the hosting scene
  123296. * @returns the plane mesh
  123297. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123298. */
  123299. static CreateTiledPlane(name: string, options: {
  123300. pattern?: number;
  123301. tileSize?: number;
  123302. tileWidth?: number;
  123303. tileHeight?: number;
  123304. size?: number;
  123305. width?: number;
  123306. height?: number;
  123307. alignHorizontal?: number;
  123308. alignVertical?: number;
  123309. sideOrientation?: number;
  123310. frontUVs?: Vector4;
  123311. backUVs?: Vector4;
  123312. updatable?: boolean;
  123313. }, scene?: Nullable<Scene>): Mesh;
  123314. /**
  123315. * Creates a plane mesh
  123316. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123317. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123318. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123322. * @param name defines the name of the mesh
  123323. * @param options defines the options used to create the mesh
  123324. * @param scene defines the hosting scene
  123325. * @returns the plane mesh
  123326. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123327. */
  123328. static CreatePlane(name: string, options: {
  123329. size?: number;
  123330. width?: number;
  123331. height?: number;
  123332. sideOrientation?: number;
  123333. frontUVs?: Vector4;
  123334. backUVs?: Vector4;
  123335. updatable?: boolean;
  123336. sourcePlane?: Plane;
  123337. }, scene?: Nullable<Scene>): Mesh;
  123338. /**
  123339. * Creates a ground mesh
  123340. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123341. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123343. * @param name defines the name of the mesh
  123344. * @param options defines the options used to create the mesh
  123345. * @param scene defines the hosting scene
  123346. * @returns the ground mesh
  123347. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123348. */
  123349. static CreateGround(name: string, options: {
  123350. width?: number;
  123351. height?: number;
  123352. subdivisions?: number;
  123353. subdivisionsX?: number;
  123354. subdivisionsY?: number;
  123355. updatable?: boolean;
  123356. }, scene?: Nullable<Scene>): Mesh;
  123357. /**
  123358. * Creates a tiled ground mesh
  123359. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123360. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123361. * * 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
  123362. * * 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
  123363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123364. * @param name defines the name of the mesh
  123365. * @param options defines the options used to create the mesh
  123366. * @param scene defines the hosting scene
  123367. * @returns the tiled ground mesh
  123368. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123369. */
  123370. static CreateTiledGround(name: string, options: {
  123371. xmin: number;
  123372. zmin: number;
  123373. xmax: number;
  123374. zmax: number;
  123375. subdivisions?: {
  123376. w: number;
  123377. h: number;
  123378. };
  123379. precision?: {
  123380. w: number;
  123381. h: number;
  123382. };
  123383. updatable?: boolean;
  123384. }, scene?: Nullable<Scene>): Mesh;
  123385. /**
  123386. * Creates a ground mesh from a height map
  123387. * * The parameter `url` sets the URL of the height map image resource.
  123388. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123389. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123390. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123391. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123392. * * 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.
  123393. * * 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).
  123394. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123396. * @param name defines the name of the mesh
  123397. * @param url defines the url to the height map
  123398. * @param options defines the options used to create the mesh
  123399. * @param scene defines the hosting scene
  123400. * @returns the ground mesh
  123401. * @see https://doc.babylonjs.com/babylon101/height_map
  123402. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123403. */
  123404. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123405. width?: number;
  123406. height?: number;
  123407. subdivisions?: number;
  123408. minHeight?: number;
  123409. maxHeight?: number;
  123410. colorFilter?: Color3;
  123411. alphaFilter?: number;
  123412. updatable?: boolean;
  123413. onReady?: (mesh: GroundMesh) => void;
  123414. }, scene?: Nullable<Scene>): GroundMesh;
  123415. /**
  123416. * Creates a polygon mesh
  123417. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123418. * * 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
  123419. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123422. * * Remember you can only change the shape positions, not their number when updating a polygon
  123423. * @param name defines the name of the mesh
  123424. * @param options defines the options used to create the mesh
  123425. * @param scene defines the hosting scene
  123426. * @param earcutInjection can be used to inject your own earcut reference
  123427. * @returns the polygon mesh
  123428. */
  123429. static CreatePolygon(name: string, options: {
  123430. shape: Vector3[];
  123431. holes?: Vector3[][];
  123432. depth?: number;
  123433. faceUV?: Vector4[];
  123434. faceColors?: Color4[];
  123435. updatable?: boolean;
  123436. sideOrientation?: number;
  123437. frontUVs?: Vector4;
  123438. backUVs?: Vector4;
  123439. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123440. /**
  123441. * Creates an extruded polygon mesh, with depth in the Y direction.
  123442. * * 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)
  123443. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123444. * @param name defines the name of the mesh
  123445. * @param options defines the options used to create the mesh
  123446. * @param scene defines the hosting scene
  123447. * @param earcutInjection can be used to inject your own earcut reference
  123448. * @returns the polygon mesh
  123449. */
  123450. static ExtrudePolygon(name: string, options: {
  123451. shape: Vector3[];
  123452. holes?: Vector3[][];
  123453. depth?: number;
  123454. faceUV?: Vector4[];
  123455. faceColors?: Color4[];
  123456. updatable?: boolean;
  123457. sideOrientation?: number;
  123458. frontUVs?: Vector4;
  123459. backUVs?: Vector4;
  123460. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123461. /**
  123462. * Creates a tube mesh.
  123463. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123464. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123465. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123466. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123467. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123468. * * 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)
  123469. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123470. * * 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
  123471. * * 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
  123472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123476. * @param name defines the name of the mesh
  123477. * @param options defines the options used to create the mesh
  123478. * @param scene defines the hosting scene
  123479. * @returns the tube mesh
  123480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123481. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123482. */
  123483. static CreateTube(name: string, options: {
  123484. path: Vector3[];
  123485. radius?: number;
  123486. tessellation?: number;
  123487. radiusFunction?: {
  123488. (i: number, distance: number): number;
  123489. };
  123490. cap?: number;
  123491. arc?: number;
  123492. updatable?: boolean;
  123493. sideOrientation?: number;
  123494. frontUVs?: Vector4;
  123495. backUVs?: Vector4;
  123496. instance?: Mesh;
  123497. invertUV?: boolean;
  123498. }, scene?: Nullable<Scene>): Mesh;
  123499. /**
  123500. * Creates a polyhedron mesh
  123501. * * 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
  123502. * * The parameter `size` (positive float, default 1) sets the polygon size
  123503. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123504. * * 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`
  123505. * * 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
  123506. * * 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)`)
  123507. * * 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
  123508. * * 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
  123509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123512. * @param name defines the name of the mesh
  123513. * @param options defines the options used to create the mesh
  123514. * @param scene defines the hosting scene
  123515. * @returns the polyhedron mesh
  123516. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123517. */
  123518. static CreatePolyhedron(name: string, options: {
  123519. type?: number;
  123520. size?: number;
  123521. sizeX?: number;
  123522. sizeY?: number;
  123523. sizeZ?: number;
  123524. custom?: any;
  123525. faceUV?: Vector4[];
  123526. faceColors?: Color4[];
  123527. flat?: boolean;
  123528. updatable?: boolean;
  123529. sideOrientation?: number;
  123530. frontUVs?: Vector4;
  123531. backUVs?: Vector4;
  123532. }, scene?: Nullable<Scene>): Mesh;
  123533. /**
  123534. * Creates a decal mesh.
  123535. * 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
  123536. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123537. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123538. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123539. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123540. * @param name defines the name of the mesh
  123541. * @param sourceMesh defines the mesh where the decal must be applied
  123542. * @param options defines the options used to create the mesh
  123543. * @param scene defines the hosting scene
  123544. * @returns the decal mesh
  123545. * @see https://doc.babylonjs.com/how_to/decals
  123546. */
  123547. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123548. position?: Vector3;
  123549. normal?: Vector3;
  123550. size?: Vector3;
  123551. angle?: number;
  123552. }): Mesh;
  123553. }
  123554. }
  123555. declare module BABYLON {
  123556. /**
  123557. * A simplifier interface for future simplification implementations
  123558. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123559. */
  123560. export interface ISimplifier {
  123561. /**
  123562. * Simplification of a given mesh according to the given settings.
  123563. * Since this requires computation, it is assumed that the function runs async.
  123564. * @param settings The settings of the simplification, including quality and distance
  123565. * @param successCallback A callback that will be called after the mesh was simplified.
  123566. * @param errorCallback in case of an error, this callback will be called. optional.
  123567. */
  123568. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123569. }
  123570. /**
  123571. * Expected simplification settings.
  123572. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123573. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123574. */
  123575. export interface ISimplificationSettings {
  123576. /**
  123577. * Gets or sets the expected quality
  123578. */
  123579. quality: number;
  123580. /**
  123581. * Gets or sets the distance when this optimized version should be used
  123582. */
  123583. distance: number;
  123584. /**
  123585. * Gets an already optimized mesh
  123586. */
  123587. optimizeMesh?: boolean;
  123588. }
  123589. /**
  123590. * Class used to specify simplification options
  123591. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123592. */
  123593. export class SimplificationSettings implements ISimplificationSettings {
  123594. /** expected quality */
  123595. quality: number;
  123596. /** distance when this optimized version should be used */
  123597. distance: number;
  123598. /** already optimized mesh */
  123599. optimizeMesh?: boolean | undefined;
  123600. /**
  123601. * Creates a SimplificationSettings
  123602. * @param quality expected quality
  123603. * @param distance distance when this optimized version should be used
  123604. * @param optimizeMesh already optimized mesh
  123605. */
  123606. constructor(
  123607. /** expected quality */
  123608. quality: number,
  123609. /** distance when this optimized version should be used */
  123610. distance: number,
  123611. /** already optimized mesh */
  123612. optimizeMesh?: boolean | undefined);
  123613. }
  123614. /**
  123615. * Interface used to define a simplification task
  123616. */
  123617. export interface ISimplificationTask {
  123618. /**
  123619. * Array of settings
  123620. */
  123621. settings: Array<ISimplificationSettings>;
  123622. /**
  123623. * Simplification type
  123624. */
  123625. simplificationType: SimplificationType;
  123626. /**
  123627. * Mesh to simplify
  123628. */
  123629. mesh: Mesh;
  123630. /**
  123631. * Callback called on success
  123632. */
  123633. successCallback?: () => void;
  123634. /**
  123635. * Defines if parallel processing can be used
  123636. */
  123637. parallelProcessing: boolean;
  123638. }
  123639. /**
  123640. * Queue used to order the simplification tasks
  123641. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123642. */
  123643. export class SimplificationQueue {
  123644. private _simplificationArray;
  123645. /**
  123646. * Gets a boolean indicating that the process is still running
  123647. */
  123648. running: boolean;
  123649. /**
  123650. * Creates a new queue
  123651. */
  123652. constructor();
  123653. /**
  123654. * Adds a new simplification task
  123655. * @param task defines a task to add
  123656. */
  123657. addTask(task: ISimplificationTask): void;
  123658. /**
  123659. * Execute next task
  123660. */
  123661. executeNext(): void;
  123662. /**
  123663. * Execute a simplification task
  123664. * @param task defines the task to run
  123665. */
  123666. runSimplification(task: ISimplificationTask): void;
  123667. private getSimplifier;
  123668. }
  123669. /**
  123670. * The implemented types of simplification
  123671. * At the moment only Quadratic Error Decimation is implemented
  123672. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123673. */
  123674. export enum SimplificationType {
  123675. /** Quadratic error decimation */
  123676. QUADRATIC = 0
  123677. }
  123678. }
  123679. declare module BABYLON {
  123680. interface Scene {
  123681. /** @hidden (Backing field) */
  123682. _simplificationQueue: SimplificationQueue;
  123683. /**
  123684. * Gets or sets the simplification queue attached to the scene
  123685. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123686. */
  123687. simplificationQueue: SimplificationQueue;
  123688. }
  123689. interface Mesh {
  123690. /**
  123691. * Simplify the mesh according to the given array of settings.
  123692. * Function will return immediately and will simplify async
  123693. * @param settings a collection of simplification settings
  123694. * @param parallelProcessing should all levels calculate parallel or one after the other
  123695. * @param simplificationType the type of simplification to run
  123696. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  123697. * @returns the current mesh
  123698. */
  123699. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  123700. }
  123701. /**
  123702. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  123703. * created in a scene
  123704. */
  123705. export class SimplicationQueueSceneComponent implements ISceneComponent {
  123706. /**
  123707. * The component name helpfull to identify the component in the list of scene components.
  123708. */
  123709. readonly name: string;
  123710. /**
  123711. * The scene the component belongs to.
  123712. */
  123713. scene: Scene;
  123714. /**
  123715. * Creates a new instance of the component for the given scene
  123716. * @param scene Defines the scene to register the component in
  123717. */
  123718. constructor(scene: Scene);
  123719. /**
  123720. * Registers the component in a given scene
  123721. */
  123722. register(): void;
  123723. /**
  123724. * Rebuilds the elements related to this component in case of
  123725. * context lost for instance.
  123726. */
  123727. rebuild(): void;
  123728. /**
  123729. * Disposes the component and the associated ressources
  123730. */
  123731. dispose(): void;
  123732. private _beforeCameraUpdate;
  123733. }
  123734. }
  123735. declare module BABYLON {
  123736. /**
  123737. * Navigation plugin interface to add navigation constrained by a navigation mesh
  123738. */
  123739. export interface INavigationEnginePlugin {
  123740. /**
  123741. * plugin name
  123742. */
  123743. name: string;
  123744. /**
  123745. * Creates a navigation mesh
  123746. * @param meshes array of all the geometry used to compute the navigatio mesh
  123747. * @param parameters bunch of parameters used to filter geometry
  123748. */
  123749. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123750. /**
  123751. * Create a navigation mesh debug mesh
  123752. * @param scene is where the mesh will be added
  123753. * @returns debug display mesh
  123754. */
  123755. createDebugNavMesh(scene: Scene): Mesh;
  123756. /**
  123757. * Get a navigation mesh constrained position, closest to the parameter position
  123758. * @param position world position
  123759. * @returns the closest point to position constrained by the navigation mesh
  123760. */
  123761. getClosestPoint(position: Vector3): Vector3;
  123762. /**
  123763. * Get a navigation mesh constrained position, within a particular radius
  123764. * @param position world position
  123765. * @param maxRadius the maximum distance to the constrained world position
  123766. * @returns the closest point to position constrained by the navigation mesh
  123767. */
  123768. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123769. /**
  123770. * Compute the final position from a segment made of destination-position
  123771. * @param position world position
  123772. * @param destination world position
  123773. * @returns the resulting point along the navmesh
  123774. */
  123775. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123776. /**
  123777. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123778. * @param start world position
  123779. * @param end world position
  123780. * @returns array containing world position composing the path
  123781. */
  123782. computePath(start: Vector3, end: Vector3): Vector3[];
  123783. /**
  123784. * If this plugin is supported
  123785. * @returns true if plugin is supported
  123786. */
  123787. isSupported(): boolean;
  123788. /**
  123789. * Create a new Crowd so you can add agents
  123790. * @param maxAgents the maximum agent count in the crowd
  123791. * @param maxAgentRadius the maximum radius an agent can have
  123792. * @param scene to attach the crowd to
  123793. * @returns the crowd you can add agents to
  123794. */
  123795. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  123796. /**
  123797. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123798. * The queries will try to find a solution within those bounds
  123799. * default is (1,1,1)
  123800. * @param extent x,y,z value that define the extent around the queries point of reference
  123801. */
  123802. setDefaultQueryExtent(extent: Vector3): void;
  123803. /**
  123804. * Get the Bounding box extent specified by setDefaultQueryExtent
  123805. * @returns the box extent values
  123806. */
  123807. getDefaultQueryExtent(): Vector3;
  123808. /**
  123809. * Release all resources
  123810. */
  123811. dispose(): void;
  123812. }
  123813. /**
  123814. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  123815. */
  123816. export interface ICrowd {
  123817. /**
  123818. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  123819. * You can attach anything to that node. The node position is updated in the scene update tick.
  123820. * @param pos world position that will be constrained by the navigation mesh
  123821. * @param parameters agent parameters
  123822. * @param transform hooked to the agent that will be update by the scene
  123823. * @returns agent index
  123824. */
  123825. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  123826. /**
  123827. * Returns the agent position in world space
  123828. * @param index agent index returned by addAgent
  123829. * @returns world space position
  123830. */
  123831. getAgentPosition(index: number): Vector3;
  123832. /**
  123833. * Gets the agent velocity in world space
  123834. * @param index agent index returned by addAgent
  123835. * @returns world space velocity
  123836. */
  123837. getAgentVelocity(index: number): Vector3;
  123838. /**
  123839. * remove a particular agent previously created
  123840. * @param index agent index returned by addAgent
  123841. */
  123842. removeAgent(index: number): void;
  123843. /**
  123844. * get the list of all agents attached to this crowd
  123845. * @returns list of agent indices
  123846. */
  123847. getAgents(): number[];
  123848. /**
  123849. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123850. * @param deltaTime in seconds
  123851. */
  123852. update(deltaTime: number): void;
  123853. /**
  123854. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  123855. * @param index agent index returned by addAgent
  123856. * @param destination targeted world position
  123857. */
  123858. agentGoto(index: number, destination: Vector3): void;
  123859. /**
  123860. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123861. * The queries will try to find a solution within those bounds
  123862. * default is (1,1,1)
  123863. * @param extent x,y,z value that define the extent around the queries point of reference
  123864. */
  123865. setDefaultQueryExtent(extent: Vector3): void;
  123866. /**
  123867. * Get the Bounding box extent specified by setDefaultQueryExtent
  123868. * @returns the box extent values
  123869. */
  123870. getDefaultQueryExtent(): Vector3;
  123871. /**
  123872. * Release all resources
  123873. */
  123874. dispose(): void;
  123875. }
  123876. /**
  123877. * Configures an agent
  123878. */
  123879. export interface IAgentParameters {
  123880. /**
  123881. * Agent radius. [Limit: >= 0]
  123882. */
  123883. radius: number;
  123884. /**
  123885. * Agent height. [Limit: > 0]
  123886. */
  123887. height: number;
  123888. /**
  123889. * Maximum allowed acceleration. [Limit: >= 0]
  123890. */
  123891. maxAcceleration: number;
  123892. /**
  123893. * Maximum allowed speed. [Limit: >= 0]
  123894. */
  123895. maxSpeed: number;
  123896. /**
  123897. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  123898. */
  123899. collisionQueryRange: number;
  123900. /**
  123901. * The path visibility optimization range. [Limit: > 0]
  123902. */
  123903. pathOptimizationRange: number;
  123904. /**
  123905. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  123906. */
  123907. separationWeight: number;
  123908. }
  123909. /**
  123910. * Configures the navigation mesh creation
  123911. */
  123912. export interface INavMeshParameters {
  123913. /**
  123914. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  123915. */
  123916. cs: number;
  123917. /**
  123918. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  123919. */
  123920. ch: number;
  123921. /**
  123922. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  123923. */
  123924. walkableSlopeAngle: number;
  123925. /**
  123926. * Minimum floor to 'ceiling' height that will still allow the floor area to
  123927. * be considered walkable. [Limit: >= 3] [Units: vx]
  123928. */
  123929. walkableHeight: number;
  123930. /**
  123931. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  123932. */
  123933. walkableClimb: number;
  123934. /**
  123935. * The distance to erode/shrink the walkable area of the heightfield away from
  123936. * obstructions. [Limit: >=0] [Units: vx]
  123937. */
  123938. walkableRadius: number;
  123939. /**
  123940. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  123941. */
  123942. maxEdgeLen: number;
  123943. /**
  123944. * The maximum distance a simplfied contour's border edges should deviate
  123945. * the original raw contour. [Limit: >=0] [Units: vx]
  123946. */
  123947. maxSimplificationError: number;
  123948. /**
  123949. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  123950. */
  123951. minRegionArea: number;
  123952. /**
  123953. * Any regions with a span count smaller than this value will, if possible,
  123954. * be merged with larger regions. [Limit: >=0] [Units: vx]
  123955. */
  123956. mergeRegionArea: number;
  123957. /**
  123958. * The maximum number of vertices allowed for polygons generated during the
  123959. * contour to polygon conversion process. [Limit: >= 3]
  123960. */
  123961. maxVertsPerPoly: number;
  123962. /**
  123963. * Sets the sampling distance to use when generating the detail mesh.
  123964. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  123965. */
  123966. detailSampleDist: number;
  123967. /**
  123968. * The maximum distance the detail mesh surface should deviate from heightfield
  123969. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  123970. */
  123971. detailSampleMaxError: number;
  123972. }
  123973. }
  123974. declare module BABYLON {
  123975. /**
  123976. * RecastJS navigation plugin
  123977. */
  123978. export class RecastJSPlugin implements INavigationEnginePlugin {
  123979. /**
  123980. * Reference to the Recast library
  123981. */
  123982. bjsRECAST: any;
  123983. /**
  123984. * plugin name
  123985. */
  123986. name: string;
  123987. /**
  123988. * the first navmesh created. We might extend this to support multiple navmeshes
  123989. */
  123990. navMesh: any;
  123991. /**
  123992. * Initializes the recastJS plugin
  123993. * @param recastInjection can be used to inject your own recast reference
  123994. */
  123995. constructor(recastInjection?: any);
  123996. /**
  123997. * Creates a navigation mesh
  123998. * @param meshes array of all the geometry used to compute the navigatio mesh
  123999. * @param parameters bunch of parameters used to filter geometry
  124000. */
  124001. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124002. /**
  124003. * Create a navigation mesh debug mesh
  124004. * @param scene is where the mesh will be added
  124005. * @returns debug display mesh
  124006. */
  124007. createDebugNavMesh(scene: Scene): Mesh;
  124008. /**
  124009. * Get a navigation mesh constrained position, closest to the parameter position
  124010. * @param position world position
  124011. * @returns the closest point to position constrained by the navigation mesh
  124012. */
  124013. getClosestPoint(position: Vector3): Vector3;
  124014. /**
  124015. * Get a navigation mesh constrained position, within a particular radius
  124016. * @param position world position
  124017. * @param maxRadius the maximum distance to the constrained world position
  124018. * @returns the closest point to position constrained by the navigation mesh
  124019. */
  124020. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124021. /**
  124022. * Compute the final position from a segment made of destination-position
  124023. * @param position world position
  124024. * @param destination world position
  124025. * @returns the resulting point along the navmesh
  124026. */
  124027. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124028. /**
  124029. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124030. * @param start world position
  124031. * @param end world position
  124032. * @returns array containing world position composing the path
  124033. */
  124034. computePath(start: Vector3, end: Vector3): Vector3[];
  124035. /**
  124036. * Create a new Crowd so you can add agents
  124037. * @param maxAgents the maximum agent count in the crowd
  124038. * @param maxAgentRadius the maximum radius an agent can have
  124039. * @param scene to attach the crowd to
  124040. * @returns the crowd you can add agents to
  124041. */
  124042. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124043. /**
  124044. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124045. * The queries will try to find a solution within those bounds
  124046. * default is (1,1,1)
  124047. * @param extent x,y,z value that define the extent around the queries point of reference
  124048. */
  124049. setDefaultQueryExtent(extent: Vector3): void;
  124050. /**
  124051. * Get the Bounding box extent specified by setDefaultQueryExtent
  124052. * @returns the box extent values
  124053. */
  124054. getDefaultQueryExtent(): Vector3;
  124055. /**
  124056. * Disposes
  124057. */
  124058. dispose(): void;
  124059. /**
  124060. * If this plugin is supported
  124061. * @returns true if plugin is supported
  124062. */
  124063. isSupported(): boolean;
  124064. }
  124065. /**
  124066. * Recast detour crowd implementation
  124067. */
  124068. export class RecastJSCrowd implements ICrowd {
  124069. /**
  124070. * Recast/detour plugin
  124071. */
  124072. bjsRECASTPlugin: RecastJSPlugin;
  124073. /**
  124074. * Link to the detour crowd
  124075. */
  124076. recastCrowd: any;
  124077. /**
  124078. * One transform per agent
  124079. */
  124080. transforms: TransformNode[];
  124081. /**
  124082. * All agents created
  124083. */
  124084. agents: number[];
  124085. /**
  124086. * Link to the scene is kept to unregister the crowd from the scene
  124087. */
  124088. private _scene;
  124089. /**
  124090. * Observer for crowd updates
  124091. */
  124092. private _onBeforeAnimationsObserver;
  124093. /**
  124094. * Constructor
  124095. * @param plugin recastJS plugin
  124096. * @param maxAgents the maximum agent count in the crowd
  124097. * @param maxAgentRadius the maximum radius an agent can have
  124098. * @param scene to attach the crowd to
  124099. * @returns the crowd you can add agents to
  124100. */
  124101. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124102. /**
  124103. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124104. * You can attach anything to that node. The node position is updated in the scene update tick.
  124105. * @param pos world position that will be constrained by the navigation mesh
  124106. * @param parameters agent parameters
  124107. * @param transform hooked to the agent that will be update by the scene
  124108. * @returns agent index
  124109. */
  124110. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124111. /**
  124112. * Returns the agent position in world space
  124113. * @param index agent index returned by addAgent
  124114. * @returns world space position
  124115. */
  124116. getAgentPosition(index: number): Vector3;
  124117. /**
  124118. * Returns the agent velocity in world space
  124119. * @param index agent index returned by addAgent
  124120. * @returns world space velocity
  124121. */
  124122. getAgentVelocity(index: number): Vector3;
  124123. /**
  124124. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124125. * @param index agent index returned by addAgent
  124126. * @param destination targeted world position
  124127. */
  124128. agentGoto(index: number, destination: Vector3): void;
  124129. /**
  124130. * remove a particular agent previously created
  124131. * @param index agent index returned by addAgent
  124132. */
  124133. removeAgent(index: number): void;
  124134. /**
  124135. * get the list of all agents attached to this crowd
  124136. * @returns list of agent indices
  124137. */
  124138. getAgents(): number[];
  124139. /**
  124140. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124141. * @param deltaTime in seconds
  124142. */
  124143. update(deltaTime: number): void;
  124144. /**
  124145. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124146. * The queries will try to find a solution within those bounds
  124147. * default is (1,1,1)
  124148. * @param extent x,y,z value that define the extent around the queries point of reference
  124149. */
  124150. setDefaultQueryExtent(extent: Vector3): void;
  124151. /**
  124152. * Get the Bounding box extent specified by setDefaultQueryExtent
  124153. * @returns the box extent values
  124154. */
  124155. getDefaultQueryExtent(): Vector3;
  124156. /**
  124157. * Release all resources
  124158. */
  124159. dispose(): void;
  124160. }
  124161. }
  124162. declare module BABYLON {
  124163. /**
  124164. * Class used to enable access to IndexedDB
  124165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124166. */
  124167. export class Database implements IOfflineProvider {
  124168. private _callbackManifestChecked;
  124169. private _currentSceneUrl;
  124170. private _db;
  124171. private _enableSceneOffline;
  124172. private _enableTexturesOffline;
  124173. private _manifestVersionFound;
  124174. private _mustUpdateRessources;
  124175. private _hasReachedQuota;
  124176. private _isSupported;
  124177. private _idbFactory;
  124178. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124179. private static IsUASupportingBlobStorage;
  124180. /**
  124181. * Gets a boolean indicating if Database storate is enabled (off by default)
  124182. */
  124183. static IDBStorageEnabled: boolean;
  124184. /**
  124185. * Gets a boolean indicating if scene must be saved in the database
  124186. */
  124187. readonly enableSceneOffline: boolean;
  124188. /**
  124189. * Gets a boolean indicating if textures must be saved in the database
  124190. */
  124191. readonly enableTexturesOffline: boolean;
  124192. /**
  124193. * Creates a new Database
  124194. * @param urlToScene defines the url to load the scene
  124195. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124196. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124197. */
  124198. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124199. private static _ParseURL;
  124200. private static _ReturnFullUrlLocation;
  124201. private _checkManifestFile;
  124202. /**
  124203. * Open the database and make it available
  124204. * @param successCallback defines the callback to call on success
  124205. * @param errorCallback defines the callback to call on error
  124206. */
  124207. open(successCallback: () => void, errorCallback: () => void): void;
  124208. /**
  124209. * Loads an image from the database
  124210. * @param url defines the url to load from
  124211. * @param image defines the target DOM image
  124212. */
  124213. loadImage(url: string, image: HTMLImageElement): void;
  124214. private _loadImageFromDBAsync;
  124215. private _saveImageIntoDBAsync;
  124216. private _checkVersionFromDB;
  124217. private _loadVersionFromDBAsync;
  124218. private _saveVersionIntoDBAsync;
  124219. /**
  124220. * Loads a file from database
  124221. * @param url defines the URL to load from
  124222. * @param sceneLoaded defines a callback to call on success
  124223. * @param progressCallBack defines a callback to call when progress changed
  124224. * @param errorCallback defines a callback to call on error
  124225. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124226. */
  124227. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124228. private _loadFileAsync;
  124229. private _saveFileAsync;
  124230. /**
  124231. * Validates if xhr data is correct
  124232. * @param xhr defines the request to validate
  124233. * @param dataType defines the expected data type
  124234. * @returns true if data is correct
  124235. */
  124236. private static _ValidateXHRData;
  124237. }
  124238. }
  124239. declare module BABYLON {
  124240. /** @hidden */
  124241. export var gpuUpdateParticlesPixelShader: {
  124242. name: string;
  124243. shader: string;
  124244. };
  124245. }
  124246. declare module BABYLON {
  124247. /** @hidden */
  124248. export var gpuUpdateParticlesVertexShader: {
  124249. name: string;
  124250. shader: string;
  124251. };
  124252. }
  124253. declare module BABYLON {
  124254. /** @hidden */
  124255. export var clipPlaneFragmentDeclaration2: {
  124256. name: string;
  124257. shader: string;
  124258. };
  124259. }
  124260. declare module BABYLON {
  124261. /** @hidden */
  124262. export var gpuRenderParticlesPixelShader: {
  124263. name: string;
  124264. shader: string;
  124265. };
  124266. }
  124267. declare module BABYLON {
  124268. /** @hidden */
  124269. export var clipPlaneVertexDeclaration2: {
  124270. name: string;
  124271. shader: string;
  124272. };
  124273. }
  124274. declare module BABYLON {
  124275. /** @hidden */
  124276. export var gpuRenderParticlesVertexShader: {
  124277. name: string;
  124278. shader: string;
  124279. };
  124280. }
  124281. declare module BABYLON {
  124282. /**
  124283. * This represents a GPU particle system in Babylon
  124284. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124285. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124286. */
  124287. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124288. /**
  124289. * The layer mask we are rendering the particles through.
  124290. */
  124291. layerMask: number;
  124292. private _capacity;
  124293. private _activeCount;
  124294. private _currentActiveCount;
  124295. private _accumulatedCount;
  124296. private _renderEffect;
  124297. private _updateEffect;
  124298. private _buffer0;
  124299. private _buffer1;
  124300. private _spriteBuffer;
  124301. private _updateVAO;
  124302. private _renderVAO;
  124303. private _targetIndex;
  124304. private _sourceBuffer;
  124305. private _targetBuffer;
  124306. private _engine;
  124307. private _currentRenderId;
  124308. private _started;
  124309. private _stopped;
  124310. private _timeDelta;
  124311. private _randomTexture;
  124312. private _randomTexture2;
  124313. private _attributesStrideSize;
  124314. private _updateEffectOptions;
  124315. private _randomTextureSize;
  124316. private _actualFrame;
  124317. private readonly _rawTextureWidth;
  124318. /**
  124319. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124320. */
  124321. static readonly IsSupported: boolean;
  124322. /**
  124323. * An event triggered when the system is disposed.
  124324. */
  124325. onDisposeObservable: Observable<GPUParticleSystem>;
  124326. /**
  124327. * Gets the maximum number of particles active at the same time.
  124328. * @returns The max number of active particles.
  124329. */
  124330. getCapacity(): number;
  124331. /**
  124332. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124333. * to override the particles.
  124334. */
  124335. forceDepthWrite: boolean;
  124336. /**
  124337. * Gets or set the number of active particles
  124338. */
  124339. activeParticleCount: number;
  124340. private _preWarmDone;
  124341. /**
  124342. * Is this system ready to be used/rendered
  124343. * @return true if the system is ready
  124344. */
  124345. isReady(): boolean;
  124346. /**
  124347. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124348. * @returns True if it has been started, otherwise false.
  124349. */
  124350. isStarted(): boolean;
  124351. /**
  124352. * Starts the particle system and begins to emit
  124353. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124354. */
  124355. start(delay?: number): void;
  124356. /**
  124357. * Stops the particle system.
  124358. */
  124359. stop(): void;
  124360. /**
  124361. * Remove all active particles
  124362. */
  124363. reset(): void;
  124364. /**
  124365. * Returns the string "GPUParticleSystem"
  124366. * @returns a string containing the class name
  124367. */
  124368. getClassName(): string;
  124369. private _colorGradientsTexture;
  124370. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124371. /**
  124372. * Adds a new color gradient
  124373. * @param gradient defines the gradient to use (between 0 and 1)
  124374. * @param color1 defines the color to affect to the specified gradient
  124375. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124376. * @returns the current particle system
  124377. */
  124378. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124379. /**
  124380. * Remove a specific color gradient
  124381. * @param gradient defines the gradient to remove
  124382. * @returns the current particle system
  124383. */
  124384. removeColorGradient(gradient: number): GPUParticleSystem;
  124385. private _angularSpeedGradientsTexture;
  124386. private _sizeGradientsTexture;
  124387. private _velocityGradientsTexture;
  124388. private _limitVelocityGradientsTexture;
  124389. private _dragGradientsTexture;
  124390. private _addFactorGradient;
  124391. /**
  124392. * Adds a new size gradient
  124393. * @param gradient defines the gradient to use (between 0 and 1)
  124394. * @param factor defines the size factor to affect to the specified gradient
  124395. * @returns the current particle system
  124396. */
  124397. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124398. /**
  124399. * Remove a specific size gradient
  124400. * @param gradient defines the gradient to remove
  124401. * @returns the current particle system
  124402. */
  124403. removeSizeGradient(gradient: number): GPUParticleSystem;
  124404. /**
  124405. * Adds a new angular speed gradient
  124406. * @param gradient defines the gradient to use (between 0 and 1)
  124407. * @param factor defines the angular speed to affect to the specified gradient
  124408. * @returns the current particle system
  124409. */
  124410. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124411. /**
  124412. * Remove a specific angular speed gradient
  124413. * @param gradient defines the gradient to remove
  124414. * @returns the current particle system
  124415. */
  124416. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124417. /**
  124418. * Adds a new velocity gradient
  124419. * @param gradient defines the gradient to use (between 0 and 1)
  124420. * @param factor defines the velocity to affect to the specified gradient
  124421. * @returns the current particle system
  124422. */
  124423. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124424. /**
  124425. * Remove a specific velocity gradient
  124426. * @param gradient defines the gradient to remove
  124427. * @returns the current particle system
  124428. */
  124429. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124430. /**
  124431. * Adds a new limit velocity gradient
  124432. * @param gradient defines the gradient to use (between 0 and 1)
  124433. * @param factor defines the limit velocity value to affect to the specified gradient
  124434. * @returns the current particle system
  124435. */
  124436. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124437. /**
  124438. * Remove a specific limit velocity gradient
  124439. * @param gradient defines the gradient to remove
  124440. * @returns the current particle system
  124441. */
  124442. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124443. /**
  124444. * Adds a new drag gradient
  124445. * @param gradient defines the gradient to use (between 0 and 1)
  124446. * @param factor defines the drag value to affect to the specified gradient
  124447. * @returns the current particle system
  124448. */
  124449. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124450. /**
  124451. * Remove a specific drag gradient
  124452. * @param gradient defines the gradient to remove
  124453. * @returns the current particle system
  124454. */
  124455. removeDragGradient(gradient: number): GPUParticleSystem;
  124456. /**
  124457. * Not supported by GPUParticleSystem
  124458. * @param gradient defines the gradient to use (between 0 and 1)
  124459. * @param factor defines the emit rate value to affect to the specified gradient
  124460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124461. * @returns the current particle system
  124462. */
  124463. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124464. /**
  124465. * Not supported by GPUParticleSystem
  124466. * @param gradient defines the gradient to remove
  124467. * @returns the current particle system
  124468. */
  124469. removeEmitRateGradient(gradient: number): IParticleSystem;
  124470. /**
  124471. * Not supported by GPUParticleSystem
  124472. * @param gradient defines the gradient to use (between 0 and 1)
  124473. * @param factor defines the start size value to affect to the specified gradient
  124474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124475. * @returns the current particle system
  124476. */
  124477. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124478. /**
  124479. * Not supported by GPUParticleSystem
  124480. * @param gradient defines the gradient to remove
  124481. * @returns the current particle system
  124482. */
  124483. removeStartSizeGradient(gradient: number): IParticleSystem;
  124484. /**
  124485. * Not supported by GPUParticleSystem
  124486. * @param gradient defines the gradient to use (between 0 and 1)
  124487. * @param min defines the color remap minimal range
  124488. * @param max defines the color remap maximal range
  124489. * @returns the current particle system
  124490. */
  124491. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124492. /**
  124493. * Not supported by GPUParticleSystem
  124494. * @param gradient defines the gradient to remove
  124495. * @returns the current particle system
  124496. */
  124497. removeColorRemapGradient(): IParticleSystem;
  124498. /**
  124499. * Not supported by GPUParticleSystem
  124500. * @param gradient defines the gradient to use (between 0 and 1)
  124501. * @param min defines the alpha remap minimal range
  124502. * @param max defines the alpha remap maximal range
  124503. * @returns the current particle system
  124504. */
  124505. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124506. /**
  124507. * Not supported by GPUParticleSystem
  124508. * @param gradient defines the gradient to remove
  124509. * @returns the current particle system
  124510. */
  124511. removeAlphaRemapGradient(): IParticleSystem;
  124512. /**
  124513. * Not supported by GPUParticleSystem
  124514. * @param gradient defines the gradient to use (between 0 and 1)
  124515. * @param color defines the color to affect to the specified gradient
  124516. * @returns the current particle system
  124517. */
  124518. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124519. /**
  124520. * Not supported by GPUParticleSystem
  124521. * @param gradient defines the gradient to remove
  124522. * @returns the current particle system
  124523. */
  124524. removeRampGradient(): IParticleSystem;
  124525. /**
  124526. * Not supported by GPUParticleSystem
  124527. * @returns the list of ramp gradients
  124528. */
  124529. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124530. /**
  124531. * Not supported by GPUParticleSystem
  124532. * Gets or sets a boolean indicating that ramp gradients must be used
  124533. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124534. */
  124535. useRampGradients: boolean;
  124536. /**
  124537. * Not supported by GPUParticleSystem
  124538. * @param gradient defines the gradient to use (between 0 and 1)
  124539. * @param factor defines the life time factor to affect to the specified gradient
  124540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124541. * @returns the current particle system
  124542. */
  124543. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124544. /**
  124545. * Not supported by GPUParticleSystem
  124546. * @param gradient defines the gradient to remove
  124547. * @returns the current particle system
  124548. */
  124549. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124550. /**
  124551. * Instantiates a GPU particle system.
  124552. * 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.
  124553. * @param name The name of the particle system
  124554. * @param options The options used to create the system
  124555. * @param scene The scene the particle system belongs to
  124556. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124557. */
  124558. constructor(name: string, options: Partial<{
  124559. capacity: number;
  124560. randomTextureSize: number;
  124561. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124562. protected _reset(): void;
  124563. private _createUpdateVAO;
  124564. private _createRenderVAO;
  124565. private _initialize;
  124566. /** @hidden */
  124567. _recreateUpdateEffect(): void;
  124568. /** @hidden */
  124569. _recreateRenderEffect(): void;
  124570. /**
  124571. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124572. * @param preWarm defines if we are in the pre-warmimg phase
  124573. */
  124574. animate(preWarm?: boolean): void;
  124575. private _createFactorGradientTexture;
  124576. private _createSizeGradientTexture;
  124577. private _createAngularSpeedGradientTexture;
  124578. private _createVelocityGradientTexture;
  124579. private _createLimitVelocityGradientTexture;
  124580. private _createDragGradientTexture;
  124581. private _createColorGradientTexture;
  124582. /**
  124583. * Renders the particle system in its current state
  124584. * @param preWarm defines if the system should only update the particles but not render them
  124585. * @returns the current number of particles
  124586. */
  124587. render(preWarm?: boolean): number;
  124588. /**
  124589. * Rebuilds the particle system
  124590. */
  124591. rebuild(): void;
  124592. private _releaseBuffers;
  124593. private _releaseVAOs;
  124594. /**
  124595. * Disposes the particle system and free the associated resources
  124596. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124597. */
  124598. dispose(disposeTexture?: boolean): void;
  124599. /**
  124600. * Clones the particle system.
  124601. * @param name The name of the cloned object
  124602. * @param newEmitter The new emitter to use
  124603. * @returns the cloned particle system
  124604. */
  124605. clone(name: string, newEmitter: any): GPUParticleSystem;
  124606. /**
  124607. * Serializes the particle system to a JSON object.
  124608. * @returns the JSON object
  124609. */
  124610. serialize(): any;
  124611. /**
  124612. * Parses a JSON object to create a GPU particle system.
  124613. * @param parsedParticleSystem The JSON object to parse
  124614. * @param scene The scene to create the particle system in
  124615. * @param rootUrl The root url to use to load external dependencies like texture
  124616. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124617. * @returns the parsed GPU particle system
  124618. */
  124619. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124620. }
  124621. }
  124622. declare module BABYLON {
  124623. /**
  124624. * Represents a set of particle systems working together to create a specific effect
  124625. */
  124626. export class ParticleSystemSet implements IDisposable {
  124627. private _emitterCreationOptions;
  124628. private _emitterNode;
  124629. /**
  124630. * Gets the particle system list
  124631. */
  124632. systems: IParticleSystem[];
  124633. /**
  124634. * Gets the emitter node used with this set
  124635. */
  124636. readonly emitterNode: Nullable<TransformNode>;
  124637. /**
  124638. * Creates a new emitter mesh as a sphere
  124639. * @param options defines the options used to create the sphere
  124640. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124641. * @param scene defines the hosting scene
  124642. */
  124643. setEmitterAsSphere(options: {
  124644. diameter: number;
  124645. segments: number;
  124646. color: Color3;
  124647. }, renderingGroupId: number, scene: Scene): void;
  124648. /**
  124649. * Starts all particle systems of the set
  124650. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124651. */
  124652. start(emitter?: AbstractMesh): void;
  124653. /**
  124654. * Release all associated resources
  124655. */
  124656. dispose(): void;
  124657. /**
  124658. * Serialize the set into a JSON compatible object
  124659. * @returns a JSON compatible representation of the set
  124660. */
  124661. serialize(): any;
  124662. /**
  124663. * Parse a new ParticleSystemSet from a serialized source
  124664. * @param data defines a JSON compatible representation of the set
  124665. * @param scene defines the hosting scene
  124666. * @param gpu defines if we want GPU particles or CPU particles
  124667. * @returns a new ParticleSystemSet
  124668. */
  124669. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124670. }
  124671. }
  124672. declare module BABYLON {
  124673. /**
  124674. * This class is made for on one-liner static method to help creating particle system set.
  124675. */
  124676. export class ParticleHelper {
  124677. /**
  124678. * Gets or sets base Assets URL
  124679. */
  124680. static BaseAssetsUrl: string;
  124681. /**
  124682. * Create a default particle system that you can tweak
  124683. * @param emitter defines the emitter to use
  124684. * @param capacity defines the system capacity (default is 500 particles)
  124685. * @param scene defines the hosting scene
  124686. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  124687. * @returns the new Particle system
  124688. */
  124689. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  124690. /**
  124691. * This is the main static method (one-liner) of this helper to create different particle systems
  124692. * @param type This string represents the type to the particle system to create
  124693. * @param scene The scene where the particle system should live
  124694. * @param gpu If the system will use gpu
  124695. * @returns the ParticleSystemSet created
  124696. */
  124697. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  124698. /**
  124699. * Static function used to export a particle system to a ParticleSystemSet variable.
  124700. * Please note that the emitter shape is not exported
  124701. * @param systems defines the particle systems to export
  124702. * @returns the created particle system set
  124703. */
  124704. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  124705. }
  124706. }
  124707. declare module BABYLON {
  124708. interface Engine {
  124709. /**
  124710. * Create an effect to use with particle systems.
  124711. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  124712. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  124713. * @param uniformsNames defines a list of attribute names
  124714. * @param samplers defines an array of string used to represent textures
  124715. * @param defines defines the string containing the defines to use to compile the shaders
  124716. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  124717. * @param onCompiled defines a function to call when the effect creation is successful
  124718. * @param onError defines a function to call when the effect creation has failed
  124719. * @returns the new Effect
  124720. */
  124721. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  124722. }
  124723. interface Mesh {
  124724. /**
  124725. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  124726. * @returns an array of IParticleSystem
  124727. */
  124728. getEmittedParticleSystems(): IParticleSystem[];
  124729. /**
  124730. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  124731. * @returns an array of IParticleSystem
  124732. */
  124733. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  124734. }
  124735. /**
  124736. * @hidden
  124737. */
  124738. export var _IDoNeedToBeInTheBuild: number;
  124739. }
  124740. declare module BABYLON {
  124741. interface Scene {
  124742. /** @hidden (Backing field) */
  124743. _physicsEngine: Nullable<IPhysicsEngine>;
  124744. /**
  124745. * Gets the current physics engine
  124746. * @returns a IPhysicsEngine or null if none attached
  124747. */
  124748. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  124749. /**
  124750. * Enables physics to the current scene
  124751. * @param gravity defines the scene's gravity for the physics engine
  124752. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  124753. * @return a boolean indicating if the physics engine was initialized
  124754. */
  124755. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  124756. /**
  124757. * Disables and disposes the physics engine associated with the scene
  124758. */
  124759. disablePhysicsEngine(): void;
  124760. /**
  124761. * Gets a boolean indicating if there is an active physics engine
  124762. * @returns a boolean indicating if there is an active physics engine
  124763. */
  124764. isPhysicsEnabled(): boolean;
  124765. /**
  124766. * Deletes a physics compound impostor
  124767. * @param compound defines the compound to delete
  124768. */
  124769. deleteCompoundImpostor(compound: any): void;
  124770. /**
  124771. * An event triggered when physic simulation is about to be run
  124772. */
  124773. onBeforePhysicsObservable: Observable<Scene>;
  124774. /**
  124775. * An event triggered when physic simulation has been done
  124776. */
  124777. onAfterPhysicsObservable: Observable<Scene>;
  124778. }
  124779. interface AbstractMesh {
  124780. /** @hidden */
  124781. _physicsImpostor: Nullable<PhysicsImpostor>;
  124782. /**
  124783. * Gets or sets impostor used for physic simulation
  124784. * @see http://doc.babylonjs.com/features/physics_engine
  124785. */
  124786. physicsImpostor: Nullable<PhysicsImpostor>;
  124787. /**
  124788. * Gets the current physics impostor
  124789. * @see http://doc.babylonjs.com/features/physics_engine
  124790. * @returns a physics impostor or null
  124791. */
  124792. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  124793. /** Apply a physic impulse to the mesh
  124794. * @param force defines the force to apply
  124795. * @param contactPoint defines where to apply the force
  124796. * @returns the current mesh
  124797. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  124798. */
  124799. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  124800. /**
  124801. * Creates a physic joint between two meshes
  124802. * @param otherMesh defines the other mesh to use
  124803. * @param pivot1 defines the pivot to use on this mesh
  124804. * @param pivot2 defines the pivot to use on the other mesh
  124805. * @param options defines additional options (can be plugin dependent)
  124806. * @returns the current mesh
  124807. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  124808. */
  124809. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  124810. /** @hidden */
  124811. _disposePhysicsObserver: Nullable<Observer<Node>>;
  124812. }
  124813. /**
  124814. * Defines the physics engine scene component responsible to manage a physics engine
  124815. */
  124816. export class PhysicsEngineSceneComponent implements ISceneComponent {
  124817. /**
  124818. * The component name helpful to identify the component in the list of scene components.
  124819. */
  124820. readonly name: string;
  124821. /**
  124822. * The scene the component belongs to.
  124823. */
  124824. scene: Scene;
  124825. /**
  124826. * Creates a new instance of the component for the given scene
  124827. * @param scene Defines the scene to register the component in
  124828. */
  124829. constructor(scene: Scene);
  124830. /**
  124831. * Registers the component in a given scene
  124832. */
  124833. register(): void;
  124834. /**
  124835. * Rebuilds the elements related to this component in case of
  124836. * context lost for instance.
  124837. */
  124838. rebuild(): void;
  124839. /**
  124840. * Disposes the component and the associated ressources
  124841. */
  124842. dispose(): void;
  124843. }
  124844. }
  124845. declare module BABYLON {
  124846. /**
  124847. * A helper for physics simulations
  124848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124849. */
  124850. export class PhysicsHelper {
  124851. private _scene;
  124852. private _physicsEngine;
  124853. /**
  124854. * Initializes the Physics helper
  124855. * @param scene Babylon.js scene
  124856. */
  124857. constructor(scene: Scene);
  124858. /**
  124859. * Applies a radial explosion impulse
  124860. * @param origin the origin of the explosion
  124861. * @param radiusOrEventOptions the radius or the options of radial explosion
  124862. * @param strength the explosion strength
  124863. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124864. * @returns A physics radial explosion event, or null
  124865. */
  124866. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  124867. /**
  124868. * Applies a radial explosion force
  124869. * @param origin the origin of the explosion
  124870. * @param radiusOrEventOptions the radius or the options of radial explosion
  124871. * @param strength the explosion strength
  124872. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124873. * @returns A physics radial explosion event, or null
  124874. */
  124875. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  124876. /**
  124877. * Creates a gravitational field
  124878. * @param origin the origin of the explosion
  124879. * @param radiusOrEventOptions the radius or the options of radial explosion
  124880. * @param strength the explosion strength
  124881. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124882. * @returns A physics gravitational field event, or null
  124883. */
  124884. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  124885. /**
  124886. * Creates a physics updraft event
  124887. * @param origin the origin of the updraft
  124888. * @param radiusOrEventOptions the radius or the options of the updraft
  124889. * @param strength the strength of the updraft
  124890. * @param height the height of the updraft
  124891. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  124892. * @returns A physics updraft event, or null
  124893. */
  124894. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  124895. /**
  124896. * Creates a physics vortex event
  124897. * @param origin the of the vortex
  124898. * @param radiusOrEventOptions the radius or the options of the vortex
  124899. * @param strength the strength of the vortex
  124900. * @param height the height of the vortex
  124901. * @returns a Physics vortex event, or null
  124902. * A physics vortex event or null
  124903. */
  124904. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  124905. }
  124906. /**
  124907. * Represents a physics radial explosion event
  124908. */
  124909. class PhysicsRadialExplosionEvent {
  124910. private _scene;
  124911. private _options;
  124912. private _sphere;
  124913. private _dataFetched;
  124914. /**
  124915. * Initializes a radial explosioin event
  124916. * @param _scene BabylonJS scene
  124917. * @param _options The options for the vortex event
  124918. */
  124919. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  124920. /**
  124921. * Returns the data related to the radial explosion event (sphere).
  124922. * @returns The radial explosion event data
  124923. */
  124924. getData(): PhysicsRadialExplosionEventData;
  124925. /**
  124926. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  124927. * @param impostor A physics imposter
  124928. * @param origin the origin of the explosion
  124929. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  124930. */
  124931. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  124932. /**
  124933. * Triggers affecterd impostors callbacks
  124934. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  124935. */
  124936. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  124937. /**
  124938. * Disposes the sphere.
  124939. * @param force Specifies if the sphere should be disposed by force
  124940. */
  124941. dispose(force?: boolean): void;
  124942. /*** Helpers ***/
  124943. private _prepareSphere;
  124944. private _intersectsWithSphere;
  124945. }
  124946. /**
  124947. * Represents a gravitational field event
  124948. */
  124949. class PhysicsGravitationalFieldEvent {
  124950. private _physicsHelper;
  124951. private _scene;
  124952. private _origin;
  124953. private _options;
  124954. private _tickCallback;
  124955. private _sphere;
  124956. private _dataFetched;
  124957. /**
  124958. * Initializes the physics gravitational field event
  124959. * @param _physicsHelper A physics helper
  124960. * @param _scene BabylonJS scene
  124961. * @param _origin The origin position of the gravitational field event
  124962. * @param _options The options for the vortex event
  124963. */
  124964. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  124965. /**
  124966. * Returns the data related to the gravitational field event (sphere).
  124967. * @returns A gravitational field event
  124968. */
  124969. getData(): PhysicsGravitationalFieldEventData;
  124970. /**
  124971. * Enables the gravitational field.
  124972. */
  124973. enable(): void;
  124974. /**
  124975. * Disables the gravitational field.
  124976. */
  124977. disable(): void;
  124978. /**
  124979. * Disposes the sphere.
  124980. * @param force The force to dispose from the gravitational field event
  124981. */
  124982. dispose(force?: boolean): void;
  124983. private _tick;
  124984. }
  124985. /**
  124986. * Represents a physics updraft event
  124987. */
  124988. class PhysicsUpdraftEvent {
  124989. private _scene;
  124990. private _origin;
  124991. private _options;
  124992. private _physicsEngine;
  124993. private _originTop;
  124994. private _originDirection;
  124995. private _tickCallback;
  124996. private _cylinder;
  124997. private _cylinderPosition;
  124998. private _dataFetched;
  124999. /**
  125000. * Initializes the physics updraft event
  125001. * @param _scene BabylonJS scene
  125002. * @param _origin The origin position of the updraft
  125003. * @param _options The options for the updraft event
  125004. */
  125005. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125006. /**
  125007. * Returns the data related to the updraft event (cylinder).
  125008. * @returns A physics updraft event
  125009. */
  125010. getData(): PhysicsUpdraftEventData;
  125011. /**
  125012. * Enables the updraft.
  125013. */
  125014. enable(): void;
  125015. /**
  125016. * Disables the updraft.
  125017. */
  125018. disable(): void;
  125019. /**
  125020. * Disposes the cylinder.
  125021. * @param force Specifies if the updraft should be disposed by force
  125022. */
  125023. dispose(force?: boolean): void;
  125024. private getImpostorHitData;
  125025. private _tick;
  125026. /*** Helpers ***/
  125027. private _prepareCylinder;
  125028. private _intersectsWithCylinder;
  125029. }
  125030. /**
  125031. * Represents a physics vortex event
  125032. */
  125033. class PhysicsVortexEvent {
  125034. private _scene;
  125035. private _origin;
  125036. private _options;
  125037. private _physicsEngine;
  125038. private _originTop;
  125039. private _tickCallback;
  125040. private _cylinder;
  125041. private _cylinderPosition;
  125042. private _dataFetched;
  125043. /**
  125044. * Initializes the physics vortex event
  125045. * @param _scene The BabylonJS scene
  125046. * @param _origin The origin position of the vortex
  125047. * @param _options The options for the vortex event
  125048. */
  125049. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125050. /**
  125051. * Returns the data related to the vortex event (cylinder).
  125052. * @returns The physics vortex event data
  125053. */
  125054. getData(): PhysicsVortexEventData;
  125055. /**
  125056. * Enables the vortex.
  125057. */
  125058. enable(): void;
  125059. /**
  125060. * Disables the cortex.
  125061. */
  125062. disable(): void;
  125063. /**
  125064. * Disposes the sphere.
  125065. * @param force
  125066. */
  125067. dispose(force?: boolean): void;
  125068. private getImpostorHitData;
  125069. private _tick;
  125070. /*** Helpers ***/
  125071. private _prepareCylinder;
  125072. private _intersectsWithCylinder;
  125073. }
  125074. /**
  125075. * Options fot the radial explosion event
  125076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125077. */
  125078. export class PhysicsRadialExplosionEventOptions {
  125079. /**
  125080. * The radius of the sphere for the radial explosion.
  125081. */
  125082. radius: number;
  125083. /**
  125084. * The strenth of the explosion.
  125085. */
  125086. strength: number;
  125087. /**
  125088. * The strenght of the force in correspondence to the distance of the affected object
  125089. */
  125090. falloff: PhysicsRadialImpulseFalloff;
  125091. /**
  125092. * Sphere options for the radial explosion.
  125093. */
  125094. sphere: {
  125095. segments: number;
  125096. diameter: number;
  125097. };
  125098. /**
  125099. * Sphere options for the radial explosion.
  125100. */
  125101. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125102. }
  125103. /**
  125104. * Options fot the updraft event
  125105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125106. */
  125107. export class PhysicsUpdraftEventOptions {
  125108. /**
  125109. * The radius of the cylinder for the vortex
  125110. */
  125111. radius: number;
  125112. /**
  125113. * The strenth of the updraft.
  125114. */
  125115. strength: number;
  125116. /**
  125117. * The height of the cylinder for the updraft.
  125118. */
  125119. height: number;
  125120. /**
  125121. * The mode for the the updraft.
  125122. */
  125123. updraftMode: PhysicsUpdraftMode;
  125124. }
  125125. /**
  125126. * Options fot the vortex event
  125127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125128. */
  125129. export class PhysicsVortexEventOptions {
  125130. /**
  125131. * The radius of the cylinder for the vortex
  125132. */
  125133. radius: number;
  125134. /**
  125135. * The strenth of the vortex.
  125136. */
  125137. strength: number;
  125138. /**
  125139. * The height of the cylinder for the vortex.
  125140. */
  125141. height: number;
  125142. /**
  125143. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125144. */
  125145. centripetalForceThreshold: number;
  125146. /**
  125147. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125148. */
  125149. centripetalForceMultiplier: number;
  125150. /**
  125151. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125152. */
  125153. centrifugalForceMultiplier: number;
  125154. /**
  125155. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125156. */
  125157. updraftForceMultiplier: number;
  125158. }
  125159. /**
  125160. * The strenght of the force in correspondence to the distance of the affected object
  125161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125162. */
  125163. export enum PhysicsRadialImpulseFalloff {
  125164. /** Defines that impulse is constant in strength across it's whole radius */
  125165. Constant = 0,
  125166. /** Defines that impulse gets weaker if it's further from the origin */
  125167. Linear = 1
  125168. }
  125169. /**
  125170. * The strength of the force in correspondence to the distance of the affected object
  125171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125172. */
  125173. export enum PhysicsUpdraftMode {
  125174. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125175. Center = 0,
  125176. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125177. Perpendicular = 1
  125178. }
  125179. /**
  125180. * Interface for a physics hit data
  125181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125182. */
  125183. export interface PhysicsHitData {
  125184. /**
  125185. * The force applied at the contact point
  125186. */
  125187. force: Vector3;
  125188. /**
  125189. * The contact point
  125190. */
  125191. contactPoint: Vector3;
  125192. /**
  125193. * The distance from the origin to the contact point
  125194. */
  125195. distanceFromOrigin: number;
  125196. }
  125197. /**
  125198. * Interface for radial explosion event data
  125199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125200. */
  125201. export interface PhysicsRadialExplosionEventData {
  125202. /**
  125203. * A sphere used for the radial explosion event
  125204. */
  125205. sphere: Mesh;
  125206. }
  125207. /**
  125208. * Interface for gravitational field event data
  125209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125210. */
  125211. export interface PhysicsGravitationalFieldEventData {
  125212. /**
  125213. * A sphere mesh used for the gravitational field event
  125214. */
  125215. sphere: Mesh;
  125216. }
  125217. /**
  125218. * Interface for updraft event data
  125219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125220. */
  125221. export interface PhysicsUpdraftEventData {
  125222. /**
  125223. * A cylinder used for the updraft event
  125224. */
  125225. cylinder: Mesh;
  125226. }
  125227. /**
  125228. * Interface for vortex event data
  125229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125230. */
  125231. export interface PhysicsVortexEventData {
  125232. /**
  125233. * A cylinder used for the vortex event
  125234. */
  125235. cylinder: Mesh;
  125236. }
  125237. /**
  125238. * Interface for an affected physics impostor
  125239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125240. */
  125241. export interface PhysicsAffectedImpostorWithData {
  125242. /**
  125243. * The impostor affected by the effect
  125244. */
  125245. impostor: PhysicsImpostor;
  125246. /**
  125247. * The data about the hit/horce from the explosion
  125248. */
  125249. hitData: PhysicsHitData;
  125250. }
  125251. }
  125252. declare module BABYLON {
  125253. /** @hidden */
  125254. export var blackAndWhitePixelShader: {
  125255. name: string;
  125256. shader: string;
  125257. };
  125258. }
  125259. declare module BABYLON {
  125260. /**
  125261. * Post process used to render in black and white
  125262. */
  125263. export class BlackAndWhitePostProcess extends PostProcess {
  125264. /**
  125265. * Linear about to convert he result to black and white (default: 1)
  125266. */
  125267. degree: number;
  125268. /**
  125269. * Creates a black and white post process
  125270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125271. * @param name The name of the effect.
  125272. * @param options The required width/height ratio to downsize to before computing the render pass.
  125273. * @param camera The camera to apply the render pass to.
  125274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125275. * @param engine The engine which the post process will be applied. (default: current engine)
  125276. * @param reusable If the post process can be reused on the same frame. (default: false)
  125277. */
  125278. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125279. }
  125280. }
  125281. declare module BABYLON {
  125282. /**
  125283. * This represents a set of one or more post processes in Babylon.
  125284. * A post process can be used to apply a shader to a texture after it is rendered.
  125285. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125286. */
  125287. export class PostProcessRenderEffect {
  125288. private _postProcesses;
  125289. private _getPostProcesses;
  125290. private _singleInstance;
  125291. private _cameras;
  125292. private _indicesForCamera;
  125293. /**
  125294. * Name of the effect
  125295. * @hidden
  125296. */
  125297. _name: string;
  125298. /**
  125299. * Instantiates a post process render effect.
  125300. * A post process can be used to apply a shader to a texture after it is rendered.
  125301. * @param engine The engine the effect is tied to
  125302. * @param name The name of the effect
  125303. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125304. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125305. */
  125306. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125307. /**
  125308. * Checks if all the post processes in the effect are supported.
  125309. */
  125310. readonly isSupported: boolean;
  125311. /**
  125312. * Updates the current state of the effect
  125313. * @hidden
  125314. */
  125315. _update(): void;
  125316. /**
  125317. * Attaches the effect on cameras
  125318. * @param cameras The camera to attach to.
  125319. * @hidden
  125320. */
  125321. _attachCameras(cameras: Camera): void;
  125322. /**
  125323. * Attaches the effect on cameras
  125324. * @param cameras The camera to attach to.
  125325. * @hidden
  125326. */
  125327. _attachCameras(cameras: Camera[]): void;
  125328. /**
  125329. * Detaches the effect on cameras
  125330. * @param cameras The camera to detatch from.
  125331. * @hidden
  125332. */
  125333. _detachCameras(cameras: Camera): void;
  125334. /**
  125335. * Detatches the effect on cameras
  125336. * @param cameras The camera to detatch from.
  125337. * @hidden
  125338. */
  125339. _detachCameras(cameras: Camera[]): void;
  125340. /**
  125341. * Enables the effect on given cameras
  125342. * @param cameras The camera to enable.
  125343. * @hidden
  125344. */
  125345. _enable(cameras: Camera): void;
  125346. /**
  125347. * Enables the effect on given cameras
  125348. * @param cameras The camera to enable.
  125349. * @hidden
  125350. */
  125351. _enable(cameras: Nullable<Camera[]>): void;
  125352. /**
  125353. * Disables the effect on the given cameras
  125354. * @param cameras The camera to disable.
  125355. * @hidden
  125356. */
  125357. _disable(cameras: Camera): void;
  125358. /**
  125359. * Disables the effect on the given cameras
  125360. * @param cameras The camera to disable.
  125361. * @hidden
  125362. */
  125363. _disable(cameras: Nullable<Camera[]>): void;
  125364. /**
  125365. * Gets a list of the post processes contained in the effect.
  125366. * @param camera The camera to get the post processes on.
  125367. * @returns The list of the post processes in the effect.
  125368. */
  125369. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125370. }
  125371. }
  125372. declare module BABYLON {
  125373. /** @hidden */
  125374. export var extractHighlightsPixelShader: {
  125375. name: string;
  125376. shader: string;
  125377. };
  125378. }
  125379. declare module BABYLON {
  125380. /**
  125381. * 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.
  125382. */
  125383. export class ExtractHighlightsPostProcess extends PostProcess {
  125384. /**
  125385. * The luminance threshold, pixels below this value will be set to black.
  125386. */
  125387. threshold: number;
  125388. /** @hidden */
  125389. _exposure: number;
  125390. /**
  125391. * Post process which has the input texture to be used when performing highlight extraction
  125392. * @hidden
  125393. */
  125394. _inputPostProcess: Nullable<PostProcess>;
  125395. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125396. }
  125397. }
  125398. declare module BABYLON {
  125399. /** @hidden */
  125400. export var bloomMergePixelShader: {
  125401. name: string;
  125402. shader: string;
  125403. };
  125404. }
  125405. declare module BABYLON {
  125406. /**
  125407. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125408. */
  125409. export class BloomMergePostProcess extends PostProcess {
  125410. /** Weight of the bloom to be added to the original input. */
  125411. weight: number;
  125412. /**
  125413. * Creates a new instance of @see BloomMergePostProcess
  125414. * @param name The name of the effect.
  125415. * @param originalFromInput Post process which's input will be used for the merge.
  125416. * @param blurred Blurred highlights post process which's output will be used.
  125417. * @param weight Weight of the bloom to be added to the original input.
  125418. * @param options The required width/height ratio to downsize to before computing the render pass.
  125419. * @param camera The camera to apply the render pass to.
  125420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125421. * @param engine The engine which the post process will be applied. (default: current engine)
  125422. * @param reusable If the post process can be reused on the same frame. (default: false)
  125423. * @param textureType Type of textures used when performing the post process. (default: 0)
  125424. * @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)
  125425. */
  125426. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125427. /** Weight of the bloom to be added to the original input. */
  125428. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125429. }
  125430. }
  125431. declare module BABYLON {
  125432. /**
  125433. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125434. */
  125435. export class BloomEffect extends PostProcessRenderEffect {
  125436. private bloomScale;
  125437. /**
  125438. * @hidden Internal
  125439. */
  125440. _effects: Array<PostProcess>;
  125441. /**
  125442. * @hidden Internal
  125443. */
  125444. _downscale: ExtractHighlightsPostProcess;
  125445. private _blurX;
  125446. private _blurY;
  125447. private _merge;
  125448. /**
  125449. * The luminance threshold to find bright areas of the image to bloom.
  125450. */
  125451. threshold: number;
  125452. /**
  125453. * The strength of the bloom.
  125454. */
  125455. weight: number;
  125456. /**
  125457. * Specifies the size of the bloom blur kernel, relative to the final output size
  125458. */
  125459. kernel: number;
  125460. /**
  125461. * Creates a new instance of @see BloomEffect
  125462. * @param scene The scene the effect belongs to.
  125463. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125464. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125465. * @param bloomWeight The the strength of bloom.
  125466. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125467. * @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)
  125468. */
  125469. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125470. /**
  125471. * Disposes each of the internal effects for a given camera.
  125472. * @param camera The camera to dispose the effect on.
  125473. */
  125474. disposeEffects(camera: Camera): void;
  125475. /**
  125476. * @hidden Internal
  125477. */
  125478. _updateEffects(): void;
  125479. /**
  125480. * Internal
  125481. * @returns if all the contained post processes are ready.
  125482. * @hidden
  125483. */
  125484. _isReady(): boolean;
  125485. }
  125486. }
  125487. declare module BABYLON {
  125488. /** @hidden */
  125489. export var chromaticAberrationPixelShader: {
  125490. name: string;
  125491. shader: string;
  125492. };
  125493. }
  125494. declare module BABYLON {
  125495. /**
  125496. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125497. */
  125498. export class ChromaticAberrationPostProcess extends PostProcess {
  125499. /**
  125500. * The amount of seperation of rgb channels (default: 30)
  125501. */
  125502. aberrationAmount: number;
  125503. /**
  125504. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125505. */
  125506. radialIntensity: number;
  125507. /**
  125508. * 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))
  125509. */
  125510. direction: Vector2;
  125511. /**
  125512. * 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))
  125513. */
  125514. centerPosition: Vector2;
  125515. /**
  125516. * Creates a new instance ChromaticAberrationPostProcess
  125517. * @param name The name of the effect.
  125518. * @param screenWidth The width of the screen to apply the effect on.
  125519. * @param screenHeight The height of the screen to apply the effect on.
  125520. * @param options The required width/height ratio to downsize to before computing the render pass.
  125521. * @param camera The camera to apply the render pass to.
  125522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125523. * @param engine The engine which the post process will be applied. (default: current engine)
  125524. * @param reusable If the post process can be reused on the same frame. (default: false)
  125525. * @param textureType Type of textures used when performing the post process. (default: 0)
  125526. * @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)
  125527. */
  125528. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125529. }
  125530. }
  125531. declare module BABYLON {
  125532. /** @hidden */
  125533. export var circleOfConfusionPixelShader: {
  125534. name: string;
  125535. shader: string;
  125536. };
  125537. }
  125538. declare module BABYLON {
  125539. /**
  125540. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125541. */
  125542. export class CircleOfConfusionPostProcess extends PostProcess {
  125543. /**
  125544. * 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.
  125545. */
  125546. lensSize: number;
  125547. /**
  125548. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125549. */
  125550. fStop: number;
  125551. /**
  125552. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125553. */
  125554. focusDistance: number;
  125555. /**
  125556. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125557. */
  125558. focalLength: number;
  125559. private _depthTexture;
  125560. /**
  125561. * Creates a new instance CircleOfConfusionPostProcess
  125562. * @param name The name of the effect.
  125563. * @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.
  125564. * @param options The required width/height ratio to downsize to before computing the render pass.
  125565. * @param camera The camera to apply the render pass to.
  125566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125567. * @param engine The engine which the post process will be applied. (default: current engine)
  125568. * @param reusable If the post process can be reused on the same frame. (default: false)
  125569. * @param textureType Type of textures used when performing the post process. (default: 0)
  125570. * @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)
  125571. */
  125572. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125573. /**
  125574. * 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.
  125575. */
  125576. depthTexture: RenderTargetTexture;
  125577. }
  125578. }
  125579. declare module BABYLON {
  125580. /** @hidden */
  125581. export var colorCorrectionPixelShader: {
  125582. name: string;
  125583. shader: string;
  125584. };
  125585. }
  125586. declare module BABYLON {
  125587. /**
  125588. *
  125589. * This post-process allows the modification of rendered colors by using
  125590. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125591. *
  125592. * The object needs to be provided an url to a texture containing the color
  125593. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125594. * Use an image editing software to tweak the LUT to match your needs.
  125595. *
  125596. * For an example of a color LUT, see here:
  125597. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125598. * For explanations on color grading, see here:
  125599. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125600. *
  125601. */
  125602. export class ColorCorrectionPostProcess extends PostProcess {
  125603. private _colorTableTexture;
  125604. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125605. }
  125606. }
  125607. declare module BABYLON {
  125608. /** @hidden */
  125609. export var convolutionPixelShader: {
  125610. name: string;
  125611. shader: string;
  125612. };
  125613. }
  125614. declare module BABYLON {
  125615. /**
  125616. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125617. * input texture to perform effects such as edge detection or sharpening
  125618. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125619. */
  125620. export class ConvolutionPostProcess extends PostProcess {
  125621. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125622. kernel: number[];
  125623. /**
  125624. * Creates a new instance ConvolutionPostProcess
  125625. * @param name The name of the effect.
  125626. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125627. * @param options The required width/height ratio to downsize to before computing the render pass.
  125628. * @param camera The camera to apply the render pass to.
  125629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125630. * @param engine The engine which the post process will be applied. (default: current engine)
  125631. * @param reusable If the post process can be reused on the same frame. (default: false)
  125632. * @param textureType Type of textures used when performing the post process. (default: 0)
  125633. */
  125634. constructor(name: string,
  125635. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125636. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125637. /**
  125638. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125639. */
  125640. static EdgeDetect0Kernel: number[];
  125641. /**
  125642. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125643. */
  125644. static EdgeDetect1Kernel: number[];
  125645. /**
  125646. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125647. */
  125648. static EdgeDetect2Kernel: number[];
  125649. /**
  125650. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125651. */
  125652. static SharpenKernel: number[];
  125653. /**
  125654. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125655. */
  125656. static EmbossKernel: number[];
  125657. /**
  125658. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125659. */
  125660. static GaussianKernel: number[];
  125661. }
  125662. }
  125663. declare module BABYLON {
  125664. /**
  125665. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125666. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125667. * based on samples that have a large difference in distance than the center pixel.
  125668. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125669. */
  125670. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125671. direction: Vector2;
  125672. /**
  125673. * Creates a new instance CircleOfConfusionPostProcess
  125674. * @param name The name of the effect.
  125675. * @param scene The scene the effect belongs to.
  125676. * @param direction The direction the blur should be applied.
  125677. * @param kernel The size of the kernel used to blur.
  125678. * @param options The required width/height ratio to downsize to before computing the render pass.
  125679. * @param camera The camera to apply the render pass to.
  125680. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125681. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125683. * @param engine The engine which the post process will be applied. (default: current engine)
  125684. * @param reusable If the post process can be reused on the same frame. (default: false)
  125685. * @param textureType Type of textures used when performing the post process. (default: 0)
  125686. * @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)
  125687. */
  125688. 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);
  125689. }
  125690. }
  125691. declare module BABYLON {
  125692. /** @hidden */
  125693. export var depthOfFieldMergePixelShader: {
  125694. name: string;
  125695. shader: string;
  125696. };
  125697. }
  125698. declare module BABYLON {
  125699. /**
  125700. * Options to be set when merging outputs from the default pipeline.
  125701. */
  125702. export class DepthOfFieldMergePostProcessOptions {
  125703. /**
  125704. * The original image to merge on top of
  125705. */
  125706. originalFromInput: PostProcess;
  125707. /**
  125708. * Parameters to perform the merge of the depth of field effect
  125709. */
  125710. depthOfField?: {
  125711. circleOfConfusion: PostProcess;
  125712. blurSteps: Array<PostProcess>;
  125713. };
  125714. /**
  125715. * Parameters to perform the merge of bloom effect
  125716. */
  125717. bloom?: {
  125718. blurred: PostProcess;
  125719. weight: number;
  125720. };
  125721. }
  125722. /**
  125723. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125724. */
  125725. export class DepthOfFieldMergePostProcess extends PostProcess {
  125726. private blurSteps;
  125727. /**
  125728. * Creates a new instance of DepthOfFieldMergePostProcess
  125729. * @param name The name of the effect.
  125730. * @param originalFromInput Post process which's input will be used for the merge.
  125731. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  125732. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  125733. * @param options The required width/height ratio to downsize to before computing the render pass.
  125734. * @param camera The camera to apply the render pass to.
  125735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125736. * @param engine The engine which the post process will be applied. (default: current engine)
  125737. * @param reusable If the post process can be reused on the same frame. (default: false)
  125738. * @param textureType Type of textures used when performing the post process. (default: 0)
  125739. * @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)
  125740. */
  125741. 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);
  125742. /**
  125743. * Updates the effect with the current post process compile time values and recompiles the shader.
  125744. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  125745. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  125746. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  125747. * @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
  125748. * @param onCompiled Called when the shader has been compiled.
  125749. * @param onError Called if there is an error when compiling a shader.
  125750. */
  125751. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  125752. }
  125753. }
  125754. declare module BABYLON {
  125755. /**
  125756. * Specifies the level of max blur that should be applied when using the depth of field effect
  125757. */
  125758. export enum DepthOfFieldEffectBlurLevel {
  125759. /**
  125760. * Subtle blur
  125761. */
  125762. Low = 0,
  125763. /**
  125764. * Medium blur
  125765. */
  125766. Medium = 1,
  125767. /**
  125768. * Large blur
  125769. */
  125770. High = 2
  125771. }
  125772. /**
  125773. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  125774. */
  125775. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  125776. private _circleOfConfusion;
  125777. /**
  125778. * @hidden Internal, blurs from high to low
  125779. */
  125780. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  125781. private _depthOfFieldBlurY;
  125782. private _dofMerge;
  125783. /**
  125784. * @hidden Internal post processes in depth of field effect
  125785. */
  125786. _effects: Array<PostProcess>;
  125787. /**
  125788. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  125789. */
  125790. focalLength: number;
  125791. /**
  125792. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125793. */
  125794. fStop: number;
  125795. /**
  125796. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125797. */
  125798. focusDistance: number;
  125799. /**
  125800. * 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.
  125801. */
  125802. lensSize: number;
  125803. /**
  125804. * Creates a new instance DepthOfFieldEffect
  125805. * @param scene The scene the effect belongs to.
  125806. * @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.
  125807. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125808. * @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)
  125809. */
  125810. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  125811. /**
  125812. * Get the current class name of the current effet
  125813. * @returns "DepthOfFieldEffect"
  125814. */
  125815. getClassName(): string;
  125816. /**
  125817. * 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.
  125818. */
  125819. depthTexture: RenderTargetTexture;
  125820. /**
  125821. * Disposes each of the internal effects for a given camera.
  125822. * @param camera The camera to dispose the effect on.
  125823. */
  125824. disposeEffects(camera: Camera): void;
  125825. /**
  125826. * @hidden Internal
  125827. */
  125828. _updateEffects(): void;
  125829. /**
  125830. * Internal
  125831. * @returns if all the contained post processes are ready.
  125832. * @hidden
  125833. */
  125834. _isReady(): boolean;
  125835. }
  125836. }
  125837. declare module BABYLON {
  125838. /** @hidden */
  125839. export var displayPassPixelShader: {
  125840. name: string;
  125841. shader: string;
  125842. };
  125843. }
  125844. declare module BABYLON {
  125845. /**
  125846. * DisplayPassPostProcess which produces an output the same as it's input
  125847. */
  125848. export class DisplayPassPostProcess extends PostProcess {
  125849. /**
  125850. * Creates the DisplayPassPostProcess
  125851. * @param name The name of the effect.
  125852. * @param options The required width/height ratio to downsize to before computing the render pass.
  125853. * @param camera The camera to apply the render pass to.
  125854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125855. * @param engine The engine which the post process will be applied. (default: current engine)
  125856. * @param reusable If the post process can be reused on the same frame. (default: false)
  125857. */
  125858. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125859. }
  125860. }
  125861. declare module BABYLON {
  125862. /** @hidden */
  125863. export var filterPixelShader: {
  125864. name: string;
  125865. shader: string;
  125866. };
  125867. }
  125868. declare module BABYLON {
  125869. /**
  125870. * Applies a kernel filter to the image
  125871. */
  125872. export class FilterPostProcess extends PostProcess {
  125873. /** The matrix to be applied to the image */
  125874. kernelMatrix: Matrix;
  125875. /**
  125876. *
  125877. * @param name The name of the effect.
  125878. * @param kernelMatrix The matrix to be applied to the image
  125879. * @param options The required width/height ratio to downsize to before computing the render pass.
  125880. * @param camera The camera to apply the render pass to.
  125881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125882. * @param engine The engine which the post process will be applied. (default: current engine)
  125883. * @param reusable If the post process can be reused on the same frame. (default: false)
  125884. */
  125885. constructor(name: string,
  125886. /** The matrix to be applied to the image */
  125887. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125888. }
  125889. }
  125890. declare module BABYLON {
  125891. /** @hidden */
  125892. export var fxaaPixelShader: {
  125893. name: string;
  125894. shader: string;
  125895. };
  125896. }
  125897. declare module BABYLON {
  125898. /** @hidden */
  125899. export var fxaaVertexShader: {
  125900. name: string;
  125901. shader: string;
  125902. };
  125903. }
  125904. declare module BABYLON {
  125905. /**
  125906. * Fxaa post process
  125907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  125908. */
  125909. export class FxaaPostProcess extends PostProcess {
  125910. /** @hidden */
  125911. texelWidth: number;
  125912. /** @hidden */
  125913. texelHeight: number;
  125914. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125915. private _getDefines;
  125916. }
  125917. }
  125918. declare module BABYLON {
  125919. /** @hidden */
  125920. export var grainPixelShader: {
  125921. name: string;
  125922. shader: string;
  125923. };
  125924. }
  125925. declare module BABYLON {
  125926. /**
  125927. * The GrainPostProcess adds noise to the image at mid luminance levels
  125928. */
  125929. export class GrainPostProcess extends PostProcess {
  125930. /**
  125931. * The intensity of the grain added (default: 30)
  125932. */
  125933. intensity: number;
  125934. /**
  125935. * If the grain should be randomized on every frame
  125936. */
  125937. animated: boolean;
  125938. /**
  125939. * Creates a new instance of @see GrainPostProcess
  125940. * @param name The name of the effect.
  125941. * @param options The required width/height ratio to downsize to before computing the render pass.
  125942. * @param camera The camera to apply the render pass to.
  125943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125944. * @param engine The engine which the post process will be applied. (default: current engine)
  125945. * @param reusable If the post process can be reused on the same frame. (default: false)
  125946. * @param textureType Type of textures used when performing the post process. (default: 0)
  125947. * @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)
  125948. */
  125949. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125950. }
  125951. }
  125952. declare module BABYLON {
  125953. /** @hidden */
  125954. export var highlightsPixelShader: {
  125955. name: string;
  125956. shader: string;
  125957. };
  125958. }
  125959. declare module BABYLON {
  125960. /**
  125961. * Extracts highlights from the image
  125962. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125963. */
  125964. export class HighlightsPostProcess extends PostProcess {
  125965. /**
  125966. * Extracts highlights from the image
  125967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125968. * @param name The name of the effect.
  125969. * @param options The required width/height ratio to downsize to before computing the render pass.
  125970. * @param camera The camera to apply the render pass to.
  125971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125972. * @param engine The engine which the post process will be applied. (default: current engine)
  125973. * @param reusable If the post process can be reused on the same frame. (default: false)
  125974. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  125975. */
  125976. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125977. }
  125978. }
  125979. declare module BABYLON {
  125980. /** @hidden */
  125981. export var mrtFragmentDeclaration: {
  125982. name: string;
  125983. shader: string;
  125984. };
  125985. }
  125986. declare module BABYLON {
  125987. /** @hidden */
  125988. export var geometryPixelShader: {
  125989. name: string;
  125990. shader: string;
  125991. };
  125992. }
  125993. declare module BABYLON {
  125994. /** @hidden */
  125995. export var geometryVertexShader: {
  125996. name: string;
  125997. shader: string;
  125998. };
  125999. }
  126000. declare module BABYLON {
  126001. /** @hidden */
  126002. interface ISavedTransformationMatrix {
  126003. world: Matrix;
  126004. viewProjection: Matrix;
  126005. }
  126006. /**
  126007. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126008. */
  126009. export class GeometryBufferRenderer {
  126010. /**
  126011. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126012. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126013. */
  126014. static readonly POSITION_TEXTURE_TYPE: number;
  126015. /**
  126016. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126017. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126018. */
  126019. static readonly VELOCITY_TEXTURE_TYPE: number;
  126020. /**
  126021. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126022. * in order to compute objects velocities when enableVelocity is set to "true"
  126023. * @hidden
  126024. */
  126025. _previousTransformationMatrices: {
  126026. [index: number]: ISavedTransformationMatrix;
  126027. };
  126028. /**
  126029. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126030. * in order to compute objects velocities when enableVelocity is set to "true"
  126031. * @hidden
  126032. */
  126033. _previousBonesTransformationMatrices: {
  126034. [index: number]: Float32Array;
  126035. };
  126036. /**
  126037. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126038. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126039. */
  126040. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126041. private _scene;
  126042. private _multiRenderTarget;
  126043. private _ratio;
  126044. private _enablePosition;
  126045. private _enableVelocity;
  126046. private _positionIndex;
  126047. private _velocityIndex;
  126048. protected _effect: Effect;
  126049. protected _cachedDefines: string;
  126050. /**
  126051. * Set the render list (meshes to be rendered) used in the G buffer.
  126052. */
  126053. renderList: Mesh[];
  126054. /**
  126055. * Gets wether or not G buffer are supported by the running hardware.
  126056. * This requires draw buffer supports
  126057. */
  126058. readonly isSupported: boolean;
  126059. /**
  126060. * Returns the index of the given texture type in the G-Buffer textures array
  126061. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126062. * @returns the index of the given texture type in the G-Buffer textures array
  126063. */
  126064. getTextureIndex(textureType: number): number;
  126065. /**
  126066. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126067. */
  126068. /**
  126069. * Sets whether or not objects positions are enabled for the G buffer.
  126070. */
  126071. enablePosition: boolean;
  126072. /**
  126073. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126074. */
  126075. /**
  126076. * Sets wether or not objects velocities are enabled for the G buffer.
  126077. */
  126078. enableVelocity: boolean;
  126079. /**
  126080. * Gets the scene associated with the buffer.
  126081. */
  126082. readonly scene: Scene;
  126083. /**
  126084. * Gets the ratio used by the buffer during its creation.
  126085. * How big is the buffer related to the main canvas.
  126086. */
  126087. readonly ratio: number;
  126088. /** @hidden */
  126089. static _SceneComponentInitialization: (scene: Scene) => void;
  126090. /**
  126091. * Creates a new G Buffer for the scene
  126092. * @param scene The scene the buffer belongs to
  126093. * @param ratio How big is the buffer related to the main canvas.
  126094. */
  126095. constructor(scene: Scene, ratio?: number);
  126096. /**
  126097. * Checks wether everything is ready to render a submesh to the G buffer.
  126098. * @param subMesh the submesh to check readiness for
  126099. * @param useInstances is the mesh drawn using instance or not
  126100. * @returns true if ready otherwise false
  126101. */
  126102. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126103. /**
  126104. * Gets the current underlying G Buffer.
  126105. * @returns the buffer
  126106. */
  126107. getGBuffer(): MultiRenderTarget;
  126108. /**
  126109. * Gets the number of samples used to render the buffer (anti aliasing).
  126110. */
  126111. /**
  126112. * Sets the number of samples used to render the buffer (anti aliasing).
  126113. */
  126114. samples: number;
  126115. /**
  126116. * Disposes the renderer and frees up associated resources.
  126117. */
  126118. dispose(): void;
  126119. protected _createRenderTargets(): void;
  126120. private _copyBonesTransformationMatrices;
  126121. }
  126122. }
  126123. declare module BABYLON {
  126124. interface Scene {
  126125. /** @hidden (Backing field) */
  126126. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126127. /**
  126128. * Gets or Sets the current geometry buffer associated to the scene.
  126129. */
  126130. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126131. /**
  126132. * Enables a GeometryBufferRender and associates it with the scene
  126133. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126134. * @returns the GeometryBufferRenderer
  126135. */
  126136. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126137. /**
  126138. * Disables the GeometryBufferRender associated with the scene
  126139. */
  126140. disableGeometryBufferRenderer(): void;
  126141. }
  126142. /**
  126143. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126144. * in several rendering techniques.
  126145. */
  126146. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126147. /**
  126148. * The component name helpful to identify the component in the list of scene components.
  126149. */
  126150. readonly name: string;
  126151. /**
  126152. * The scene the component belongs to.
  126153. */
  126154. scene: Scene;
  126155. /**
  126156. * Creates a new instance of the component for the given scene
  126157. * @param scene Defines the scene to register the component in
  126158. */
  126159. constructor(scene: Scene);
  126160. /**
  126161. * Registers the component in a given scene
  126162. */
  126163. register(): void;
  126164. /**
  126165. * Rebuilds the elements related to this component in case of
  126166. * context lost for instance.
  126167. */
  126168. rebuild(): void;
  126169. /**
  126170. * Disposes the component and the associated ressources
  126171. */
  126172. dispose(): void;
  126173. private _gatherRenderTargets;
  126174. }
  126175. }
  126176. declare module BABYLON {
  126177. /** @hidden */
  126178. export var motionBlurPixelShader: {
  126179. name: string;
  126180. shader: string;
  126181. };
  126182. }
  126183. declare module BABYLON {
  126184. /**
  126185. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126186. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126187. * As an example, all you have to do is to create the post-process:
  126188. * var mb = new BABYLON.MotionBlurPostProcess(
  126189. * 'mb', // The name of the effect.
  126190. * scene, // The scene containing the objects to blur according to their velocity.
  126191. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126192. * camera // The camera to apply the render pass to.
  126193. * );
  126194. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126195. */
  126196. export class MotionBlurPostProcess extends PostProcess {
  126197. /**
  126198. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126199. */
  126200. motionStrength: number;
  126201. /**
  126202. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126203. */
  126204. /**
  126205. * Sets the number of iterations to be used for motion blur quality
  126206. */
  126207. motionBlurSamples: number;
  126208. private _motionBlurSamples;
  126209. private _geometryBufferRenderer;
  126210. /**
  126211. * Creates a new instance MotionBlurPostProcess
  126212. * @param name The name of the effect.
  126213. * @param scene The scene containing the objects to blur according to their velocity.
  126214. * @param options The required width/height ratio to downsize to before computing the render pass.
  126215. * @param camera The camera to apply the render pass to.
  126216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126217. * @param engine The engine which the post process will be applied. (default: current engine)
  126218. * @param reusable If the post process can be reused on the same frame. (default: false)
  126219. * @param textureType Type of textures used when performing the post process. (default: 0)
  126220. * @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)
  126221. */
  126222. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126223. /**
  126224. * Excludes the given skinned mesh from computing bones velocities.
  126225. * 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.
  126226. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126227. */
  126228. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126229. /**
  126230. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126231. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126232. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126233. */
  126234. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126235. /**
  126236. * Disposes the post process.
  126237. * @param camera The camera to dispose the post process on.
  126238. */
  126239. dispose(camera?: Camera): void;
  126240. }
  126241. }
  126242. declare module BABYLON {
  126243. /** @hidden */
  126244. export var refractionPixelShader: {
  126245. name: string;
  126246. shader: string;
  126247. };
  126248. }
  126249. declare module BABYLON {
  126250. /**
  126251. * Post process which applies a refractin texture
  126252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126253. */
  126254. export class RefractionPostProcess extends PostProcess {
  126255. /** the base color of the refraction (used to taint the rendering) */
  126256. color: Color3;
  126257. /** simulated refraction depth */
  126258. depth: number;
  126259. /** the coefficient of the base color (0 to remove base color tainting) */
  126260. colorLevel: number;
  126261. private _refTexture;
  126262. private _ownRefractionTexture;
  126263. /**
  126264. * Gets or sets the refraction texture
  126265. * Please note that you are responsible for disposing the texture if you set it manually
  126266. */
  126267. refractionTexture: Texture;
  126268. /**
  126269. * Initializes the RefractionPostProcess
  126270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126271. * @param name The name of the effect.
  126272. * @param refractionTextureUrl Url of the refraction texture to use
  126273. * @param color the base color of the refraction (used to taint the rendering)
  126274. * @param depth simulated refraction depth
  126275. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126276. * @param camera The camera to apply the render pass to.
  126277. * @param options The required width/height ratio to downsize to before computing the render pass.
  126278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126279. * @param engine The engine which the post process will be applied. (default: current engine)
  126280. * @param reusable If the post process can be reused on the same frame. (default: false)
  126281. */
  126282. constructor(name: string, refractionTextureUrl: string,
  126283. /** the base color of the refraction (used to taint the rendering) */
  126284. color: Color3,
  126285. /** simulated refraction depth */
  126286. depth: number,
  126287. /** the coefficient of the base color (0 to remove base color tainting) */
  126288. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126289. /**
  126290. * Disposes of the post process
  126291. * @param camera Camera to dispose post process on
  126292. */
  126293. dispose(camera: Camera): void;
  126294. }
  126295. }
  126296. declare module BABYLON {
  126297. /** @hidden */
  126298. export var sharpenPixelShader: {
  126299. name: string;
  126300. shader: string;
  126301. };
  126302. }
  126303. declare module BABYLON {
  126304. /**
  126305. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126306. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126307. */
  126308. export class SharpenPostProcess extends PostProcess {
  126309. /**
  126310. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126311. */
  126312. colorAmount: number;
  126313. /**
  126314. * How much sharpness should be applied (default: 0.3)
  126315. */
  126316. edgeAmount: number;
  126317. /**
  126318. * Creates a new instance ConvolutionPostProcess
  126319. * @param name The name of the effect.
  126320. * @param options The required width/height ratio to downsize to before computing the render pass.
  126321. * @param camera The camera to apply the render pass to.
  126322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126323. * @param engine The engine which the post process will be applied. (default: current engine)
  126324. * @param reusable If the post process can be reused on the same frame. (default: false)
  126325. * @param textureType Type of textures used when performing the post process. (default: 0)
  126326. * @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)
  126327. */
  126328. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126329. }
  126330. }
  126331. declare module BABYLON {
  126332. /**
  126333. * PostProcessRenderPipeline
  126334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126335. */
  126336. export class PostProcessRenderPipeline {
  126337. private engine;
  126338. private _renderEffects;
  126339. private _renderEffectsForIsolatedPass;
  126340. /**
  126341. * List of inspectable custom properties (used by the Inspector)
  126342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126343. */
  126344. inspectableCustomProperties: IInspectable[];
  126345. /**
  126346. * @hidden
  126347. */
  126348. protected _cameras: Camera[];
  126349. /** @hidden */
  126350. _name: string;
  126351. /**
  126352. * Gets pipeline name
  126353. */
  126354. readonly name: string;
  126355. /**
  126356. * Initializes a PostProcessRenderPipeline
  126357. * @param engine engine to add the pipeline to
  126358. * @param name name of the pipeline
  126359. */
  126360. constructor(engine: Engine, name: string);
  126361. /**
  126362. * Gets the class name
  126363. * @returns "PostProcessRenderPipeline"
  126364. */
  126365. getClassName(): string;
  126366. /**
  126367. * If all the render effects in the pipeline are supported
  126368. */
  126369. readonly isSupported: boolean;
  126370. /**
  126371. * Adds an effect to the pipeline
  126372. * @param renderEffect the effect to add
  126373. */
  126374. addEffect(renderEffect: PostProcessRenderEffect): void;
  126375. /** @hidden */
  126376. _rebuild(): void;
  126377. /** @hidden */
  126378. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126379. /** @hidden */
  126380. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126381. /** @hidden */
  126382. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126383. /** @hidden */
  126384. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126385. /** @hidden */
  126386. _attachCameras(cameras: Camera, unique: boolean): void;
  126387. /** @hidden */
  126388. _attachCameras(cameras: Camera[], unique: boolean): void;
  126389. /** @hidden */
  126390. _detachCameras(cameras: Camera): void;
  126391. /** @hidden */
  126392. _detachCameras(cameras: Nullable<Camera[]>): void;
  126393. /** @hidden */
  126394. _update(): void;
  126395. /** @hidden */
  126396. _reset(): void;
  126397. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126398. /**
  126399. * Disposes of the pipeline
  126400. */
  126401. dispose(): void;
  126402. }
  126403. }
  126404. declare module BABYLON {
  126405. /**
  126406. * PostProcessRenderPipelineManager class
  126407. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126408. */
  126409. export class PostProcessRenderPipelineManager {
  126410. private _renderPipelines;
  126411. /**
  126412. * Initializes a PostProcessRenderPipelineManager
  126413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126414. */
  126415. constructor();
  126416. /**
  126417. * Gets the list of supported render pipelines
  126418. */
  126419. readonly supportedPipelines: PostProcessRenderPipeline[];
  126420. /**
  126421. * Adds a pipeline to the manager
  126422. * @param renderPipeline The pipeline to add
  126423. */
  126424. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126425. /**
  126426. * Attaches a camera to the pipeline
  126427. * @param renderPipelineName The name of the pipeline to attach to
  126428. * @param cameras the camera to attach
  126429. * @param unique if the camera can be attached multiple times to the pipeline
  126430. */
  126431. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126432. /**
  126433. * Detaches a camera from the pipeline
  126434. * @param renderPipelineName The name of the pipeline to detach from
  126435. * @param cameras the camera to detach
  126436. */
  126437. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126438. /**
  126439. * Enables an effect by name on a pipeline
  126440. * @param renderPipelineName the name of the pipeline to enable the effect in
  126441. * @param renderEffectName the name of the effect to enable
  126442. * @param cameras the cameras that the effect should be enabled on
  126443. */
  126444. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126445. /**
  126446. * Disables an effect by name on a pipeline
  126447. * @param renderPipelineName the name of the pipeline to disable the effect in
  126448. * @param renderEffectName the name of the effect to disable
  126449. * @param cameras the cameras that the effect should be disabled on
  126450. */
  126451. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126452. /**
  126453. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126454. */
  126455. update(): void;
  126456. /** @hidden */
  126457. _rebuild(): void;
  126458. /**
  126459. * Disposes of the manager and pipelines
  126460. */
  126461. dispose(): void;
  126462. }
  126463. }
  126464. declare module BABYLON {
  126465. interface Scene {
  126466. /** @hidden (Backing field) */
  126467. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126468. /**
  126469. * Gets the postprocess render pipeline manager
  126470. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126471. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126472. */
  126473. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126474. }
  126475. /**
  126476. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126477. */
  126478. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126479. /**
  126480. * The component name helpfull to identify the component in the list of scene components.
  126481. */
  126482. readonly name: string;
  126483. /**
  126484. * The scene the component belongs to.
  126485. */
  126486. scene: Scene;
  126487. /**
  126488. * Creates a new instance of the component for the given scene
  126489. * @param scene Defines the scene to register the component in
  126490. */
  126491. constructor(scene: Scene);
  126492. /**
  126493. * Registers the component in a given scene
  126494. */
  126495. register(): void;
  126496. /**
  126497. * Rebuilds the elements related to this component in case of
  126498. * context lost for instance.
  126499. */
  126500. rebuild(): void;
  126501. /**
  126502. * Disposes the component and the associated ressources
  126503. */
  126504. dispose(): void;
  126505. private _gatherRenderTargets;
  126506. }
  126507. }
  126508. declare module BABYLON {
  126509. /**
  126510. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126511. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126512. */
  126513. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126514. private _scene;
  126515. private _camerasToBeAttached;
  126516. /**
  126517. * ID of the sharpen post process,
  126518. */
  126519. private readonly SharpenPostProcessId;
  126520. /**
  126521. * @ignore
  126522. * ID of the image processing post process;
  126523. */
  126524. readonly ImageProcessingPostProcessId: string;
  126525. /**
  126526. * @ignore
  126527. * ID of the Fast Approximate Anti-Aliasing post process;
  126528. */
  126529. readonly FxaaPostProcessId: string;
  126530. /**
  126531. * ID of the chromatic aberration post process,
  126532. */
  126533. private readonly ChromaticAberrationPostProcessId;
  126534. /**
  126535. * ID of the grain post process
  126536. */
  126537. private readonly GrainPostProcessId;
  126538. /**
  126539. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126540. */
  126541. sharpen: SharpenPostProcess;
  126542. private _sharpenEffect;
  126543. private bloom;
  126544. /**
  126545. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126546. */
  126547. depthOfField: DepthOfFieldEffect;
  126548. /**
  126549. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126550. */
  126551. fxaa: FxaaPostProcess;
  126552. /**
  126553. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126554. */
  126555. imageProcessing: ImageProcessingPostProcess;
  126556. /**
  126557. * Chromatic aberration post process which will shift rgb colors in the image
  126558. */
  126559. chromaticAberration: ChromaticAberrationPostProcess;
  126560. private _chromaticAberrationEffect;
  126561. /**
  126562. * Grain post process which add noise to the image
  126563. */
  126564. grain: GrainPostProcess;
  126565. private _grainEffect;
  126566. /**
  126567. * Glow post process which adds a glow to emissive areas of the image
  126568. */
  126569. private _glowLayer;
  126570. /**
  126571. * Animations which can be used to tweak settings over a period of time
  126572. */
  126573. animations: Animation[];
  126574. private _imageProcessingConfigurationObserver;
  126575. private _sharpenEnabled;
  126576. private _bloomEnabled;
  126577. private _depthOfFieldEnabled;
  126578. private _depthOfFieldBlurLevel;
  126579. private _fxaaEnabled;
  126580. private _imageProcessingEnabled;
  126581. private _defaultPipelineTextureType;
  126582. private _bloomScale;
  126583. private _chromaticAberrationEnabled;
  126584. private _grainEnabled;
  126585. private _buildAllowed;
  126586. /**
  126587. * Gets active scene
  126588. */
  126589. readonly scene: Scene;
  126590. /**
  126591. * Enable or disable the sharpen process from the pipeline
  126592. */
  126593. sharpenEnabled: boolean;
  126594. private _resizeObserver;
  126595. private _hardwareScaleLevel;
  126596. private _bloomKernel;
  126597. /**
  126598. * Specifies the size of the bloom blur kernel, relative to the final output size
  126599. */
  126600. bloomKernel: number;
  126601. /**
  126602. * Specifies the weight of the bloom in the final rendering
  126603. */
  126604. private _bloomWeight;
  126605. /**
  126606. * Specifies the luma threshold for the area that will be blurred by the bloom
  126607. */
  126608. private _bloomThreshold;
  126609. private _hdr;
  126610. /**
  126611. * The strength of the bloom.
  126612. */
  126613. bloomWeight: number;
  126614. /**
  126615. * The strength of the bloom.
  126616. */
  126617. bloomThreshold: number;
  126618. /**
  126619. * The scale of the bloom, lower value will provide better performance.
  126620. */
  126621. bloomScale: number;
  126622. /**
  126623. * Enable or disable the bloom from the pipeline
  126624. */
  126625. bloomEnabled: boolean;
  126626. private _rebuildBloom;
  126627. /**
  126628. * If the depth of field is enabled.
  126629. */
  126630. depthOfFieldEnabled: boolean;
  126631. /**
  126632. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126633. */
  126634. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126635. /**
  126636. * If the anti aliasing is enabled.
  126637. */
  126638. fxaaEnabled: boolean;
  126639. private _samples;
  126640. /**
  126641. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126642. */
  126643. samples: number;
  126644. /**
  126645. * If image processing is enabled.
  126646. */
  126647. imageProcessingEnabled: boolean;
  126648. /**
  126649. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126650. */
  126651. glowLayerEnabled: boolean;
  126652. /**
  126653. * Gets the glow layer (or null if not defined)
  126654. */
  126655. readonly glowLayer: Nullable<GlowLayer>;
  126656. /**
  126657. * Enable or disable the chromaticAberration process from the pipeline
  126658. */
  126659. chromaticAberrationEnabled: boolean;
  126660. /**
  126661. * Enable or disable the grain process from the pipeline
  126662. */
  126663. grainEnabled: boolean;
  126664. /**
  126665. * @constructor
  126666. * @param name - The rendering pipeline name (default: "")
  126667. * @param hdr - If high dynamic range textures should be used (default: true)
  126668. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126669. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126670. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126671. */
  126672. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126673. /**
  126674. * Get the class name
  126675. * @returns "DefaultRenderingPipeline"
  126676. */
  126677. getClassName(): string;
  126678. /**
  126679. * Force the compilation of the entire pipeline.
  126680. */
  126681. prepare(): void;
  126682. private _hasCleared;
  126683. private _prevPostProcess;
  126684. private _prevPrevPostProcess;
  126685. private _setAutoClearAndTextureSharing;
  126686. private _depthOfFieldSceneObserver;
  126687. private _buildPipeline;
  126688. private _disposePostProcesses;
  126689. /**
  126690. * Adds a camera to the pipeline
  126691. * @param camera the camera to be added
  126692. */
  126693. addCamera(camera: Camera): void;
  126694. /**
  126695. * Removes a camera from the pipeline
  126696. * @param camera the camera to remove
  126697. */
  126698. removeCamera(camera: Camera): void;
  126699. /**
  126700. * Dispose of the pipeline and stop all post processes
  126701. */
  126702. dispose(): void;
  126703. /**
  126704. * Serialize the rendering pipeline (Used when exporting)
  126705. * @returns the serialized object
  126706. */
  126707. serialize(): any;
  126708. /**
  126709. * Parse the serialized pipeline
  126710. * @param source Source pipeline.
  126711. * @param scene The scene to load the pipeline to.
  126712. * @param rootUrl The URL of the serialized pipeline.
  126713. * @returns An instantiated pipeline from the serialized object.
  126714. */
  126715. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  126716. }
  126717. }
  126718. declare module BABYLON {
  126719. /** @hidden */
  126720. export var lensHighlightsPixelShader: {
  126721. name: string;
  126722. shader: string;
  126723. };
  126724. }
  126725. declare module BABYLON {
  126726. /** @hidden */
  126727. export var depthOfFieldPixelShader: {
  126728. name: string;
  126729. shader: string;
  126730. };
  126731. }
  126732. declare module BABYLON {
  126733. /**
  126734. * BABYLON.JS Chromatic Aberration GLSL Shader
  126735. * Author: Olivier Guyot
  126736. * Separates very slightly R, G and B colors on the edges of the screen
  126737. * Inspired by Francois Tarlier & Martins Upitis
  126738. */
  126739. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  126740. /**
  126741. * @ignore
  126742. * The chromatic aberration PostProcess id in the pipeline
  126743. */
  126744. LensChromaticAberrationEffect: string;
  126745. /**
  126746. * @ignore
  126747. * The highlights enhancing PostProcess id in the pipeline
  126748. */
  126749. HighlightsEnhancingEffect: string;
  126750. /**
  126751. * @ignore
  126752. * The depth-of-field PostProcess id in the pipeline
  126753. */
  126754. LensDepthOfFieldEffect: string;
  126755. private _scene;
  126756. private _depthTexture;
  126757. private _grainTexture;
  126758. private _chromaticAberrationPostProcess;
  126759. private _highlightsPostProcess;
  126760. private _depthOfFieldPostProcess;
  126761. private _edgeBlur;
  126762. private _grainAmount;
  126763. private _chromaticAberration;
  126764. private _distortion;
  126765. private _highlightsGain;
  126766. private _highlightsThreshold;
  126767. private _dofDistance;
  126768. private _dofAperture;
  126769. private _dofDarken;
  126770. private _dofPentagon;
  126771. private _blurNoise;
  126772. /**
  126773. * @constructor
  126774. *
  126775. * Effect parameters are as follow:
  126776. * {
  126777. * chromatic_aberration: number; // from 0 to x (1 for realism)
  126778. * edge_blur: number; // from 0 to x (1 for realism)
  126779. * distortion: number; // from 0 to x (1 for realism)
  126780. * grain_amount: number; // from 0 to 1
  126781. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  126782. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  126783. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  126784. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  126785. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  126786. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  126787. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  126788. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  126789. * }
  126790. * Note: if an effect parameter is unset, effect is disabled
  126791. *
  126792. * @param name The rendering pipeline name
  126793. * @param parameters - An object containing all parameters (see above)
  126794. * @param scene The scene linked to this pipeline
  126795. * @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)
  126796. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126797. */
  126798. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  126799. /**
  126800. * Get the class name
  126801. * @returns "LensRenderingPipeline"
  126802. */
  126803. getClassName(): string;
  126804. /**
  126805. * Gets associated scene
  126806. */
  126807. readonly scene: Scene;
  126808. /**
  126809. * Gets or sets the edge blur
  126810. */
  126811. edgeBlur: number;
  126812. /**
  126813. * Gets or sets the grain amount
  126814. */
  126815. grainAmount: number;
  126816. /**
  126817. * Gets or sets the chromatic aberration amount
  126818. */
  126819. chromaticAberration: number;
  126820. /**
  126821. * Gets or sets the depth of field aperture
  126822. */
  126823. dofAperture: number;
  126824. /**
  126825. * Gets or sets the edge distortion
  126826. */
  126827. edgeDistortion: number;
  126828. /**
  126829. * Gets or sets the depth of field distortion
  126830. */
  126831. dofDistortion: number;
  126832. /**
  126833. * Gets or sets the darken out of focus amount
  126834. */
  126835. darkenOutOfFocus: number;
  126836. /**
  126837. * Gets or sets a boolean indicating if blur noise is enabled
  126838. */
  126839. blurNoise: boolean;
  126840. /**
  126841. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  126842. */
  126843. pentagonBokeh: boolean;
  126844. /**
  126845. * Gets or sets the highlight grain amount
  126846. */
  126847. highlightsGain: number;
  126848. /**
  126849. * Gets or sets the highlight threshold
  126850. */
  126851. highlightsThreshold: number;
  126852. /**
  126853. * Sets the amount of blur at the edges
  126854. * @param amount blur amount
  126855. */
  126856. setEdgeBlur(amount: number): void;
  126857. /**
  126858. * Sets edge blur to 0
  126859. */
  126860. disableEdgeBlur(): void;
  126861. /**
  126862. * Sets the amout of grain
  126863. * @param amount Amount of grain
  126864. */
  126865. setGrainAmount(amount: number): void;
  126866. /**
  126867. * Set grain amount to 0
  126868. */
  126869. disableGrain(): void;
  126870. /**
  126871. * Sets the chromatic aberration amount
  126872. * @param amount amount of chromatic aberration
  126873. */
  126874. setChromaticAberration(amount: number): void;
  126875. /**
  126876. * Sets chromatic aberration amount to 0
  126877. */
  126878. disableChromaticAberration(): void;
  126879. /**
  126880. * Sets the EdgeDistortion amount
  126881. * @param amount amount of EdgeDistortion
  126882. */
  126883. setEdgeDistortion(amount: number): void;
  126884. /**
  126885. * Sets edge distortion to 0
  126886. */
  126887. disableEdgeDistortion(): void;
  126888. /**
  126889. * Sets the FocusDistance amount
  126890. * @param amount amount of FocusDistance
  126891. */
  126892. setFocusDistance(amount: number): void;
  126893. /**
  126894. * Disables depth of field
  126895. */
  126896. disableDepthOfField(): void;
  126897. /**
  126898. * Sets the Aperture amount
  126899. * @param amount amount of Aperture
  126900. */
  126901. setAperture(amount: number): void;
  126902. /**
  126903. * Sets the DarkenOutOfFocus amount
  126904. * @param amount amount of DarkenOutOfFocus
  126905. */
  126906. setDarkenOutOfFocus(amount: number): void;
  126907. private _pentagonBokehIsEnabled;
  126908. /**
  126909. * Creates a pentagon bokeh effect
  126910. */
  126911. enablePentagonBokeh(): void;
  126912. /**
  126913. * Disables the pentagon bokeh effect
  126914. */
  126915. disablePentagonBokeh(): void;
  126916. /**
  126917. * Enables noise blur
  126918. */
  126919. enableNoiseBlur(): void;
  126920. /**
  126921. * Disables noise blur
  126922. */
  126923. disableNoiseBlur(): void;
  126924. /**
  126925. * Sets the HighlightsGain amount
  126926. * @param amount amount of HighlightsGain
  126927. */
  126928. setHighlightsGain(amount: number): void;
  126929. /**
  126930. * Sets the HighlightsThreshold amount
  126931. * @param amount amount of HighlightsThreshold
  126932. */
  126933. setHighlightsThreshold(amount: number): void;
  126934. /**
  126935. * Disables highlights
  126936. */
  126937. disableHighlights(): void;
  126938. /**
  126939. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  126940. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  126941. */
  126942. dispose(disableDepthRender?: boolean): void;
  126943. private _createChromaticAberrationPostProcess;
  126944. private _createHighlightsPostProcess;
  126945. private _createDepthOfFieldPostProcess;
  126946. private _createGrainTexture;
  126947. }
  126948. }
  126949. declare module BABYLON {
  126950. /** @hidden */
  126951. export var ssao2PixelShader: {
  126952. name: string;
  126953. shader: string;
  126954. };
  126955. }
  126956. declare module BABYLON {
  126957. /** @hidden */
  126958. export var ssaoCombinePixelShader: {
  126959. name: string;
  126960. shader: string;
  126961. };
  126962. }
  126963. declare module BABYLON {
  126964. /**
  126965. * Render pipeline to produce ssao effect
  126966. */
  126967. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  126968. /**
  126969. * @ignore
  126970. * The PassPostProcess id in the pipeline that contains the original scene color
  126971. */
  126972. SSAOOriginalSceneColorEffect: string;
  126973. /**
  126974. * @ignore
  126975. * The SSAO PostProcess id in the pipeline
  126976. */
  126977. SSAORenderEffect: string;
  126978. /**
  126979. * @ignore
  126980. * The horizontal blur PostProcess id in the pipeline
  126981. */
  126982. SSAOBlurHRenderEffect: string;
  126983. /**
  126984. * @ignore
  126985. * The vertical blur PostProcess id in the pipeline
  126986. */
  126987. SSAOBlurVRenderEffect: string;
  126988. /**
  126989. * @ignore
  126990. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  126991. */
  126992. SSAOCombineRenderEffect: string;
  126993. /**
  126994. * The output strength of the SSAO post-process. Default value is 1.0.
  126995. */
  126996. totalStrength: number;
  126997. /**
  126998. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  126999. */
  127000. maxZ: number;
  127001. /**
  127002. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127003. */
  127004. minZAspect: number;
  127005. private _samples;
  127006. /**
  127007. * Number of samples used for the SSAO calculations. Default value is 8
  127008. */
  127009. samples: number;
  127010. private _textureSamples;
  127011. /**
  127012. * Number of samples to use for antialiasing
  127013. */
  127014. textureSamples: number;
  127015. /**
  127016. * Ratio object used for SSAO ratio and blur ratio
  127017. */
  127018. private _ratio;
  127019. /**
  127020. * Dynamically generated sphere sampler.
  127021. */
  127022. private _sampleSphere;
  127023. /**
  127024. * Blur filter offsets
  127025. */
  127026. private _samplerOffsets;
  127027. private _expensiveBlur;
  127028. /**
  127029. * If bilateral blur should be used
  127030. */
  127031. expensiveBlur: boolean;
  127032. /**
  127033. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127034. */
  127035. radius: number;
  127036. /**
  127037. * The base color of the SSAO post-process
  127038. * The final result is "base + ssao" between [0, 1]
  127039. */
  127040. base: number;
  127041. /**
  127042. * Support test.
  127043. */
  127044. static readonly IsSupported: boolean;
  127045. private _scene;
  127046. private _depthTexture;
  127047. private _normalTexture;
  127048. private _randomTexture;
  127049. private _originalColorPostProcess;
  127050. private _ssaoPostProcess;
  127051. private _blurHPostProcess;
  127052. private _blurVPostProcess;
  127053. private _ssaoCombinePostProcess;
  127054. private _firstUpdate;
  127055. /**
  127056. * Gets active scene
  127057. */
  127058. readonly scene: Scene;
  127059. /**
  127060. * @constructor
  127061. * @param name The rendering pipeline name
  127062. * @param scene The scene linked to this pipeline
  127063. * @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 }
  127064. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127065. */
  127066. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127067. /**
  127068. * Get the class name
  127069. * @returns "SSAO2RenderingPipeline"
  127070. */
  127071. getClassName(): string;
  127072. /**
  127073. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127074. */
  127075. dispose(disableGeometryBufferRenderer?: boolean): void;
  127076. private _createBlurPostProcess;
  127077. /** @hidden */
  127078. _rebuild(): void;
  127079. private _bits;
  127080. private _radicalInverse_VdC;
  127081. private _hammersley;
  127082. private _hemisphereSample_uniform;
  127083. private _generateHemisphere;
  127084. private _createSSAOPostProcess;
  127085. private _createSSAOCombinePostProcess;
  127086. private _createRandomTexture;
  127087. /**
  127088. * Serialize the rendering pipeline (Used when exporting)
  127089. * @returns the serialized object
  127090. */
  127091. serialize(): any;
  127092. /**
  127093. * Parse the serialized pipeline
  127094. * @param source Source pipeline.
  127095. * @param scene The scene to load the pipeline to.
  127096. * @param rootUrl The URL of the serialized pipeline.
  127097. * @returns An instantiated pipeline from the serialized object.
  127098. */
  127099. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127100. }
  127101. }
  127102. declare module BABYLON {
  127103. /** @hidden */
  127104. export var ssaoPixelShader: {
  127105. name: string;
  127106. shader: string;
  127107. };
  127108. }
  127109. declare module BABYLON {
  127110. /**
  127111. * Render pipeline to produce ssao effect
  127112. */
  127113. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127114. /**
  127115. * @ignore
  127116. * The PassPostProcess id in the pipeline that contains the original scene color
  127117. */
  127118. SSAOOriginalSceneColorEffect: string;
  127119. /**
  127120. * @ignore
  127121. * The SSAO PostProcess id in the pipeline
  127122. */
  127123. SSAORenderEffect: string;
  127124. /**
  127125. * @ignore
  127126. * The horizontal blur PostProcess id in the pipeline
  127127. */
  127128. SSAOBlurHRenderEffect: string;
  127129. /**
  127130. * @ignore
  127131. * The vertical blur PostProcess id in the pipeline
  127132. */
  127133. SSAOBlurVRenderEffect: string;
  127134. /**
  127135. * @ignore
  127136. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127137. */
  127138. SSAOCombineRenderEffect: string;
  127139. /**
  127140. * The output strength of the SSAO post-process. Default value is 1.0.
  127141. */
  127142. totalStrength: number;
  127143. /**
  127144. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127145. */
  127146. radius: number;
  127147. /**
  127148. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127149. * Must not be equal to fallOff and superior to fallOff.
  127150. * Default value is 0.0075
  127151. */
  127152. area: number;
  127153. /**
  127154. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127155. * Must not be equal to area and inferior to area.
  127156. * Default value is 0.000001
  127157. */
  127158. fallOff: number;
  127159. /**
  127160. * The base color of the SSAO post-process
  127161. * The final result is "base + ssao" between [0, 1]
  127162. */
  127163. base: number;
  127164. private _scene;
  127165. private _depthTexture;
  127166. private _randomTexture;
  127167. private _originalColorPostProcess;
  127168. private _ssaoPostProcess;
  127169. private _blurHPostProcess;
  127170. private _blurVPostProcess;
  127171. private _ssaoCombinePostProcess;
  127172. private _firstUpdate;
  127173. /**
  127174. * Gets active scene
  127175. */
  127176. readonly scene: Scene;
  127177. /**
  127178. * @constructor
  127179. * @param name - The rendering pipeline name
  127180. * @param scene - The scene linked to this pipeline
  127181. * @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 }
  127182. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127183. */
  127184. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127185. /**
  127186. * Get the class name
  127187. * @returns "SSAORenderingPipeline"
  127188. */
  127189. getClassName(): string;
  127190. /**
  127191. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127192. */
  127193. dispose(disableDepthRender?: boolean): void;
  127194. private _createBlurPostProcess;
  127195. /** @hidden */
  127196. _rebuild(): void;
  127197. private _createSSAOPostProcess;
  127198. private _createSSAOCombinePostProcess;
  127199. private _createRandomTexture;
  127200. }
  127201. }
  127202. declare module BABYLON {
  127203. /** @hidden */
  127204. export var standardPixelShader: {
  127205. name: string;
  127206. shader: string;
  127207. };
  127208. }
  127209. declare module BABYLON {
  127210. /**
  127211. * Standard rendering pipeline
  127212. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127213. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127214. */
  127215. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127216. /**
  127217. * Public members
  127218. */
  127219. /**
  127220. * Post-process which contains the original scene color before the pipeline applies all the effects
  127221. */
  127222. originalPostProcess: Nullable<PostProcess>;
  127223. /**
  127224. * Post-process used to down scale an image x4
  127225. */
  127226. downSampleX4PostProcess: Nullable<PostProcess>;
  127227. /**
  127228. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127229. */
  127230. brightPassPostProcess: Nullable<PostProcess>;
  127231. /**
  127232. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127233. */
  127234. blurHPostProcesses: PostProcess[];
  127235. /**
  127236. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127237. */
  127238. blurVPostProcesses: PostProcess[];
  127239. /**
  127240. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127241. */
  127242. textureAdderPostProcess: Nullable<PostProcess>;
  127243. /**
  127244. * Post-process used to create volumetric lighting effect
  127245. */
  127246. volumetricLightPostProcess: Nullable<PostProcess>;
  127247. /**
  127248. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127249. */
  127250. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127251. /**
  127252. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127253. */
  127254. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127255. /**
  127256. * Post-process used to merge the volumetric light effect and the real scene color
  127257. */
  127258. volumetricLightMergePostProces: Nullable<PostProcess>;
  127259. /**
  127260. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127261. */
  127262. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127263. /**
  127264. * Base post-process used to calculate the average luminance of the final image for HDR
  127265. */
  127266. luminancePostProcess: Nullable<PostProcess>;
  127267. /**
  127268. * Post-processes used to create down sample post-processes in order to get
  127269. * the average luminance of the final image for HDR
  127270. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127271. */
  127272. luminanceDownSamplePostProcesses: PostProcess[];
  127273. /**
  127274. * Post-process used to create a HDR effect (light adaptation)
  127275. */
  127276. hdrPostProcess: Nullable<PostProcess>;
  127277. /**
  127278. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127279. */
  127280. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127281. /**
  127282. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127283. */
  127284. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127285. /**
  127286. * Post-process used to merge the final HDR post-process and the real scene color
  127287. */
  127288. hdrFinalPostProcess: Nullable<PostProcess>;
  127289. /**
  127290. * Post-process used to create a lens flare effect
  127291. */
  127292. lensFlarePostProcess: Nullable<PostProcess>;
  127293. /**
  127294. * Post-process that merges the result of the lens flare post-process and the real scene color
  127295. */
  127296. lensFlareComposePostProcess: Nullable<PostProcess>;
  127297. /**
  127298. * Post-process used to create a motion blur effect
  127299. */
  127300. motionBlurPostProcess: Nullable<PostProcess>;
  127301. /**
  127302. * Post-process used to create a depth of field effect
  127303. */
  127304. depthOfFieldPostProcess: Nullable<PostProcess>;
  127305. /**
  127306. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127307. */
  127308. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127309. /**
  127310. * Represents the brightness threshold in order to configure the illuminated surfaces
  127311. */
  127312. brightThreshold: number;
  127313. /**
  127314. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127315. */
  127316. blurWidth: number;
  127317. /**
  127318. * Sets if the blur for highlighted surfaces must be only horizontal
  127319. */
  127320. horizontalBlur: boolean;
  127321. /**
  127322. * Gets the overall exposure used by the pipeline
  127323. */
  127324. /**
  127325. * Sets the overall exposure used by the pipeline
  127326. */
  127327. exposure: number;
  127328. /**
  127329. * Texture used typically to simulate "dirty" on camera lens
  127330. */
  127331. lensTexture: Nullable<Texture>;
  127332. /**
  127333. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127334. */
  127335. volumetricLightCoefficient: number;
  127336. /**
  127337. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127338. */
  127339. volumetricLightPower: number;
  127340. /**
  127341. * Used the set the blur intensity to smooth the volumetric lights
  127342. */
  127343. volumetricLightBlurScale: number;
  127344. /**
  127345. * Light (spot or directional) used to generate the volumetric lights rays
  127346. * The source light must have a shadow generate so the pipeline can get its
  127347. * depth map
  127348. */
  127349. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127350. /**
  127351. * For eye adaptation, represents the minimum luminance the eye can see
  127352. */
  127353. hdrMinimumLuminance: number;
  127354. /**
  127355. * For eye adaptation, represents the decrease luminance speed
  127356. */
  127357. hdrDecreaseRate: number;
  127358. /**
  127359. * For eye adaptation, represents the increase luminance speed
  127360. */
  127361. hdrIncreaseRate: number;
  127362. /**
  127363. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127364. */
  127365. /**
  127366. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127367. */
  127368. hdrAutoExposure: boolean;
  127369. /**
  127370. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127371. */
  127372. lensColorTexture: Nullable<Texture>;
  127373. /**
  127374. * The overall strengh for the lens flare effect
  127375. */
  127376. lensFlareStrength: number;
  127377. /**
  127378. * Dispersion coefficient for lens flare ghosts
  127379. */
  127380. lensFlareGhostDispersal: number;
  127381. /**
  127382. * Main lens flare halo width
  127383. */
  127384. lensFlareHaloWidth: number;
  127385. /**
  127386. * Based on the lens distortion effect, defines how much the lens flare result
  127387. * is distorted
  127388. */
  127389. lensFlareDistortionStrength: number;
  127390. /**
  127391. * Configures the blur intensity used for for lens flare (halo)
  127392. */
  127393. lensFlareBlurWidth: number;
  127394. /**
  127395. * Lens star texture must be used to simulate rays on the flares and is available
  127396. * in the documentation
  127397. */
  127398. lensStarTexture: Nullable<Texture>;
  127399. /**
  127400. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127401. * flare effect by taking account of the dirt texture
  127402. */
  127403. lensFlareDirtTexture: Nullable<Texture>;
  127404. /**
  127405. * Represents the focal length for the depth of field effect
  127406. */
  127407. depthOfFieldDistance: number;
  127408. /**
  127409. * Represents the blur intensity for the blurred part of the depth of field effect
  127410. */
  127411. depthOfFieldBlurWidth: number;
  127412. /**
  127413. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127414. */
  127415. /**
  127416. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127417. */
  127418. motionStrength: number;
  127419. /**
  127420. * Gets wether or not the motion blur post-process is object based or screen based.
  127421. */
  127422. /**
  127423. * Sets wether or not the motion blur post-process should be object based or screen based
  127424. */
  127425. objectBasedMotionBlur: boolean;
  127426. /**
  127427. * List of animations for the pipeline (IAnimatable implementation)
  127428. */
  127429. animations: Animation[];
  127430. /**
  127431. * Private members
  127432. */
  127433. private _scene;
  127434. private _currentDepthOfFieldSource;
  127435. private _basePostProcess;
  127436. private _fixedExposure;
  127437. private _currentExposure;
  127438. private _hdrAutoExposure;
  127439. private _hdrCurrentLuminance;
  127440. private _motionStrength;
  127441. private _isObjectBasedMotionBlur;
  127442. private _floatTextureType;
  127443. private _camerasToBeAttached;
  127444. private _ratio;
  127445. private _bloomEnabled;
  127446. private _depthOfFieldEnabled;
  127447. private _vlsEnabled;
  127448. private _lensFlareEnabled;
  127449. private _hdrEnabled;
  127450. private _motionBlurEnabled;
  127451. private _fxaaEnabled;
  127452. private _motionBlurSamples;
  127453. private _volumetricLightStepsCount;
  127454. private _samples;
  127455. /**
  127456. * @ignore
  127457. * Specifies if the bloom pipeline is enabled
  127458. */
  127459. BloomEnabled: boolean;
  127460. /**
  127461. * @ignore
  127462. * Specifies if the depth of field pipeline is enabed
  127463. */
  127464. DepthOfFieldEnabled: boolean;
  127465. /**
  127466. * @ignore
  127467. * Specifies if the lens flare pipeline is enabed
  127468. */
  127469. LensFlareEnabled: boolean;
  127470. /**
  127471. * @ignore
  127472. * Specifies if the HDR pipeline is enabled
  127473. */
  127474. HDREnabled: boolean;
  127475. /**
  127476. * @ignore
  127477. * Specifies if the volumetric lights scattering effect is enabled
  127478. */
  127479. VLSEnabled: boolean;
  127480. /**
  127481. * @ignore
  127482. * Specifies if the motion blur effect is enabled
  127483. */
  127484. MotionBlurEnabled: boolean;
  127485. /**
  127486. * Specifies if anti-aliasing is enabled
  127487. */
  127488. fxaaEnabled: boolean;
  127489. /**
  127490. * Specifies the number of steps used to calculate the volumetric lights
  127491. * Typically in interval [50, 200]
  127492. */
  127493. volumetricLightStepsCount: number;
  127494. /**
  127495. * Specifies the number of samples used for the motion blur effect
  127496. * Typically in interval [16, 64]
  127497. */
  127498. motionBlurSamples: number;
  127499. /**
  127500. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127501. */
  127502. samples: number;
  127503. /**
  127504. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127505. * @constructor
  127506. * @param name The rendering pipeline name
  127507. * @param scene The scene linked to this pipeline
  127508. * @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)
  127509. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127510. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127511. */
  127512. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127513. private _buildPipeline;
  127514. private _createDownSampleX4PostProcess;
  127515. private _createBrightPassPostProcess;
  127516. private _createBlurPostProcesses;
  127517. private _createTextureAdderPostProcess;
  127518. private _createVolumetricLightPostProcess;
  127519. private _createLuminancePostProcesses;
  127520. private _createHdrPostProcess;
  127521. private _createLensFlarePostProcess;
  127522. private _createDepthOfFieldPostProcess;
  127523. private _createMotionBlurPostProcess;
  127524. private _getDepthTexture;
  127525. private _disposePostProcesses;
  127526. /**
  127527. * Dispose of the pipeline and stop all post processes
  127528. */
  127529. dispose(): void;
  127530. /**
  127531. * Serialize the rendering pipeline (Used when exporting)
  127532. * @returns the serialized object
  127533. */
  127534. serialize(): any;
  127535. /**
  127536. * Parse the serialized pipeline
  127537. * @param source Source pipeline.
  127538. * @param scene The scene to load the pipeline to.
  127539. * @param rootUrl The URL of the serialized pipeline.
  127540. * @returns An instantiated pipeline from the serialized object.
  127541. */
  127542. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127543. /**
  127544. * Luminance steps
  127545. */
  127546. static LuminanceSteps: number;
  127547. }
  127548. }
  127549. declare module BABYLON {
  127550. /** @hidden */
  127551. export var tonemapPixelShader: {
  127552. name: string;
  127553. shader: string;
  127554. };
  127555. }
  127556. declare module BABYLON {
  127557. /** Defines operator used for tonemapping */
  127558. export enum TonemappingOperator {
  127559. /** Hable */
  127560. Hable = 0,
  127561. /** Reinhard */
  127562. Reinhard = 1,
  127563. /** HejiDawson */
  127564. HejiDawson = 2,
  127565. /** Photographic */
  127566. Photographic = 3
  127567. }
  127568. /**
  127569. * Defines a post process to apply tone mapping
  127570. */
  127571. export class TonemapPostProcess extends PostProcess {
  127572. private _operator;
  127573. /** Defines the required exposure adjustement */
  127574. exposureAdjustment: number;
  127575. /**
  127576. * Creates a new TonemapPostProcess
  127577. * @param name defines the name of the postprocess
  127578. * @param _operator defines the operator to use
  127579. * @param exposureAdjustment defines the required exposure adjustement
  127580. * @param camera defines the camera to use (can be null)
  127581. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127582. * @param engine defines the hosting engine (can be ignore if camera is set)
  127583. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127584. */
  127585. constructor(name: string, _operator: TonemappingOperator,
  127586. /** Defines the required exposure adjustement */
  127587. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127588. }
  127589. }
  127590. declare module BABYLON {
  127591. /** @hidden */
  127592. export var depthVertexShader: {
  127593. name: string;
  127594. shader: string;
  127595. };
  127596. }
  127597. declare module BABYLON {
  127598. /** @hidden */
  127599. export var volumetricLightScatteringPixelShader: {
  127600. name: string;
  127601. shader: string;
  127602. };
  127603. }
  127604. declare module BABYLON {
  127605. /** @hidden */
  127606. export var volumetricLightScatteringPassVertexShader: {
  127607. name: string;
  127608. shader: string;
  127609. };
  127610. }
  127611. declare module BABYLON {
  127612. /** @hidden */
  127613. export var volumetricLightScatteringPassPixelShader: {
  127614. name: string;
  127615. shader: string;
  127616. };
  127617. }
  127618. declare module BABYLON {
  127619. /**
  127620. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127621. */
  127622. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127623. private _volumetricLightScatteringPass;
  127624. private _volumetricLightScatteringRTT;
  127625. private _viewPort;
  127626. private _screenCoordinates;
  127627. private _cachedDefines;
  127628. /**
  127629. * If not undefined, the mesh position is computed from the attached node position
  127630. */
  127631. attachedNode: {
  127632. position: Vector3;
  127633. };
  127634. /**
  127635. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127636. */
  127637. customMeshPosition: Vector3;
  127638. /**
  127639. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127640. */
  127641. useCustomMeshPosition: boolean;
  127642. /**
  127643. * If the post-process should inverse the light scattering direction
  127644. */
  127645. invert: boolean;
  127646. /**
  127647. * The internal mesh used by the post-process
  127648. */
  127649. mesh: Mesh;
  127650. /**
  127651. * @hidden
  127652. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127653. */
  127654. useDiffuseColor: boolean;
  127655. /**
  127656. * Array containing the excluded meshes not rendered in the internal pass
  127657. */
  127658. excludedMeshes: AbstractMesh[];
  127659. /**
  127660. * Controls the overall intensity of the post-process
  127661. */
  127662. exposure: number;
  127663. /**
  127664. * Dissipates each sample's contribution in range [0, 1]
  127665. */
  127666. decay: number;
  127667. /**
  127668. * Controls the overall intensity of each sample
  127669. */
  127670. weight: number;
  127671. /**
  127672. * Controls the density of each sample
  127673. */
  127674. density: number;
  127675. /**
  127676. * @constructor
  127677. * @param name The post-process name
  127678. * @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)
  127679. * @param camera The camera that the post-process will be attached to
  127680. * @param mesh The mesh used to create the light scattering
  127681. * @param samples The post-process quality, default 100
  127682. * @param samplingModeThe post-process filtering mode
  127683. * @param engine The babylon engine
  127684. * @param reusable If the post-process is reusable
  127685. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127686. */
  127687. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  127688. /**
  127689. * Returns the string "VolumetricLightScatteringPostProcess"
  127690. * @returns "VolumetricLightScatteringPostProcess"
  127691. */
  127692. getClassName(): string;
  127693. private _isReady;
  127694. /**
  127695. * Sets the new light position for light scattering effect
  127696. * @param position The new custom light position
  127697. */
  127698. setCustomMeshPosition(position: Vector3): void;
  127699. /**
  127700. * Returns the light position for light scattering effect
  127701. * @return Vector3 The custom light position
  127702. */
  127703. getCustomMeshPosition(): Vector3;
  127704. /**
  127705. * Disposes the internal assets and detaches the post-process from the camera
  127706. */
  127707. dispose(camera: Camera): void;
  127708. /**
  127709. * Returns the render target texture used by the post-process
  127710. * @return the render target texture used by the post-process
  127711. */
  127712. getPass(): RenderTargetTexture;
  127713. private _meshExcluded;
  127714. private _createPass;
  127715. private _updateMeshScreenCoordinates;
  127716. /**
  127717. * Creates a default mesh for the Volumeric Light Scattering post-process
  127718. * @param name The mesh name
  127719. * @param scene The scene where to create the mesh
  127720. * @return the default mesh
  127721. */
  127722. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  127723. }
  127724. }
  127725. declare module BABYLON {
  127726. interface Scene {
  127727. /** @hidden (Backing field) */
  127728. _boundingBoxRenderer: BoundingBoxRenderer;
  127729. /** @hidden (Backing field) */
  127730. _forceShowBoundingBoxes: boolean;
  127731. /**
  127732. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  127733. */
  127734. forceShowBoundingBoxes: boolean;
  127735. /**
  127736. * Gets the bounding box renderer associated with the scene
  127737. * @returns a BoundingBoxRenderer
  127738. */
  127739. getBoundingBoxRenderer(): BoundingBoxRenderer;
  127740. }
  127741. interface AbstractMesh {
  127742. /** @hidden (Backing field) */
  127743. _showBoundingBox: boolean;
  127744. /**
  127745. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  127746. */
  127747. showBoundingBox: boolean;
  127748. }
  127749. /**
  127750. * Component responsible of rendering the bounding box of the meshes in a scene.
  127751. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  127752. */
  127753. export class BoundingBoxRenderer implements ISceneComponent {
  127754. /**
  127755. * The component name helpfull to identify the component in the list of scene components.
  127756. */
  127757. readonly name: string;
  127758. /**
  127759. * The scene the component belongs to.
  127760. */
  127761. scene: Scene;
  127762. /**
  127763. * Color of the bounding box lines placed in front of an object
  127764. */
  127765. frontColor: Color3;
  127766. /**
  127767. * Color of the bounding box lines placed behind an object
  127768. */
  127769. backColor: Color3;
  127770. /**
  127771. * Defines if the renderer should show the back lines or not
  127772. */
  127773. showBackLines: boolean;
  127774. /**
  127775. * @hidden
  127776. */
  127777. renderList: SmartArray<BoundingBox>;
  127778. private _colorShader;
  127779. private _vertexBuffers;
  127780. private _indexBuffer;
  127781. private _fillIndexBuffer;
  127782. private _fillIndexData;
  127783. /**
  127784. * Instantiates a new bounding box renderer in a scene.
  127785. * @param scene the scene the renderer renders in
  127786. */
  127787. constructor(scene: Scene);
  127788. /**
  127789. * Registers the component in a given scene
  127790. */
  127791. register(): void;
  127792. private _evaluateSubMesh;
  127793. private _activeMesh;
  127794. private _prepareRessources;
  127795. private _createIndexBuffer;
  127796. /**
  127797. * Rebuilds the elements related to this component in case of
  127798. * context lost for instance.
  127799. */
  127800. rebuild(): void;
  127801. /**
  127802. * @hidden
  127803. */
  127804. reset(): void;
  127805. /**
  127806. * Render the bounding boxes of a specific rendering group
  127807. * @param renderingGroupId defines the rendering group to render
  127808. */
  127809. render(renderingGroupId: number): void;
  127810. /**
  127811. * In case of occlusion queries, we can render the occlusion bounding box through this method
  127812. * @param mesh Define the mesh to render the occlusion bounding box for
  127813. */
  127814. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  127815. /**
  127816. * Dispose and release the resources attached to this renderer.
  127817. */
  127818. dispose(): void;
  127819. }
  127820. }
  127821. declare module BABYLON {
  127822. /** @hidden */
  127823. export var depthPixelShader: {
  127824. name: string;
  127825. shader: string;
  127826. };
  127827. }
  127828. declare module BABYLON {
  127829. /**
  127830. * This represents a depth renderer in Babylon.
  127831. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127832. */
  127833. export class DepthRenderer {
  127834. private _scene;
  127835. private _depthMap;
  127836. private _effect;
  127837. private readonly _storeNonLinearDepth;
  127838. private readonly _clearColor;
  127839. /** Get if the depth renderer is using packed depth or not */
  127840. readonly isPacked: boolean;
  127841. private _cachedDefines;
  127842. private _camera;
  127843. /**
  127844. * Specifiess that the depth renderer will only be used within
  127845. * the camera it is created for.
  127846. * This can help forcing its rendering during the camera processing.
  127847. */
  127848. useOnlyInActiveCamera: boolean;
  127849. /** @hidden */
  127850. static _SceneComponentInitialization: (scene: Scene) => void;
  127851. /**
  127852. * Instantiates a depth renderer
  127853. * @param scene The scene the renderer belongs to
  127854. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127855. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127856. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127857. */
  127858. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127859. /**
  127860. * Creates the depth rendering effect and checks if the effect is ready.
  127861. * @param subMesh The submesh to be used to render the depth map of
  127862. * @param useInstances If multiple world instances should be used
  127863. * @returns if the depth renderer is ready to render the depth map
  127864. */
  127865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127866. /**
  127867. * Gets the texture which the depth map will be written to.
  127868. * @returns The depth map texture
  127869. */
  127870. getDepthMap(): RenderTargetTexture;
  127871. /**
  127872. * Disposes of the depth renderer.
  127873. */
  127874. dispose(): void;
  127875. }
  127876. }
  127877. declare module BABYLON {
  127878. interface Scene {
  127879. /** @hidden (Backing field) */
  127880. _depthRenderer: {
  127881. [id: string]: DepthRenderer;
  127882. };
  127883. /**
  127884. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  127885. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  127886. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127887. * @returns the created depth renderer
  127888. */
  127889. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  127890. /**
  127891. * Disables a depth renderer for a given camera
  127892. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  127893. */
  127894. disableDepthRenderer(camera?: Nullable<Camera>): void;
  127895. }
  127896. /**
  127897. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  127898. * in several rendering techniques.
  127899. */
  127900. export class DepthRendererSceneComponent implements ISceneComponent {
  127901. /**
  127902. * The component name helpfull to identify the component in the list of scene components.
  127903. */
  127904. readonly name: string;
  127905. /**
  127906. * The scene the component belongs to.
  127907. */
  127908. scene: Scene;
  127909. /**
  127910. * Creates a new instance of the component for the given scene
  127911. * @param scene Defines the scene to register the component in
  127912. */
  127913. constructor(scene: Scene);
  127914. /**
  127915. * Registers the component in a given scene
  127916. */
  127917. register(): void;
  127918. /**
  127919. * Rebuilds the elements related to this component in case of
  127920. * context lost for instance.
  127921. */
  127922. rebuild(): void;
  127923. /**
  127924. * Disposes the component and the associated ressources
  127925. */
  127926. dispose(): void;
  127927. private _gatherRenderTargets;
  127928. private _gatherActiveCameraRenderTargets;
  127929. }
  127930. }
  127931. declare module BABYLON {
  127932. /** @hidden */
  127933. export var outlinePixelShader: {
  127934. name: string;
  127935. shader: string;
  127936. };
  127937. }
  127938. declare module BABYLON {
  127939. /** @hidden */
  127940. export var outlineVertexShader: {
  127941. name: string;
  127942. shader: string;
  127943. };
  127944. }
  127945. declare module BABYLON {
  127946. interface Scene {
  127947. /** @hidden */
  127948. _outlineRenderer: OutlineRenderer;
  127949. /**
  127950. * Gets the outline renderer associated with the scene
  127951. * @returns a OutlineRenderer
  127952. */
  127953. getOutlineRenderer(): OutlineRenderer;
  127954. }
  127955. interface AbstractMesh {
  127956. /** @hidden (Backing field) */
  127957. _renderOutline: boolean;
  127958. /**
  127959. * Gets or sets a boolean indicating if the outline must be rendered as well
  127960. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  127961. */
  127962. renderOutline: boolean;
  127963. /** @hidden (Backing field) */
  127964. _renderOverlay: boolean;
  127965. /**
  127966. * Gets or sets a boolean indicating if the overlay must be rendered as well
  127967. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  127968. */
  127969. renderOverlay: boolean;
  127970. }
  127971. /**
  127972. * This class is responsible to draw bothe outline/overlay of meshes.
  127973. * It should not be used directly but through the available method on mesh.
  127974. */
  127975. export class OutlineRenderer implements ISceneComponent {
  127976. /**
  127977. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  127978. */
  127979. private static _StencilReference;
  127980. /**
  127981. * The name of the component. Each component must have a unique name.
  127982. */
  127983. name: string;
  127984. /**
  127985. * The scene the component belongs to.
  127986. */
  127987. scene: Scene;
  127988. /**
  127989. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  127990. */
  127991. zOffset: number;
  127992. private _engine;
  127993. private _effect;
  127994. private _cachedDefines;
  127995. private _savedDepthWrite;
  127996. /**
  127997. * Instantiates a new outline renderer. (There could be only one per scene).
  127998. * @param scene Defines the scene it belongs to
  127999. */
  128000. constructor(scene: Scene);
  128001. /**
  128002. * Register the component to one instance of a scene.
  128003. */
  128004. register(): void;
  128005. /**
  128006. * Rebuilds the elements related to this component in case of
  128007. * context lost for instance.
  128008. */
  128009. rebuild(): void;
  128010. /**
  128011. * Disposes the component and the associated ressources.
  128012. */
  128013. dispose(): void;
  128014. /**
  128015. * Renders the outline in the canvas.
  128016. * @param subMesh Defines the sumesh to render
  128017. * @param batch Defines the batch of meshes in case of instances
  128018. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128019. */
  128020. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128021. /**
  128022. * Returns whether or not the outline renderer is ready for a given submesh.
  128023. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128024. * @param subMesh Defines the submesh to check readyness for
  128025. * @param useInstances Defines wheter wee are trying to render instances or not
  128026. * @returns true if ready otherwise false
  128027. */
  128028. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128029. private _beforeRenderingMesh;
  128030. private _afterRenderingMesh;
  128031. }
  128032. }
  128033. declare module BABYLON {
  128034. /**
  128035. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128036. * @see http://doc.babylonjs.com/babylon101/sprites
  128037. */
  128038. export class SpritePackedManager extends SpriteManager {
  128039. /** defines the packed manager's name */
  128040. name: string;
  128041. /**
  128042. * Creates a new sprite manager from a packed sprite sheet
  128043. * @param name defines the manager's name
  128044. * @param imgUrl defines the sprite sheet url
  128045. * @param capacity defines the maximum allowed number of sprites
  128046. * @param scene defines the hosting scene
  128047. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128048. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128049. * @param samplingMode defines the smapling mode to use with spritesheet
  128050. * @param fromPacked set to true; do not alter
  128051. */
  128052. constructor(
  128053. /** defines the packed manager's name */
  128054. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128055. }
  128056. }
  128057. declare module BABYLON {
  128058. /**
  128059. * Defines the list of states available for a task inside a AssetsManager
  128060. */
  128061. export enum AssetTaskState {
  128062. /**
  128063. * Initialization
  128064. */
  128065. INIT = 0,
  128066. /**
  128067. * Running
  128068. */
  128069. RUNNING = 1,
  128070. /**
  128071. * Done
  128072. */
  128073. DONE = 2,
  128074. /**
  128075. * Error
  128076. */
  128077. ERROR = 3
  128078. }
  128079. /**
  128080. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128081. */
  128082. export abstract class AbstractAssetTask {
  128083. /**
  128084. * Task name
  128085. */ name: string;
  128086. /**
  128087. * Callback called when the task is successful
  128088. */
  128089. onSuccess: (task: any) => void;
  128090. /**
  128091. * Callback called when the task is not successful
  128092. */
  128093. onError: (task: any, message?: string, exception?: any) => void;
  128094. /**
  128095. * Creates a new AssetsManager
  128096. * @param name defines the name of the task
  128097. */
  128098. constructor(
  128099. /**
  128100. * Task name
  128101. */ name: string);
  128102. private _isCompleted;
  128103. private _taskState;
  128104. private _errorObject;
  128105. /**
  128106. * Get if the task is completed
  128107. */
  128108. readonly isCompleted: boolean;
  128109. /**
  128110. * Gets the current state of the task
  128111. */
  128112. readonly taskState: AssetTaskState;
  128113. /**
  128114. * Gets the current error object (if task is in error)
  128115. */
  128116. readonly errorObject: {
  128117. message?: string;
  128118. exception?: any;
  128119. };
  128120. /**
  128121. * Internal only
  128122. * @hidden
  128123. */
  128124. _setErrorObject(message?: string, exception?: any): void;
  128125. /**
  128126. * Execute the current task
  128127. * @param scene defines the scene where you want your assets to be loaded
  128128. * @param onSuccess is a callback called when the task is successfully executed
  128129. * @param onError is a callback called if an error occurs
  128130. */
  128131. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128132. /**
  128133. * Execute the current task
  128134. * @param scene defines the scene where you want your assets to be loaded
  128135. * @param onSuccess is a callback called when the task is successfully executed
  128136. * @param onError is a callback called if an error occurs
  128137. */
  128138. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128139. /**
  128140. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128141. * This can be used with failed tasks that have the reason for failure fixed.
  128142. */
  128143. reset(): void;
  128144. private onErrorCallback;
  128145. private onDoneCallback;
  128146. }
  128147. /**
  128148. * Define the interface used by progress events raised during assets loading
  128149. */
  128150. export interface IAssetsProgressEvent {
  128151. /**
  128152. * Defines the number of remaining tasks to process
  128153. */
  128154. remainingCount: number;
  128155. /**
  128156. * Defines the total number of tasks
  128157. */
  128158. totalCount: number;
  128159. /**
  128160. * Defines the task that was just processed
  128161. */
  128162. task: AbstractAssetTask;
  128163. }
  128164. /**
  128165. * Class used to share progress information about assets loading
  128166. */
  128167. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128168. /**
  128169. * Defines the number of remaining tasks to process
  128170. */
  128171. remainingCount: number;
  128172. /**
  128173. * Defines the total number of tasks
  128174. */
  128175. totalCount: number;
  128176. /**
  128177. * Defines the task that was just processed
  128178. */
  128179. task: AbstractAssetTask;
  128180. /**
  128181. * Creates a AssetsProgressEvent
  128182. * @param remainingCount defines the number of remaining tasks to process
  128183. * @param totalCount defines the total number of tasks
  128184. * @param task defines the task that was just processed
  128185. */
  128186. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128187. }
  128188. /**
  128189. * Define a task used by AssetsManager to load meshes
  128190. */
  128191. export class MeshAssetTask extends AbstractAssetTask {
  128192. /**
  128193. * Defines the name of the task
  128194. */
  128195. name: string;
  128196. /**
  128197. * Defines the list of mesh's names you want to load
  128198. */
  128199. meshesNames: any;
  128200. /**
  128201. * Defines the root url to use as a base to load your meshes and associated resources
  128202. */
  128203. rootUrl: string;
  128204. /**
  128205. * Defines the filename of the scene to load from
  128206. */
  128207. sceneFilename: string;
  128208. /**
  128209. * Gets the list of loaded meshes
  128210. */
  128211. loadedMeshes: Array<AbstractMesh>;
  128212. /**
  128213. * Gets the list of loaded particle systems
  128214. */
  128215. loadedParticleSystems: Array<IParticleSystem>;
  128216. /**
  128217. * Gets the list of loaded skeletons
  128218. */
  128219. loadedSkeletons: Array<Skeleton>;
  128220. /**
  128221. * Gets the list of loaded animation groups
  128222. */
  128223. loadedAnimationGroups: Array<AnimationGroup>;
  128224. /**
  128225. * Callback called when the task is successful
  128226. */
  128227. onSuccess: (task: MeshAssetTask) => void;
  128228. /**
  128229. * Callback called when the task is successful
  128230. */
  128231. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128232. /**
  128233. * Creates a new MeshAssetTask
  128234. * @param name defines the name of the task
  128235. * @param meshesNames defines the list of mesh's names you want to load
  128236. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128237. * @param sceneFilename defines the filename of the scene to load from
  128238. */
  128239. constructor(
  128240. /**
  128241. * Defines the name of the task
  128242. */
  128243. name: string,
  128244. /**
  128245. * Defines the list of mesh's names you want to load
  128246. */
  128247. meshesNames: any,
  128248. /**
  128249. * Defines the root url to use as a base to load your meshes and associated resources
  128250. */
  128251. rootUrl: string,
  128252. /**
  128253. * Defines the filename of the scene to load from
  128254. */
  128255. sceneFilename: string);
  128256. /**
  128257. * Execute the current task
  128258. * @param scene defines the scene where you want your assets to be loaded
  128259. * @param onSuccess is a callback called when the task is successfully executed
  128260. * @param onError is a callback called if an error occurs
  128261. */
  128262. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128263. }
  128264. /**
  128265. * Define a task used by AssetsManager to load text content
  128266. */
  128267. export class TextFileAssetTask extends AbstractAssetTask {
  128268. /**
  128269. * Defines the name of the task
  128270. */
  128271. name: string;
  128272. /**
  128273. * Defines the location of the file to load
  128274. */
  128275. url: string;
  128276. /**
  128277. * Gets the loaded text string
  128278. */
  128279. text: string;
  128280. /**
  128281. * Callback called when the task is successful
  128282. */
  128283. onSuccess: (task: TextFileAssetTask) => void;
  128284. /**
  128285. * Callback called when the task is successful
  128286. */
  128287. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128288. /**
  128289. * Creates a new TextFileAssetTask object
  128290. * @param name defines the name of the task
  128291. * @param url defines the location of the file to load
  128292. */
  128293. constructor(
  128294. /**
  128295. * Defines the name of the task
  128296. */
  128297. name: string,
  128298. /**
  128299. * Defines the location of the file to load
  128300. */
  128301. url: string);
  128302. /**
  128303. * Execute the current task
  128304. * @param scene defines the scene where you want your assets to be loaded
  128305. * @param onSuccess is a callback called when the task is successfully executed
  128306. * @param onError is a callback called if an error occurs
  128307. */
  128308. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128309. }
  128310. /**
  128311. * Define a task used by AssetsManager to load binary data
  128312. */
  128313. export class BinaryFileAssetTask extends AbstractAssetTask {
  128314. /**
  128315. * Defines the name of the task
  128316. */
  128317. name: string;
  128318. /**
  128319. * Defines the location of the file to load
  128320. */
  128321. url: string;
  128322. /**
  128323. * Gets the lodaded data (as an array buffer)
  128324. */
  128325. data: ArrayBuffer;
  128326. /**
  128327. * Callback called when the task is successful
  128328. */
  128329. onSuccess: (task: BinaryFileAssetTask) => void;
  128330. /**
  128331. * Callback called when the task is successful
  128332. */
  128333. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128334. /**
  128335. * Creates a new BinaryFileAssetTask object
  128336. * @param name defines the name of the new task
  128337. * @param url defines the location of the file to load
  128338. */
  128339. constructor(
  128340. /**
  128341. * Defines the name of the task
  128342. */
  128343. name: string,
  128344. /**
  128345. * Defines the location of the file to load
  128346. */
  128347. url: string);
  128348. /**
  128349. * Execute the current task
  128350. * @param scene defines the scene where you want your assets to be loaded
  128351. * @param onSuccess is a callback called when the task is successfully executed
  128352. * @param onError is a callback called if an error occurs
  128353. */
  128354. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128355. }
  128356. /**
  128357. * Define a task used by AssetsManager to load images
  128358. */
  128359. export class ImageAssetTask extends AbstractAssetTask {
  128360. /**
  128361. * Defines the name of the task
  128362. */
  128363. name: string;
  128364. /**
  128365. * Defines the location of the image to load
  128366. */
  128367. url: string;
  128368. /**
  128369. * Gets the loaded images
  128370. */
  128371. image: HTMLImageElement;
  128372. /**
  128373. * Callback called when the task is successful
  128374. */
  128375. onSuccess: (task: ImageAssetTask) => void;
  128376. /**
  128377. * Callback called when the task is successful
  128378. */
  128379. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128380. /**
  128381. * Creates a new ImageAssetTask
  128382. * @param name defines the name of the task
  128383. * @param url defines the location of the image to load
  128384. */
  128385. constructor(
  128386. /**
  128387. * Defines the name of the task
  128388. */
  128389. name: string,
  128390. /**
  128391. * Defines the location of the image to load
  128392. */
  128393. url: string);
  128394. /**
  128395. * Execute the current task
  128396. * @param scene defines the scene where you want your assets to be loaded
  128397. * @param onSuccess is a callback called when the task is successfully executed
  128398. * @param onError is a callback called if an error occurs
  128399. */
  128400. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128401. }
  128402. /**
  128403. * Defines the interface used by texture loading tasks
  128404. */
  128405. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128406. /**
  128407. * Gets the loaded texture
  128408. */
  128409. texture: TEX;
  128410. }
  128411. /**
  128412. * Define a task used by AssetsManager to load 2D textures
  128413. */
  128414. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128415. /**
  128416. * Defines the name of the task
  128417. */
  128418. name: string;
  128419. /**
  128420. * Defines the location of the file to load
  128421. */
  128422. url: string;
  128423. /**
  128424. * Defines if mipmap should not be generated (default is false)
  128425. */
  128426. noMipmap?: boolean | undefined;
  128427. /**
  128428. * Defines if texture must be inverted on Y axis (default is false)
  128429. */
  128430. invertY?: boolean | undefined;
  128431. /**
  128432. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128433. */
  128434. samplingMode: number;
  128435. /**
  128436. * Gets the loaded texture
  128437. */
  128438. texture: Texture;
  128439. /**
  128440. * Callback called when the task is successful
  128441. */
  128442. onSuccess: (task: TextureAssetTask) => void;
  128443. /**
  128444. * Callback called when the task is successful
  128445. */
  128446. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128447. /**
  128448. * Creates a new TextureAssetTask object
  128449. * @param name defines the name of the task
  128450. * @param url defines the location of the file to load
  128451. * @param noMipmap defines if mipmap should not be generated (default is false)
  128452. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128453. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128454. */
  128455. constructor(
  128456. /**
  128457. * Defines the name of the task
  128458. */
  128459. name: string,
  128460. /**
  128461. * Defines the location of the file to load
  128462. */
  128463. url: string,
  128464. /**
  128465. * Defines if mipmap should not be generated (default is false)
  128466. */
  128467. noMipmap?: boolean | undefined,
  128468. /**
  128469. * Defines if texture must be inverted on Y axis (default is false)
  128470. */
  128471. invertY?: boolean | undefined,
  128472. /**
  128473. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128474. */
  128475. samplingMode?: number);
  128476. /**
  128477. * Execute the current task
  128478. * @param scene defines the scene where you want your assets to be loaded
  128479. * @param onSuccess is a callback called when the task is successfully executed
  128480. * @param onError is a callback called if an error occurs
  128481. */
  128482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128483. }
  128484. /**
  128485. * Define a task used by AssetsManager to load cube textures
  128486. */
  128487. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128488. /**
  128489. * Defines the name of the task
  128490. */
  128491. name: string;
  128492. /**
  128493. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128494. */
  128495. url: string;
  128496. /**
  128497. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128498. */
  128499. extensions?: string[] | undefined;
  128500. /**
  128501. * Defines if mipmaps should not be generated (default is false)
  128502. */
  128503. noMipmap?: boolean | undefined;
  128504. /**
  128505. * Defines the explicit list of files (undefined by default)
  128506. */
  128507. files?: string[] | undefined;
  128508. /**
  128509. * Gets the loaded texture
  128510. */
  128511. texture: CubeTexture;
  128512. /**
  128513. * Callback called when the task is successful
  128514. */
  128515. onSuccess: (task: CubeTextureAssetTask) => void;
  128516. /**
  128517. * Callback called when the task is successful
  128518. */
  128519. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128520. /**
  128521. * Creates a new CubeTextureAssetTask
  128522. * @param name defines the name of the task
  128523. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128524. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128525. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128526. * @param files defines the explicit list of files (undefined by default)
  128527. */
  128528. constructor(
  128529. /**
  128530. * Defines the name of the task
  128531. */
  128532. name: string,
  128533. /**
  128534. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128535. */
  128536. url: string,
  128537. /**
  128538. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128539. */
  128540. extensions?: string[] | undefined,
  128541. /**
  128542. * Defines if mipmaps should not be generated (default is false)
  128543. */
  128544. noMipmap?: boolean | undefined,
  128545. /**
  128546. * Defines the explicit list of files (undefined by default)
  128547. */
  128548. files?: string[] | undefined);
  128549. /**
  128550. * Execute the current task
  128551. * @param scene defines the scene where you want your assets to be loaded
  128552. * @param onSuccess is a callback called when the task is successfully executed
  128553. * @param onError is a callback called if an error occurs
  128554. */
  128555. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128556. }
  128557. /**
  128558. * Define a task used by AssetsManager to load HDR cube textures
  128559. */
  128560. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128561. /**
  128562. * Defines the name of the task
  128563. */
  128564. name: string;
  128565. /**
  128566. * Defines the location of the file to load
  128567. */
  128568. url: string;
  128569. /**
  128570. * Defines the desired size (the more it increases the longer the generation will be)
  128571. */
  128572. size: number;
  128573. /**
  128574. * Defines if mipmaps should not be generated (default is false)
  128575. */
  128576. noMipmap: boolean;
  128577. /**
  128578. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128579. */
  128580. generateHarmonics: boolean;
  128581. /**
  128582. * 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)
  128583. */
  128584. gammaSpace: boolean;
  128585. /**
  128586. * Internal Use Only
  128587. */
  128588. reserved: boolean;
  128589. /**
  128590. * Gets the loaded texture
  128591. */
  128592. texture: HDRCubeTexture;
  128593. /**
  128594. * Callback called when the task is successful
  128595. */
  128596. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128597. /**
  128598. * Callback called when the task is successful
  128599. */
  128600. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128601. /**
  128602. * Creates a new HDRCubeTextureAssetTask object
  128603. * @param name defines the name of the task
  128604. * @param url defines the location of the file to load
  128605. * @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.
  128606. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128607. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128608. * @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)
  128609. * @param reserved Internal use only
  128610. */
  128611. constructor(
  128612. /**
  128613. * Defines the name of the task
  128614. */
  128615. name: string,
  128616. /**
  128617. * Defines the location of the file to load
  128618. */
  128619. url: string,
  128620. /**
  128621. * Defines the desired size (the more it increases the longer the generation will be)
  128622. */
  128623. size: number,
  128624. /**
  128625. * Defines if mipmaps should not be generated (default is false)
  128626. */
  128627. noMipmap?: boolean,
  128628. /**
  128629. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128630. */
  128631. generateHarmonics?: boolean,
  128632. /**
  128633. * 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)
  128634. */
  128635. gammaSpace?: boolean,
  128636. /**
  128637. * Internal Use Only
  128638. */
  128639. reserved?: boolean);
  128640. /**
  128641. * Execute the current task
  128642. * @param scene defines the scene where you want your assets to be loaded
  128643. * @param onSuccess is a callback called when the task is successfully executed
  128644. * @param onError is a callback called if an error occurs
  128645. */
  128646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128647. }
  128648. /**
  128649. * Define a task used by AssetsManager to load Equirectangular cube textures
  128650. */
  128651. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128652. /**
  128653. * Defines the name of the task
  128654. */
  128655. name: string;
  128656. /**
  128657. * Defines the location of the file to load
  128658. */
  128659. url: string;
  128660. /**
  128661. * Defines the desired size (the more it increases the longer the generation will be)
  128662. */
  128663. size: number;
  128664. /**
  128665. * Defines if mipmaps should not be generated (default is false)
  128666. */
  128667. noMipmap: boolean;
  128668. /**
  128669. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128670. * but the standard material would require them in Gamma space) (default is true)
  128671. */
  128672. gammaSpace: boolean;
  128673. /**
  128674. * Gets the loaded texture
  128675. */
  128676. texture: EquiRectangularCubeTexture;
  128677. /**
  128678. * Callback called when the task is successful
  128679. */
  128680. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  128681. /**
  128682. * Callback called when the task is successful
  128683. */
  128684. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  128685. /**
  128686. * Creates a new EquiRectangularCubeTextureAssetTask object
  128687. * @param name defines the name of the task
  128688. * @param url defines the location of the file to load
  128689. * @param size defines the desired size (the more it increases the longer the generation will be)
  128690. * If the size is omitted this implies you are using a preprocessed cubemap.
  128691. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128692. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  128693. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  128694. * (default is true)
  128695. */
  128696. constructor(
  128697. /**
  128698. * Defines the name of the task
  128699. */
  128700. name: string,
  128701. /**
  128702. * Defines the location of the file to load
  128703. */
  128704. url: string,
  128705. /**
  128706. * Defines the desired size (the more it increases the longer the generation will be)
  128707. */
  128708. size: number,
  128709. /**
  128710. * Defines if mipmaps should not be generated (default is false)
  128711. */
  128712. noMipmap?: boolean,
  128713. /**
  128714. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128715. * but the standard material would require them in Gamma space) (default is true)
  128716. */
  128717. gammaSpace?: boolean);
  128718. /**
  128719. * Execute the current task
  128720. * @param scene defines the scene where you want your assets to be loaded
  128721. * @param onSuccess is a callback called when the task is successfully executed
  128722. * @param onError is a callback called if an error occurs
  128723. */
  128724. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128725. }
  128726. /**
  128727. * This class can be used to easily import assets into a scene
  128728. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  128729. */
  128730. export class AssetsManager {
  128731. private _scene;
  128732. private _isLoading;
  128733. protected _tasks: AbstractAssetTask[];
  128734. protected _waitingTasksCount: number;
  128735. protected _totalTasksCount: number;
  128736. /**
  128737. * Callback called when all tasks are processed
  128738. */
  128739. onFinish: (tasks: AbstractAssetTask[]) => void;
  128740. /**
  128741. * Callback called when a task is successful
  128742. */
  128743. onTaskSuccess: (task: AbstractAssetTask) => void;
  128744. /**
  128745. * Callback called when a task had an error
  128746. */
  128747. onTaskError: (task: AbstractAssetTask) => void;
  128748. /**
  128749. * Callback called when a task is done (whatever the result is)
  128750. */
  128751. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  128752. /**
  128753. * Observable called when all tasks are processed
  128754. */
  128755. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  128756. /**
  128757. * Observable called when a task had an error
  128758. */
  128759. onTaskErrorObservable: Observable<AbstractAssetTask>;
  128760. /**
  128761. * Observable called when all tasks were executed
  128762. */
  128763. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  128764. /**
  128765. * Observable called when a task is done (whatever the result is)
  128766. */
  128767. onProgressObservable: Observable<IAssetsProgressEvent>;
  128768. /**
  128769. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  128770. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128771. */
  128772. useDefaultLoadingScreen: boolean;
  128773. /**
  128774. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  128775. * when all assets have been downloaded.
  128776. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  128777. */
  128778. autoHideLoadingUI: boolean;
  128779. /**
  128780. * Creates a new AssetsManager
  128781. * @param scene defines the scene to work on
  128782. */
  128783. constructor(scene: Scene);
  128784. /**
  128785. * Add a MeshAssetTask to the list of active tasks
  128786. * @param taskName defines the name of the new task
  128787. * @param meshesNames defines the name of meshes to load
  128788. * @param rootUrl defines the root url to use to locate files
  128789. * @param sceneFilename defines the filename of the scene file
  128790. * @returns a new MeshAssetTask object
  128791. */
  128792. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  128793. /**
  128794. * Add a TextFileAssetTask to the list of active tasks
  128795. * @param taskName defines the name of the new task
  128796. * @param url defines the url of the file to load
  128797. * @returns a new TextFileAssetTask object
  128798. */
  128799. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  128800. /**
  128801. * Add a BinaryFileAssetTask to the list of active tasks
  128802. * @param taskName defines the name of the new task
  128803. * @param url defines the url of the file to load
  128804. * @returns a new BinaryFileAssetTask object
  128805. */
  128806. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  128807. /**
  128808. * Add a ImageAssetTask to the list of active tasks
  128809. * @param taskName defines the name of the new task
  128810. * @param url defines the url of the file to load
  128811. * @returns a new ImageAssetTask object
  128812. */
  128813. addImageTask(taskName: string, url: string): ImageAssetTask;
  128814. /**
  128815. * Add a TextureAssetTask to the list of active tasks
  128816. * @param taskName defines the name of the new task
  128817. * @param url defines the url of the file to load
  128818. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128819. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  128820. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  128821. * @returns a new TextureAssetTask object
  128822. */
  128823. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  128824. /**
  128825. * Add a CubeTextureAssetTask to the list of active tasks
  128826. * @param taskName defines the name of the new task
  128827. * @param url defines the url of the file to load
  128828. * @param extensions defines the extension to use to load the cube map (can be null)
  128829. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128830. * @param files defines the list of files to load (can be null)
  128831. * @returns a new CubeTextureAssetTask object
  128832. */
  128833. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  128834. /**
  128835. *
  128836. * Add a HDRCubeTextureAssetTask to the list of active tasks
  128837. * @param taskName defines the name of the new task
  128838. * @param url defines the url of the file to load
  128839. * @param size defines the size you want for the cubemap (can be null)
  128840. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128841. * @param generateHarmonics defines if you want to automatically generate (true by default)
  128842. * @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)
  128843. * @param reserved Internal use only
  128844. * @returns a new HDRCubeTextureAssetTask object
  128845. */
  128846. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  128847. /**
  128848. *
  128849. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  128850. * @param taskName defines the name of the new task
  128851. * @param url defines the url of the file to load
  128852. * @param size defines the size you want for the cubemap (can be null)
  128853. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128854. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128855. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128856. * @returns a new EquiRectangularCubeTextureAssetTask object
  128857. */
  128858. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  128859. /**
  128860. * Remove a task from the assets manager.
  128861. * @param task the task to remove
  128862. */
  128863. removeTask(task: AbstractAssetTask): void;
  128864. private _decreaseWaitingTasksCount;
  128865. private _runTask;
  128866. /**
  128867. * Reset the AssetsManager and remove all tasks
  128868. * @return the current instance of the AssetsManager
  128869. */
  128870. reset(): AssetsManager;
  128871. /**
  128872. * Start the loading process
  128873. * @return the current instance of the AssetsManager
  128874. */
  128875. load(): AssetsManager;
  128876. /**
  128877. * Start the loading process as an async operation
  128878. * @return a promise returning the list of failed tasks
  128879. */
  128880. loadAsync(): Promise<void>;
  128881. }
  128882. }
  128883. declare module BABYLON {
  128884. /**
  128885. * Wrapper class for promise with external resolve and reject.
  128886. */
  128887. export class Deferred<T> {
  128888. /**
  128889. * The promise associated with this deferred object.
  128890. */
  128891. readonly promise: Promise<T>;
  128892. private _resolve;
  128893. private _reject;
  128894. /**
  128895. * The resolve method of the promise associated with this deferred object.
  128896. */
  128897. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  128898. /**
  128899. * The reject method of the promise associated with this deferred object.
  128900. */
  128901. readonly reject: (reason?: any) => void;
  128902. /**
  128903. * Constructor for this deferred object.
  128904. */
  128905. constructor();
  128906. }
  128907. }
  128908. declare module BABYLON {
  128909. /**
  128910. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  128911. */
  128912. export class MeshExploder {
  128913. private _centerMesh;
  128914. private _meshes;
  128915. private _meshesOrigins;
  128916. private _toCenterVectors;
  128917. private _scaledDirection;
  128918. private _newPosition;
  128919. private _centerPosition;
  128920. /**
  128921. * Explodes meshes from a center mesh.
  128922. * @param meshes The meshes to explode.
  128923. * @param centerMesh The mesh to be center of explosion.
  128924. */
  128925. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  128926. private _setCenterMesh;
  128927. /**
  128928. * Get class name
  128929. * @returns "MeshExploder"
  128930. */
  128931. getClassName(): string;
  128932. /**
  128933. * "Exploded meshes"
  128934. * @returns Array of meshes with the centerMesh at index 0.
  128935. */
  128936. getMeshes(): Array<Mesh>;
  128937. /**
  128938. * Explodes meshes giving a specific direction
  128939. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  128940. */
  128941. explode(direction?: number): void;
  128942. }
  128943. }
  128944. declare module BABYLON {
  128945. /**
  128946. * Class used to help managing file picking and drag'n'drop
  128947. */
  128948. export class FilesInput {
  128949. /**
  128950. * List of files ready to be loaded
  128951. */
  128952. static readonly FilesToLoad: {
  128953. [key: string]: File;
  128954. };
  128955. /**
  128956. * Callback called when a file is processed
  128957. */
  128958. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  128959. private _engine;
  128960. private _currentScene;
  128961. private _sceneLoadedCallback;
  128962. private _progressCallback;
  128963. private _additionalRenderLoopLogicCallback;
  128964. private _textureLoadingCallback;
  128965. private _startingProcessingFilesCallback;
  128966. private _onReloadCallback;
  128967. private _errorCallback;
  128968. private _elementToMonitor;
  128969. private _sceneFileToLoad;
  128970. private _filesToLoad;
  128971. /**
  128972. * Creates a new FilesInput
  128973. * @param engine defines the rendering engine
  128974. * @param scene defines the hosting scene
  128975. * @param sceneLoadedCallback callback called when scene is loaded
  128976. * @param progressCallback callback called to track progress
  128977. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  128978. * @param textureLoadingCallback callback called when a texture is loading
  128979. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  128980. * @param onReloadCallback callback called when a reload is requested
  128981. * @param errorCallback callback call if an error occurs
  128982. */
  128983. 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);
  128984. private _dragEnterHandler;
  128985. private _dragOverHandler;
  128986. private _dropHandler;
  128987. /**
  128988. * Calls this function to listen to drag'n'drop events on a specific DOM element
  128989. * @param elementToMonitor defines the DOM element to track
  128990. */
  128991. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  128992. /**
  128993. * Release all associated resources
  128994. */
  128995. dispose(): void;
  128996. private renderFunction;
  128997. private drag;
  128998. private drop;
  128999. private _traverseFolder;
  129000. private _processFiles;
  129001. /**
  129002. * Load files from a drop event
  129003. * @param event defines the drop event to use as source
  129004. */
  129005. loadFiles(event: any): void;
  129006. private _processReload;
  129007. /**
  129008. * Reload the current scene from the loaded files
  129009. */
  129010. reload(): void;
  129011. }
  129012. }
  129013. declare module BABYLON {
  129014. /**
  129015. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129017. */
  129018. export class SceneOptimization {
  129019. /**
  129020. * Defines the priority of this optimization (0 by default which means first in the list)
  129021. */
  129022. priority: number;
  129023. /**
  129024. * Gets a string describing the action executed by the current optimization
  129025. * @returns description string
  129026. */
  129027. getDescription(): string;
  129028. /**
  129029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129030. * @param scene defines the current scene where to apply this optimization
  129031. * @param optimizer defines the current optimizer
  129032. * @returns true if everything that can be done was applied
  129033. */
  129034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129035. /**
  129036. * Creates the SceneOptimization object
  129037. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129038. * @param desc defines the description associated with the optimization
  129039. */
  129040. constructor(
  129041. /**
  129042. * Defines the priority of this optimization (0 by default which means first in the list)
  129043. */
  129044. priority?: number);
  129045. }
  129046. /**
  129047. * Defines an optimization used to reduce the size of render target textures
  129048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129049. */
  129050. export class TextureOptimization extends SceneOptimization {
  129051. /**
  129052. * Defines the priority of this optimization (0 by default which means first in the list)
  129053. */
  129054. priority: number;
  129055. /**
  129056. * 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
  129057. */
  129058. maximumSize: number;
  129059. /**
  129060. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129061. */
  129062. step: number;
  129063. /**
  129064. * Gets a string describing the action executed by the current optimization
  129065. * @returns description string
  129066. */
  129067. getDescription(): string;
  129068. /**
  129069. * Creates the TextureOptimization object
  129070. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129071. * @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
  129072. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129073. */
  129074. constructor(
  129075. /**
  129076. * Defines the priority of this optimization (0 by default which means first in the list)
  129077. */
  129078. priority?: number,
  129079. /**
  129080. * 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
  129081. */
  129082. maximumSize?: number,
  129083. /**
  129084. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129085. */
  129086. step?: number);
  129087. /**
  129088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129089. * @param scene defines the current scene where to apply this optimization
  129090. * @param optimizer defines the current optimizer
  129091. * @returns true if everything that can be done was applied
  129092. */
  129093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129094. }
  129095. /**
  129096. * Defines an optimization used to increase or decrease the rendering resolution
  129097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129098. */
  129099. export class HardwareScalingOptimization extends SceneOptimization {
  129100. /**
  129101. * Defines the priority of this optimization (0 by default which means first in the list)
  129102. */
  129103. priority: number;
  129104. /**
  129105. * Defines the maximum scale to use (2 by default)
  129106. */
  129107. maximumScale: number;
  129108. /**
  129109. * Defines the step to use between two passes (0.5 by default)
  129110. */
  129111. step: number;
  129112. private _currentScale;
  129113. private _directionOffset;
  129114. /**
  129115. * Gets a string describing the action executed by the current optimization
  129116. * @return description string
  129117. */
  129118. getDescription(): string;
  129119. /**
  129120. * Creates the HardwareScalingOptimization object
  129121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129122. * @param maximumScale defines the maximum scale to use (2 by default)
  129123. * @param step defines the step to use between two passes (0.5 by default)
  129124. */
  129125. constructor(
  129126. /**
  129127. * Defines the priority of this optimization (0 by default which means first in the list)
  129128. */
  129129. priority?: number,
  129130. /**
  129131. * Defines the maximum scale to use (2 by default)
  129132. */
  129133. maximumScale?: number,
  129134. /**
  129135. * Defines the step to use between two passes (0.5 by default)
  129136. */
  129137. step?: number);
  129138. /**
  129139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129140. * @param scene defines the current scene where to apply this optimization
  129141. * @param optimizer defines the current optimizer
  129142. * @returns true if everything that can be done was applied
  129143. */
  129144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129145. }
  129146. /**
  129147. * Defines an optimization used to remove shadows
  129148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129149. */
  129150. export class ShadowsOptimization extends SceneOptimization {
  129151. /**
  129152. * Gets a string describing the action executed by the current optimization
  129153. * @return description string
  129154. */
  129155. getDescription(): string;
  129156. /**
  129157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129158. * @param scene defines the current scene where to apply this optimization
  129159. * @param optimizer defines the current optimizer
  129160. * @returns true if everything that can be done was applied
  129161. */
  129162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129163. }
  129164. /**
  129165. * Defines an optimization used to turn post-processes off
  129166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129167. */
  129168. export class PostProcessesOptimization extends SceneOptimization {
  129169. /**
  129170. * Gets a string describing the action executed by the current optimization
  129171. * @return description string
  129172. */
  129173. getDescription(): string;
  129174. /**
  129175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129176. * @param scene defines the current scene where to apply this optimization
  129177. * @param optimizer defines the current optimizer
  129178. * @returns true if everything that can be done was applied
  129179. */
  129180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129181. }
  129182. /**
  129183. * Defines an optimization used to turn lens flares off
  129184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129185. */
  129186. export class LensFlaresOptimization extends SceneOptimization {
  129187. /**
  129188. * Gets a string describing the action executed by the current optimization
  129189. * @return description string
  129190. */
  129191. getDescription(): string;
  129192. /**
  129193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129194. * @param scene defines the current scene where to apply this optimization
  129195. * @param optimizer defines the current optimizer
  129196. * @returns true if everything that can be done was applied
  129197. */
  129198. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129199. }
  129200. /**
  129201. * Defines an optimization based on user defined callback.
  129202. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129203. */
  129204. export class CustomOptimization extends SceneOptimization {
  129205. /**
  129206. * Callback called to apply the custom optimization.
  129207. */
  129208. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129209. /**
  129210. * Callback called to get custom description
  129211. */
  129212. onGetDescription: () => string;
  129213. /**
  129214. * Gets a string describing the action executed by the current optimization
  129215. * @returns description string
  129216. */
  129217. getDescription(): string;
  129218. /**
  129219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129220. * @param scene defines the current scene where to apply this optimization
  129221. * @param optimizer defines the current optimizer
  129222. * @returns true if everything that can be done was applied
  129223. */
  129224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129225. }
  129226. /**
  129227. * Defines an optimization used to turn particles off
  129228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129229. */
  129230. export class ParticlesOptimization extends SceneOptimization {
  129231. /**
  129232. * Gets a string describing the action executed by the current optimization
  129233. * @return description string
  129234. */
  129235. getDescription(): string;
  129236. /**
  129237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129238. * @param scene defines the current scene where to apply this optimization
  129239. * @param optimizer defines the current optimizer
  129240. * @returns true if everything that can be done was applied
  129241. */
  129242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129243. }
  129244. /**
  129245. * Defines an optimization used to turn render targets off
  129246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129247. */
  129248. export class RenderTargetsOptimization extends SceneOptimization {
  129249. /**
  129250. * Gets a string describing the action executed by the current optimization
  129251. * @return description string
  129252. */
  129253. getDescription(): string;
  129254. /**
  129255. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129256. * @param scene defines the current scene where to apply this optimization
  129257. * @param optimizer defines the current optimizer
  129258. * @returns true if everything that can be done was applied
  129259. */
  129260. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129261. }
  129262. /**
  129263. * Defines an optimization used to merge meshes with compatible materials
  129264. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129265. */
  129266. export class MergeMeshesOptimization extends SceneOptimization {
  129267. private static _UpdateSelectionTree;
  129268. /**
  129269. * Gets or sets a boolean which defines if optimization octree has to be updated
  129270. */
  129271. /**
  129272. * Gets or sets a boolean which defines if optimization octree has to be updated
  129273. */
  129274. static UpdateSelectionTree: boolean;
  129275. /**
  129276. * Gets a string describing the action executed by the current optimization
  129277. * @return description string
  129278. */
  129279. getDescription(): string;
  129280. private _canBeMerged;
  129281. /**
  129282. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129283. * @param scene defines the current scene where to apply this optimization
  129284. * @param optimizer defines the current optimizer
  129285. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129286. * @returns true if everything that can be done was applied
  129287. */
  129288. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129289. }
  129290. /**
  129291. * Defines a list of options used by SceneOptimizer
  129292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129293. */
  129294. export class SceneOptimizerOptions {
  129295. /**
  129296. * Defines the target frame rate to reach (60 by default)
  129297. */
  129298. targetFrameRate: number;
  129299. /**
  129300. * Defines the interval between two checkes (2000ms by default)
  129301. */
  129302. trackerDuration: number;
  129303. /**
  129304. * Gets the list of optimizations to apply
  129305. */
  129306. optimizations: SceneOptimization[];
  129307. /**
  129308. * Creates a new list of options used by SceneOptimizer
  129309. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129310. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129311. */
  129312. constructor(
  129313. /**
  129314. * Defines the target frame rate to reach (60 by default)
  129315. */
  129316. targetFrameRate?: number,
  129317. /**
  129318. * Defines the interval between two checkes (2000ms by default)
  129319. */
  129320. trackerDuration?: number);
  129321. /**
  129322. * Add a new optimization
  129323. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129324. * @returns the current SceneOptimizerOptions
  129325. */
  129326. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129327. /**
  129328. * Add a new custom optimization
  129329. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129330. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129331. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129332. * @returns the current SceneOptimizerOptions
  129333. */
  129334. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129335. /**
  129336. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129337. * @param targetFrameRate defines the target frame rate (60 by default)
  129338. * @returns a SceneOptimizerOptions object
  129339. */
  129340. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129341. /**
  129342. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129343. * @param targetFrameRate defines the target frame rate (60 by default)
  129344. * @returns a SceneOptimizerOptions object
  129345. */
  129346. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129347. /**
  129348. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129349. * @param targetFrameRate defines the target frame rate (60 by default)
  129350. * @returns a SceneOptimizerOptions object
  129351. */
  129352. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129353. }
  129354. /**
  129355. * Class used to run optimizations in order to reach a target frame rate
  129356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129357. */
  129358. export class SceneOptimizer implements IDisposable {
  129359. private _isRunning;
  129360. private _options;
  129361. private _scene;
  129362. private _currentPriorityLevel;
  129363. private _targetFrameRate;
  129364. private _trackerDuration;
  129365. private _currentFrameRate;
  129366. private _sceneDisposeObserver;
  129367. private _improvementMode;
  129368. /**
  129369. * Defines an observable called when the optimizer reaches the target frame rate
  129370. */
  129371. onSuccessObservable: Observable<SceneOptimizer>;
  129372. /**
  129373. * Defines an observable called when the optimizer enables an optimization
  129374. */
  129375. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129376. /**
  129377. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129378. */
  129379. onFailureObservable: Observable<SceneOptimizer>;
  129380. /**
  129381. * Gets a boolean indicating if the optimizer is in improvement mode
  129382. */
  129383. readonly isInImprovementMode: boolean;
  129384. /**
  129385. * Gets the current priority level (0 at start)
  129386. */
  129387. readonly currentPriorityLevel: number;
  129388. /**
  129389. * Gets the current frame rate checked by the SceneOptimizer
  129390. */
  129391. readonly currentFrameRate: number;
  129392. /**
  129393. * Gets or sets the current target frame rate (60 by default)
  129394. */
  129395. /**
  129396. * Gets or sets the current target frame rate (60 by default)
  129397. */
  129398. targetFrameRate: number;
  129399. /**
  129400. * Gets or sets the current interval between two checks (every 2000ms by default)
  129401. */
  129402. /**
  129403. * Gets or sets the current interval between two checks (every 2000ms by default)
  129404. */
  129405. trackerDuration: number;
  129406. /**
  129407. * Gets the list of active optimizations
  129408. */
  129409. readonly optimizations: SceneOptimization[];
  129410. /**
  129411. * Creates a new SceneOptimizer
  129412. * @param scene defines the scene to work on
  129413. * @param options defines the options to use with the SceneOptimizer
  129414. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129415. * @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)
  129416. */
  129417. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129418. /**
  129419. * Stops the current optimizer
  129420. */
  129421. stop(): void;
  129422. /**
  129423. * Reset the optimizer to initial step (current priority level = 0)
  129424. */
  129425. reset(): void;
  129426. /**
  129427. * Start the optimizer. By default it will try to reach a specific framerate
  129428. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129429. */
  129430. start(): void;
  129431. private _checkCurrentState;
  129432. /**
  129433. * Release all resources
  129434. */
  129435. dispose(): void;
  129436. /**
  129437. * Helper function to create a SceneOptimizer with one single line of code
  129438. * @param scene defines the scene to work on
  129439. * @param options defines the options to use with the SceneOptimizer
  129440. * @param onSuccess defines a callback to call on success
  129441. * @param onFailure defines a callback to call on failure
  129442. * @returns the new SceneOptimizer object
  129443. */
  129444. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129445. }
  129446. }
  129447. declare module BABYLON {
  129448. /**
  129449. * Class used to serialize a scene into a string
  129450. */
  129451. export class SceneSerializer {
  129452. /**
  129453. * Clear cache used by a previous serialization
  129454. */
  129455. static ClearCache(): void;
  129456. /**
  129457. * Serialize a scene into a JSON compatible object
  129458. * @param scene defines the scene to serialize
  129459. * @returns a JSON compatible object
  129460. */
  129461. static Serialize(scene: Scene): any;
  129462. /**
  129463. * Serialize a mesh into a JSON compatible object
  129464. * @param toSerialize defines the mesh to serialize
  129465. * @param withParents defines if parents must be serialized as well
  129466. * @param withChildren defines if children must be serialized as well
  129467. * @returns a JSON compatible object
  129468. */
  129469. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129470. }
  129471. }
  129472. declare module BABYLON {
  129473. /**
  129474. * Class used to host texture specific utilities
  129475. */
  129476. export class TextureTools {
  129477. /**
  129478. * Uses the GPU to create a copy texture rescaled at a given size
  129479. * @param texture Texture to copy from
  129480. * @param width defines the desired width
  129481. * @param height defines the desired height
  129482. * @param useBilinearMode defines if bilinear mode has to be used
  129483. * @return the generated texture
  129484. */
  129485. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129486. }
  129487. }
  129488. declare module BABYLON {
  129489. /**
  129490. * This represents the different options available for the video capture.
  129491. */
  129492. export interface VideoRecorderOptions {
  129493. /** Defines the mime type of the video. */
  129494. mimeType: string;
  129495. /** Defines the FPS the video should be recorded at. */
  129496. fps: number;
  129497. /** Defines the chunk size for the recording data. */
  129498. recordChunckSize: number;
  129499. /** The audio tracks to attach to the recording. */
  129500. audioTracks?: MediaStreamTrack[];
  129501. }
  129502. /**
  129503. * This can help with recording videos from BabylonJS.
  129504. * This is based on the available WebRTC functionalities of the browser.
  129505. *
  129506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129507. */
  129508. export class VideoRecorder {
  129509. private static readonly _defaultOptions;
  129510. /**
  129511. * Returns whether or not the VideoRecorder is available in your browser.
  129512. * @param engine Defines the Babylon Engine.
  129513. * @returns true if supported otherwise false.
  129514. */
  129515. static IsSupported(engine: Engine): boolean;
  129516. private readonly _options;
  129517. private _canvas;
  129518. private _mediaRecorder;
  129519. private _recordedChunks;
  129520. private _fileName;
  129521. private _resolve;
  129522. private _reject;
  129523. /**
  129524. * True when a recording is already in progress.
  129525. */
  129526. readonly isRecording: boolean;
  129527. /**
  129528. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129529. * @param engine Defines the BabylonJS Engine you wish to record.
  129530. * @param options Defines options that can be used to customize the capture.
  129531. */
  129532. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129533. /**
  129534. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129535. */
  129536. stopRecording(): void;
  129537. /**
  129538. * Starts recording the canvas for a max duration specified in parameters.
  129539. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129540. * If null no automatic download will start and you can rely on the promise to get the data back.
  129541. * @param maxDuration Defines the maximum recording time in seconds.
  129542. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129543. * @return A promise callback at the end of the recording with the video data in Blob.
  129544. */
  129545. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129546. /**
  129547. * Releases internal resources used during the recording.
  129548. */
  129549. dispose(): void;
  129550. private _handleDataAvailable;
  129551. private _handleError;
  129552. private _handleStop;
  129553. }
  129554. }
  129555. declare module BABYLON {
  129556. /**
  129557. * Class containing a set of static utilities functions for screenshots
  129558. */
  129559. export class ScreenshotTools {
  129560. /**
  129561. * Captures a screenshot of the current rendering
  129562. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129563. * @param engine defines the rendering engine
  129564. * @param camera defines the source camera
  129565. * @param size This parameter can be set to a single number or to an object with the
  129566. * following (optional) properties: precision, width, height. If a single number is passed,
  129567. * it will be used for both width and height. If an object is passed, the screenshot size
  129568. * will be derived from the parameters. The precision property is a multiplier allowing
  129569. * rendering at a higher or lower resolution
  129570. * @param successCallback defines the callback receives a single parameter which contains the
  129571. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129572. * src parameter of an <img> to display it
  129573. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129574. * Check your browser for supported MIME types
  129575. */
  129576. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129577. /**
  129578. * Captures a screenshot of the current rendering
  129579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129580. * @param engine defines the rendering engine
  129581. * @param camera defines the source camera
  129582. * @param size This parameter can be set to a single number or to an object with the
  129583. * following (optional) properties: precision, width, height. If a single number is passed,
  129584. * it will be used for both width and height. If an object is passed, the screenshot size
  129585. * will be derived from the parameters. The precision property is a multiplier allowing
  129586. * rendering at a higher or lower resolution
  129587. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129588. * Check your browser for supported MIME types
  129589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129590. * to the src parameter of an <img> to display it
  129591. */
  129592. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129593. /**
  129594. * Generates an image screenshot from the specified camera.
  129595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129596. * @param engine The engine to use for rendering
  129597. * @param camera The camera to use for rendering
  129598. * @param size This parameter can be set to a single number or to an object with the
  129599. * following (optional) properties: precision, width, height. If a single number is passed,
  129600. * it will be used for both width and height. If an object is passed, the screenshot size
  129601. * will be derived from the parameters. The precision property is a multiplier allowing
  129602. * rendering at a higher or lower resolution
  129603. * @param successCallback The callback receives a single parameter which contains the
  129604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129605. * src parameter of an <img> to display it
  129606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129607. * Check your browser for supported MIME types
  129608. * @param samples Texture samples (default: 1)
  129609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129610. * @param fileName A name for for the downloaded file.
  129611. */
  129612. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129613. /**
  129614. * Generates an image screenshot from the specified camera.
  129615. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129616. * @param engine The engine to use for rendering
  129617. * @param camera The camera to use for rendering
  129618. * @param size This parameter can be set to a single number or to an object with the
  129619. * following (optional) properties: precision, width, height. If a single number is passed,
  129620. * it will be used for both width and height. If an object is passed, the screenshot size
  129621. * will be derived from the parameters. The precision property is a multiplier allowing
  129622. * rendering at a higher or lower resolution
  129623. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129624. * Check your browser for supported MIME types
  129625. * @param samples Texture samples (default: 1)
  129626. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129627. * @param fileName A name for for the downloaded file.
  129628. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129629. * to the src parameter of an <img> to display it
  129630. */
  129631. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129632. /**
  129633. * Gets height and width for screenshot size
  129634. * @private
  129635. */
  129636. private static _getScreenshotSize;
  129637. }
  129638. }
  129639. declare module BABYLON {
  129640. /**
  129641. * A cursor which tracks a point on a path
  129642. */
  129643. export class PathCursor {
  129644. private path;
  129645. /**
  129646. * Stores path cursor callbacks for when an onchange event is triggered
  129647. */
  129648. private _onchange;
  129649. /**
  129650. * The value of the path cursor
  129651. */
  129652. value: number;
  129653. /**
  129654. * The animation array of the path cursor
  129655. */
  129656. animations: Animation[];
  129657. /**
  129658. * Initializes the path cursor
  129659. * @param path The path to track
  129660. */
  129661. constructor(path: Path2);
  129662. /**
  129663. * Gets the cursor point on the path
  129664. * @returns A point on the path cursor at the cursor location
  129665. */
  129666. getPoint(): Vector3;
  129667. /**
  129668. * Moves the cursor ahead by the step amount
  129669. * @param step The amount to move the cursor forward
  129670. * @returns This path cursor
  129671. */
  129672. moveAhead(step?: number): PathCursor;
  129673. /**
  129674. * Moves the cursor behind by the step amount
  129675. * @param step The amount to move the cursor back
  129676. * @returns This path cursor
  129677. */
  129678. moveBack(step?: number): PathCursor;
  129679. /**
  129680. * Moves the cursor by the step amount
  129681. * If the step amount is greater than one, an exception is thrown
  129682. * @param step The amount to move the cursor
  129683. * @returns This path cursor
  129684. */
  129685. move(step: number): PathCursor;
  129686. /**
  129687. * Ensures that the value is limited between zero and one
  129688. * @returns This path cursor
  129689. */
  129690. private ensureLimits;
  129691. /**
  129692. * Runs onchange callbacks on change (used by the animation engine)
  129693. * @returns This path cursor
  129694. */
  129695. private raiseOnChange;
  129696. /**
  129697. * Executes a function on change
  129698. * @param f A path cursor onchange callback
  129699. * @returns This path cursor
  129700. */
  129701. onchange(f: (cursor: PathCursor) => void): PathCursor;
  129702. }
  129703. }
  129704. declare module BABYLON {
  129705. /** @hidden */
  129706. export var blurPixelShader: {
  129707. name: string;
  129708. shader: string;
  129709. };
  129710. }
  129711. declare module BABYLON {
  129712. /** @hidden */
  129713. export var pointCloudVertexDeclaration: {
  129714. name: string;
  129715. shader: string;
  129716. };
  129717. }
  129718. // Mixins
  129719. interface Window {
  129720. mozIndexedDB: IDBFactory;
  129721. webkitIndexedDB: IDBFactory;
  129722. msIndexedDB: IDBFactory;
  129723. webkitURL: typeof URL;
  129724. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  129725. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  129726. WebGLRenderingContext: WebGLRenderingContext;
  129727. MSGesture: MSGesture;
  129728. CANNON: any;
  129729. AudioContext: AudioContext;
  129730. webkitAudioContext: AudioContext;
  129731. PointerEvent: any;
  129732. Math: Math;
  129733. Uint8Array: Uint8ArrayConstructor;
  129734. Float32Array: Float32ArrayConstructor;
  129735. mozURL: typeof URL;
  129736. msURL: typeof URL;
  129737. VRFrameData: any; // WebVR, from specs 1.1
  129738. DracoDecoderModule: any;
  129739. setImmediate(handler: (...args: any[]) => void): number;
  129740. }
  129741. interface HTMLCanvasElement {
  129742. requestPointerLock(): void;
  129743. msRequestPointerLock?(): void;
  129744. mozRequestPointerLock?(): void;
  129745. webkitRequestPointerLock?(): void;
  129746. /** Track wether a record is in progress */
  129747. isRecording: boolean;
  129748. /** Capture Stream method defined by some browsers */
  129749. captureStream(fps?: number): MediaStream;
  129750. }
  129751. interface CanvasRenderingContext2D {
  129752. msImageSmoothingEnabled: boolean;
  129753. }
  129754. interface MouseEvent {
  129755. mozMovementX: number;
  129756. mozMovementY: number;
  129757. webkitMovementX: number;
  129758. webkitMovementY: number;
  129759. msMovementX: number;
  129760. msMovementY: number;
  129761. }
  129762. interface Navigator {
  129763. mozGetVRDevices: (any: any) => any;
  129764. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129765. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129766. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129767. webkitGetGamepads(): Gamepad[];
  129768. msGetGamepads(): Gamepad[];
  129769. webkitGamepads(): Gamepad[];
  129770. }
  129771. interface HTMLVideoElement {
  129772. mozSrcObject: any;
  129773. }
  129774. interface Math {
  129775. fround(x: number): number;
  129776. imul(a: number, b: number): number;
  129777. }
  129778. interface WebGLRenderingContext {
  129779. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  129780. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  129781. vertexAttribDivisor(index: number, divisor: number): void;
  129782. createVertexArray(): any;
  129783. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  129784. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  129785. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  129786. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  129787. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  129788. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  129789. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  129790. // Queries
  129791. createQuery(): WebGLQuery;
  129792. deleteQuery(query: WebGLQuery): void;
  129793. beginQuery(target: number, query: WebGLQuery): void;
  129794. endQuery(target: number): void;
  129795. getQueryParameter(query: WebGLQuery, pname: number): any;
  129796. getQuery(target: number, pname: number): any;
  129797. MAX_SAMPLES: number;
  129798. RGBA8: number;
  129799. READ_FRAMEBUFFER: number;
  129800. DRAW_FRAMEBUFFER: number;
  129801. UNIFORM_BUFFER: number;
  129802. HALF_FLOAT_OES: number;
  129803. RGBA16F: number;
  129804. RGBA32F: number;
  129805. R32F: number;
  129806. RG32F: number;
  129807. RGB32F: number;
  129808. R16F: number;
  129809. RG16F: number;
  129810. RGB16F: number;
  129811. RED: number;
  129812. RG: number;
  129813. R8: number;
  129814. RG8: number;
  129815. UNSIGNED_INT_24_8: number;
  129816. DEPTH24_STENCIL8: number;
  129817. MIN: number;
  129818. MAX: number;
  129819. /* Multiple Render Targets */
  129820. drawBuffers(buffers: number[]): void;
  129821. readBuffer(src: number): void;
  129822. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  129823. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  129824. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  129825. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  129826. // Occlusion Query
  129827. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  129828. ANY_SAMPLES_PASSED: number;
  129829. QUERY_RESULT_AVAILABLE: number;
  129830. QUERY_RESULT: number;
  129831. }
  129832. interface WebGLProgram {
  129833. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  129834. }
  129835. interface EXT_disjoint_timer_query {
  129836. QUERY_COUNTER_BITS_EXT: number;
  129837. TIME_ELAPSED_EXT: number;
  129838. TIMESTAMP_EXT: number;
  129839. GPU_DISJOINT_EXT: number;
  129840. QUERY_RESULT_EXT: number;
  129841. QUERY_RESULT_AVAILABLE_EXT: number;
  129842. queryCounterEXT(query: WebGLQuery, target: number): void;
  129843. createQueryEXT(): WebGLQuery;
  129844. beginQueryEXT(target: number, query: WebGLQuery): void;
  129845. endQueryEXT(target: number): void;
  129846. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  129847. deleteQueryEXT(query: WebGLQuery): void;
  129848. }
  129849. interface WebGLUniformLocation {
  129850. _currentState: any;
  129851. }
  129852. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  129853. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  129854. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  129855. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129856. interface WebGLRenderingContext {
  129857. readonly RASTERIZER_DISCARD: number;
  129858. readonly DEPTH_COMPONENT24: number;
  129859. readonly TEXTURE_3D: number;
  129860. readonly TEXTURE_2D_ARRAY: number;
  129861. readonly TEXTURE_COMPARE_FUNC: number;
  129862. readonly TEXTURE_COMPARE_MODE: number;
  129863. readonly COMPARE_REF_TO_TEXTURE: number;
  129864. readonly TEXTURE_WRAP_R: number;
  129865. readonly HALF_FLOAT: number;
  129866. readonly RGB8: number;
  129867. readonly RED_INTEGER: number;
  129868. readonly RG_INTEGER: number;
  129869. readonly RGB_INTEGER: number;
  129870. readonly RGBA_INTEGER: number;
  129871. readonly R8_SNORM: number;
  129872. readonly RG8_SNORM: number;
  129873. readonly RGB8_SNORM: number;
  129874. readonly RGBA8_SNORM: number;
  129875. readonly R8I: number;
  129876. readonly RG8I: number;
  129877. readonly RGB8I: number;
  129878. readonly RGBA8I: number;
  129879. readonly R8UI: number;
  129880. readonly RG8UI: number;
  129881. readonly RGB8UI: number;
  129882. readonly RGBA8UI: number;
  129883. readonly R16I: number;
  129884. readonly RG16I: number;
  129885. readonly RGB16I: number;
  129886. readonly RGBA16I: number;
  129887. readonly R16UI: number;
  129888. readonly RG16UI: number;
  129889. readonly RGB16UI: number;
  129890. readonly RGBA16UI: number;
  129891. readonly R32I: number;
  129892. readonly RG32I: number;
  129893. readonly RGB32I: number;
  129894. readonly RGBA32I: number;
  129895. readonly R32UI: number;
  129896. readonly RG32UI: number;
  129897. readonly RGB32UI: number;
  129898. readonly RGBA32UI: number;
  129899. readonly RGB10_A2UI: number;
  129900. readonly R11F_G11F_B10F: number;
  129901. readonly RGB9_E5: number;
  129902. readonly RGB10_A2: number;
  129903. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  129904. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  129905. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  129906. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  129907. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  129908. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  129909. 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;
  129910. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  129911. readonly TRANSFORM_FEEDBACK: number;
  129912. readonly INTERLEAVED_ATTRIBS: number;
  129913. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  129914. createTransformFeedback(): WebGLTransformFeedback;
  129915. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  129916. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  129917. beginTransformFeedback(primitiveMode: number): void;
  129918. endTransformFeedback(): void;
  129919. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  129920. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129921. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129922. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129923. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  129924. }
  129925. interface ImageBitmap {
  129926. readonly width: number;
  129927. readonly height: number;
  129928. close(): void;
  129929. }
  129930. interface WebGLQuery extends WebGLObject {
  129931. }
  129932. declare var WebGLQuery: {
  129933. prototype: WebGLQuery;
  129934. new(): WebGLQuery;
  129935. };
  129936. interface WebGLSampler extends WebGLObject {
  129937. }
  129938. declare var WebGLSampler: {
  129939. prototype: WebGLSampler;
  129940. new(): WebGLSampler;
  129941. };
  129942. interface WebGLSync extends WebGLObject {
  129943. }
  129944. declare var WebGLSync: {
  129945. prototype: WebGLSync;
  129946. new(): WebGLSync;
  129947. };
  129948. interface WebGLTransformFeedback extends WebGLObject {
  129949. }
  129950. declare var WebGLTransformFeedback: {
  129951. prototype: WebGLTransformFeedback;
  129952. new(): WebGLTransformFeedback;
  129953. };
  129954. interface WebGLVertexArrayObject extends WebGLObject {
  129955. }
  129956. declare var WebGLVertexArrayObject: {
  129957. prototype: WebGLVertexArrayObject;
  129958. new(): WebGLVertexArrayObject;
  129959. };
  129960. // Type definitions for WebVR API
  129961. // Project: https://w3c.github.io/webvr/
  129962. // Definitions by: six a <https://github.com/lostfictions>
  129963. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129964. interface VRDisplay extends EventTarget {
  129965. /**
  129966. * Dictionary of capabilities describing the VRDisplay.
  129967. */
  129968. readonly capabilities: VRDisplayCapabilities;
  129969. /**
  129970. * z-depth defining the far plane of the eye view frustum
  129971. * enables mapping of values in the render target depth
  129972. * attachment to scene coordinates. Initially set to 10000.0.
  129973. */
  129974. depthFar: number;
  129975. /**
  129976. * z-depth defining the near plane of the eye view frustum
  129977. * enables mapping of values in the render target depth
  129978. * attachment to scene coordinates. Initially set to 0.01.
  129979. */
  129980. depthNear: number;
  129981. /**
  129982. * An identifier for this distinct VRDisplay. Used as an
  129983. * association point in the Gamepad API.
  129984. */
  129985. readonly displayId: number;
  129986. /**
  129987. * A display name, a user-readable name identifying it.
  129988. */
  129989. readonly displayName: string;
  129990. readonly isConnected: boolean;
  129991. readonly isPresenting: boolean;
  129992. /**
  129993. * If this VRDisplay supports room-scale experiences, the optional
  129994. * stage attribute contains details on the room-scale parameters.
  129995. */
  129996. readonly stageParameters: VRStageParameters | null;
  129997. /**
  129998. * Passing the value returned by `requestAnimationFrame` to
  129999. * `cancelAnimationFrame` will unregister the callback.
  130000. * @param handle Define the hanle of the request to cancel
  130001. */
  130002. cancelAnimationFrame(handle: number): void;
  130003. /**
  130004. * Stops presenting to the VRDisplay.
  130005. * @returns a promise to know when it stopped
  130006. */
  130007. exitPresent(): Promise<void>;
  130008. /**
  130009. * Return the current VREyeParameters for the given eye.
  130010. * @param whichEye Define the eye we want the parameter for
  130011. * @returns the eye parameters
  130012. */
  130013. getEyeParameters(whichEye: string): VREyeParameters;
  130014. /**
  130015. * Populates the passed VRFrameData with the information required to render
  130016. * the current frame.
  130017. * @param frameData Define the data structure to populate
  130018. * @returns true if ok otherwise false
  130019. */
  130020. getFrameData(frameData: VRFrameData): boolean;
  130021. /**
  130022. * Get the layers currently being presented.
  130023. * @returns the list of VR layers
  130024. */
  130025. getLayers(): VRLayer[];
  130026. /**
  130027. * Return a VRPose containing the future predicted pose of the VRDisplay
  130028. * when the current frame will be presented. The value returned will not
  130029. * change until JavaScript has returned control to the browser.
  130030. *
  130031. * The VRPose will contain the position, orientation, velocity,
  130032. * and acceleration of each of these properties.
  130033. * @returns the pose object
  130034. */
  130035. getPose(): VRPose;
  130036. /**
  130037. * Return the current instantaneous pose of the VRDisplay, with no
  130038. * prediction applied.
  130039. * @returns the current instantaneous pose
  130040. */
  130041. getImmediatePose(): VRPose;
  130042. /**
  130043. * The callback passed to `requestAnimationFrame` will be called
  130044. * any time a new frame should be rendered. When the VRDisplay is
  130045. * presenting the callback will be called at the native refresh
  130046. * rate of the HMD. When not presenting this function acts
  130047. * identically to how window.requestAnimationFrame acts. Content should
  130048. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130049. * asynchronously from other displays and at differing refresh rates.
  130050. * @param callback Define the eaction to run next frame
  130051. * @returns the request handle it
  130052. */
  130053. requestAnimationFrame(callback: FrameRequestCallback): number;
  130054. /**
  130055. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130056. * Repeat calls while already presenting will update the VRLayers being displayed.
  130057. * @param layers Define the list of layer to present
  130058. * @returns a promise to know when the request has been fulfilled
  130059. */
  130060. requestPresent(layers: VRLayer[]): Promise<void>;
  130061. /**
  130062. * Reset the pose for this display, treating its current position and
  130063. * orientation as the "origin/zero" values. VRPose.position,
  130064. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130065. * updated when calling resetPose(). This should be called in only
  130066. * sitting-space experiences.
  130067. */
  130068. resetPose(): void;
  130069. /**
  130070. * The VRLayer provided to the VRDisplay will be captured and presented
  130071. * in the HMD. Calling this function has the same effect on the source
  130072. * canvas as any other operation that uses its source image, and canvases
  130073. * created without preserveDrawingBuffer set to true will be cleared.
  130074. * @param pose Define the pose to submit
  130075. */
  130076. submitFrame(pose?: VRPose): void;
  130077. }
  130078. declare var VRDisplay: {
  130079. prototype: VRDisplay;
  130080. new(): VRDisplay;
  130081. };
  130082. interface VRLayer {
  130083. leftBounds?: number[] | Float32Array | null;
  130084. rightBounds?: number[] | Float32Array | null;
  130085. source?: HTMLCanvasElement | null;
  130086. }
  130087. interface VRDisplayCapabilities {
  130088. readonly canPresent: boolean;
  130089. readonly hasExternalDisplay: boolean;
  130090. readonly hasOrientation: boolean;
  130091. readonly hasPosition: boolean;
  130092. readonly maxLayers: number;
  130093. }
  130094. interface VREyeParameters {
  130095. /** @deprecated */
  130096. readonly fieldOfView: VRFieldOfView;
  130097. readonly offset: Float32Array;
  130098. readonly renderHeight: number;
  130099. readonly renderWidth: number;
  130100. }
  130101. interface VRFieldOfView {
  130102. readonly downDegrees: number;
  130103. readonly leftDegrees: number;
  130104. readonly rightDegrees: number;
  130105. readonly upDegrees: number;
  130106. }
  130107. interface VRFrameData {
  130108. readonly leftProjectionMatrix: Float32Array;
  130109. readonly leftViewMatrix: Float32Array;
  130110. readonly pose: VRPose;
  130111. readonly rightProjectionMatrix: Float32Array;
  130112. readonly rightViewMatrix: Float32Array;
  130113. readonly timestamp: number;
  130114. }
  130115. interface VRPose {
  130116. readonly angularAcceleration: Float32Array | null;
  130117. readonly angularVelocity: Float32Array | null;
  130118. readonly linearAcceleration: Float32Array | null;
  130119. readonly linearVelocity: Float32Array | null;
  130120. readonly orientation: Float32Array | null;
  130121. readonly position: Float32Array | null;
  130122. readonly timestamp: number;
  130123. }
  130124. interface VRStageParameters {
  130125. sittingToStandingTransform?: Float32Array;
  130126. sizeX?: number;
  130127. sizeY?: number;
  130128. }
  130129. interface Navigator {
  130130. getVRDisplays(): Promise<VRDisplay[]>;
  130131. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130132. }
  130133. interface Window {
  130134. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130135. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130136. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130137. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130138. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130139. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130140. }
  130141. interface Gamepad {
  130142. readonly displayId: number;
  130143. }
  130144. type XRSessionMode =
  130145. | "inline"
  130146. | "immersive-vr"
  130147. | "immersive-ar";
  130148. type XRReferenceSpaceType =
  130149. | "viewer"
  130150. | "local"
  130151. | "local-floor"
  130152. | "bounded-floor"
  130153. | "unbounded";
  130154. type XREnvironmentBlendMode =
  130155. | "opaque"
  130156. | "additive"
  130157. | "alpha-blend";
  130158. type XRVisibilityState =
  130159. | "visible"
  130160. | "visible-blurred"
  130161. | "hidden";
  130162. type XRHandedness =
  130163. | "none"
  130164. | "left"
  130165. | "right";
  130166. type XRTargetRayMode =
  130167. | "gaze"
  130168. | "tracked-pointer"
  130169. | "screen";
  130170. type XREye =
  130171. | "none"
  130172. | "left"
  130173. | "right";
  130174. interface XRSpace extends EventTarget {
  130175. }
  130176. interface XRRenderState {
  130177. depthNear?: number;
  130178. depthFar?: number;
  130179. inlineVerticalFieldOfView?: number;
  130180. baseLayer?: XRWebGLLayer;
  130181. }
  130182. interface XRInputSource {
  130183. handedness: XRHandedness;
  130184. targetRayMode: XRTargetRayMode;
  130185. targetRaySpace: XRSpace;
  130186. gripSpace: XRSpace | undefined;
  130187. gamepad: Gamepad | undefined;
  130188. profiles: Array<string>;
  130189. }
  130190. interface XRSession {
  130191. addEventListener: Function;
  130192. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130193. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130194. requestAnimationFrame: Function;
  130195. end(): Promise<void>;
  130196. renderState: XRRenderState;
  130197. inputSources: Array<XRInputSource>;
  130198. }
  130199. interface XRReferenceSpace extends XRSpace {
  130200. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130201. onreset: any;
  130202. }
  130203. interface XRFrame {
  130204. session: XRSession;
  130205. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130206. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130207. }
  130208. interface XRViewerPose extends XRPose {
  130209. views: Array<XRView>;
  130210. }
  130211. interface XRPose {
  130212. transform: XRRigidTransform;
  130213. emulatedPosition: boolean;
  130214. }
  130215. declare var XRWebGLLayer: {
  130216. prototype: XRWebGLLayer;
  130217. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130218. };
  130219. interface XRWebGLLayer {
  130220. framebuffer: WebGLFramebuffer;
  130221. framebufferWidth: number;
  130222. framebufferHeight: number;
  130223. getViewport: Function;
  130224. }
  130225. interface XRRigidTransform {
  130226. position: DOMPointReadOnly;
  130227. orientation: DOMPointReadOnly;
  130228. matrix: Float32Array;
  130229. inverse: XRRigidTransform;
  130230. }
  130231. interface XRView {
  130232. eye: XREye;
  130233. projectionMatrix: Float32Array;
  130234. transform: XRRigidTransform;
  130235. }
  130236. interface XRInputSourceChangeEvent {
  130237. session: XRSession;
  130238. removed: Array<XRInputSource>;
  130239. added: Array<XRInputSource>;
  130240. }